/* CodeWave Studio Admin — matches public site dark + orange/pink theme */
:root {
  --primary: #ff8a00;
  --secondary: #e52e71;
  --accent: #ff8a00;
  --text-primary: #ffffff;
  --text-secondary: #bfbfbf;
  --text-muted: #9e9e9e;
  --bg-primary: #000000;
  --bg-secondary: #0a0a0a;
  --bg-tertiary: #1e1e1e;
  --bg-card: rgba(20, 20, 20, 0.95);
  --bg-hover: rgba(255, 138, 0, 0.08);
  --border-color: rgba(255, 138, 0, 0.15);
  --border-light: rgba(255, 255, 255, 0.08);
  --gradient-primary: linear-gradient(135deg, #ff8a00, #e52e71);
  --gradient-soft: linear-gradient(135deg, rgba(255,138,0,0.15), rgba(229,46,113,0.15));
  --success: #22c55e;
  --danger: #ef4444;
  --warning: #f59e0b;
  --info: #3b82f6;
  --sidebar-width: 270px;
  --topbar-height: 64px;
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
  --font: 'Manrope', 'DM Sans', system-ui, sans-serif;
  --transition: 0.25s ease;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { scroll-behavior: smooth; scrollbar-gutter: stable; }

/* ===================== CUSTOM SCROLLBAR ===================== */
* {
  scrollbar-width: thin;
  scrollbar-color: #ff8a00 #1e1e1e;
}

::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

::-webkit-scrollbar-track {
  background: var(--bg-tertiary);
  border-radius: 10px;
}

::-webkit-scrollbar-thumb {
  background: var(--gradient-primary);
  border-radius: 10px;
  border: 2px solid var(--bg-tertiary);
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.3);
}

::-webkit-scrollbar-thumb:hover {
  background: linear-gradient(135deg, #ffb347, #f04d8a);
}

::-webkit-scrollbar-corner {
  background: var(--bg-tertiary);
}

/* Sidebar nav — slimmer scrollbar */
.sidebar-nav::-webkit-scrollbar { width: 5px; }
.sidebar-nav::-webkit-scrollbar-thumb {
  border-width: 1px;
  background: rgba(255, 138, 0, 0.45);
}
.sidebar-nav::-webkit-scrollbar-thumb:hover {
  background: var(--gradient-primary);
}

/* Tables & modals */
.table-wrap::-webkit-scrollbar,
.modal::-webkit-scrollbar,
.admin-content::-webkit-scrollbar {
  height: 6px;
  width: 6px;
}

.table-wrap::-webkit-scrollbar-thumb,
.modal::-webkit-scrollbar-thumb {
  border-width: 1px;
}

body.admin-body {
  font-family: var(--font);
  background: var(--bg-primary);
  color: var(--text-primary);
  line-height: 1.6;
  min-height: 100vh;
}

a { color: var(--primary); text-decoration: none; transition: color var(--transition); }
a:hover { color: #ffb347; }

.muted { color: var(--text-muted); }

.admin-app { display: flex; min-height: 100vh; }

/* Sidebar */
.admin-sidebar {
  width: var(--sidebar-width);
  background: var(--bg-secondary);
  border-right: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  z-index: 1000;
  transition: transform var(--transition);
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 20px 18px;
  border-bottom: 1px solid var(--border-light);
  text-decoration: none;
  color: inherit;
  transition: background var(--transition);
}

.sidebar-brand:hover { background: var(--bg-hover); }

.sidebar-logo { width: 42px; height: 42px; border-radius: 10px; object-fit: cover; }

.sidebar-brand-text { display: flex; flex-direction: column; }
.brand-name { font-weight: 700; font-size: 0.95rem; background: var(--gradient-primary); -webkit-background-clip: text; -webkit-text-fill-color: transparent; background-clip: text; }
.brand-tag { font-size: 0.7rem; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.08em; }

.sidebar-nav { flex: 1; padding: 16px 12px; overflow-y: auto; }

.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  font-size: 0.9rem;
  font-weight: 500;
  margin-bottom: 4px;
  transition: all var(--transition);
}

.nav-item i { width: 20px; text-align: center; font-size: 0.95rem; }
.nav-item:hover { background: var(--bg-hover); color: var(--text-primary); }
.nav-item.active { background: var(--gradient-soft); color: var(--primary); border: 1px solid var(--border-color); }
.logout-link:hover { color: var(--danger) !important; background: rgba(239,68,68,0.1) !important; }

.sidebar-footer { padding: 12px; border-top: 1px solid var(--border-light); }

/* Main area */
.admin-main {
  flex: 1;
  margin-left: var(--sidebar-width);
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.admin-topbar {
  height: auto;
  min-height: var(--topbar-height);
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 0;
  padding: 0 24px;
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border-color);
  position: sticky;
  top: 0;
  z-index: 100;
}

.admin-topbar-row {
  display: flex;
  align-items: center;
  gap: 16px;
  min-height: var(--topbar-height);
  width: 100%;
}

.topbar-actions-compact {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}

.topbar-actions-secondary {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
  padding-bottom: 12px;
  width: 100%;
}

.admin-badge-desktop { }

.sidebar-toggle {
  display: none;
  background: none;
  border: 1px solid var(--border-color);
  color: var(--text-primary);
  width: 40px; height: 40px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 1.1rem;
}

.topbar-title h1 { font-size: 1.15rem; font-weight: 600; }
.topbar-actions { display: flex; align-items: center; gap: 12px; }

.admin-badge {
  font-size: 0.75rem;
  padding: 6px 12px;
  border-radius: 999px;
  background: var(--gradient-soft);
  border: 1px solid var(--border-color);
  color: var(--primary);
}

.admin-content { flex: 1; padding: 24px; }
.admin-footer {
  padding: 16px 24px;
  border-top: 1px solid var(--border-light);
  text-align: center;
  font-size: 0.8rem;
  color: var(--text-muted);
}

.sidebar-overlay {
  display: none;
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.6);
  z-index: 999;
}

/* Cards & stats */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 20px;
  margin-bottom: 28px;
}

.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 22px;
  transition: transform var(--transition), box-shadow var(--transition);
}

.stat-card:hover { transform: translateY(-2px); box-shadow: var(--shadow); }

.stat-card .stat-icon {
  width: 44px; height: 44px;
  border-radius: var(--radius-sm);
  display: flex; align-items: center; justify-content: center;
  background: var(--gradient-soft);
  color: var(--primary);
  font-size: 1.1rem;
  margin-bottom: 14px;
}

.stat-card .stat-value { font-size: 1.75rem; font-weight: 700; margin-bottom: 4px; }
.stat-card .stat-label { font-size: 0.85rem; color: var(--text-muted); }

.card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 24px;
  margin-bottom: 24px;
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}

.card-header h2 { font-size: 1.1rem; font-weight: 600; }

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 18px;
  border: none;
  border-radius: var(--radius-sm);
  font-family: inherit;
  font-size: 0.875rem;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition);
  text-decoration: none;
}

.btn-primary { background: var(--gradient-primary); color: #fff; }
.btn-primary:hover { opacity: 0.9; transform: translateY(-1px); color: #fff; }
.btn-secondary { background: var(--bg-tertiary); color: var(--text-primary); border: 1px solid var(--border-light); }
.btn-secondary:hover { border-color: var(--border-color); color: var(--text-primary); }
.btn-success { background: var(--success); color: #fff; }
.btn-danger { background: var(--danger); color: #fff; }
.btn-sm { padding: 6px 12px; font-size: 0.8rem; }
.btn-group { display: flex; gap: 10px; flex-wrap: wrap; }

/* Tables */
.table-wrap { overflow-x: auto; border-radius: var(--radius-sm); }
.data-table {
  width: 100%;
  border-collapse: collapse;
  min-width: 700px;
}

.data-table th {
  text-align: left;
  padding: 14px 16px;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  background: var(--bg-tertiary);
  border-bottom: 1px solid var(--border-light);
}

.data-table td {
  padding: 14px 16px;
  border-bottom: 1px solid var(--border-light);
  font-size: 0.9rem;
  color: var(--text-secondary);
}

.data-table tr:hover td { background: var(--bg-hover); }
.data-table tr:last-child td { border-bottom: none; }

.badge {
  display: inline-block;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 600;
}

.badge-primary { background: rgba(255,138,0,0.15); color: var(--primary); }
.badge-secondary { background: rgba(255,255,255,0.08); color: var(--text-muted); }
.badge-success { background: rgba(34,197,94,0.15); color: var(--success); }
.badge-warning { background: rgba(245,158,11,0.15); color: var(--warning); }
.badge-danger { background: rgba(239,68,68,0.15); color: var(--danger); }

/* Forms */
.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 16px;
}

.form-group { margin-bottom: 16px; }
.form-group label,
.form-label { display: block; font-size: 0.85rem; color: var(--text-muted); margin-bottom: 6px; font-weight: 500; }

.form-control {
  width: 100%;
  padding: 11px 14px;
  background: var(--bg-tertiary);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-family: inherit;
  font-size: 0.9rem;
  transition: border-color var(--transition);
}

.form-control:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(255,138,0,0.15);
}

textarea.form-control { min-height: 100px; resize: vertical; }
select.form-control { cursor: pointer; }

/* Alerts */
.alert {
  padding: 14px 18px;
  border-radius: var(--radius-sm);
  margin-bottom: 20px;
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 0.9rem;
}

.alert-error { background: rgba(239,68,68,0.12); border: 1px solid rgba(239,68,68,0.3); color: #fca5a5; }
.alert-success { background: rgba(34,197,94,0.12); border: 1px solid rgba(34,197,94,0.3); color: #86efac; }
.alert-warning { background: rgba(245,158,11,0.12); border: 1px solid rgba(245,158,11,0.3); color: #fcd34d; }

/* Modal */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.75);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 2000;
  padding: 20px;
}

.modal-overlay.active { display: flex; }

.modal {
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  width: 100%;
  max-width: 560px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: var(--shadow);
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 24px;
  border-bottom: 1px solid var(--border-light);
}

.modal-header h3 { font-size: 1.1rem; }
.modal-close { background: none; border: none; color: var(--text-muted); font-size: 1.25rem; cursor: pointer; }
.modal-body { padding: 24px; }
.modal-footer { padding: 16px 24px; border-top: 1px solid var(--border-light); display: flex; justify-content: flex-end; gap: 10px; }

/* Empty state */
.empty-state { text-align: center; padding: 60px 20px; color: var(--text-muted); }
.empty-state i { font-size: 3rem; margin-bottom: 16px; opacity: 0.4; }
.empty-state h3 { color: var(--text-secondary); margin-bottom: 8px; }

/* Quick links grid (dashboard) */
.quick-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 16px;
}

.quick-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  padding: 28px 20px;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  color: var(--text-secondary);
  transition: all var(--transition);
  text-align: center;
}

.quick-card i { font-size: 1.75rem; color: var(--primary); }
.quick-card:hover { border-color: var(--primary); color: var(--text-primary); transform: translateY(-3px); box-shadow: var(--shadow); }

/* Tabs */
.tabs { display: flex; gap: 8px; margin-bottom: 20px; flex-wrap: wrap; }
.tab-btn {
  padding: 10px 18px;
  background: var(--bg-tertiary);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  cursor: pointer;
  font-family: inherit;
  font-size: 0.875rem;
  font-weight: 500;
  transition: all var(--transition);
}

.tab-btn.active, .tab-btn:hover { background: var(--gradient-soft); border-color: var(--border-color); color: var(--primary); }
.tab-panel { display: none; }
.tab-panel.active { display: block; }

/* Login page */
.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: radial-gradient(ellipse at top, rgba(255,138,0,0.12) 0%, transparent 50%),
              radial-gradient(ellipse at bottom right, rgba(229,46,113,0.1) 0%, transparent 50%),
              var(--bg-primary);
}

.login-card {
  width: 100%;
  max-width: 420px;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 40px 32px;
  box-shadow: var(--shadow);
}

.login-brand { text-align: center; margin-bottom: 32px; }
.login-brand img { width: 64px; height: 64px; border-radius: 14px; margin-bottom: 16px; }
.login-brand h1 { font-size: 1.35rem; background: var(--gradient-primary); -webkit-background-clip: text; -webkit-text-fill-color: transparent; background-clip: text; }
.login-brand p { color: var(--text-muted); font-size: 0.85rem; margin-top: 4px; }

/* Invoice specific */
.invoice-page .invoice-card { background: #fff; color: #111; border-radius: var(--radius-md); padding: 32px; }
.invoice-page .admin-content { max-width: 100%; }
@media print {
  .admin-sidebar, .admin-topbar, .admin-footer, .sidebar-overlay, .no-print { display: none !important; }
  .admin-main { margin-left: 0 !important; }
  .admin-content { padding: 0 !important; }
}

/* Responsive */
@media (max-width: 992px) {
  .admin-sidebar { transform: translateX(-100%); transition: transform 0.25s ease; z-index: 1000; }
  .admin-sidebar.open { transform: translateX(0); }
  .admin-main { margin-left: 0; }
  .sidebar-toggle { display: flex; align-items: center; justify-content: center; }
  .sidebar-overlay.active { display: block; }
  .admin-badge-desktop { display: none; }
}

@media (max-width: 768px) {
  .admin-topbar {
    padding: 0 12px;
  }
  .admin-topbar-row {
    gap: 10px;
    min-height: 56px;
  }
  .topbar-title {
    flex: 1;
    min-width: 0;
  }
  .topbar-title h1 {
    font-size: 1rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }
  .topbar-actions-secondary {
    padding-bottom: 10px;
  }
  .form-grid {
    grid-template-columns: 1fr;
  }
  .card {
    padding: 16px;
    margin-bottom: 16px;
  }
  .card-header {
    margin-bottom: 14px;
    flex-direction: column;
    align-items: flex-start;
  }
  .card-header .btn { width: 100%; justify-content: center; }
  .stats-grid { grid-template-columns: repeat(2, 1fr); gap: 12px; }
  .quick-grid { grid-template-columns: repeat(2, 1fr); gap: 10px; }
  .quick-card { padding: 20px 14px; }
  .table-wrap {
    margin: 0 -16px;
    padding: 0 16px;
    border-radius: 0;
  }
  .data-table { min-width: 560px; }
  .btn { min-height: 40px; }
}

@media (max-width: 576px) {
  .admin-content { padding: 14px; }
  .stats-grid { grid-template-columns: 1fr; }
  .quick-grid { grid-template-columns: 1fr 1fr; }
  .stat-card { padding: 16px; }
  .stat-card .stat-value { font-size: 1.35rem; }
  .btn-sm {
    padding: 8px 12px;
  }
  .data-table th,
  .data-table td {
    padding: 10px 12px;
    font-size: 0.82rem;
  }
  .empty-state { padding: 40px 16px; }
  .login-card { padding: 28px 20px; margin: 12px; }
}
