/* Wahid Affiliate — Design System (Desktop & Mobile Responsive) */

:root {
  --bg: #faf6f0;
  --surface: #fffdfa;
  --surface-muted: #f3ece2;
  --fg: #261e19;
  --fg-muted: #6c5e54;
  --primary: #c0562b;
  --primary-hover: #a5441d;
  --primary-soft: #faeae2;
  --primary-fg: #fffcf9;
  --accent: #deece0;
  --accent-fg: #244b2c;
  --secondary: #efe6da;
  --secondary-fg: #44372d;
  --danger: #c6372c;
  --danger-hover: #a62a21;
  --danger-soft: #fdebe9;
  --border: #e6dacb;
  --ring: rgba(192, 86, 43, 0.28);
  --shadow-sm: 0 1px 2px rgba(38, 30, 25, 0.05);
  --shadow-md: 0 8px 24px rgba(38, 30, 25, 0.08);
  --shadow-lg: 0 20px 48px rgba(38, 30, 25, 0.16);
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 20px;
  --font: 'Plus Jakarta Sans', system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

*, *::before, *::after {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-height: 100vh;
  background-color: var(--bg);
  color: var(--fg);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

a {
  color: inherit;
  text-decoration: none;
}

img, video {
  display: block;
  max-width: 100%;
}

button, input, textarea {
  font-family: inherit;
  font-size: inherit;
  color: inherit;
}

/* Layout Containers */
.container {
  width: 100%;
  max-width: 1200px;
  margin-inline: auto;
  padding-inline: 16px;
}

@media (min-width: 640px) {
  .container { padding-inline: 24px; }
}

/* Sticky Topbar */
.topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  background: rgba(255, 253, 250, 0.88);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
}

.topbar-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 64px;
  padding-block: 10px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.brand-logo {
  width: 36px;
  height: 36px;
  flex-shrink: 0;
  border-radius: 10px;
}

.brand-text {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.brand-title {
  font-size: 1rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.brand-sub {
  font-size: 0.75rem;
  color: var(--fg-muted);
  display: none;
}

@media (min-width: 640px) {
  .brand-sub { display: block; }
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.user-pill {
  display: none;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border-radius: 999px;
  background: var(--surface-muted);
  font-size: 0.8rem;
  color: var(--fg-muted);
  max-width: 220px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

@media (min-width: 768px) {
  .user-pill { display: inline-flex; }
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 42px;
  padding: 0 16px;
  border: 1px solid transparent;
  border-radius: var(--radius-md);
  font-size: 0.875rem;
  font-weight: 600;
  cursor: pointer;
  transition: background-color 0.15s ease, border-color 0.15s ease, color 0.15s ease, transform 0.1s ease, box-shadow 0.15s ease;
  white-space: nowrap;
  user-select: none;
}

.btn:active:not(:disabled) {
  transform: scale(0.98);
}

.btn:focus-visible, input:focus-visible, textarea:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px var(--ring);
}

.btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.btn-primary {
  background: var(--primary);
  color: var(--primary-fg);
}

.btn-primary:hover:not(:disabled) {
  background: var(--primary-hover);
}

.btn-outline {
  background: var(--surface);
  border-color: var(--border);
  color: var(--fg);
}

.btn-outline:hover:not(:disabled) {
  background: var(--surface-muted);
}

.btn-ghost {
  background: transparent;
  color: var(--fg-muted);
}

.btn-ghost:hover:not(:disabled) {
  background: var(--surface-muted);
  color: var(--fg);
}

.btn-danger {
  background: var(--danger);
  color: #fff;
}

.btn-danger:hover:not(:disabled) {
  background: var(--danger-hover);
}

.btn-danger-ghost {
  background: transparent;
  color: var(--danger);
}

.btn-danger-ghost:hover:not(:disabled) {
  background: var(--danger-soft);
}

.btn-sm {
  min-height: 36px;
  padding: 0 12px;
  font-size: 0.8125rem;
  border-radius: var(--radius-sm);
}

.btn-icon {
  width: 42px;
  min-width: 42px;
  height: 42px;
  padding: 0;
}

.btn-icon-sm {
  width: 36px;
  min-width: 36px;
  height: 36px;
  padding: 0;
  border-radius: var(--radius-sm);
}

.btn-full {
  width: 100%;
}

/* Icons */
.icon {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
}

.icon-sm {
  width: 15px;
  height: 15px;
  flex-shrink: 0;
}

/* Form Elements */
.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.field-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.label {
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--fg);
}

.input, .textarea {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--surface);
  color: var(--fg);
  padding: 10px 14px;
  font-size: 0.9375rem;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.input {
  min-height: 44px;
}

.textarea {
  resize: vertical;
  min-height: 104px;
  line-height: 1.55;
}

.input:focus, .textarea:focus {
  border-color: var(--primary);
}

.input-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.input-row .input {
  flex: 1;
  min-width: 0;
}

.input-icon-wrap {
  position: relative;
  flex: 1;
  min-width: 0;
}

.input-icon-wrap .icon {
  position: absolute;
  left: 13px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--fg-muted);
  pointer-events: none;
}

.input-icon-wrap .input {
  padding-left: 40px;
}

/* Cards & Surfaces */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-sm);
}

/* Auth Page */
.auth-shell {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px 16px;
  background:
    radial-gradient(circle at 85% 12%, rgba(192, 86, 43, 0.12), transparent 38%),
    radial-gradient(circle at 12% 88%, rgba(120, 162, 128, 0.15), transparent 40%),
    var(--bg);
}

.auth-wrap {
  width: 100%;
  max-width: 400px;
}

.auth-brand {
  text-align: center;
  margin-bottom: 24px;
}

.auth-brand img {
  width: 60px;
  height: 60px;
  margin: 0 auto 14px;
  border-radius: 16px;
  box-shadow: var(--shadow-md);
}

.auth-brand h1 {
  margin: 0;
  font-size: 1.5rem;
  font-weight: 700;
  letter-spacing: -0.025em;
}

.auth-brand p {
  margin: 6px 0 0;
  font-size: 0.875rem;
  color: var(--fg-muted);
}

.auth-card {
  padding: 24px;
}

.auth-form {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.alert-error {
  padding: 12px 14px;
  border-radius: var(--radius-md);
  background: var(--danger-soft);
  border: 1px solid rgba(198, 55, 44, 0.22);
  color: var(--danger);
  font-size: 0.85rem;
  font-weight: 500;
}

.auth-foot {
  margin-top: 16px;
  text-align: center;
  font-size: 0.78rem;
  color: var(--fg-muted);
}

/* Main Content */
.main {
  padding-block: 24px 56px;
}

@media (min-width: 768px) {
  .main { padding-block: 32px 64px; }
}

/* Dashboard Stats */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 20px;
}

@media (min-width: 640px) {
  .stats-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 16px;
    margin-bottom: 24px;
  }
}

.stat-card {
  padding: 16px 18px;
  border-radius: var(--radius-lg);
  background: var(--surface);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.stat-card.stat-wide {
  grid-column: span 2;
}

@media (min-width: 640px) {
  .stat-card.stat-wide { grid-column: span 1; }
}

.stat-label {
  font-size: 0.78rem;
  font-weight: 500;
  color: var(--fg-muted);
  display: flex;
  align-items: center;
  gap: 6px;
}

.stat-dot {
  width: 8px;
  height: 8px;
  border-radius: 999px;
  background: var(--primary);
}

.stat-dot.dot-sage { background: #4a8556; }
.stat-dot.dot-amber { background: #c58b32; }

.stat-value {
  font-size: 1.5rem;
  font-weight: 700;
  letter-spacing: -0.025em;
  line-height: 1.2;
}

@media (min-width: 640px) {
  .stat-value { font-size: 1.7rem; }
}

/* Toolbar */
.toolbar {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-bottom: 24px;
}

@media (min-width: 768px) {
  .toolbar {
    flex-direction: row;
    align-items: center;
  }
}

.toolbar-row {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.filter-pills {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px;
  border-radius: var(--radius-md);
  background: var(--surface-muted);
  border: 1px solid var(--border);
}

.filter-pill {
  border: none;
  background: transparent;
  padding: 7px 12px;
  border-radius: 8px;
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--fg-muted);
  cursor: pointer;
  transition: background-color 0.15s ease, color 0.15s ease, box-shadow 0.15s ease;
}

.filter-pill.is-active {
  background: var(--surface);
  color: var(--fg);
  box-shadow: var(--shadow-sm);
}

/* Product Grid */
.product-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 16px;
}

@media (min-width: 540px) {
  .product-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (min-width: 960px) {
  .product-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 20px;
  }
}

@media (min-width: 1200px) {
  .product-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}

.product-card {
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border-radius: var(--radius-xl);
  background: var(--surface);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
  transition: transform 0.18s ease, box-shadow 0.18s ease, border-color 0.18s ease;
}

.product-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
  border-color: #d6c3ae;
}

.product-cover {
  position: relative;
  aspect-ratio: 4 / 3;
  background: var(--surface-muted);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.product-cover img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.3s ease;
}

.product-card:hover .product-cover img {
  transform: scale(1.03);
}

.product-cover-empty {
  color: var(--fg-muted);
  opacity: 0.45;
}

.product-number-badge {
  position: absolute;
  top: 10px;
  left: 10px;
  padding: 4px 10px;
  border-radius: 999px;
  background: rgba(38, 30, 25, 0.78);
  color: #fff;
  font-size: 0.72rem;
  font-weight: 600;
  backdrop-filter: blur(6px);
}

.product-body {
  padding: 16px;
  display: flex;
  flex-direction: column;
  flex: 1;
}

.product-name {
  margin: 0;
  font-size: 0.98rem;
  font-weight: 700;
  line-height: 1.35;
  color: var(--fg);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.product-card:hover .product-name {
  color: var(--primary);
}

.product-desc {
  margin: 6px 0 0;
  font-size: 0.835rem;
  color: var(--fg-muted);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  min-height: 2.5em;
}

.product-footer {
  margin-top: auto;
  padding-top: 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  flex-wrap: wrap;
}

.badge-group {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 8px;
  border-radius: 6px;
  font-size: 0.72rem;
  font-weight: 600;
}

.badge-photo {
  background: var(--accent);
  color: var(--accent-fg);
}

.badge-video {
  background: var(--secondary);
  color: var(--secondary-fg);
}

.badge-neutral {
  background: var(--surface-muted);
  color: var(--fg-muted);
}

.product-meta-size {
  font-size: 0.75rem;
  color: var(--fg-muted);
  font-weight: 500;
}

/* Empty State */
.empty-box {
  padding: 48px 24px;
  text-align: center;
  border: 1.5px dashed var(--border);
  border-radius: var(--radius-xl);
  background: rgba(255, 253, 250, 0.55);
  color: var(--fg-muted);
}

.empty-box h3 {
  margin: 12px 0 6px;
  font-size: 1rem;
  color: var(--fg);
}

.empty-box p {
  margin: 0 auto 18px;
  max-width: 380px;
  font-size: 0.875rem;
}

/* Product Detail Layout */
.quick-copy-bar {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 6px;
  margin-bottom: 16px;
  scrollbar-width: none;
}

.quick-copy-bar::-webkit-scrollbar { display: none; }

@media (min-width: 1024px) {
  .quick-copy-bar { display: none; }
}

.detail-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 24px;
  align-items: start;
}

@media (min-width: 1024px) {
  .detail-grid {
    grid-template-columns: minmax(360px, 430px) minmax(0, 1fr);
    gap: 28px;
  }
  .detail-form-panel {
    position: sticky;
    top: 84px;
  }
}

.detail-form-panel {
  padding: 20px;
}

@media (min-width: 640px) {
  .detail-form-panel { padding: 24px; }
}

.detail-form {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.panel-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}

.panel-heading h2 {
  margin: 0;
  font-size: 1.1rem;
  font-weight: 700;
  letter-spacing: -0.015em;
}

/* Dropzone */
.dropzone {
  position: relative;
  border: 2px dashed var(--border);
  border-radius: var(--radius-xl);
  background: var(--surface);
  padding: 24px 18px;
  text-align: center;
  cursor: pointer;
  transition: border-color 0.15s ease, background-color 0.15s ease;
  margin-bottom: 18px;
}

.dropzone:hover, .dropzone.is-dragover {
  border-color: var(--primary);
  background: var(--primary-soft);
}

.dropzone-title {
  margin: 8px 0 4px;
  font-size: 0.92rem;
  font-weight: 600;
  color: var(--fg);
}

.dropzone-hint {
  margin: 0;
  font-size: 0.8rem;
  color: var(--fg-muted);
}

/* Progress Bar */
.upload-progress {
  margin-bottom: 16px;
  padding: 12px 14px;
  border-radius: var(--radius-md);
  background: var(--surface);
  border: 1px solid var(--border);
}

.progress-head {
  display: flex;
  justify-content: space-between;
  font-size: 0.8rem;
  font-weight: 600;
  margin-bottom: 8px;
}

.progress-track {
  height: 8px;
  border-radius: 999px;
  background: var(--surface-muted);
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  width: 0%;
  border-radius: 999px;
  background: var(--primary);
  transition: width 0.15s ease;
}

/* Media Grid */
.media-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 14px;
}

@media (min-width: 420px) {
  .media-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (min-width: 1200px) {
  .media-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

.media-card {
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border-radius: var(--radius-lg);
  background: var(--surface);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
}

.media-preview {
  position: relative;
  aspect-ratio: 1 / 1;
  background: #1b1714;
  overflow: hidden;
}

.media-preview img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  cursor: zoom-in;
}

.media-preview video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  background: #000;
}

.media-kind-pill {
  position: absolute;
  top: 8px;
  left: 8px;
  padding: 3px 8px;
  border-radius: 6px;
  background: rgba(20, 16, 14, 0.72);
  color: #fff;
  font-size: 0.7rem;
  font-weight: 600;
  pointer-events: none;
}

.media-info {
  padding: 10px 12px 6px;
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
}

.media-name {
  font-size: 0.8rem;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;
}

.media-size {
  font-size: 0.72rem;
  color: var(--fg-muted);
  flex-shrink: 0;
}

.media-actions {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 4px;
  padding: 6px 8px 8px;
  border-top: 1px solid var(--surface-muted);
}

.media-action-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 38px;
  border: none;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--fg-muted);
  cursor: pointer;
  transition: background-color 0.15s ease, color 0.15s ease;
}

.media-action-btn:hover {
  background: var(--surface-muted);
  color: var(--fg);
}

.media-action-btn.is-danger {
  color: var(--danger);
}

.media-action-btn.is-danger:hover {
  background: var(--danger-soft);
}

/* Modal & Mobile Bottom Sheet */
.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  background: rgba(24, 18, 14, 0.56);
  backdrop-filter: blur(4px);
  padding: 0;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.18s ease;
}

@media (min-width: 640px) {
  .modal-backdrop {
    align-items: center;
    padding: 20px;
  }
}

.modal-backdrop.is-open {
  opacity: 1;
  pointer-events: auto;
}

.modal-dialog {
  width: 100%;
  max-width: 520px;
  max-height: 92vh;
  overflow-y: auto;
  background: var(--surface);
  border-radius: 22px 22px 0 0;
  box-shadow: var(--shadow-lg);
  padding: 20px 20px calc(24px + env(safe-area-inset-bottom, 0px));
  transform: translateY(20px);
  transition: transform 0.2s ease;
}

@media (min-width: 640px) {
  .modal-dialog {
    border-radius: var(--radius-xl);
    padding: 24px;
    transform: translateY(8px) scale(0.98);
  }
}

.modal-backdrop.is-open .modal-dialog {
  transform: translateY(0) scale(1);
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 18px;
}

.modal-header h3 {
  margin: 0;
  font-size: 1.1rem;
  font-weight: 700;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 20px;
}

/* Lightbox */
.lightbox {
  position: fixed;
  inset: 0;
  z-index: 60;
  background: rgba(15, 12, 10, 0.92);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 20px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.18s ease;
}

.lightbox.is-open {
  opacity: 1;
  pointer-events: auto;
}

.lightbox-bar {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 18px;
  color: #fff;
}

.lightbox-caption {
  font-size: 0.875rem;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.lightbox img {
  max-width: 94vw;
  max-height: 82vh;
  border-radius: 12px;
  object-fit: contain;
}

/* Toast Notifications */
.toast-stack {
  position: fixed;
  top: 16px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 80;
  display: flex;
  flex-direction: column;
  gap: 8px;
  width: min(92vw, 420px);
  pointer-events: none;
}

.toast {
  pointer-events: auto;
  padding: 12px 16px;
  border-radius: var(--radius-md);
  background: var(--fg);
  color: #fff;
  font-size: 0.85rem;
  font-weight: 600;
  box-shadow: var(--shadow-lg);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  animation: toastIn 0.2s ease;
}

.toast.toast-success { background: #1f5a2e; }
.toast.toast-error { background: var(--danger); }

@keyframes toastIn {
  from { opacity: 0; transform: translateY(-8px); }
  to { opacity: 1; transform: translateY(0); }
}

.hidden {
  display: none !important;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}
