/* =====================================================
   AstroZapp Admin — layout Dastone-like (Bootstrap 5)
   ===================================================== */

:root {
  --sidebar-width: 240px;
  --sidebar-collapsed-width: 64px;
  --sidebar-bg: #1b1f2a;
  --sidebar-border: rgba(255,255,255,.06);
  --sidebar-text: #a8b0c8;
  --sidebar-text-active: #fff;
  --sidebar-active-bg: rgba(115,103,240,.18);
  --sidebar-active-border: #7367f0;
  --topbar-height: 60px;
  --topbar-bg: #fff;
  --topbar-shadow: 0 2px 8px rgba(0,0,0,.06);
  --primary: #7367f0;
  --primary-light: rgba(115,103,240,.12);
  --success: #28c76f;
  --warning: #ff9f43;
  --danger: #ea5455;
  --info: #00cfe8;
  --card-radius: 10px;
  --body-bg: #f4f5fa;
}

body { background: var(--body-bg); font-family: 'Montserrat', 'Segoe UI', sans-serif; }

/* ── Sidebar ─────────────────────────────────────── */
#sidebar {
  position: fixed; top: 0; left: 0;
  width: var(--sidebar-width); height: 100vh;
  background: var(--sidebar-bg);
  display: flex; flex-direction: column;
  transition: width .25s ease;
  z-index: 1040; overflow-x: hidden;
}

.sidebar-logo {
  height: var(--topbar-height);
  display: flex; align-items: center; gap: 10px;
  padding: 0 16px;
  border-bottom: 1px solid var(--sidebar-border);
  flex-shrink: 0;
}
.sidebar-logo .logo-icon { font-size: 1.5rem; }
.sidebar-logo .logo-text { color: #fff; font-weight: 700; font-size: .95rem; white-space: nowrap; }

.sidebar-nav { flex: 1; overflow-y: auto; padding: 12px 0; }
.nav-section-label {
  font-size: .68rem; letter-spacing: .08em; text-transform: uppercase;
  color: rgba(255,255,255,.3); padding: 8px 20px 4px;
}

.sidebar-nav .nav-item {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 20px; color: var(--sidebar-text);
  text-decoration: none; border-radius: 6px; margin: 2px 8px;
  transition: background .15s, color .15s;
  white-space: nowrap;
}
.sidebar-nav .nav-item svg { width: 18px; height: 18px; flex-shrink: 0; }
.sidebar-nav .nav-item:hover { background: var(--sidebar-active-bg); color: #fff; }
.sidebar-nav .nav-item.active {
  background: var(--sidebar-active-bg);
  color: var(--sidebar-text-active);
  border-left: 3px solid var(--sidebar-active-border);
  padding-left: 17px;
}

.sidebar-user {
  border-top: 1px solid var(--sidebar-border);
  padding: 14px 16px;
  display: flex; align-items: center; gap: 10px; flex-shrink: 0;
}
.sidebar-user .user-avatar {
  width: 34px; height: 34px; border-radius: 50%;
  background: var(--primary); color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: .85rem; flex-shrink: 0;
}
.sidebar-user .user-info { overflow: hidden; }
.sidebar-user strong { display: block; color: #fff; font-size: .82rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sidebar-user small { color: var(--sidebar-text); font-size: .72rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; display: block; }

/* ── Main wrapper ───────────────────────────────── */
.main-wrapper {
  margin-left: var(--sidebar-width);
  min-height: 100vh;
  transition: margin-left .25s ease;
  display: flex; flex-direction: column;
}

/* ── Topbar ─────────────────────────────────────── */
.topbar {
  position: sticky; top: 0; z-index: 1030;
  height: var(--topbar-height);
  background: var(--topbar-bg);
  box-shadow: var(--topbar-shadow);
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 24px;
}
.topbar-left { display: flex; align-items: center; gap: 12px; }
.topbar .page-title { font-weight: 600; font-size: .95rem; color: #333; }
.topbar-right { display: flex; align-items: center; gap: 12px; }
.topbar-user { display: flex; align-items: center; gap: 8px; }
.topbar-user-avatar {
  width: 32px; height: 32px; border-radius: 50%;
  background: var(--primary); color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: .8rem;
}
.topbar-username { font-size: .85rem; font-weight: 500; color: #333; }
.btn-logout {
  display: flex; align-items: center; gap: 6px;
  padding: 6px 14px; border-radius: 6px;
  background: var(--primary-light); color: var(--primary);
  text-decoration: none; font-size: .82rem; font-weight: 600;
  transition: background .15s;
}
.btn-logout:hover { background: var(--primary); color: #fff; }
.mobile-menu-btn {
  display: none; background: none; border: none;
  color: #555; cursor: pointer; padding: 4px;
}

/* ── Content ─────────────────────────────────────── */
.content { flex: 1; padding: 24px; }
.page-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 20px; }
.page-header h1 { font-size: 1.2rem; font-weight: 700; color: #2d3158; margin: 0; }

/* ── Stat cards ──────────────────────────────────── */
.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 16px; margin-bottom: 24px; }
.stat-card {
  background: #fff; border-radius: var(--card-radius);
  padding: 20px; display: flex; align-items: center; justify-content: space-between;
  box-shadow: 0 2px 8px rgba(0,0,0,.05);
}
.stat-label { font-size: .78rem; color: #888; font-weight: 500; margin-bottom: 4px; }
.stat-value { font-size: 1.5rem; font-weight: 700; color: #2d3158; }
.stat-change { font-size: .75rem; margin-top: 2px; color: var(--success); }
.stat-icon {
  width: 46px; height: 46px; border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
}
.stat-icon svg { width: 22px; height: 22px; }
.stat-icon.purple { background: rgba(115,103,240,.12); color: var(--primary); }
.stat-icon.orange { background: rgba(255,159,67,.12); color: var(--warning); }
.stat-icon.blue   { background: rgba(0,207,232,.12);  color: var(--info); }
.stat-icon.green  { background: rgba(40,199,111,.12); color: var(--success); }
.stat-icon.red    { background: rgba(234,84,85,.12);  color: var(--danger); }

/* ── Table card ──────────────────────────────────── */
.table-card {
  background: #fff; border-radius: var(--card-radius);
  box-shadow: 0 2px 8px rgba(0,0,0,.05); overflow: hidden;
}
.table-header {
  padding: 16px 20px; display: flex; align-items: center; justify-content: space-between;
  border-bottom: 1px solid #f0f0f0;
}
.table-header h2 { font-size: 1rem; font-weight: 600; color: #2d3158; margin: 0; }
.data-table { width: 100%; border-collapse: collapse; font-size: .85rem; }
.data-table thead th {
  padding: 12px 16px; text-align: left;
  background: #fafafa; color: #888;
  font-size: .75rem; font-weight: 600; text-transform: uppercase; letter-spacing: .05em;
  border-bottom: 1px solid #f0f0f0;
}
.data-table tbody td { padding: 12px 16px; border-bottom: 1px solid #f8f8f8; vertical-align: middle; }
.data-table tbody tr:hover { background: #fafbff; }
.table-responsive { overflow-x: auto; }

/* ── Badges ──────────────────────────────────────── */
.badge { display: inline-flex; align-items: center; padding: 3px 10px; border-radius: 20px; font-size: .72rem; font-weight: 600; }
.badge-success { background: rgba(40,199,111,.12); color: var(--success); }
.badge-warning { background: rgba(255,159,67,.12); color: var(--warning); }
.badge-danger  { background: rgba(234,84,85,.12);  color: var(--danger); }
.badge-info    { background: rgba(0,207,232,.12);  color: var(--info); }
.badge-secondary { background: #f0f0f0; color: #888; }

/* ── Alerts ──────────────────────────────────────── */
.alert { padding: 12px 16px; border-radius: 8px; margin-bottom: 16px; font-size: .88rem; }
.alert-success { background: rgba(40,199,111,.1); color: #1a8a50; border-left: 4px solid var(--success); }
.alert-error   { background: rgba(234,84,85,.1);  color: #b92929; border-left: 4px solid var(--danger); }
.alert-info    { background: rgba(0,207,232,.1);  color: #007a96; border-left: 4px solid var(--info); }

/* ── Forms ───────────────────────────────────────── */
.form-card { background: #fff; border-radius: var(--card-radius); padding: 24px; box-shadow: 0 2px 8px rgba(0,0,0,.05); }
.form-label { font-size: .82rem; font-weight: 600; color: #555; margin-bottom: 4px; }
.form-control, .form-select {
  border: 1px solid #e0e0e0; border-radius: 7px;
  padding: 9px 13px; font-size: .88rem;
  transition: border-color .15s, box-shadow .15s;
}
.form-control:focus, .form-select:focus {
  border-color: var(--primary); box-shadow: 0 0 0 3px rgba(115,103,240,.12); outline: none;
}

/* ── Buttons ─────────────────────────────────────── */
.btn-primary-az {
  background: var(--primary); color: #fff; border: none;
  padding: 9px 20px; border-radius: 7px; font-weight: 600; font-size: .88rem;
  cursor: pointer; transition: opacity .15s;
}
.btn-primary-az:hover { opacity: .88; }
.btn-secondary-az {
  background: #f0f0f0; color: #555; border: none;
  padding: 9px 20px; border-radius: 7px; font-weight: 600; font-size: .88rem;
  cursor: pointer; text-decoration: none;
}
.btn-sm-az { padding: 5px 12px; font-size: .78rem; }

/* ── Pagination ──────────────────────────────────── */
.pagination { display: flex; gap: 4px; list-style: none; padding: 0; margin: 16px 0 0; justify-content: center; }
.pagination a, .pagination span {
  display: flex; align-items: center; justify-content: center;
  min-width: 32px; height: 32px; border-radius: 6px; padding: 0 8px;
  font-size: .82rem; font-weight: 500; text-decoration: none;
  color: #555; background: #fff; border: 1px solid #e0e0e0;
}
.pagination .active span { background: var(--primary); color: #fff; border-color: var(--primary); }
.pagination a:hover { background: var(--primary-light); color: var(--primary); }

/* ── No data ─────────────────────────────────────── */
.no-data { padding: 40px; text-align: center; color: #aaa; font-size: .9rem; }

/* ── Overlay (mobile sidebar) ────────────────────── */
#sidebar-overlay {
  display: none; position: fixed; inset: 0;
  background: rgba(0,0,0,.4); z-index: 1035;
}

/* ── Mobile ──────────────────────────────────────── */
@media (max-width: 991px) {
  #sidebar {
    transform: translateX(-100%);
    transition: transform .25s ease;
  }
  #sidebar.open {
    transform: translateX(0);
  }
  #sidebar-overlay.show { display: block; }
  .main-wrapper { margin-left: 0; }
  .mobile-menu-btn { display: flex; }
  .topbar-username { display: none; }

  /* Tables: hide secondary columns on mobile */
  .d-none-mobile { display: none !important; }

  .stats-grid { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 575px) {
  .stats-grid { grid-template-columns: 1fr; }
  .content { padding: 16px; }
  .table-header { flex-direction: column; align-items: flex-start; gap: 8px; }
}

/* ── Login page ──────────────────────────────────── */
.login-page {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  background: linear-gradient(135deg, #1b1f2a 0%, #2d3158 100%);
}
.login-card {
  background: #fff; border-radius: 14px; padding: 40px;
  width: 100%; max-width: 420px;
  box-shadow: 0 20px 60px rgba(0,0,0,.3);
}
.login-logo { text-align: center; margin-bottom: 28px; }
.login-logo .logo-icon { font-size: 2.5rem; }
.login-logo h1 { font-size: 1.4rem; font-weight: 700; color: #2d3158; margin: 8px 0 4px; }
.login-logo p { font-size: .82rem; color: #888; margin: 0; }
