/* ═══════════════════════════════════════════════════════
   ROPKART DESIGN SYSTEM v2.0 — Shared across all portals
   Mobile-first · Light theme · Modern aesthetic
═══════════════════════════════════════════════════════ */

/* ── TOKENS ─────────────────────────────────────────── */
:root {
  /* Brand */
  --brand-500: #f26522;
  --brand-600: #d4541a;
  --brand-100: #fff3ee;
  --brand-50:  #fff8f5;

  /* Neutrals */
  --gray-900: #0f172a;
  --gray-800: #1e293b;
  --gray-700: #334155;
  --gray-600: #475569;
  --gray-500: #64748b;
  --gray-400: #94a3b8;
  --gray-300: #cbd5e1;
  --gray-200: #e2e8f0;
  --gray-100: #f1f5f9;
  --gray-50:  #f8fafc;

  /* Semantic */
  --success: #16a34a;   --success-bg: #f0fdf4;
  --warning: #d97706;   --warning-bg: #fffbeb;
  --error:   #dc2626;   --error-bg:   #fef2f2;
  --info:    #2563eb;   --info-bg:    #eff6ff;

  /* Surface */
  --bg:       #f8fafc;
  --surface:  #ffffff;
  --border:   #e2e8f0;
  --border-sm: #f1f5f9;

  /* Typography */
  --font-display: 'Sora', system-ui, sans-serif;
  --font-body:    'Plus Jakarta Sans', system-ui, sans-serif;

  /* Spacing */
  --space-xs: 4px;  --space-sm: 8px;  --space-md: 16px;
  --space-lg: 24px; --space-xl: 32px; --space-2xl: 48px;

  /* Layout */
  --sidebar-w: 260px;
  --topbar-h:  60px;
  --content-max: 1320px;

  /* Shadows */
  --shadow-xs: 0 1px 2px rgba(15,23,42,.04);
  --shadow-sm: 0 1px 4px rgba(15,23,42,.07);
  --shadow-md: 0 4px 16px rgba(15,23,42,.08);
  --shadow-lg: 0 8px 32px rgba(15,23,42,.10);
  --shadow-xl: 0 20px 60px rgba(15,23,42,.12);

  /* Radius */
  --r-sm: 8px; --r-md: 12px; --r-lg: 16px; --r-xl: 24px;

  /* Transitions */
  --ease: cubic-bezier(.4,0,.2,1);
  --t-fast: 150ms; --t-base: 220ms; --t-slow: 350ms;
}

/* ── RESET ───────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
body {
  font-family: var(--font-body);
  background: var(--bg);
  color: var(--gray-900);
  overflow-x: hidden;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}
img, svg, video { max-width: 100%; display: block; }
button { font-family: inherit; cursor: pointer; border: none; outline: none; }
a { text-decoration: none; color: inherit; }
input, select, textarea { font-family: inherit; }
ul, ol { list-style: none; }

/* ── UTILITIES ───────────────────────────────────────── */
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0,0,0,0); }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.line-clamp-2 { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }

/* ── DASHBOARD LAYOUT ────────────────────────────────── */
.dash-layout { display: flex; min-height: 100vh; }

.sidebar {
  width: var(--sidebar-w);
  background: var(--surface);
  border-right: 1px solid var(--border);
  position: fixed;
  top: 0; left: 0; bottom: 0;
  display: flex;
  flex-direction: column;
  z-index: 300;
  transition: transform var(--t-base) var(--ease);
  overflow-y: auto;
  overflow-x: hidden;
  scrollbar-width: thin;
  scrollbar-color: var(--gray-200) transparent;
}

.main-area {
  margin-left: var(--sidebar-w);
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.topbar {
  height: var(--topbar-h);
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 var(--space-lg);
  gap: var(--space-md);
  position: sticky;
  top: 0;
  z-index: 200;
  box-shadow: var(--shadow-xs);
}

.page-body {
  padding: var(--space-lg);
  flex: 1;
}

/* ── SIDEBAR COMPONENTS ──────────────────────────────── */
.sidebar-logo {
  padding: 20px var(--space-lg);
  border-bottom: 1px solid var(--border-sm);
  flex-shrink: 0;
}
.logo-wordmark {
  font-family: var(--font-display);
  font-size: 1.35rem;
  font-weight: 800;
  color: var(--gray-900);
  letter-spacing: -.5px;
}
.logo-wordmark em { color: var(--brand-500); font-style: normal; }
.logo-tag {
  font-size: .62rem;
  font-weight: 700;
  letter-spacing: .8px;
  text-transform: uppercase;
  color: var(--gray-400);
  margin-top: 1px;
}

.sidebar-user {
  padding: 14px var(--space-lg);
  border-bottom: 1px solid var(--border-sm);
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}
.user-avatar {
  width: 36px; height: 36px;
  border-radius: 10px;
  background: linear-gradient(135deg, var(--brand-500), #e91e8c);
  color: #fff;
  font-weight: 700;
  font-size: .75rem;
  font-family: var(--font-display);
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.user-name { font-size: .82rem; font-weight: 700; color: var(--gray-800); line-height: 1.2; }
.user-role { font-size: .65rem; color: var(--gray-500); }

.nav-section { padding: 10px 0; }
.nav-label {
  font-size: .6rem;
  font-weight: 700;
  letter-spacing: 1px;
  text-transform: uppercase;
  color: var(--gray-400);
  padding: 8px var(--space-lg) 4px;
}
.nav-link {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 9px var(--space-lg);
  font-size: .8rem;
  font-weight: 600;
  color: var(--gray-600);
  border-left: 2px solid transparent;
  transition: all var(--t-fast) var(--ease);
  cursor: pointer;
}
.nav-link:hover { color: var(--gray-900); background: var(--gray-50); }
.nav-link.active {
  color: var(--brand-500);
  background: var(--brand-50);
  border-left-color: var(--brand-500);
}
.nav-link svg { width: 15px; height: 15px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; flex-shrink: 0; }
.nav-badge {
  margin-left: auto;
  background: var(--brand-500);
  color: #fff;
  font-size: .55rem;
  font-weight: 800;
  padding: 1px 5px;
  border-radius: 99px;
  min-width: 16px;
  text-align: center;
}
.nav-badge.warn { background: var(--warning); }
.nav-badge.err  { background: var(--error); }

/* ── TOPBAR COMPONENTS ───────────────────────────────── */
.hamburger {
  display: none;
  width: 36px; height: 36px;
  border-radius: var(--r-sm);
  background: var(--gray-100);
  align-items: center; justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
}
.hamburger svg { width: 18px; height: 18px; fill: none; stroke: var(--gray-700); stroke-width: 2; stroke-linecap: round; }
.topbar-title { font-family: var(--font-display); font-size: 1rem; font-weight: 700; color: var(--gray-900); }
.topbar-spacer { flex: 1; }
.topbar-actions { display: flex; align-items: center; gap: 8px; }
.icon-btn {
  width: 36px; height: 36px;
  border-radius: var(--r-sm);
  background: var(--gray-100);
  border: 1px solid var(--border);
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  position: relative;
  transition: background var(--t-fast);
  flex-shrink: 0;
}
.icon-btn:hover { background: var(--gray-200); }
.icon-btn svg { width: 15px; height: 15px; fill: none; stroke: var(--gray-600); stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.notif-dot {
  position: absolute; top: 6px; right: 6px;
  width: 6px; height: 6px;
  background: var(--error);
  border-radius: 50%;
  border: 1.5px solid var(--surface);
}

/* ── CARDS ───────────────────────────────────────────── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  box-shadow: var(--shadow-sm);
}
.card-pad { padding: var(--space-lg); }
.card-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: var(--space-md);
  flex-wrap: wrap;
}
.card-title { font-family: var(--font-display); font-size: .9rem; font-weight: 700; color: var(--gray-900); }
.card-sub { font-size: .72rem; color: var(--gray-500); margin-top: 2px; }

/* ── STAT CARDS ──────────────────────────────────────── */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 14px;
  margin-bottom: var(--space-lg);
}
.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: 18px;
  box-shadow: var(--shadow-sm);
  position: relative;
  overflow: hidden;
  transition: transform var(--t-base), box-shadow var(--t-base);
}
.stat-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); }
.stat-emoji { position: absolute; bottom: -6px; right: -4px; font-size: 3rem; opacity: .08; user-select: none; }
.stat-label { font-size: .68rem; font-weight: 700; color: var(--gray-500); text-transform: uppercase; letter-spacing: .5px; margin-bottom: 6px; }
.stat-value { font-family: var(--font-display); font-size: clamp(1.3rem, 2.5vw, 1.6rem); font-weight: 800; color: var(--gray-900); margin-bottom: 4px; }
.stat-delta { font-size: .7rem; font-weight: 700; }
.stat-delta.up   { color: var(--success); }
.stat-delta.down { color: var(--error); }
.stat-delta.neutral { color: var(--gray-400); }

/* ── BUTTONS ─────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 9px 18px;
  border-radius: var(--r-sm);
  font-size: .8rem; font-weight: 700;
  font-family: var(--font-display);
  letter-spacing: .2px;
  transition: all var(--t-fast) var(--ease);
  cursor: pointer;
  white-space: nowrap;
  border: 1.5px solid transparent;
  flex-shrink: 0;
}
.btn svg { width: 13px; height: 13px; fill: none; stroke: currentColor; stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; }
.btn-primary { background: var(--brand-500); color: #fff; border-color: var(--brand-500); }
.btn-primary:hover { background: var(--brand-600); border-color: var(--brand-600); transform: translateY(-1px); box-shadow: 0 4px 14px rgba(242,101,34,.35); }
.btn-secondary { background: var(--surface); color: var(--gray-700); border-color: var(--border); }
.btn-secondary:hover { background: var(--gray-50); border-color: var(--gray-300); }
.btn-success { background: var(--success-bg); color: var(--success); border-color: rgba(22,163,74,.2); }
.btn-success:hover { background: #dcfce7; }
.btn-danger { background: var(--error-bg); color: var(--error); border-color: rgba(220,38,38,.2); }
.btn-danger:hover { background: #fee2e2; }
.btn-ghost { background: transparent; color: var(--gray-600); border-color: transparent; }
.btn-ghost:hover { background: var(--gray-100); }
.btn-sm { padding: 5px 12px; font-size: .72rem; }
.btn-lg { padding: 12px 24px; font-size: .88rem; }
.btn-full { width: 100%; justify-content: center; }

/* ── FORM ELEMENTS ───────────────────────────────────── */
.form-group { margin-bottom: 14px; }
.form-label { display: block; font-size: .72rem; font-weight: 700; color: var(--gray-700); margin-bottom: 5px; letter-spacing: .2px; }
.form-input, .form-select, .form-textarea {
  width: 100%;
  border: 1.5px solid var(--border);
  border-radius: var(--r-sm);
  padding: 10px 13px;
  font-size: .85rem;
  color: var(--gray-900);
  background: var(--surface);
  transition: border-color var(--t-fast), box-shadow var(--t-fast);
  appearance: none;
}
.form-input:focus, .form-select:focus, .form-textarea:focus {
  outline: none;
  border-color: var(--brand-500);
  box-shadow: 0 0 0 3px rgba(242,101,34,.1);
}
.form-textarea { min-height: 90px; resize: vertical; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
@media(max-width:480px){ .form-row { grid-template-columns: 1fr; } }

/* ── TABLE ───────────────────────────────────────────── */
.table-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table { width: 100%; border-collapse: collapse; }
th {
  text-align: left;
  font-size: .65rem;
  font-weight: 700;
  color: var(--gray-500);
  text-transform: uppercase;
  letter-spacing: .5px;
  padding: 9px 12px;
  border-bottom: 2px solid var(--border);
  white-space: nowrap;
  background: var(--gray-50);
}
td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--border-sm);
  font-size: .8rem;
  color: var(--gray-800);
  vertical-align: middle;
}
tr:last-child td { border-bottom: none; }
tbody tr:hover td { background: var(--gray-50); }

/* ── CHIPS / BADGES ──────────────────────────────────── */
.chip {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 3px 8px;
  border-radius: 99px;
  font-size: .62rem;
  font-weight: 700;
  white-space: nowrap;
}
.chip-success { background: var(--success-bg); color: var(--success); }
.chip-warning { background: var(--warning-bg); color: var(--warning); }
.chip-error   { background: var(--error-bg);   color: var(--error);   }
.chip-info    { background: var(--info-bg);     color: var(--info);    }
.chip-gray    { background: var(--gray-100);    color: var(--gray-600);}
.chip-brand   { background: var(--brand-100);   color: var(--brand-600);}

/* ── TOAST ───────────────────────────────────────────── */
.toast-wrap {
  position: fixed;
  bottom: 20px; right: 20px;
  z-index: 9999;
  display: flex; flex-direction: column; gap: 8px;
  pointer-events: none;
  max-width: calc(100vw - 40px);
}
.toast {
  background: var(--gray-900);
  color: #fff;
  padding: 11px 18px;
  border-radius: var(--r-md);
  font-size: .8rem;
  font-weight: 600;
  box-shadow: var(--shadow-xl);
  display: flex; align-items: center; gap: 8px;
  transform: translateY(20px) scale(.96);
  opacity: 0;
  transition: all .3s var(--ease);
  pointer-events: auto;
  max-width: 340px;
}
.toast.show { transform: translateY(0) scale(1); opacity: 1; }
.toast-icon { font-size: 1rem; flex-shrink: 0; }

/* ── MODAL ───────────────────────────────────────────── */
.modal-backdrop {
  position: fixed; inset: 0;
  background: rgba(15,23,42,.5);
  backdrop-filter: blur(4px);
  z-index: 800;
  display: flex; align-items: center; justify-content: center;
  padding: var(--space-md);
  opacity: 0; visibility: hidden;
  transition: all .3s;
}
.modal-backdrop.open { opacity: 1; visibility: visible; }
.modal {
  background: var(--surface);
  border-radius: var(--r-xl);
  width: 100%;
  max-width: 520px;
  max-height: 90vh;
  overflow-y: auto;
  padding: 28px;
  box-shadow: var(--shadow-xl);
  transform: scale(.95) translateY(16px);
  transition: transform .3s var(--ease);
}
.modal-backdrop.open .modal { transform: scale(1) translateY(0); }
.modal-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 20px; }
.modal-title { font-family: var(--font-display); font-size: 1.05rem; font-weight: 700; }
.modal-close { width: 32px; height: 32px; border-radius: 50%; background: var(--gray-100); display: flex; align-items: center; justify-content: center; cursor: pointer; font-size: 1rem; color: var(--gray-500); transition: background var(--t-fast); border: none; }
.modal-close:hover { background: var(--gray-200); }
.modal-footer { display: flex; gap: 8px; justify-content: flex-end; margin-top: 20px; flex-wrap: wrap; }

/* ── SIDEBAR OVERLAY (mobile) ────────────────────────── */
.sidebar-overlay {
  display: none;
  position: fixed; inset: 0;
  background: rgba(15,23,42,.5);
  z-index: 290;
}

/* ── RESPONSIVE BREAKPOINTS ──────────────────────────── */
@media (max-width: 1024px) {
  :root { --sidebar-w: 240px; }
}

@media (max-width: 768px) {
  .sidebar {
    transform: translateX(-100%);
    box-shadow: var(--shadow-xl);
  }
  .sidebar.open { transform: translateX(0); }
  .sidebar-overlay.open { display: block; }
  .main-area { margin-left: 0; }
  .hamburger { display: flex; }
  .page-body { padding: 14px; }
  .topbar { padding: 0 14px; height: 54px; }
  .stat-grid { grid-template-columns: repeat(2, 1fr); gap: 10px; }
  .form-row { grid-template-columns: 1fr; }
}

@media (max-width: 480px) {
  .stat-grid { grid-template-columns: 1fr 1fr; }
  .topbar-title { font-size: .88rem; }
  .page-body { padding: 12px; }
  .card-pad { padding: 14px; }
  .modal { padding: 20px; border-radius: var(--r-lg); }
}

/* ── PRINT ───────────────────────────────────────────── */
@media print {
  .sidebar, .topbar, .toast-wrap { display: none; }
  .main-area { margin-left: 0; }
  .page-body { padding: 0; }
}
</style>
