/* PijarAI Design System v2.0 ─ globals.css */

/* ── Tokens ─────────────────────────────────────────────── */
:root {
  --brand-50:  #FBF5F5;
  --brand-100: #F5E8E7;
  --brand-200: #E8CCCB;
  --brand-300: #D4A09D;
  --brand-500: #8B4B48;
  --brand-600: #4B2E2B;
  --brand-700: #3A2220;
  --brand-800: #2A1917;
  --brand-900: #1A100F;

  --surface:   #FFFFFF;
  --surface-2: #F8FAFC;
  --surface-3: #F1F5F9;
  --border:    #E2E8F0;
  --border-2:  #CBD5E1;

  --text-primary:   #0F172A;
  --text-secondary: #475569;
  --text-muted:     #94A3B8;
  --text-brand:     #4B2E2B;

  --success-bg:     #F0FDF4;
  --success-text:   #166534;
  --success-border: #BBF7D0;
  --warn-bg:        #FEFCE8;
  --warn-text:      #854D0E;
  --warn-border:    #FDE68A;
  --danger-bg:      #FFF1F2;
  --danger-text:    #9F1239;
  --danger-border:  #FECDD3;

  --sidebar-w:           220px;
  --sidebar-collapsed-w: 52px;
  --topbar-h:            56px;

  --radius-sm: 6px;
  --radius:    10px;
  --radius-lg: 14px;
  --radius-xl: 20px;
  --shadow-sm: 0 1px 3px rgba(15,23,42,.06), 0 1px 2px rgba(15,23,42,.04);
  --shadow:    0 4px 12px rgba(15,23,42,.08);
  --shadow-lg: 0 10px 30px rgba(15,23,42,.14);
}

/* dark mode dinonaktifkan — site selalu light */
:root[data-theme="dark"] {
  --surface:   #0F172A;
  --surface-2: #1E293B;
  --surface-3: #293548;
  --border:    #334155;
  --border-2:  #475569;
  --text-primary:   #F1F5F9;
  --text-secondary: #94A3B8;
  --text-muted:     #64748B;
  --text-brand:     #818CF8;
  --success-bg: #052E16; --success-text: #86EFAC; --success-border: #166534;
  --warn-bg:    #1C1400; --warn-text:    #FDE047; --warn-border:    #854D0E;
  --danger-bg:  #1C0308; --danger-text:  #FDA4AF; --danger-border:  #9F1239;
}
:root[data-theme="light"] {
  --surface:   #FFFFFF;
  --surface-2: #F8FAFC;
  --surface-3: #F1F5F9;
  --border:    #E2E8F0;
  --border-2:  #CBD5E1;
  --text-primary:   #0F172A;
  --text-secondary: #475569;
  --text-muted:     #94A3B8;
  --text-brand:     #4B2E2B;
  --success-bg: #F0FDF4; --success-text: #166534; --success-border: #BBF7D0;
  --warn-bg:    #FEFCE8; --warn-text:    #854D0E; --warn-border:    #FDE68A;
  --danger-bg:  #FFF1F2; --danger-text:  #9F1239; --danger-border:  #FECDD3;
}

/* ── Reset ──────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; }

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
  font-size: 15px;
  line-height: 1.6;
  color: var(--text-primary);
  background: var(--surface-2);
  -webkit-font-smoothing: antialiased;
  margin: 0;
  padding: 0;
}

/* ── Material Symbols util ──────────────────────────────── */
.mat {
  font-family: 'Material Symbols Rounded';
  font-weight: normal;
  font-style: normal;
  font-size: 20px;
  line-height: 1;
  letter-spacing: normal;
  text-transform: none;
  display: inline-block;
  white-space: nowrap;
  direction: ltr;
  font-variation-settings: 'FILL' 1, 'wght' 400, 'GRAD' 0, 'opsz' 24;
  vertical-align: middle;
  flex-shrink: 0;
}
.mat-sm  { font-size: 16px; }
.mat-lg  { font-size: 24px; }
.mat-xl  { font-size: 32px; }

/* ── App Shell (authenticated layout) ──────────────────── */
.app-shell {
  display: flex;
  min-height: 100vh;
}

/* ── Sidebar ────────────────────────────────────────────── */
.sidebar {
  width: var(--sidebar-w);
  flex-shrink: 0;
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
  overflow-x: hidden;
  transition: width .2s ease;
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
}
.sidebar.collapsed {
  width: var(--sidebar-collapsed-w);
}

.sidebar-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 16px 12px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  min-height: var(--topbar-h);
  overflow: hidden;
}
.sidebar-logo-icon {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  background: var(--brand-600);
  color: #fff;
  font-size: 15px;
  font-weight: 800;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  letter-spacing: -.02em;
}
.sidebar-logo-text {
  font-size: 15px;
  font-weight: 800;
  color: var(--text-primary);
  letter-spacing: -.02em;
  white-space: nowrap;
  opacity: 1;
  transition: opacity .15s;
}
.sidebar.collapsed .sidebar-logo-text {
  opacity: 0;
  width: 0;
  overflow: hidden;
}

.sidebar-nav {
  flex: 1;
  padding: 12px 8px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.nav-group-label {
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: .09em;
  text-transform: uppercase;
  color: var(--text-muted);
  padding: 12px 8px 4px;
  white-space: nowrap;
  overflow: hidden;
  transition: opacity .15s;
}
.sidebar.collapsed .nav-group-label {
  opacity: 0;
  height: 4px;
  padding: 0;
}

.nav-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px;
  border-radius: var(--radius);
  color: var(--text-secondary);
  text-decoration: none;
  font-size: 13.5px;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  transition: background .12s, color .12s;
  position: relative;
}
.nav-link:hover {
  background: var(--surface-3);
  color: var(--text-primary);
}
.nav-link.active {
  background: var(--brand-50);
  color: var(--brand-700);
  font-weight: 600;
}
.nav-link.active .mat { color: var(--brand-600); }
.nav-link .mat { color: var(--text-muted); transition: color .12s; }
.nav-link:hover .mat { color: var(--text-secondary); }
.nav-link-label {
  opacity: 1;
  transition: opacity .15s;
  flex: 1;
}
.sidebar.collapsed .nav-link-label { opacity: 0; width: 0; overflow: hidden; }

.nav-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 18px;
  height: 18px;
  border-radius: 99px;
  background: var(--brand-600);
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  padding: 0 4px;
  transition: opacity .15s;
}
.sidebar.collapsed .nav-badge { opacity: 0; }

.sidebar-footer {
  padding: 8px;
  border-top: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.sidebar-toggle {
  width: 28px;
  height: 28px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-muted);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  position: absolute;
  top: 14px;
  right: -14px;
  box-shadow: var(--shadow-sm);
  z-index: 10;
  transition: background .12s, color .12s;
}
.sidebar-toggle:hover { background: var(--surface-3); color: var(--text-primary); }
.sidebar-toggle .mat { font-size: 16px; }

/* ── App Main ───────────────────────────────────────────── */
.app-main {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

/* ── Topbar ─────────────────────────────────────────────── */
.topbar {
  height: var(--topbar-h);
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 24px;
  gap: 16px;
  position: sticky;
  top: 0;
  z-index: 20;
  flex-shrink: 0;
}
.topbar-hamburger {
  display: none;
  width: 36px;
  height: 36px;
  border-radius: var(--radius-sm);
  border: none;
  background: transparent;
  color: var(--text-secondary);
  cursor: pointer;
  align-items: center;
  justify-content: center;
}
.topbar-title {
  font-size: 15px;
  font-weight: 700;
  color: var(--text-primary);
  flex: 1;
}
.topbar-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.plan-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 10px;
  border-radius: 99px;
  font-size: 11.5px;
  font-weight: 700;
}
.plan-badge.free {
  background: var(--surface-3);
  color: var(--text-secondary);
  border: 1px solid var(--border);
}
.plan-badge.pro {
  background: var(--brand-50);
  color: var(--brand-700);
  border: 1px solid var(--brand-200);
}
.plan-badge .mat { font-size: 13px; }

.avatar-btn {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--brand-600);
  color: #fff;
  font-size: 12px;
  font-weight: 700;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  letter-spacing: .02em;
  position: relative;
}
.avatar-menu {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  min-width: 200px;
  padding: 6px;
  display: none;
  z-index: 100;
}
.avatar-menu.open { display: block; }
.avatar-menu-header {
  padding: 8px 12px 10px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 4px;
}
.avatar-menu-name { font-size: 13.5px; font-weight: 700; color: var(--text-primary); }
.avatar-menu-email { font-size: 12px; color: var(--text-muted); }
.avatar-menu a,
.avatar-menu button {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 7px 12px;
  border-radius: var(--radius);
  font-size: 13.5px;
  font-weight: 500;
  color: var(--text-secondary);
  text-decoration: none;
  border: none;
  background: none;
  cursor: pointer;
  text-align: left;
  font-family: inherit;
  transition: background .1s, color .1s;
}
.avatar-menu a:hover,
.avatar-menu button:hover {
  background: var(--surface-3);
  color: var(--text-primary);
}
.avatar-menu a.danger, .avatar-menu button.danger {
  color: var(--danger-text);
}
.avatar-menu a.danger:hover, .avatar-menu button.danger:hover {
  background: var(--danger-bg);
}

/* ── Page Content ───────────────────────────────────────── */
.page-content {
  flex: 1;
  padding: 28px 32px 64px;
  min-width: 0;
}
.page-header {
  margin-bottom: 24px;
}
.page-title {
  font-size: 22px;
  font-weight: 800;
  letter-spacing: -.025em;
  color: var(--text-primary);
  margin: 0 0 4px;
}
.page-subtitle {
  font-size: 14px;
  color: var(--text-secondary);
  margin: 0;
}

/* ── Public Shell (non-auth pages) ─────────────────────── */
.public-shell {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}
.public-nav {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 20;
}
.public-nav-inner {
  max-width: 1120px;
  margin: 0 auto;
  padding: 0 24px;
  height: 60px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.public-nav-logo {
  display: flex;
  align-items: center;
  gap: 8px;
  text-decoration: none;
  font-weight: 800;
  font-size: 15px;
  color: var(--text-primary);
  letter-spacing: -.02em;
  margin-right: auto;
}
.public-nav-logo-icon {
  width: 30px;
  height: 30px;
  border-radius: 8px;
  background: var(--brand-600);
  color: #fff;
  font-size: 14px;
  font-weight: 800;
  display: flex;
  align-items: center;
  justify-content: center;
}
.public-main {
  flex: 1;
}

/* ── Flash Messages ─────────────────────────────────────── */
.flash-container {
  margin-bottom: 20px;
}
.flash {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  border-radius: var(--radius);
  font-size: 14px;
  font-weight: 500;
  border: 1px solid;
  margin-bottom: 8px;
  animation: flash-in .2s ease;
}
@keyframes flash-in {
  from { opacity: 0; transform: translateY(-6px); }
  to   { opacity: 1; transform: translateY(0); }
}
.flash-error {
  background: var(--danger-bg);
  border-color: var(--danger-border);
  color: var(--danger-text);
}
.flash-success {
  background: var(--success-bg);
  border-color: var(--success-border);
  color: var(--success-text);
}
.flash-warn {
  background: var(--warn-bg);
  border-color: var(--warn-border);
  color: var(--warn-text);
}
.flash .mat { font-size: 18px; }
.flash-body { flex: 1; }
.flash-close {
  background: none;
  border: none;
  cursor: pointer;
  color: inherit;
  opacity: .5;
  padding: 0;
  display: flex;
  align-items: center;
}
.flash-close:hover { opacity: 1; }

/* ── Toast ──────────────────────────────────────────────── */
#toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 999;
  pointer-events: none;
}
.toast {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  border-radius: var(--radius-lg);
  font-size: 13.5px;
  font-weight: 500;
  background: var(--text-primary);
  color: var(--surface);
  box-shadow: var(--shadow-lg);
  pointer-events: auto;
  animation: toast-in .2s ease;
  min-width: 200px;
  max-width: 340px;
}
.toast.toast-success { background: #166534; }
.toast.toast-error   { background: #9F1239; }
@keyframes toast-in {
  from { opacity: 0; transform: translateY(12px); }
  to   { opacity: 1; transform: translateY(0); }
}
@keyframes toast-out {
  to { opacity: 0; transform: translateY(12px); }
}
.toast.removing { animation: toast-out .2s ease forwards; }

/* ── Buttons ────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 8px 16px;
  border-radius: var(--radius);
  font-size: 13.5px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  border: none;
  text-decoration: none;
  white-space: nowrap;
  transition: background .12s, box-shadow .12s, opacity .12s;
  line-height: 1;
}
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn .mat { font-size: 17px; }

.btn-primary {
  background: var(--brand-600);
  color: #fff;
}
.btn-primary:hover:not(:disabled) { background: var(--brand-700); }

.btn-secondary {
  background: var(--surface);
  color: var(--text-secondary);
  border: 1px solid var(--border-2);
}
.btn-secondary:hover:not(:disabled) { background: var(--surface-3); }

.btn-ghost {
  background: transparent;
  color: var(--text-secondary);
}
.btn-ghost:hover:not(:disabled) { background: var(--surface-3); color: var(--text-primary); }

.btn-danger {
  background: #DC2626;
  color: #fff;
}
.btn-danger:hover:not(:disabled) { background: #B91C1C; }

.btn-brand-ghost {
  background: transparent;
  color: var(--brand-600);
}
.btn-brand-ghost:hover:not(:disabled) { background: var(--brand-50); }

.btn-sm  { padding: 5px 12px; font-size: 12.5px; }
.btn-sm .mat { font-size: 15px; }
.btn-lg  { padding: 11px 22px; font-size: 15px; }
.btn-lg .mat { font-size: 20px; }

/* ── Cards ──────────────────────────────────────────────── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
}
.card-header {
  padding: 18px 22px 16px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.card-header h2, .card-header h3 {
  font-size: 15px;
  font-weight: 700;
  color: var(--text-primary);
  margin: 0;
}
.card-body { padding: 22px; }
.card-footer {
  padding: 14px 22px;
  border-top: 1px solid var(--border);
  background: var(--surface-2);
  border-radius: 0 0 var(--radius-lg) var(--radius-lg);
  display: flex;
  align-items: center;
  gap: 8px;
}

.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 18px 20px;
  box-shadow: var(--shadow-sm);
}
.stat-card-icon {
  width: 36px;
  height: 36px;
  border-radius: 8px;
  background: var(--brand-50);
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 12px;
}
.stat-card-icon .mat { color: var(--brand-600); font-size: 20px; }
.stat-card-value {
  font-size: 26px;
  font-weight: 800;
  letter-spacing: -.03em;
  color: var(--text-primary);
  line-height: 1;
  font-variant-numeric: tabular-nums;
}
.stat-card-label {
  font-size: 12.5px;
  color: var(--text-muted);
  margin-top: 4px;
  font-weight: 500;
}
.stat-card-bar {
  height: 3px;
  border-radius: 2px;
  background: var(--surface-3);
  margin-top: 12px;
  overflow: hidden;
}
.stat-card-fill {
  height: 100%;
  border-radius: 2px;
  background: var(--brand-600);
  transition: width .4s ease;
}

/* ── Form Elements ──────────────────────────────────────── */
.label {
  display: block;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: .05em;
  text-transform: uppercase;
  color: var(--text-secondary);
  margin-bottom: 6px;
}
.input {
  width: 100%;
  padding: 9px 12px;
  border: 1px solid var(--border-2);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text-primary);
  font-size: 14px;
  font-family: inherit;
  transition: border-color .12s, box-shadow .12s;
  outline: none;
  line-height: 1.5;
}
.input:focus {
  border-color: var(--brand-500);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--brand-500) 12%, transparent);
}
.input::placeholder { color: var(--text-muted); }
.input.error { border-color: #F87171; }
.input-hint {
  font-size: 12.5px;
  color: var(--text-muted);
  margin-top: 5px;
}
.input-error-msg {
  font-size: 12.5px;
  color: var(--danger-text);
  margin-top: 5px;
  display: flex;
  align-items: center;
  gap: 4px;
}

.field { margin-bottom: 18px; }
.field:last-child { margin-bottom: 0; }

/* ── Badges ─────────────────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 9px;
  border-radius: 99px;
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
}
.badge .mat { font-size: 13px; }

.badge-brand  { background: var(--brand-50);      color: var(--brand-700);    border: 1px solid var(--brand-200); }
.badge-green  { background: var(--success-bg);    color: var(--success-text); border: 1px solid var(--success-border); }
.badge-yellow { background: var(--warn-bg);       color: var(--warn-text);    border: 1px solid var(--warn-border); }
.badge-red    { background: var(--danger-bg);     color: var(--danger-text);  border: 1px solid var(--danger-border); }
.badge-gray   { background: var(--surface-3);     color: var(--text-secondary); border: 1px solid var(--border); }
.badge-purple { background: #F3E8FF; color: #6B21A8; border: 1px solid #E9D5FF; }

/* ── Tables ─────────────────────────────────────────────── */
.table-wrap { overflow-x: auto; }
.table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13.5px;
}
.table thead th {
  background: var(--surface-2);
  color: var(--text-muted);
  font-size: 11.5px;
  font-weight: 700;
  letter-spacing: .06em;
  text-transform: uppercase;
  padding: 10px 16px;
  text-align: left;
  border-bottom: 1px solid var(--border-2);
  white-space: nowrap;
}
.table tbody td {
  padding: 13px 16px;
  border-bottom: 1px solid var(--border);
  color: var(--text-secondary);
  vertical-align: middle;
}
.table tbody tr:last-child td { border-bottom: none; }
.table tbody tr:hover td { background: var(--surface-2); }

/* ── Empty State ────────────────────────────────────────── */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 56px 24px;
  text-align: center;
}
.empty-state-icon {
  width: 56px;
  height: 56px;
  border-radius: 14px;
  background: var(--surface-3);
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 16px;
}
.empty-state-icon .mat { font-size: 28px; color: var(--text-muted); }
.empty-state h3 { font-size: 15px; font-weight: 700; color: var(--text-primary); margin: 0 0 6px; }
.empty-state p  { font-size: 13.5px; color: var(--text-muted); margin: 0 0 20px; }

/* ── Quota Progress ─────────────────────────────────────── */
.quota-bar-wrap {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 13px;
  color: var(--text-secondary);
  margin-bottom: 16px;
}
.quota-bar {
  flex: 1;
  height: 5px;
  border-radius: 3px;
  background: var(--surface-3);
  overflow: hidden;
}
.quota-bar-fill {
  height: 100%;
  border-radius: 3px;
  background: var(--brand-600);
  transition: width .4s ease;
}
.quota-bar-fill.danger { background: #DC2626; }
.quota-bar-fill.warn   { background: #D97706; }
.quota-label-pro {
  font-size: 13px;
  color: var(--success-text);
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 4px;
  margin-bottom: 16px;
}

/* ── Skeleton Loader ────────────────────────────────────── */
.skeleton {
  background: linear-gradient(90deg, var(--surface-3) 25%, var(--border) 50%, var(--surface-3) 75%);
  background-size: 200% 100%;
  animation: skeleton-wave 1.4s infinite;
  border-radius: var(--radius-sm);
}
@keyframes skeleton-wave {
  0%   { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* ── Mobile Overlay ─────────────────────────────────────── */
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(15,23,42,.4);
  z-index: 40;
  backdrop-filter: blur(2px);
}
.sidebar-overlay.open { display: block; }

@media (max-width: 768px) {
  .sidebar {
    position: fixed;
    top: 0;
    left: 0;
    height: 100vh;
    z-index: 50;
    transform: translateX(-100%);
    transition: transform .2s ease, width .2s ease;
    width: var(--sidebar-w) !important;
  }
  .sidebar.mobile-open {
    transform: translateX(0);
  }
  .topbar-hamburger { display: flex; }
  .page-content { padding: 20px 16px 48px; }
  .sidebar-toggle { display: none; }
}
