/* assets/css/app.css - SiAbsen Modern UI */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&family=Plus+Jakarta+Sans:wght@400;500;600;700&family=Roboto:wght@300;400;500;700&family=Poppins:wght@300;400;500;600;700&display=swap');

/* ====== CSS VARIABLES ====== */
:root {
  --primary: #4f46e5;
  --primary-light: #818cf8;
  --primary-dark: #3730a3;
  --secondary: #64748b;
  --success: #10b981;
  --warning: #f59e0b;
  --danger: #ef4444;
  --info: #06b6d4;
  --orange: #f97316;
  --teal: #14b8a6;
  --purple: #8b5cf6;
  --bg: #f1f5f9;
  --surface: #ffffff;
  --surface2: #f8fafc;
  --border: #e2e8f0;
  --text: #1e293b;
  --text-muted: #64748b;
  --text-light: #94a3b8;
  --sidebar-bg: #1e1b4b;
  --sidebar-text: #c7d2fe;
  --sidebar-active: #4f46e5;
  --sidebar-hover: rgba(79,70,229,0.15);
  --header-bg: #ffffff;
  --shadow-sm: 0 1px 3px rgba(0,0,0,.08);
  --shadow: 0 4px 16px rgba(0,0,0,.08);
  --shadow-lg: 0 8px 32px rgba(0,0,0,.12);
  --radius: 12px;
  --radius-sm: 8px;
  --radius-lg: 16px;
  --transition: all .2s ease;
  --font: 'Inter', sans-serif;
  --font-size: 14px;
  --sidebar-width: 260px;
  --header-height: 64px;
}

/* Dark Theme */
[data-theme="dark"] {
  --bg: #0f172a;
  --surface: #1e293b;
  --surface2: #162032;
  --border: #334155;
  --text: #f1f5f9;
  --text-muted: #94a3b8;
  --text-light: #64748b;
  --header-bg: #1e293b;
  --shadow-sm: 0 1px 3px rgba(0,0,0,.3);
  --shadow: 0 4px 16px rgba(0,0,0,.3);
}

/* Font sizes */
[data-fontsize="sm"] { --font-size: 12px; }
[data-fontsize="md"] { --font-size: 14px; }
[data-fontsize="lg"] { --font-size: 16px; }

/* ====== RESET & BASE ====== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { font-size: var(--font-size); scroll-behavior: smooth; }
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  line-height: 1.6;
}

/* ====== LAYOUT ====== */
.app-wrapper { display: flex; min-height: 100vh; }

/* ====== SIDEBAR ====== */
.sidebar {
  width: var(--sidebar-width);
  background: var(--sidebar-bg);
  min-height: 100vh;
  position: fixed;
  left: 0; top: 0;
  display: flex;
  flex-direction: column;
  z-index: 1000;
  transition: transform .3s ease;
  overflow-y: auto;
  overflow-x: hidden;
}
.sidebar-brand {
  padding: 20px 20px 16px;
  display: flex;
  align-items: center;
  gap: 12px;
  border-bottom: 1px solid rgba(255,255,255,.08);
  text-decoration: none;
}
.sidebar-brand-icon {
  width: 40px; height: 40px;
  background: var(--primary);
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  font-size: 20px;
  flex-shrink: 0;
}
.sidebar-brand-text { flex: 1; min-width: 0; }
.sidebar-brand-name {
  font-weight: 700;
  font-size: 1.1rem;
  color: #fff;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.sidebar-brand-sub {
  font-size: .72rem;
  color: var(--sidebar-text);
  opacity: .7;
}
.sidebar-nav { flex: 1; padding: 12px 0; }
.nav-section-label {
  font-size: .65rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: rgba(199,210,254,.4);
  padding: 16px 20px 6px;
}
.nav-item { position: relative; }
.nav-link {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 20px;
  color: var(--sidebar-text);
  text-decoration: none;
  font-size: .88rem;
  font-weight: 500;
  transition: var(--transition);
  border-radius: 0;
  cursor: pointer;
  border: none;
  background: none;
  width: 100%;
  text-align: left;
}
.nav-link:hover { background: var(--sidebar-hover); color: #fff; }
.nav-link.active {
  background: var(--primary);
  color: #fff;
}
.nav-link.active::before {
  content: '';
  position: absolute;
  right: 0; top: 0; bottom: 0;
  width: 3px;
  background: #818cf8;
  border-radius: 2px 0 0 2px;
}
.nav-icon { font-size: 1.1rem; width: 20px; text-align: center; flex-shrink: 0; }
.nav-label { flex: 1; }
.nav-badge {
  background: var(--primary);
  color: #fff;
  font-size: .65rem;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: 20px;
  min-width: 20px;
  text-align: center;
}
/* Submenu */
.nav-submenu { display: none; background: rgba(0,0,0,.2); }
.nav-submenu.open { display: block; }
.nav-submenu .nav-link { padding-left: 52px; font-size: .83rem; }
.nav-arrow { font-size: .7rem; transition: transform .2s; }
.nav-link.has-sub.open .nav-arrow { transform: rotate(180deg); }
/* Sidebar footer */
.sidebar-footer {
  padding: 16px 20px;
  border-top: 1px solid rgba(255,255,255,.08);
}
.user-info {
  display: flex; align-items: center; gap: 10px;
}
.user-avatar {
  width: 36px; height: 36px;
  background: var(--primary);
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; color: #fff;
  font-size: .9rem;
  flex-shrink: 0;
}
.user-name { font-size: .85rem; font-weight: 600; color: #fff; }
.user-role { font-size: .72rem; color: var(--sidebar-text); opacity: .7; }
.btn-logout {
  margin-top: 10px;
  display: flex; align-items: center; gap: 8px;
  color: #fca5a5; font-size: .82rem; cursor: pointer;
  background: none; border: none; padding: 0;
  text-decoration: none;
  transition: color .2s;
}
.btn-logout:hover { color: #f87171; }

/* ====== MAIN CONTENT ====== */
.main-content {
  margin-left: var(--sidebar-width);
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  transition: margin-left .3s ease;
}

/* ====== HEADER ====== */
.header {
  height: var(--header-height);
  background: var(--header-bg);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 24px;
  gap: 16px;
  position: sticky;
  top: 0;
  z-index: 900;
  box-shadow: var(--shadow-sm);
}
.header-toggle {
  display: none;
  background: none; border: none;
  color: var(--text-muted); font-size: 1.3rem;
  cursor: pointer; padding: 4px;
}
.header-title {
  flex: 1;
  font-weight: 600;
  font-size: 1rem;
  color: var(--text);
}
.header-title small {
  display: block;
  font-size: .75rem;
  font-weight: 400;
  color: var(--text-muted);
}
.header-actions { display: flex; align-items: center; gap: 8px; }
.header-btn {
  width: 38px; height: 38px;
  display: flex; align-items: center; justify-content: center;
  border-radius: 10px;
  background: var(--surface2);
  border: 1px solid var(--border);
  color: var(--text-muted);
  cursor: pointer;
  font-size: 1rem;
  transition: var(--transition);
  text-decoration: none;
}
.header-btn:hover { background: var(--primary); color: #fff; border-color: var(--primary); }
.header-clock {
  font-size: .82rem;
  font-weight: 600;
  color: var(--text-muted);
  background: var(--surface2);
  border: 1px solid var(--border);
  padding: 6px 12px;
  border-radius: 8px;
  font-feature-settings: 'tnum';
}

/* ====== PAGE CONTENT ====== */
.page-content { padding: 24px; flex: 1; }
.page-header { margin-bottom: 24px; }
.page-header h1 {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--text);
}
.page-header p { color: var(--text-muted); font-size: .9rem; margin-top: 2px; }

/* ====== CARDS ====== */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}
.card-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center;
  justify-content: space-between;
  gap: 12px;
  background: var(--surface);
}
.card-title {
  font-size: .95rem;
  font-weight: 600;
  color: var(--text);
  display: flex; align-items: center; gap: 8px;
}
.card-body { padding: 20px; }
.card-footer {
  padding: 12px 20px;
  border-top: 1px solid var(--border);
  background: var(--surface2);
}

/* ====== STAT CARDS ====== */
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 16px; margin-bottom: 24px; }
.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  display: flex;
  align-items: center;
  gap: 16px;
  box-shadow: var(--shadow-sm);
  transition: var(--transition);
}
.stat-card:hover { transform: translateY(-2px); box-shadow: var(--shadow); }
.stat-icon {
  width: 52px; height: 52px;
  border-radius: var(--radius-sm);
  display: flex; align-items: center; justify-content: center;
  font-size: 1.4rem;
  flex-shrink: 0;
}
.stat-icon.primary { background: rgba(79,70,229,.12); color: var(--primary); }
.stat-icon.success { background: rgba(16,185,129,.12); color: var(--success); }
.stat-icon.warning { background: rgba(245,158,11,.12); color: var(--warning); }
.stat-icon.danger  { background: rgba(239,68,68,.12);  color: var(--danger); }
.stat-icon.info    { background: rgba(6,182,212,.12);  color: var(--info); }
.stat-icon.purple  { background: rgba(139,92,246,.12); color: var(--purple); }
.stat-value { font-size: 1.8rem; font-weight: 700; color: var(--text); line-height: 1.1; }
.stat-label { font-size: .78rem; color: var(--text-muted); font-weight: 500; margin-top: 2px; }
.stat-trend { font-size: .75rem; margin-top: 4px; }
.stat-trend.up { color: var(--success); }
.stat-trend.down { color: var(--danger); }

/* ====== TABLE ====== */
.table-responsive { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: .88rem; }
thead th {
  background: var(--surface2);
  color: var(--text-muted);
  font-weight: 600;
  font-size: .75rem;
  text-transform: uppercase;
  letter-spacing: .04em;
  padding: 10px 14px;
  white-space: nowrap;
  border-bottom: 2px solid var(--border);
  text-align: left;
}
tbody td {
  padding: 11px 14px;
  border-bottom: 1px solid var(--border);
  color: var(--text);
  vertical-align: middle;
}
tbody tr:hover { background: var(--surface2); }
tbody tr:last-child td { border-bottom: none; }

/* ====== BADGES ====== */
.badge {
  display: inline-flex; align-items: center;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: .72rem;
  font-weight: 600;
  white-space: nowrap;
}
.badge-success { background: rgba(16,185,129,.12); color: #059669; }
.badge-warning { background: rgba(245,158,11,.12); color: #d97706; }
.badge-danger  { background: rgba(239,68,68,.12);  color: #dc2626; }
.badge-info    { background: rgba(6,182,212,.12);  color: #0891b2; }
.badge-secondary{background:rgba(100,116,139,.12);color: #475569; }
.badge-purple  { background: rgba(139,92,246,.12); color: #7c3aed; }
.badge-orange  { background: rgba(249,115,22,.12); color: #ea580c; }
.badge-teal    { background: rgba(20,184,166,.12); color: #0d9488; }
.badge-primary { background: rgba(79,70,229,.12);  color: #4338ca; }

/* ====== BUTTONS ====== */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 8px 16px;
  border-radius: var(--radius-sm);
  font-size: .85rem;
  font-weight: 500;
  cursor: pointer;
  transition: var(--transition);
  border: 1px solid transparent;
  text-decoration: none;
  white-space: nowrap;
  font-family: var(--font);
  line-height: 1.4;
}
.btn:disabled { opacity: .6; cursor: not-allowed; }
.btn-primary { background: var(--primary); color: #fff; border-color: var(--primary); }
.btn-primary:hover { background: var(--primary-dark); border-color: var(--primary-dark); }
.btn-success { background: var(--success); color: #fff; border-color: var(--success); }
.btn-success:hover { filter: brightness(.9); }
.btn-warning { background: var(--warning); color: #fff; border-color: var(--warning); }
.btn-danger  { background: var(--danger);  color: #fff; border-color: var(--danger); }
.btn-danger:hover { filter: brightness(.9); }
.btn-info    { background: var(--info);    color: #fff; border-color: var(--info); }
.btn-secondary{background:var(--surface2); color:var(--text); border-color:var(--border); }
.btn-secondary:hover { background: var(--border); }
.btn-sm { padding: 5px 10px; font-size: .78rem; }
.btn-lg { padding: 11px 22px; font-size: .95rem; }
.btn-icon { padding: 7px; }
.btn-outline-primary { background: transparent; color: var(--primary); border-color: var(--primary); }
.btn-outline-primary:hover { background: var(--primary); color: #fff; }

/* ====== FORMS ====== */
.form-group { margin-bottom: 16px; }
.form-label {
  display: block;
  font-size: .82rem;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 6px;
  text-transform: uppercase;
  letter-spacing: .03em;
}
.form-control {
  width: 100%;
  padding: 9px 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-size: .88rem;
  font-family: var(--font);
  transition: var(--transition);
  outline: none;
}
.form-control:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(79,70,229,.12);
}
.form-control::placeholder { color: var(--text-light); }
select.form-control { cursor: pointer; }
textarea.form-control { resize: vertical; min-height: 80px; }
.input-group { display: flex; gap: 0; }
.input-group .form-control { border-radius: var(--radius-sm) 0 0 var(--radius-sm); flex: 1; }
.input-group .btn { border-radius: 0 var(--radius-sm) var(--radius-sm) 0; }
.form-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 16px; }
.form-hint { font-size: .75rem; color: var(--text-muted); margin-top: 4px; }

/* ====== MODALS ====== */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,.5);
  backdrop-filter: blur(4px);
  z-index: 2000;
  display: flex; align-items: center; justify-content: center;
  padding: 16px;
  opacity: 0; visibility: hidden;
  transition: all .2s ease;
}
.modal-overlay.open { opacity: 1; visibility: visible; }
.modal {
  background: var(--surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  width: 100%;
  max-width: 520px;
  max-height: 90vh;
  overflow-y: auto;
  transform: scale(.95);
  transition: transform .2s ease;
}
.modal-overlay.open .modal { transform: scale(1); }
.modal-lg { max-width: 800px; }
.modal-xl { max-width: 1000px; }
.modal-header {
  padding: 20px 24px 16px;
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
}
.modal-title { font-size: 1rem; font-weight: 700; }
.modal-close {
  background: none; border: none;
  color: var(--text-muted); cursor: pointer;
  font-size: 1.3rem; line-height: 1;
  padding: 2px;
  transition: color .2s;
}
.modal-close:hover { color: var(--danger); }
.modal-body { padding: 20px 24px; }
.modal-footer {
  padding: 16px 24px;
  border-top: 1px solid var(--border);
  display: flex; gap: 8px; justify-content: flex-end;
  background: var(--surface2);
}

/* ====== ALERTS ====== */
.alert {
  display: flex; align-items: flex-start; gap: 12px;
  padding: 14px 16px;
  border-radius: var(--radius-sm);
  font-size: .88rem;
  margin-bottom: 16px;
  border-left: 4px solid;
}
.alert-success { background: rgba(16,185,129,.08); border-color: var(--success); color: #065f46; }
.alert-danger   { background: rgba(239,68,68,.08);  border-color: var(--danger);  color: #991b1b; }
.alert-warning  { background: rgba(245,158,11,.08); border-color: var(--warning); color: #92400e; }
.alert-info     { background: rgba(6,182,212,.08);  border-color: var(--info);    color: #164e63; }
[data-theme="dark"] .alert-success { color: #6ee7b7; }
[data-theme="dark"] .alert-danger  { color: #fca5a5; }
[data-theme="dark"] .alert-warning { color: #fcd34d; }
[data-theme="dark"] .alert-info    { color: #67e8f9; }

/* ====== TOAST NOTIFICATIONS ====== */
.toast-container {
  position: fixed; top: 20px; right: 20px;
  z-index: 9999; display: flex; flex-direction: column; gap: 8px;
}
.toast {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px 16px;
  box-shadow: var(--shadow);
  display: flex; align-items: center; gap: 10px;
  min-width: 280px; max-width: 360px;
  animation: slideInRight .3s ease;
  font-size: .85rem;
}
.toast.success { border-left: 3px solid var(--success); }
.toast.error   { border-left: 3px solid var(--danger); }
.toast.warning { border-left: 3px solid var(--warning); }
.toast.info    { border-left: 3px solid var(--info); }
@keyframes slideInRight {
  from { transform: translateX(100%); opacity: 0; }
  to   { transform: translateX(0);    opacity: 1; }
}

/* ====== PAGINATION ====== */
.pagination { display: flex; gap: 4px; align-items: center; flex-wrap: wrap; }
.page-link {
  display: flex; align-items: center; justify-content: center;
  width: 34px; height: 34px;
  border-radius: 8px;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text-muted);
  font-size: .82rem;
  cursor: pointer;
  text-decoration: none;
  transition: var(--transition);
  font-weight: 500;
}
.page-link:hover, .page-link.active {
  background: var(--primary); color: #fff; border-color: var(--primary);
}

/* ====== FILTER BAR ====== */
.filter-bar {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 20px;
  margin-bottom: 20px;
  display: flex; flex-wrap: wrap; gap: 12px; align-items: flex-end;
}
.filter-group { display: flex; flex-direction: column; gap: 4px; flex: 1; min-width: 140px; }
.filter-label { font-size: .72rem; font-weight: 600; color: var(--text-muted); text-transform: uppercase; letter-spacing: .04em; }

/* ====== TABS ====== */
.tabs { display: flex; gap: 0; border-bottom: 2px solid var(--border); margin-bottom: 20px; overflow-x: auto; }
.tab-btn {
  padding: 10px 18px;
  background: none; border: none;
  color: var(--text-muted); font-size: .88rem; font-weight: 500;
  cursor: pointer; white-space: nowrap;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  transition: var(--transition);
}
.tab-btn.active, .tab-btn:hover { color: var(--primary); border-bottom-color: var(--primary); }
.tab-panel { display: none; }
.tab-panel.active { display: block; }

/* ====== EMPTY STATE ====== */
.empty-state {
  text-align: center; padding: 60px 20px; color: var(--text-muted);
}
.empty-state-icon { font-size: 3.5rem; margin-bottom: 16px; opacity: .4; }
.empty-state h3 { font-size: 1.1rem; font-weight: 600; color: var(--text); margin-bottom: 8px; }
.empty-state p { font-size: .88rem; max-width: 300px; margin: 0 auto; }

/* ====== SYNC STATUS ====== */
.sync-indicator { display: flex; align-items: center; gap: 6px; font-size: .78rem; color: var(--text-muted); }
.sync-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--success); }
.sync-dot.syncing { animation: pulse 1s infinite; background: var(--warning); }
.sync-dot.error   { background: var(--danger); }
@keyframes pulse { 0%,100%{opacity:1} 50%{opacity:.3} }

/* ====== SKELETON LOADER ====== */
.skeleton {
  background: linear-gradient(90deg, var(--border) 25%, var(--surface2) 50%, var(--border) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
  border-radius: 4px;
}
@keyframes shimmer { 0%{background-position:200%} 100%{background-position:-200%} }

/* ====== UTILITY ====== */
.flex { display: flex; }
.flex-col { flex-direction: column; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-2 { gap: 8px; }
.gap-3 { gap: 12px; }
.gap-4 { gap: 16px; }
.mt-0 { margin-top: 0; }
.mt-4 { margin-top: 16px; }
.mt-6 { margin-top: 24px; }
.mb-4 { margin-bottom: 16px; }
.mb-6 { margin-bottom: 24px; }
.text-right { text-align: right; }
.text-center { text-align: center; }
.text-muted { color: var(--text-muted); }
.text-sm { font-size: .8rem; }
.text-xs { font-size: .72rem; }
.font-bold { font-weight: 700; }
.font-semibold { font-weight: 600; }
.w-full { width: 100%; }
.hidden { display: none; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 16px; }
.grid-4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; }

/* ====== SIDEBAR OVERLAY (mobile) ====== */
.sidebar-overlay {
  display: none; position: fixed; inset: 0;
  background: rgba(0,0,0,.5); z-index: 999;
}

/* ====== RESPONSIVE ====== */
@media (max-width: 1024px) {
  .grid-4 { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 768px) {
  .sidebar { transform: translateX(-100%); }
  .sidebar.open { transform: translateX(0); }
  .sidebar-overlay { display: block; }
  .main-content { margin-left: 0; }
  .header-toggle { display: flex; }
  .page-content { padding: 16px; }
  .stat-grid { grid-template-columns: 1fr 1fr; }
  .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; }
  .form-row { grid-template-columns: 1fr; }
  .filter-bar { flex-direction: column; }
  .modal { max-width: 100%; margin: 0; }
}
@media (max-width: 480px) {
  .stat-grid { grid-template-columns: 1fr; }
  .header { padding: 0 16px; }
}

/* ====== PRINT ====== */
@media print {
  .sidebar, .header, .filter-bar, .btn, .pagination { display: none !important; }
  .main-content { margin-left: 0; }
  .card { box-shadow: none; border: 1px solid #ddd; }
}
