/* ============================================================
   QLS Admin Suite — Design System
   Shared CSS for all suite apps.
   ============================================================ */

/* --- Tokens --- */
:root {
  --onyx: #1d1d1b;
  --gold: #C5B58E;
  --gold-light: #e8dcc4;
  --gold-dark: #9e8e68;
  --burgundy: #7A2535;
  --burgundy-dark: #5e1a27;
  --mocha: #A47864;
  --almond: #EAE0CD;
  --charcoal: #383838;
  --brass: #A68A64;
  --mist: #F4F4F4;
  --white: #fff;
  --success-bg: #d8f3dc;
  --success: #2d6a4f;
  --error-bg: #ffe0e0;
  --error: #c1121f;
  --amber-bg: #fff3cd;
  --amber: #856404;
  --radius: 4px;
  --shadow-sm: 0 1px 3px rgba(0,0,0,.06);
  --shadow-md: 0 4px 12px rgba(0,0,0,.08);
  --shadow-lg: 0 8px 24px rgba(0,0,0,.12);
  --transition: .18s ease;
}

/* --- Reset & Base --- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 14px; -webkit-font-smoothing: antialiased; }
body {
  font-family: 'Poppins', sans-serif;
  font-weight: 300;
  color: var(--onyx);
  background: var(--mist);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}
a { color: var(--burgundy); text-decoration: none; }
a:hover { text-decoration: underline; }
img { max-width: 100%; display: block; }

/* --- Typography --- */
h1, h2, h3, h4 { font-family: 'Cormorant Garamond', serif; font-weight: 400; }
.page-title { font-family: 'Cormorant Garamond', serif; font-size: 26px; font-weight: 400; color: var(--onyx); }
.page-sub { font-size: 11px; color: var(--mocha); font-weight: 300; margin-top: 2px; }
.text-muted { color: var(--mocha); }
.text-small { font-size: 11px; }
.text-xs { font-size: 10px; }
.text-gold { color: var(--gold); }
.text-burgundy { color: var(--burgundy); }
.text-success { color: var(--success); }
.text-error { color: var(--error); }

/* --- Topbar --- */
.suite-topbar {
  display: flex; align-items: center; height: 58px;
  background: var(--onyx); color: var(--gold-light);
  padding: 0 20px; position: sticky; top: 0; z-index: 100;
}
.topbar-hamburger {
  display: none; background: none; border: none; color: var(--gold-light);
  font-size: 22px; margin-right: 12px; cursor: pointer;
}
.topbar-logo {
  display: flex; align-items: center; gap: 10px;
  text-decoration: none; color: var(--gold-light);
}
.topbar-logo svg, .topbar-logo img { height: 28px; width: auto; }
.topbar-logo-text {
  font-family: 'Cormorant Garamond', serif; font-size: 16px;
  font-weight: 400; letter-spacing: .04em; color: var(--gold-light);
}
.topbar-badge {
  background: var(--burgundy); color: var(--gold-light);
  font-size: 9px; font-weight: 500; letter-spacing: .08em;
  text-transform: uppercase; padding: 3px 8px; border-radius: 3px;
  margin-left: 10px;
}
.topbar-spacer { flex: 1; }
.topbar-right { display: flex; align-items: center; gap: 8px; }

/* App Switcher */
.app-switcher-btn {
  background: none; border: none; color: var(--gold-light);
  cursor: pointer; padding: 6px; border-radius: var(--radius);
  display: flex; align-items: center; justify-content: center;
  transition: background var(--transition);
}
.app-switcher-btn:hover { background: rgba(197,181,142,.15); }
.app-switcher-btn svg { width: 20px; height: 20px; }

.app-switcher-dropdown {
  display: none; position: absolute; right: 60px; top: 54px;
  background: var(--white); border: 1px solid var(--gold-light);
  border-radius: var(--radius); box-shadow: var(--shadow-lg);
  z-index: 150; padding: 12px; min-width: 320px;
}
.app-switcher-dropdown.open { display: block; }
.app-switcher-grid {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 4px;
}
.app-switcher-item {
  display: flex; flex-direction: column; align-items: center;
  gap: 6px; padding: 14px 8px; border-radius: var(--radius);
  text-decoration: none; color: var(--onyx); cursor: pointer;
  transition: background var(--transition); border: none; background: none;
  font-family: inherit;
}
.app-switcher-item:hover { background: var(--almond); text-decoration: none; }
.app-switcher-item.active { background: #f5ede6; }
.app-switcher-item.coming-soon { opacity: .4; pointer-events: none; }
.app-switcher-icon {
  width: 40px; height: 40px; border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  font-size: 18px; color: var(--white);
}
.app-switcher-label { font-size: 10px; font-weight: 400; text-align: center; line-height: 1.3; }

/* Profile Button & Menu */
.profile-btn {
  width: 34px; height: 34px; border-radius: 50%;
  background: rgba(197,181,142,.15); border: 1px solid rgba(197,181,142,.25);
  color: var(--gold); cursor: pointer; font-weight: 500; font-size: 13px;
  display: flex; align-items: center; justify-content: center;
  transition: background var(--transition);
}
.profile-btn:hover { background: rgba(197,181,142,.25); }

.profile-menu {
  display: none; position: absolute; right: 0; top: 100%;
  margin-top: 8px; background: var(--white);
  border: 1px solid #e8dcc4; box-shadow: var(--shadow-lg);
  z-index: 150; min-width: 220px; border-radius: var(--radius);
}
.profile-menu.open { display: block; }
.profile-menu-header {
  padding: 14px 16px; background: var(--mist);
  border-bottom: 1px solid #e8dcc4;
}
.profile-menu-email { font-size: 12px; font-weight: 400; color: var(--onyx); }
.profile-menu-role { margin-top: 5px; }
.profile-menu-item {
  display: block; width: 100%; padding: 10px 16px;
  background: none; border: none; text-align: left;
  font-family: inherit; font-size: 12px; color: var(--charcoal);
  cursor: pointer; transition: background var(--transition);
}
.profile-menu-item:hover { background: var(--mist); }
.profile-menu-item:last-child { border-top: 1px solid #e8dcc4; color: var(--error); }

/* --- Gold Bar --- */
.gold-bar {
  height: 2px;
  background: linear-gradient(90deg, var(--gold-dark), var(--gold), var(--gold-light));
}

/* --- Layout --- */
.suite-layout { display: flex; flex: 1; min-height: 0; }
.suite-sidebar {
  width: 210px; background: var(--white);
  border-right: 1px solid #e0d5c4;
  overflow-y: auto; flex-shrink: 0;
}
.suite-content { flex: 1; overflow-y: auto; padding: 24px; }

/* Sidebar Navigation */
.nav-section { margin-bottom: 6px; }
.nav-label {
  font-size: 9px; font-weight: 600; text-transform: uppercase;
  letter-spacing: .08em; color: var(--brass); padding: 14px 18px 6px;
}
.nav-item {
  display: flex; align-items: center; gap: 8px;
  padding: 9px 18px; font-size: 12px; font-weight: 400;
  color: var(--charcoal); cursor: pointer;
  border-left: 2px solid transparent;
  transition: background var(--transition), border-color var(--transition);
  text-decoration: none;
}
.nav-item:hover { background: #f9f5ef; text-decoration: none; }
.nav-item.active {
  color: var(--burgundy); font-weight: 500;
  background: #f5ede6; border-left-color: var(--burgundy);
}
.nav-item svg { width: 15px; height: 15px; opacity: .65; flex-shrink: 0; }
.nav-divider { height: 1px; background: var(--gold-light); margin: 4px 18px; }

/* --- Pages (tab-like navigation) --- */
.page { display: none; }
.page.active { display: block; }

/* --- Page Header --- */
.page-header {
  display: flex; justify-content: space-between; align-items: flex-start;
  margin-bottom: 22px; flex-wrap: wrap; gap: 12px;
}
.page-header-actions { display: flex; gap: 8px; align-items: center; }

/* --- Stat Cards --- */
.stats-row { display: grid; grid-template-columns: repeat(6, 1fr); gap: 12px; margin-bottom: 22px; }
.stat-card {
  background: var(--white); border: 1px solid #e8dcc4;
  border-left: 3px solid var(--burgundy); padding: 14px 16px;
  border-radius: var(--radius); cursor: default;
  transition: border-color var(--transition), box-shadow var(--transition);
}
.stat-card:hover { border-color: var(--gold); box-shadow: var(--shadow-sm); }
.stat-value { font-family: 'Cormorant Garamond', serif; font-size: 32px; font-weight: 400; color: var(--onyx); }
.stat-label { font-size: 10px; color: var(--mocha); margin-top: 2px; }
.stat-sub { font-size: 9px; color: #bbb; margin-top: 1px; }

/* --- Cards --- */
.card {
  background: var(--white); border: 1px solid #e8dcc4;
  border-radius: var(--radius); margin-bottom: 18px;
}
.card-header {
  padding: 14px 18px; border-bottom: 1px solid #f0e8db;
  display: flex; justify-content: space-between; align-items: center;
}
.card-title { font-size: 12px; font-weight: 600; letter-spacing: .03em; }
.card-body { padding: 18px; }
.card-footer {
  padding: 12px 18px; border-top: 1px solid #f0e8db;
  background: var(--mist); display: flex; justify-content: flex-end; gap: 8px;
}

/* --- Tables --- */
table { width: 100%; border-collapse: collapse; font-size: 12px; }
thead th {
  font-size: 9px; font-weight: 600; text-transform: uppercase;
  letter-spacing: .06em; color: var(--mocha);
  background: var(--mist); padding: 8px 12px;
  border-bottom: 1px solid #e0d5c4; text-align: left;
}
tbody td {
  padding: 10px 12px; color: var(--charcoal);
  border-bottom: 1px solid #f0e8db; vertical-align: middle;
}
tbody tr:hover { background: #fdf9f5; }
tbody tr:last-child td { border-bottom: none; }

/* --- Buttons --- */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 8px 14px; font-family: inherit; font-size: 11px;
  font-weight: 500; letter-spacing: .05em; border-radius: var(--radius);
  cursor: pointer; border: 1px solid transparent;
  transition: background var(--transition), border-color var(--transition), color var(--transition);
  text-decoration: none; line-height: 1;
}
.btn:hover { text-decoration: none; }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn-primary { background: var(--burgundy); color: var(--white); }
.btn-primary:hover:not(:disabled) { background: var(--burgundy-dark); }
.btn-secondary { background: transparent; color: var(--charcoal); border-color: transparent; }
.btn-secondary:hover:not(:disabled) { border-color: var(--gold); }
.btn-gold { background: var(--gold); color: var(--onyx); }
.btn-gold:hover:not(:disabled) { background: var(--gold-dark); color: var(--white); }
.btn-danger { background: transparent; color: var(--error); border-color: var(--error); }
.btn-danger:hover:not(:disabled) { background: var(--error); color: var(--white); }
.btn-sm { padding: 5px 10px; font-size: 10px; }
.btn-lg { padding: 10px 20px; font-size: 13px; }
.btn-icon {
  width: 30px; height: 30px; padding: 0;
  display: flex; align-items: center; justify-content: center;
  background: transparent; border: 1px solid #e0d5c4;
}
.btn-icon:hover:not(:disabled) { background: var(--almond); border-color: var(--gold); }
.btn-icon.danger { border-color: transparent; }
.btn-icon.danger:hover:not(:disabled) { background: var(--error-bg); border-color: var(--error); color: var(--error); }

/* --- Badges --- */
.badge {
  display: inline-block; font-size: 9px; font-weight: 600;
  text-transform: uppercase; letter-spacing: .04em;
  padding: 2px 7px; border-radius: 3px;
}
.badge-active { background: var(--success-bg); color: var(--success); }
.badge-inactive { background: #f0e8db; color: var(--mocha); }
.badge-green { background: var(--success-bg); color: var(--success); }
.badge-amber { background: var(--amber-bg); color: var(--amber); }
.badge-red { background: var(--error-bg); color: var(--error); }
.badge-gold { background: var(--gold-light); color: var(--gold-dark); }
.badge-muted { background: var(--mist); color: #999; }

.role-chip {
  display: inline-block; font-size: 9px; font-weight: 600;
  text-transform: uppercase; letter-spacing: .04em;
  padding: 2px 8px; border-radius: 3px;
  background: var(--burgundy); color: var(--white);
}
.role-chip.editor { background: var(--gold); color: var(--onyx); }
.role-chip.viewer { background: var(--mist); color: var(--charcoal); }
.role-chip.super-admin { background: var(--onyx); color: var(--gold); }

/* --- Forms --- */
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.form-field { display: flex; flex-direction: column; gap: 4px; }
.form-field.full { grid-column: 1 / -1; }
label {
  font-size: 10px; font-weight: 500; text-transform: uppercase;
  letter-spacing: .04em; color: var(--brass);
}
input, select, textarea {
  padding: 9px 11px; font-family: inherit; font-size: 12px;
  border: 1px solid #d0c8b8; border-radius: var(--radius);
  background: var(--white); color: var(--onyx);
  transition: border-color var(--transition);
}
input:focus, select:focus, textarea:focus {
  outline: none; border-color: var(--gold);
}
textarea { resize: vertical; min-height: 70px; }
input::placeholder, textarea::placeholder { color: #c0b8a8; }
input[type="color"] { padding: 2px; height: 36px; cursor: pointer; }

/* --- Modals --- */
.modal-overlay {
  display: none; position: fixed; inset: 0;
  background: rgba(29,29,27,.55); z-index: 200;
  align-items: center; justify-content: center;
}
.modal-overlay.open { display: flex; }
.modal {
  background: var(--white); width: 640px; max-width: 95vw;
  max-height: 85vh; border-radius: var(--radius);
  border-top: 3px solid var(--gold); display: flex; flex-direction: column;
  box-shadow: var(--shadow-lg);
}
.modal-sm .modal { width: 420px; }
.modal-lg .modal { width: 860px; }
.modal-header {
  padding: 18px 22px; display: flex; justify-content: space-between;
  align-items: center; border-bottom: 1px solid #f0e8db;
}
.modal-title { font-family: 'Cormorant Garamond', serif; font-size: 20px; }
.modal-close {
  width: 28px; height: 28px; border-radius: 50%;
  background: none; border: 1px solid #e8dcc4; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  font-size: 14px; color: var(--charcoal);
  transition: background var(--transition);
}
.modal-close:hover { background: var(--mist); }
.modal-body { padding: 22px; flex: 1; overflow-y: auto; }
.modal-footer {
  padding: 14px 22px; display: flex; justify-content: flex-end; gap: 8px;
  background: var(--mist); border-top: 1px solid #f0e8db;
}

/* --- Tabs --- */
.tabs {
  display: flex; border-bottom: 1px solid #e0d5c4;
  margin-bottom: 18px; gap: 0;
}
.tab {
  padding: 9px 14px; font-size: 11px; font-weight: 500;
  color: var(--charcoal); cursor: pointer; border: none;
  background: none; font-family: inherit;
  border-bottom: 2px solid transparent;
  transition: color var(--transition), border-color var(--transition);
}
.tab:hover { color: var(--burgundy); }
.tab.active { color: var(--burgundy); border-bottom-color: var(--burgundy); }
.tab-panel { display: none; }
.tab-panel.active { display: block; }

/* --- Toast Notifications --- */
.toast {
  position: fixed; bottom: 22px; right: 22px;
  background: var(--onyx); color: var(--white);
  padding: 12px 18px; border-radius: var(--radius);
  font-size: 12px; z-index: 999; border-left: 3px solid var(--gold);
  box-shadow: var(--shadow-lg); max-width: 380px;
  transform: translateY(100px); opacity: 0;
  transition: transform .3s ease, opacity .3s ease;
}
.toast.show { transform: translateY(0); opacity: 1; }
.toast.toast-success { border-left-color: var(--success); }
.toast.toast-error { border-left-color: var(--error); }

/* --- Spinners --- */
.spinner {
  width: 14px; height: 14px; border: 1.5px solid var(--gold-light);
  border-top-color: var(--gold); border-radius: 50%;
  animation: spin .7s linear infinite; display: inline-block;
}
.spinner-lg { width: 28px; height: 28px; border-width: 2.5px; }
@keyframes spin { to { transform: rotate(360deg); } }

/* --- Empty States --- */
.empty-state {
  text-align: center; padding: 44px 20px; color: var(--mocha);
}
.empty-state h3 {
  font-family: 'Cormorant Garamond', serif; font-size: 20px;
  color: var(--onyx); margin-bottom: 8px;
}
.empty-state p { font-size: 12px; max-width: 360px; margin: 0 auto; line-height: 1.6; }

/* --- AI Panel --- */
.ai-panel {
  background: linear-gradient(135deg, #1d1d1b 0%, #2a2a28 100%);
  border: 1px solid var(--gold-dark); border-radius: var(--radius);
  padding: 18px; margin-bottom: 18px;
}
.ai-panel-title {
  font-family: 'Cormorant Garamond', serif; font-size: 16px;
  color: var(--gold); display: flex; align-items: center; gap: 8px;
}
.ai-panel-sub { font-size: 11px; color: #999; line-height: 1.6; margin-top: 6px; }
.ai-status { display: none; margin-top: 10px; font-size: 11px; align-items: center; gap: 8px; }
.ai-status.loading { display: flex; color: var(--gold); }
.ai-status.success { display: flex; color: var(--success); }
.ai-status.error { display: flex; color: var(--error); }

/* --- Utility --- */
.flex { display: flex; }
.flex-col { flex-direction: column; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.justify-end { justify-content: flex-end; }
.gap-4 { gap: 4px; }
.gap-8 { gap: 8px; }
.gap-12 { gap: 12px; }
.gap-16 { gap: 16px; }
.mt-8 { margin-top: 8px; }
.mt-12 { margin-top: 12px; }
.mt-16 { margin-top: 16px; }
.mb-8 { margin-bottom: 8px; }
.mb-16 { margin-bottom: 16px; }
.hidden { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); border: 0; }

/* --- Login Page --- */
.login-page {
  display: flex; align-items: center; justify-content: center;
  min-height: 100vh; background: var(--onyx);
  padding: 20px;
}
.login-card {
  background: var(--white); border-radius: var(--radius);
  border-top: 3px solid var(--gold); width: 380px; max-width: 100%;
  box-shadow: var(--shadow-lg);
}
.login-header {
  padding: 32px 32px 20px; text-align: center;
}
.login-logo { height: 56px; margin: 0 auto 16px; }
.login-title {
  font-family: 'Cormorant Garamond', serif; font-size: 22px;
  color: var(--onyx); margin-bottom: 4px;
}
.login-subtitle { font-size: 11px; color: var(--mocha); }
.login-body { padding: 0 32px 32px; }
.login-body .form-field { margin-bottom: 14px; }
.login-body .btn { width: 100%; justify-content: center; padding: 10px; }
.login-error {
  display: none; background: var(--error-bg); color: var(--error);
  font-size: 11px; padding: 8px 12px; border-radius: var(--radius);
  margin-bottom: 12px;
}
.login-error.show { display: block; }
.login-footer {
  padding: 14px 32px; text-align: center;
  border-top: 1px solid #f0e8db; font-size: 11px; color: var(--mocha);
}
.login-footer a { font-size: 11px; }

/* --- Dashboard App Cards --- */
.app-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 16px;
}
.app-card {
  background: var(--white); border: 1px solid #e8dcc4;
  border-radius: var(--radius); padding: 20px;
  display: flex; align-items: flex-start; gap: 14px;
  cursor: pointer; text-decoration: none; color: inherit;
  transition: border-color var(--transition), box-shadow var(--transition);
}
.app-card:hover { border-color: var(--gold); box-shadow: var(--shadow-sm); text-decoration: none; }
.app-card.coming-soon { opacity: .5; cursor: default; }
.app-card.no-access { opacity: .35; cursor: default; }
.app-card-icon {
  width: 48px; height: 48px; border-radius: 12px;
  display: flex; align-items: center; justify-content: center;
  font-size: 20px; color: var(--white); flex-shrink: 0;
}
.app-card-info { flex: 1; min-width: 0; }
.app-card-name { font-size: 14px; font-weight: 500; margin-bottom: 4px; }
.app-card-desc { font-size: 11px; color: var(--mocha); line-height: 1.5; }
.app-card-role { margin-top: 8px; }

/* --- Responsive --- */
@media (max-width: 1024px) {
  .stats-row { grid-template-columns: repeat(4, 1fr); }
}
@media (max-width: 768px) {
  .topbar-hamburger { display: block; }
  .topbar-logo-text { display: none; }
  .suite-sidebar {
    position: fixed; left: 0; top: 0; bottom: 0;
    z-index: 120; transform: translateX(-100%);
    transition: transform .25s ease; box-shadow: none;
  }
  .suite-sidebar.open { transform: translateX(0); box-shadow: var(--shadow-lg); }
  .sidebar-overlay {
    display: none; position: fixed; inset: 0;
    background: rgba(0,0,0,.3); z-index: 110;
  }
  .sidebar-overlay.open { display: block; }
  .suite-content { padding: 16px; }
  .stats-row { grid-template-columns: repeat(2, 1fr); }
  .form-grid { grid-template-columns: 1fr; }
  .modal { max-width: 95vw; max-height: 90vh; }
  .page-header { flex-direction: column; }
  .app-grid { grid-template-columns: 1fr; }
  .app-switcher-dropdown { right: 10px; min-width: 280px; }
}
@media (max-width: 480px) {
  .stats-row { grid-template-columns: 1fr; }
}
