/* ── Shared admin styles ── */

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

:root {
  --bg: #FEFAF6;
  --bg-nav: #FEFAF6;
  --bg-content: #f5f3ef;
  --border: rgba(0,0,0,0.08);
  --text: #1B1B1B;
  --text-2: #555;
  --muted: #999;
  --accent: #3939C6;
  --green: #4FB0A1;
  --green-light: #DCEFEC;
  --green-dark: #2C4C48;
  --violet-light: #D7D7F3;
  --red: #ef4444;
  --orange: #f59e0b;
  --teal: #3d8b7a;
  --nav-collapsed: 64px;
  --nav-expanded: 240px;
}

html, body {
  width: 100%; height: 100%;
  font-family: 'Inter', -apple-system, sans-serif;
  background: var(--bg-content);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
}

/* ── Layout ── */
.layout { display: flex; height: 100vh; }

/* ── Sidebar ── */
.sidebar {
  position: relative; z-index: 10;
  width: var(--nav-collapsed); min-width: var(--nav-collapsed);
  height: 100vh; background: var(--bg-nav);
  border-right: 1px solid var(--border);
  display: flex; flex-direction: column;
  transition: width 0.2s ease, min-width 0.2s ease;
  overflow: hidden;
}
.sidebar:hover {
  width: var(--nav-expanded); min-width: var(--nav-expanded);
  box-shadow: 4px 0 24px rgba(0,0,0,0.06);
}
.sidebar-logo {
  height: 72px; display: flex; align-items: center;
  padding: 0 16px; flex-shrink: 0;
}
.sidebar-logo .logo-icon { width: 32px; height: 32px; flex-shrink: 0; }
.sidebar-logo .logo-text {
  font-size: 22px; font-weight: 700; margin-left: 12px;
  white-space: nowrap; opacity: 0; transition: opacity 0.15s ease;
}
.sidebar:hover .logo-text { opacity: 1; }

.sidebar-nav {
  flex: 1; display: flex; flex-direction: column;
  padding: 8px; gap: 0px; overflow-y: auto; overflow-x: hidden;
  transition: gap 0.2s ease;
}
.sidebar:hover .sidebar-nav { gap: 2px; }

.nav-item {
  display: flex; align-items: center; gap: 12px;
  padding: 8px 12px; border-radius: 8px; cursor: pointer;
  white-space: nowrap; font-size: 14px; font-weight: 500;
  color: var(--text-2); transition: background 0.12s, color 0.12s;
  text-decoration: none; user-select: none;
}
.nav-item:hover { background: var(--green-light); color: var(--text); }
.nav-item.active { color: var(--green); }

.nav-item .nav-icon {
  width: 24px; height: 24px; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
}
.nav-item .nav-icon svg {
  width: 20px; height: 20px; stroke: currentColor; fill: none;
  stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round;
}
.nav-item .nav-label { opacity: 0; transition: opacity 0.15s ease; flex: 1; }
.sidebar:hover .nav-label { opacity: 1; }

.nav-item .nav-chevron {
  opacity: 0; transition: opacity 0.15s ease, transform 0.2s ease;
  width: 16px; height: 16px; flex-shrink: 0;
}
.sidebar:hover .nav-chevron { opacity: 1; }
.nav-chevron.open { transform: rotate(180deg); }
.nav-chevron svg {
  width: 16px; height: 16px; stroke: currentColor; fill: none;
  stroke-width: 2; stroke-linecap: round; stroke-linejoin: round;
}

.nav-sub {
  display: flex; flex-direction: column; gap: 1px;
  overflow: hidden; max-height: 0; transition: max-height 0.2s ease;
}
.sidebar:hover .nav-sub.open { max-height: 200px; }

.nav-sub .nav-sub-item {
  padding: 6px 12px 6px 48px; font-size: 13px; font-weight: 500;
  color: var(--text-2); border-radius: 6px; cursor: pointer;
  white-space: nowrap; opacity: 0;
  transition: opacity 0.15s ease, background 0.12s, color 0.12s;
  text-decoration: none; display: block;
}
.sidebar:hover .nav-sub .nav-sub-item { opacity: 1; }
.nav-sub .nav-sub-item:hover { background: var(--green-light); color: var(--text); }
.nav-sub .nav-sub-item.active { color: var(--green); font-weight: 600; }

.sidebar-footer {
  height: 56px; display: flex; align-items: center;
  padding: 0 8px; border-top: 1px solid var(--border); flex-shrink: 0;
}
.sidebar-footer .nav-item { color: var(--muted); }

/* ── Main content ── */
.main {
  flex: 1; display: flex; flex-direction: column;
  overflow: hidden; min-width: 0;
}
.main-header {
  display: flex; align-items: flex-start; justify-content: space-between;
  height: auto; padding: 20px 32px 0; flex-shrink: 0;
}
.main-header h1 {
  font-size: 28px; font-weight: 700; letter-spacing: -0.02em;
}
.main-header .subtitle {
  font-size: 14px; color: var(--text-2); margin-top: 4px;
}
.main-body { flex: 1; overflow-y: auto; padding: 20px 32px 32px; }

/* ── Data table ── */
.data-table {
  width: 100%; border-collapse: collapse; font-size: 13px;
  background: var(--bg);
}
.data-table thead th {
  text-align: left; padding: 10px 14px; font-weight: 600;
  font-size: 12px; color: var(--text-2);
  border-bottom: 1px solid var(--border);
  white-space: nowrap; user-select: none;
}
.data-table thead th .th-inner {
  display: inline-flex; align-items: center; gap: 4px;
}
.data-table thead th svg {
  width: 14px; height: 14px; stroke: var(--muted); fill: none;
  stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; flex-shrink: 0;
}
.data-table tbody td {
  padding: 10px 14px; border-bottom: 1px solid var(--border);
  vertical-align: middle; white-space: nowrap;
}
.data-table tbody tr:last-child td { border-bottom: none; }
.data-table tbody tr:hover { background: rgba(79, 176, 161, 0.04); }

.cell-checkbox { width: 32px; }
.cell-checkbox input { width: 16px; height: 16px; accent-color: var(--green); cursor: pointer; }

/* ── Badges ── */
.badge {
  display: inline-block; padding: 3px 10px; border-radius: 100px;
  font-size: 12px; font-weight: 500;
}
.badge-green { background: var(--green-light); color: var(--green-dark); }
.badge-violet { background: var(--violet-light); color: var(--accent); }
.badge-muted { background: #f0eeea; color: var(--text-2); }

/* ── Mobile toggle ── */
.mobile-toggle {
  display: none;
  align-items: center; justify-content: center;
  width: 40px; height: 40px; border-radius: 8px;
  border: 1px solid var(--border); background: var(--bg);
  cursor: pointer; flex-shrink: 0;
}
.mobile-toggle svg {
  width: 20px; height: 20px; stroke: var(--text); fill: none;
  stroke-width: 2; stroke-linecap: round; stroke-linejoin: round;
}

/* ── Sidebar backdrop ── */
.sidebar-backdrop {
  display: none; position: fixed; inset: 0;
  background: rgba(0,0,0,0.4); z-index: 9;
}

/* ── Responsive ── */
@media (max-width: 768px) {
  html, body { overflow: auto; }
  .layout { height: auto; min-height: 100vh; }

  /* Sidebar: off-screen drawer */
  .sidebar {
    position: fixed; left: -260px;
    width: 240px !important; min-width: 240px !important;
    transition: left 0.25s ease;
    z-index: 20;
  }
  .sidebar:hover {
    width: 240px; min-width: 240px;
    box-shadow: none;
  }
  .sidebar.open {
    left: 0;
    box-shadow: 4px 0 24px rgba(0,0,0,0.12);
  }
  /* Always show labels on mobile sidebar */
  .sidebar .logo-text,
  .sidebar .nav-label,
  .sidebar .nav-chevron,
  .sidebar .nav-sub .nav-sub-item { opacity: 1 !important; }
  .sidebar .sidebar-nav { gap: 2px; }
  .sidebar .nav-sub.open { max-height: 200px; }

  .sidebar-backdrop.open { display: block; }

  .mobile-toggle { display: flex; }

  /* Main content */
  .main { width: 100%; }
  .main-header { padding: 16px 16px 0; flex-wrap: wrap; gap: 8px; }
  .main-header h1 { font-size: 22px; }
  .main-body { padding: 16px 16px 24px; }

  /* Data table scroll */
  .table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .data-table { min-width: 700px; }
}

@media (max-width: 480px) {
  .main-header h1 { font-size: 20px; }
  .main-body { padding: 12px 12px 20px; }
}
