/* ===================================================================
   Soulife Supplier Portal — Modern Slate Theme
   Light + Dark mode (toggle via [data-theme])
   =================================================================== */

:root,
[data-theme="light"] {
  /* Background */
  --bg-app: #f8fafc;
  --bg-card: #ffffff;
  --bg-input: #ffffff;
  --bg-hover: #f1f5f9;
  --bg-active: #e2e8f0;
  --bg-muted: #f1f5f9;

  /* Text */
  --text-primary: #0f172a;
  --text-secondary: #475569;
  --text-tertiary: #64748b;
  --text-muted: #94a3b8;
  --text-inverse: #ffffff;

  /* Border */
  --border-primary: #e2e8f0;
  --border-secondary: #cbd5e1;
  --border-focus: #4f46e5;

  /* Accent — Indigo */
  --accent-50: #eef2ff;
  --accent-100: #e0e7ff;
  --accent-500: #6366f1;
  --accent-600: #4f46e5;
  --accent-700: #4338ca;
  --accent-800: #3730a3;
  --accent-900: #312e81;

  /* Semantic */
  --color-success-bg: #ecfdf5;
  --color-success-border: #a7f3d0;
  --color-success-text: #065f46;
  --color-success-strong: #059669;

  --color-warning-bg: #fffbeb;
  --color-warning-border: #fde68a;
  --color-warning-text: #92400e;
  --color-warning-strong: #d97706;

  --color-danger-bg: #fef2f2;
  --color-danger-border: #fecaca;
  --color-danger-text: #991b1b;
  --color-danger-strong: #dc2626;

  --color-info-bg: #eff6ff;
  --color-info-border: #bfdbfe;
  --color-info-text: #1e40af;
  --color-info-strong: #2563eb;

  /* Shadow */
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.04);
  --shadow-md: 0 2px 6px rgba(0, 0, 0, 0.06);
  --shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.08);

  /* Radius */
  --radius-sm: 4px;
  --radius-md: 6px;
  --radius-lg: 8px;
  --radius-xl: 12px;
  --radius-full: 9999px;
}

[data-theme="dark"] {
  --bg-app: #020617;
  --bg-card: #0f172a;
  --bg-input: #1e293b;
  --bg-hover: #1e293b;
  --bg-active: #334155;
  --bg-muted: #1e293b;

  --text-primary: #f1f5f9;
  --text-secondary: #cbd5e1;
  --text-tertiary: #94a3b8;
  --text-muted: #64748b;
  --text-inverse: #0f172a;

  --border-primary: #1e293b;
  --border-secondary: #334155;
  --border-focus: #6366f1;

  --accent-50: #1e1b4b;
  --accent-100: #312e81;
  --accent-500: #6366f1;
  --accent-600: #818cf8;
  --accent-700: #a5b4fc;
  --accent-800: #c7d2fe;
  --accent-900: #e0e7ff;

  --color-success-bg: #022c22;
  --color-success-border: #065f46;
  --color-success-text: #6ee7b7;
  --color-success-strong: #10b981;

  --color-warning-bg: #451a03;
  --color-warning-border: #92400e;
  --color-warning-text: #fbbf24;
  --color-warning-strong: #f59e0b;

  --color-danger-bg: #450a0a;
  --color-danger-border: #991b1b;
  --color-danger-text: #f87171;
  --color-danger-strong: #ef4444;

  --color-info-bg: #1e1b4b;
  --color-info-border: #3730a3;
  --color-info-text: #a5b4fc;
  --color-info-strong: #6366f1;

  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 2px 6px rgba(0, 0, 0, 0.4);
  --shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.5);
}

/* ===================================================================
   Base
   =================================================================== */

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  font-size: 14px;
  line-height: 1.5;
  color: var(--text-primary);
  background: var(--bg-app);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  transition: background-color 200ms ease, color 200ms ease;
}

a { color: var(--accent-600); text-decoration: none; }
a:hover { text-decoration: underline; }

h1, h2, h3, h4, h5, h6 {
  margin: 0 0 0.5em;
  color: var(--text-primary);
  font-weight: 600;
  line-height: 1.3;
}

h1 { font-size: 24px; }
h2 { font-size: 20px; }
h3 { font-size: 16px; }
h4 { font-size: 14px; }

p { margin: 0 0 1em; }

/* ===================================================================
   Layout — Sidebar + Topbar
   =================================================================== */

.app-layout {
  display: grid;
  grid-template-columns: 240px 1fr;
  grid-template-rows: 56px 1fr;
  grid-template-areas:
    "sidebar topbar"
    "sidebar main";
  min-height: 100vh;
}

.app-sidebar {
  grid-area: sidebar;
  background: var(--bg-card);
  border-right: 1px solid var(--border-primary);
  padding: 16px 0;
  overflow-y: auto;
}

.app-topbar {
  grid-area: topbar;
  background: var(--bg-card);
  border-bottom: 1px solid var(--border-primary);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
}

.app-main {
  grid-area: main;
  padding: 24px;
  overflow-y: auto;
}

.sidebar-brand {
  padding: 0 20px 16px;
  border-bottom: 1px solid var(--border-primary);
  margin-bottom: 12px;
}

.sidebar-brand-name {
  font-size: 16px;
  font-weight: 600;
  color: var(--text-primary);
}

.sidebar-brand-sub {
  font-size: 12px;
  color: var(--text-tertiary);
  margin-top: 2px;
}

.sidebar-nav {
  list-style: none;
  margin: 0;
  padding: 0;
}

.sidebar-nav-item { margin: 1px 8px; }

.sidebar-nav-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  border-radius: var(--radius-md);
  color: var(--text-secondary);
  font-size: 13px;
  text-decoration: none;
  transition: background-color 120ms;
}

.sidebar-nav-link:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
  text-decoration: none;
}

.sidebar-nav-link.is-active {
  background: var(--accent-50);
  color: var(--accent-700);
  font-weight: 500;
}

.sidebar-nav-link.is-disabled {
  color: var(--text-muted);
  cursor: not-allowed;
  opacity: 0.6;
}

.sidebar-nav-link.is-disabled:hover {
  background: transparent;
  color: var(--text-muted);
}

.sidebar-badge {
  margin-left: auto;
  background: var(--color-danger-bg);
  color: var(--color-danger-strong);
  font-size: 11px;
  font-weight: 500;
  padding: 1px 7px;
  border-radius: var(--radius-full);
}

.sidebar-tag {
  margin-left: auto;
  background: var(--bg-muted);
  color: var(--text-muted);
  font-size: 10px;
  font-weight: 500;
  padding: 1px 6px;
  border-radius: var(--radius-sm);
  text-transform: uppercase;
}

.sidebar-section-title {
  padding: 16px 20px 6px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  color: var(--text-muted);
  letter-spacing: 0.5px;
}

/* Topbar */

.topbar-search {
  flex: 1;
  max-width: 400px;
  margin: 0 24px;
  position: relative;
}

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

.icon-btn {
  background: transparent;
  border: 1px solid var(--border-primary);
  color: var(--text-secondary);
  width: 36px;
  height: 36px;
  border-radius: var(--radius-md);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 120ms;
  position: relative;
}

.icon-btn:hover {
  background: var(--bg-hover);
  border-color: var(--border-secondary);
  color: var(--text-primary);
}

.icon-btn-badge {
  position: absolute;
  top: -4px;
  right: -4px;
  background: var(--color-danger-strong);
  color: white;
  font-size: 10px;
  font-weight: 500;
  min-width: 16px;
  height: 16px;
  border-radius: 8px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 4px;
}

.user-menu {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 10px;
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: background-color 120ms;
}

.user-menu:hover { background: var(--bg-hover); }

.user-avatar {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-full);
  background: var(--accent-100);
  color: var(--accent-700);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 500;
  font-size: 13px;
}

.user-info {
  display: flex;
  flex-direction: column;
  line-height: 1.3;
}

.user-name { font-size: 13px; font-weight: 500; color: var(--text-primary); }
.user-role { font-size: 11px; color: var(--text-tertiary); }

/* ===================================================================
   Card
   =================================================================== */

.card {
  background: var(--bg-card);
  border: 1px solid var(--border-primary);
  border-radius: var(--radius-lg);
  padding: 16px;
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border-primary);
}

.card-title {
  margin: 0;
  font-size: 16px;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 8px;
}

.card-subtitle {
  font-size: 13px;
  color: var(--text-tertiary);
  margin-top: 2px;
}

/* KPI card */
.kpi-card {
  background: var(--bg-card);
  border: 1px solid var(--border-primary);
  border-radius: var(--radius-lg);
  padding: 14px 16px;
}

.kpi-label {
  font-size: 12px;
  color: var(--text-tertiary);
  margin-bottom: 6px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.kpi-value {
  font-size: 24px;
  font-weight: 600;
  color: var(--text-primary);
}

.kpi-value.is-success { color: var(--color-success-strong); }
.kpi-value.is-warning { color: var(--color-warning-strong); }
.kpi-value.is-danger { color: var(--color-danger-strong); }

/* ===================================================================
   Buttons
   =================================================================== */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 14px;
  font-size: 13px;
  font-weight: 500;
  line-height: 1;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-primary);
  background: var(--bg-card);
  color: var(--text-primary);
  cursor: pointer;
  transition: all 120ms;
  text-decoration: none;
}

.btn:hover {
  background: var(--bg-hover);
  border-color: var(--border-secondary);
  text-decoration: none;
}

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

.btn:disabled,
.btn.is-disabled {
  opacity: 0.5;
  cursor: not-allowed;
  pointer-events: none;
}

.btn-primary {
  background: var(--accent-600);
  border-color: var(--accent-600);
  color: white;
}

.btn-primary:hover {
  background: var(--accent-700);
  border-color: var(--accent-700);
  color: white;
}

.btn-danger {
  background: var(--color-danger-strong);
  border-color: var(--color-danger-strong);
  color: white;
}

.btn-danger:hover {
  background: var(--color-danger-text);
  color: white;
}

.btn-sm { padding: 6px 10px; font-size: 12px; }
.btn-lg { padding: 10px 18px; font-size: 14px; }

/* ===================================================================
   Forms
   =================================================================== */

.form-group { margin-bottom: 16px; }

.form-label {
  display: block;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
  margin-bottom: 4px;
}

.form-label .required { color: var(--color-danger-strong); }

.form-input,
.form-select,
.form-textarea {
  width: 100%;
  padding: 8px 12px;
  font-size: 13px;
  line-height: 1.5;
  color: var(--text-primary);
  background: var(--bg-input);
  border: 1px solid var(--border-primary);
  border-radius: var(--radius-md);
  font-family: inherit;
  transition: border-color 120ms, box-shadow 120ms;
}

.form-input:focus,
.form-select:focus,
.form-textarea:focus {
  outline: none;
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px var(--accent-50);
}

.form-textarea { resize: vertical; min-height: 80px; }

.form-help {
  font-size: 12px;
  color: var(--text-tertiary);
  margin-top: 4px;
}

.form-error {
  font-size: 12px;
  color: var(--color-danger-strong);
  margin-top: 4px;
}

/* ===================================================================
   Badges
   =================================================================== */

.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  font-size: 12px;
  font-weight: 500;
  border-radius: var(--radius-md);
  border: 1px solid;
}

.badge-success { background: var(--color-success-bg); color: var(--color-success-text); border-color: var(--color-success-border); }
.badge-warning { background: var(--color-warning-bg); color: var(--color-warning-text); border-color: var(--color-warning-border); }
.badge-danger { background: var(--color-danger-bg); color: var(--color-danger-text); border-color: var(--color-danger-border); }
.badge-info { background: var(--color-info-bg); color: var(--color-info-text); border-color: var(--color-info-border); }
.badge-accent { background: var(--accent-50); color: var(--accent-800); border-color: var(--accent-100); }
.badge-muted { background: var(--bg-muted); color: var(--text-secondary); border-color: var(--border-primary); }

/* ===================================================================
   Tables
   =================================================================== */

.table-wrap {
  background: var(--bg-card);
  border: 1px solid var(--border-primary);
  border-radius: var(--radius-lg);
  overflow: hidden;
}

table.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.data-table thead {
  background: var(--bg-muted);
  border-bottom: 1px solid var(--border-primary);
}

.data-table th {
  text-align: left;
  font-weight: 500;
  font-size: 12px;
  color: var(--text-tertiary);
  padding: 10px 14px;
  white-space: nowrap;
}

.data-table tbody tr {
  border-bottom: 1px solid var(--border-primary);
  transition: background-color 120ms;
}

.data-table tbody tr:hover { background: var(--bg-hover); }
.data-table tbody tr:last-child { border-bottom: none; }

.data-table td {
  padding: 12px 14px;
  color: var(--text-primary);
}

.data-table td.muted { color: var(--text-tertiary); }

/* ===================================================================
   Alerts / Flash
   =================================================================== */

.alert {
  padding: 12px 16px;
  border-radius: var(--radius-md);
  border: 1px solid;
  display: flex;
  align-items: flex-start;
  gap: 10px;
  margin-bottom: 16px;
  font-size: 13px;
}

.alert-success { background: var(--color-success-bg); color: var(--color-success-text); border-color: var(--color-success-border); }
.alert-warning { background: var(--color-warning-bg); color: var(--color-warning-text); border-color: var(--color-warning-border); }
.alert-danger { background: var(--color-danger-bg); color: var(--color-danger-text); border-color: var(--color-danger-border); }
.alert-info { background: var(--color-info-bg); color: var(--color-info-text); border-color: var(--color-info-border); }

/* ===================================================================
   Auth (login) layout
   =================================================================== */

.auth-layout {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.auth-card {
  width: 100%;
  max-width: 380px;
  background: var(--bg-card);
  border: 1px solid var(--border-primary);
  border-radius: var(--radius-xl);
  padding: 32px 28px;
  box-shadow: var(--shadow-lg);
}

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

.auth-brand-name {
  font-size: 22px;
  font-weight: 600;
  color: var(--text-primary);
}

.auth-brand-sub {
  font-size: 13px;
  color: var(--text-tertiary);
  margin-top: 4px;
}

/* ===================================================================
   Mobile
   =================================================================== */

@media (max-width: 768px) {
  .app-layout {
    grid-template-columns: 1fr;
    grid-template-areas:
      "topbar"
      "main";
  }
  .app-sidebar {
    position: fixed;
    top: 0;
    left: 0;
    height: 100vh;
    width: 260px;
    z-index: 50;
    transform: translateX(-100%);
    transition: transform 200ms ease;
    overflow-y: auto;
    box-shadow: 2px 0 12px rgba(0, 0, 0, 0.15);
  }
  .app-sidebar.is-open { transform: translateX(0); }
  .sidebar-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 49;
    display: none;
  }
  .sidebar-backdrop.is-active { display: block; }

  /* Touch tap targets: minimum 44px iOS önerisi */
  .sidebar-nav-link {
    min-height: 44px;
    padding: 10px 14px;
  }
  .btn, .btn-sm {
    min-height: 38px;
  }
  .icon-btn {
    min-width: 38px;
    min-height: 38px;
  }

  /* Tablolar yatay scroll */
  .table-wrap {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  /* Form'lar tam genişlik */
  .form-input, .form-select {
    font-size: 16px; /* iOS zoom önleme */
  }

  /* Grid'ler mobilde tek sütun */
  .grid.grid-cols-2,
  .grid.grid-cols-3,
  .grid.grid-cols-4 {
    grid-template-columns: 1fr !important;
  }

  /* Topbar kompakt */
  .app-topbar {
    padding: 8px 12px;
  }
  .user-info {
    display: none; /* mobilde sadece avatar göster */
  }

  /* Arama kutusu mobilde daralsın, taşmasın */
  .topbar-search {
    flex: 1;
    min-width: 0;
    margin: 0 8px;
  }
  .topbar-search input { font-size: 16px; } /* iOS zoom önleme */

  /* Ana içerik padding mobilde azalt */
  .app-main {
    padding: 12px;
  }
  .card {
    padding: 14px;
  }

  /* Başlıklar mobilde küçülsün */
  h1 { font-size: 22px; }
  h2 { font-size: 18px; }

  /* Üretim aşama kartları mobilde tek sütun rahat okunsun */
  .card h1 { font-size: 20px; }
}

/* ===================================================================
   PWA standalone modu (ana ekrandan açılınca)
   =================================================================== */
@media (display-mode: standalone) {
  /* iOS notch / safe-area desteği */
  .app-topbar {
    padding-top: max(8px, env(safe-area-inset-top));
  }
  .app-main {
    padding-bottom: max(16px, env(safe-area-inset-bottom));
  }
}

/* ===================================================================
   Utility
   =================================================================== */

.flex { display: flex; }
.flex-col { flex-direction: column; }
.items-center { align-items: center; }
.items-start { align-items: flex-start; }
.justify-between { justify-content: space-between; }
.justify-center { justify-content: center; }
.gap-2 { gap: 8px; }
.gap-3 { gap: 12px; }
.gap-4 { gap: 16px; }
.text-sm { font-size: 13px; }
.text-xs { font-size: 12px; }
.text-secondary { color: var(--text-secondary); }
.text-tertiary { color: var(--text-tertiary); }
.text-muted { color: var(--text-muted); }
.text-success { color: var(--color-success-strong); }
.text-warning { color: var(--color-warning-strong); }
.text-danger { color: var(--color-danger-strong); }
.font-medium { font-weight: 500; }
.font-semibold { font-weight: 600; }
.mt-1 { margin-top: 4px; }
.mt-2 { margin-top: 8px; }
.mt-3 { margin-top: 12px; }
.mt-4 { margin-top: 16px; }
.mb-1 { margin-bottom: 4px; }
.mb-2 { margin-bottom: 8px; }
.mb-3 { margin-bottom: 12px; }
.mb-4 { margin-bottom: 16px; }
.grid { display: grid; }
.grid-cols-2 { grid-template-columns: repeat(2, 1fr); }
.grid-cols-3 { grid-template-columns: repeat(3, 1fr); }
.grid-cols-4 { grid-template-columns: repeat(4, 1fr); }
.w-full { width: 100%; }
