@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap');

:root {
  --sidebar-width: 240px;
  --topbar-height: 56px;

  --color-sidebar-bg:    #0f172a;
  --color-accent:        #6366f1;
  --color-accent-hover:  #4f46e5;
  --color-accent-light:  rgba(99,102,241,.15);

  --color-bg:            #f8fafc;
  --color-card:          #ffffff;
  --color-border:        #f1f5f9;
  --color-border-input:  #e2e8f0;

  --color-text:          #0f172a;
  --color-text-muted:    #64748b;
  --color-text-light:    #94a3b8;

  --color-pending-bg:    #fef9c3;
  --color-pending-text:  #854d0e;
  --color-pending-border:#fde047;
  --color-complete-bg:   #dcfce7;
  --color-complete-text: #166534;
  --color-complete-border:#86efac;

  --shadow-card: 0 1px 3px rgba(15,23,42,.06), 0 1px 2px rgba(15,23,42,.04);
  --radius-card: 12px;
  --radius-input: 8px;
  --transition: .15s ease;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html, body { height: 100%; }

body {
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  font-size: 14px;
  line-height: 1.5;
  color: var(--color-text);
  background: var(--color-bg);
  -webkit-font-smoothing: antialiased;
}

/* ── Layout ───────────────────────────────────────────────── */
.app-shell {
  display: flex;
  height: 100vh;
  overflow: hidden;
}

.app-sidebar {
  width: var(--sidebar-width);
  min-width: var(--sidebar-width);
  background: var(--color-sidebar-bg);
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  flex-shrink: 0;
}

.app-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  overflow: hidden;
}

.app-topbar {
  height: var(--topbar-height);
  background: #fff;
  border-bottom: 1px solid var(--color-border);
  display: flex;
  align-items: center;
  padding: 0 24px;
  gap: 16px;
  flex-shrink: 0;
}

.app-content {
  flex: 1;
  overflow-y: auto;
  padding: 24px;
  background: var(--color-bg);
}

/* ── Sidebar Brand ───────────────────────────────────────── */
.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 16px 20px;
  border-bottom: 1px solid rgba(255,255,255,.06);
  text-decoration: none;
}
.sidebar-brand-icon {
  width: 32px; height: 32px;
  background: var(--color-accent);
  border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.sidebar-brand-icon i { color: #fff; font-size: 13px; }
.sidebar-brand-name { color: #fff; font-size: 15px; font-weight: 600; letter-spacing: -.2px; }

/* ── Sidebar Nav ─────────────────────────────────────────── */
.sidebar-nav { flex: 1; padding: 12px; }

.sidebar-section-label {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .8px;
  color: #475569;
  padding: 16px 8px 6px;
}
.sidebar-section-label:first-child { padding-top: 8px; }

.sidebar-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  border-radius: 8px;
  font-size: 13.5px;
  font-weight: 500;
  color: #94a3b8;
  text-decoration: none;
  transition: background var(--transition), color var(--transition);
  position: relative;
}
.sidebar-link:hover { background: rgba(255,255,255,.06); color: #e2e8f0; }
.sidebar-link.active { background: var(--color-accent-light); color: #a5b4fc; }

.sidebar-link-icon { width: 18px; text-align: center; font-size: 12px; flex-shrink: 0; }

.sidebar-badge {
  margin-left: auto;
  font-size: 10px;
  font-weight: 700;
  padding: 1px 6px;
  border-radius: 5px;
  background: #1e293b;
  color: #94a3b8;
}
.sidebar-badge.amber { background: rgba(245,158,11,.18); color: #fbbf24; }
.sidebar-badge.indigo { background: rgba(99,102,241,.2); color: #a5b4fc; }

/* ── Sidebar User Footer ─────────────────────────────────── */
.sidebar-user {
  padding: 10px 12px;
  border-top: 1px solid rgba(255,255,255,.06);
}
.sidebar-user-inner {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 8px;
  border-radius: 8px;
  cursor: pointer;
  transition: background var(--transition);
}
.sidebar-user-inner:hover { background: rgba(255,255,255,.05); }
.sidebar-avatar {
  width: 28px; height: 28px;
  border-radius: 50%;
  background: var(--color-accent);
  display: flex; align-items: center; justify-content: center;
  font-size: 11px; font-weight: 700; color: #fff;
  flex-shrink: 0;
}
.sidebar-user-name  { font-size: 13px; font-weight: 500; color: #cbd5e1; }
.sidebar-user-role  { font-size: 11px; color: #475569; }
.sidebar-logout     { margin-left: auto; color: #475569; font-size: 12px; text-decoration: none; }
.sidebar-logout:hover { color: #94a3b8; }

/* ── Topbar ──────────────────────────────────────────────── */
.topbar-title       { flex: 1; }
.topbar-title h1    { font-size: 15px; font-weight: 600; color: #0f172a; line-height: 1.2; }
.topbar-title p     { font-size: 12px; color: var(--color-text-muted); line-height: 1; margin-top: 2px; }

.topbar-actions { display: flex; align-items: center; gap: 10px; }
.topbar-icon-btn {
  width: 32px; height: 32px;
  border-radius: 8px;
  border: none; background: transparent; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  color: var(--color-text-muted);
  transition: background var(--transition), color var(--transition);
}
.topbar-icon-btn:hover { background: #f1f5f9; color: #334155; }

.topbar-divider { width: 1px; height: 16px; background: #e2e8f0; }

.topbar-user { display: flex; align-items: center; gap: 8px; cursor: pointer; }
.topbar-user-name { font-size: 13px; font-weight: 500; color: #334155; }

/* ── Page Header ─────────────────────────────────────────── */
.page-header { margin-bottom: 20px; }
.page-header h1 { font-size: 18px; font-weight: 600; color: var(--color-text); }
.page-header p   { font-size: 13px; color: var(--color-text-muted); margin-top: 2px; }

.page-header-row {
  display: flex; align-items: flex-start; justify-content: space-between;
  margin-bottom: 20px; gap: 16px;
}

/* ── Stat Cards ──────────────────────────────────────────── */
.stats-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; margin-bottom: 20px; }
@media (max-width: 768px) { .stats-grid { grid-template-columns: 1fr; } }

.stat-card {
  background: var(--color-card);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-card);
  padding: 20px 22px;
  box-shadow: var(--shadow-card);
}
.stat-card-inner { display: flex; align-items: flex-start; justify-content: space-between; }
.stat-label  { font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .5px; color: var(--color-text-light); }
.stat-value  { font-size: 30px; font-weight: 700; color: var(--color-text); margin-top: 6px; line-height: 1; }
.stat-sub    { font-size: 12px; font-weight: 500; margin-top: 6px; }
.stat-sub.up    { color: #10b981; }
.stat-sub.muted { color: var(--color-text-light); }

.stat-icon {
  width: 40px; height: 40px; border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  font-size: 16px; flex-shrink: 0;
}
.stat-icon.amber  { background: #fef9c3; color: #d97706; }
.stat-icon.green  { background: #dcfce7; color: #16a34a; }
.stat-icon.indigo { background: #e0e7ff; color: #6366f1; }

/* ── Cards / Panels ──────────────────────────────────────── */
.card {
  background: var(--color-card);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-card);
  box-shadow: var(--shadow-card);
  overflow: hidden;
}

.card-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 20px;
  border-bottom: 1px solid var(--color-border);
}
.card-header h2 { font-size: 14px; font-weight: 600; color: var(--color-text); margin: 0; }
.card-header p  { font-size: 12px; color: var(--color-text-muted); margin-top: 1px; }
.card-header a  { font-size: 13px; font-weight: 500; color: var(--color-accent); text-decoration: none; }
.card-header a:hover { color: var(--color-accent-hover); }

.card-body { padding: 20px; }

/* collapsible panel toggle */
.panel-toggle {
  width: 100%; display: flex; align-items: center; justify-content: space-between;
  padding: 14px 20px; background: transparent; border: none; cursor: pointer;
  text-align: left;
  transition: background var(--transition);
}
.panel-toggle:hover { background: #f8fafc; }
.panel-toggle-title { font-size: 14px; font-weight: 600; color: var(--color-text); display: flex; align-items: center; gap: 8px; }
.panel-toggle-title i { font-size: 12px; color: var(--color-accent); }
.panel-toggle-icon { font-size: 12px; color: var(--color-text-light); transition: transform var(--transition); }
.panel-toggle.open .panel-toggle-icon { transform: rotate(180deg); }
.panel-body { border-top: 1px solid var(--color-border); padding: 16px 20px; display: none; }
.panel-body.open { display: block; }

/* ── Filter Bar ──────────────────────────────────────────── */
.filter-bar {
  background: var(--color-card);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-card);
  padding: 12px 16px;
  box-shadow: var(--shadow-card);
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  margin-bottom: 16px;
}

/* ── Filter Tabs ─────────────────────────────────────────── */
.filter-tabs {
  display: inline-flex;
  background: #fff;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  padding: 2px;
}
.filter-tab {
  padding: 5px 14px;
  border-radius: 6px;
  font-size: 13px; font-weight: 500;
  cursor: pointer; border: none; background: transparent;
  color: #64748b;
  text-decoration: none;
  display: inline-block;
  transition: background var(--transition), color var(--transition);
}
.filter-tab:hover { color: #334155; }
.filter-tab.active { background: #0f172a; color: #fff; }

/* ── Form inputs ─────────────────────────────────────────── */
.form-group { margin-bottom: 14px; }
.form-label { display: block; font-size: 13px; font-weight: 500; color: #475569; margin-bottom: 5px; }

.form-input, .form-select {
  width: 100%; padding: 8px 12px;
  border: 1px solid var(--color-border-input);
  border-radius: var(--radius-input);
  font-size: 13.5px; color: var(--color-text);
  background: #fff; outline: none;
  transition: border-color var(--transition), box-shadow var(--transition);
  font-family: inherit;
}
.form-input:focus, .form-select:focus {
  border-color: var(--color-accent);
  box-shadow: 0 0 0 3px rgba(99,102,241,.12);
}
.form-input.inline { width: auto; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 0 16px; }

/* ── Tables ──────────────────────────────────────────────── */
.table-wrap { overflow-x: auto; }

.data-table { width: 100%; border-collapse: collapse; }

.data-table th {
  font-size: 11px; font-weight: 600; text-transform: uppercase;
  letter-spacing: .5px; color: var(--color-text-light);
  padding: 10px 14px;
  background: #f8fafc;
  border-bottom: 1px solid var(--color-border);
  white-space: nowrap;
}
.data-table td {
  font-size: 13.5px; color: #334155;
  padding: 11px 14px;
}
.data-table tbody tr:nth-child(odd)  td { background: #ffffff; }
.data-table tbody tr:nth-child(even) td { background: #f1f5f9; }
.data-table tbody tr:hover td { background: #e0e7ff !important; }

/* ── Status Badges ───────────────────────────────────────── */
.badge {
  display: inline-flex; align-items: center;
  padding: 2px 10px; border-radius: 9999px;
  font-size: 11px; font-weight: 600; letter-spacing: .2px;
}
.badge-pending  { background: var(--color-pending-bg);  color: var(--color-pending-text); }
.badge-complete { background: var(--color-complete-bg); color: var(--color-complete-text); }
.badge-active   { background: #dcfce7; color: #166534; }
.badge-inactive { background: #f1f5f9; color: #64748b; }
.badge-admin    { background: #ede9fe; color: #5b21b6; }
.badge-new      { background: rgba(99,102,241,.15); color: #6366f1; }

/* ── Status Dropdown (inline table select) ───────────────── */
.status-select {
  font-size: 12px; font-weight: 600;
  padding: 3px 10px;
  border-radius: 99px;
  border: 1px solid;
  cursor: pointer;
  outline: none;
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath d='M0 0l5 6 5-6z' fill='%2394a3b8'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 8px center;
  padding-right: 24px;
  transition: box-shadow var(--transition);
}
.status-select:focus { box-shadow: 0 0 0 3px rgba(99,102,241,.15); }
.status-select.pending  { background-color: var(--color-pending-bg);  color: var(--color-pending-text);  border-color: var(--color-pending-border); }
.status-select.complete { background-color: var(--color-complete-bg); color: var(--color-complete-text); border-color: var(--color-complete-border); }
.status-select.active   { background-color: #dcfce7; color: #166534; border-color: #86efac; }
.status-select.inactive { background-color: #f1f5f9; color: #64748b; border-color: #cbd5e1; }

/* ── FDN / Inline text input ─────────────────────────────── */
.fdn-input {
  font-size: 12px; padding: 5px 9px;
  border: 1px solid var(--color-border-input);
  border-radius: 7px; width: 110px;
  outline: none;
  transition: border-color var(--transition), box-shadow var(--transition);
}
.fdn-input:focus { border-color: var(--color-accent); box-shadow: 0 0 0 3px rgba(99,102,241,.12); }

/* ── Buttons ─────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 8px 16px; border-radius: 8px;
  font-size: 13px; font-weight: 500; font-family: inherit;
  cursor: pointer; border: none; text-decoration: none;
  transition: background var(--transition), color var(--transition), box-shadow var(--transition);
}
.btn-primary { background: var(--color-accent); color: #fff; }
.btn-primary:hover { background: var(--color-accent-hover); }
.btn-secondary { background: #f1f5f9; color: #334155; }
.btn-secondary:hover { background: #e2e8f0; }
.btn-sm { padding: 5px 11px; font-size: 12px; border-radius: 7px; }
.btn-ghost { background: transparent; color: var(--color-text-muted); border: 1px solid var(--color-border-input); }
.btn-ghost:hover { background: #f8fafc; color: #334155; }

/* action button in table rows */
.row-btn {
  font-size: 12px; padding: 4px 10px; border-radius: 7px;
  background: #f8fafc; border: 1px solid var(--color-border-input);
  color: #64748b; cursor: pointer; font-family: inherit; font-weight: 500;
  transition: background var(--transition), border-color var(--transition), color var(--transition);
}
.row-btn:hover { background: #e0e7ff; border-color: #c7d2fe; color: #4f46e5; }
.row-btn.warn:hover { background: #fef9c3; border-color: #fde047; color: #854d0e; }

/* detail toggle button */
.detail-toggle {
  width: 28px; height: 28px; border-radius: 7px;
  background: transparent; border: none; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  color: #94a3b8; font-size: 11px;
  transition: background var(--transition), color var(--transition);
}
.detail-toggle:hover, .detail-toggle.open { background: #e0e7ff; color: #4f46e5; }

/* ── Order Details Row ───────────────────────────────────── */
.details-row { display: none; }
.details-row.open { display: table-row; }
.details-row td { background: #f8fafc !important; padding: 14px 20px; }

.details-inner { font-size: 13px; }
.details-inner h4 { font-size: 13px; font-weight: 600; color: #475569; margin-bottom: 10px; }
.details-sub-table { width: auto; max-width: 560px; border-collapse: collapse; }
.details-sub-table th { font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .4px; color: #94a3b8; padding: 0 12px 6px; border-bottom: 1px solid #e2e8f0; background: transparent !important; text-align: left; }
.details-sub-table td { font-size: 12.5px; color: #475569; padding: 5px 12px; background: transparent !important; }

/* ── Pagination ──────────────────────────────────────────── */
.pagination {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 20px; border-top: 1px solid var(--color-border);
}
.pagination-info { font-size: 12px; color: var(--color-text-light); }
.pagination-pages { display: flex; gap: 4px; }
.page-btn {
  width: 32px; height: 32px; display: flex; align-items: center; justify-content: center;
  border-radius: 8px; border: 1px solid var(--color-border-input);
  font-size: 12px; font-weight: 500; color: #475569; text-decoration: none;
  cursor: pointer; background: #fff;
  transition: background var(--transition), border-color var(--transition);
}
.page-btn:hover { background: #f1f5f9; }
.page-btn.active { background: var(--color-accent); color: #fff; border-color: var(--color-accent); }
.page-btn.disabled { color: var(--color-text-light); pointer-events: none; }

/* ── User Avatar ─────────────────────────────────────────── */
.user-avatar {
  width: 28px; height: 28px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 11px; font-weight: 700; color: #fff; flex-shrink: 0;
}

/* ── Toast ───────────────────────────────────────────────── */
#toast-container {
  position: fixed; bottom: 20px; right: 20px; z-index: 9999;
  display: flex; flex-direction: column; gap: 8px;
}
.toast {
  padding: 10px 16px; border-radius: 10px; font-size: 13px; font-weight: 500;
  color: #fff; box-shadow: 0 4px 12px rgba(0,0,0,.15);
  animation: toastIn .2s ease;
}
.toast.success { background: #16a34a; }
.toast.error   { background: #dc2626; }
.toast.info    { background: var(--color-accent); }
@keyframes toastIn { from { opacity:0; transform:translateY(8px); } to { opacity:1; transform:translateY(0); } }

/* ── Print ───────────────────────────────────────────────── */
@media print {
  .app-sidebar, .app-topbar, .filter-bar, .filter-tabs,
  .pagination, .panel-toggle, .btn, .row-btn, .detail-toggle,
  #toast-container { display: none !important; }
  html, body    { height: auto !important; overflow: visible !important; }
  .app-shell    { display: block !important; height: auto !important; overflow: visible !important; }
  .app-main     { display: block !important; height: auto !important; overflow: visible !important; }
  .app-content  { display: block !important; height: auto !important; overflow: visible !important; padding: 0 !important; }
  .card         { overflow: visible !important; }
  .table-wrap   { overflow: visible !important; }
  body { background: #fff !important; }
  .data-table tbody tr:nth-child(odd)  td { background: #fff !important; }
  .data-table tbody tr:nth-child(even) td { background: #f5f5f5 !important; }
}

/* ── Scrollbar ───────────────────────────────────────────── */
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #e2e8f0; border-radius: 99px; }
