/* ============================================================
   NexaForge ERP — Creative Studio Suite
   styles.css  |  Phase 2: Refactoring
   ============================================================ */

:root {
  --primary: #000B7E;
  --primary-hover: #0010B0;
  --primary-light: #e8eaf6;
  --accent: #20DA2E;
  --accent-soft: #80EE77;
  --accent-muted: #dcfce7;
  --bg: #f5f6fa;
  --surface: #ffffff;
  --surface2: #f9fafb;
  --border: #e5e7eb;
  --text: #0a0e1a;
  --text-muted: #64748b;
  --text-light: #94a3b8;
  --danger: #ef4444;
  --danger-soft: #fee2e2;
  --warning: #f59e0b;
  --warning-soft: #fef3c7;
  --success: #16a34a;
  --success-soft: #d1fae5;
  --radius: 8px;
  --radius-lg: 12px;
  --shadow: 0 1px 3px rgba(0,0,0,0.06), 0 1px 2px rgba(0,0,0,0.04);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.08);
  --sidebar-w: 220px;
  --topbar-h: 56px;
  --bottomnav-h: 64px;
}

* { font-family: 'DM Sans', sans-serif; box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html { height: 100%; }
body { background: var(--bg); color: var(--text); -webkit-font-smoothing: antialiased; margin: 0; height: 100%; }

/* ---- CARDS ---- */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 24px; box-shadow: var(--shadow); }

/* ---- BUTTONS ---- */
.btn { background: var(--primary); color: #fff; padding: 9px 16px; border-radius: var(--radius); font-weight: 600; font-size: 13px; cursor: pointer; border: none; transition: all 0.15s; display: inline-flex; align-items: center; gap: 6px; letter-spacing: 0.01em; white-space: nowrap; }
.btn:hover { background: var(--primary-hover); transform: translateY(-1px); box-shadow: 0 4px 8px rgba(0,11,126,0.25); }
.btn:active { transform: translateY(0); }
.btn-accent { background: var(--accent); color: var(--primary); }
.btn-accent:hover { background: #1bc227; box-shadow: 0 4px 8px rgba(32,218,46,0.3); }
.btn-secondary { background: var(--surface); color: var(--text); border: 1px solid var(--border); }
.btn-secondary:hover { background: var(--bg); }
.btn-success { background: var(--success); color: white; }
.btn-success:hover { background: #15803d; }
.btn-danger { background: var(--danger); color: white; }
.btn-danger:hover { background: #b91c1c; }
.btn-sm { padding: 6px 12px; font-size: 12px; }
.btn-full { width: 100%; justify-content: center; padding: 13px; font-size: 15px; border-radius: 10px; }

/* ---- INPUTS ---- */
input, select, textarea { background: var(--surface); border: 1px solid var(--border); color: var(--text); border-radius: var(--radius); padding: 9px 12px; width: 100%; font-size: 14px; transition: all 0.15s; font-family: 'DM Sans', sans-serif; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(0,11,126,0.08); }

/* ---- TABLES ---- */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table { width: 100%; border-collapse: separate; border-spacing: 0; }
th { background: var(--surface2); font-weight: 600; font-size: 11px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--text-muted); padding: 11px 16px; border-bottom: 1px solid var(--border); text-align: left; white-space: nowrap; }
td { padding: 12px 16px; border-bottom: 1px solid #f1f5f9; font-size: 14px; color: var(--text); }
tr:last-child td { border-bottom: none; }
tr:hover td { background: #fafbff; }

/* ---- DESKTOP SIDEBAR ---- */
.sidebar { background: var(--primary); display: flex; flex-direction: column; padding: 16px; height: 100vh; overflow-y: auto; position: sticky; top: 0; }
.sidebar-logo { background: rgba(255,255,255,0.1); border-radius: var(--radius-lg); }
.nav-item { display: flex; align-items: center; gap: 10px; padding: 9px 12px; border-radius: var(--radius); color: rgba(255,255,255,0.65); font-size: 13px; font-weight: 500; cursor: pointer; transition: all 0.15s; margin-bottom: 1px; border: none; width: 100%; text-align: left; background: none; }
.nav-item:hover { background: rgba(255,255,255,0.1); color: rgba(255,255,255,0.95); }
.nav-item.active { background: var(--accent); color: var(--primary); font-weight: 700; }
.nav-item .nav-icon { width: 18px; text-align: center; font-size: 16px; flex-shrink: 0; }

/* ---- MOBILE TOP BAR ---- */
.mobile-topbar { display: none; position: fixed; top: 0; left: 0; right: 0; height: var(--topbar-h); background: var(--primary); z-index: 200; align-items: center; padding: 0 16px; gap: 12px; box-shadow: 0 2px 8px rgba(0,0,0,0.2); }
.mobile-topbar .topbar-logo { width: 32px; height: 32px; border-radius: 8px; background: var(--accent); display: flex; align-items: center; justify-content: center; font-weight: 800; font-size: 11px; color: var(--primary); flex-shrink: 0; overflow: hidden; }
.mobile-topbar .topbar-title { flex: 1; color: white; font-weight: 700; font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mobile-topbar .topbar-role { color: var(--accent); font-size: 11px; font-weight: 700; white-space: nowrap; }
.hamburger { background: none; border: none; cursor: pointer; padding: 8px; display: flex; flex-direction: column; gap: 5px; }
.hamburger span { display: block; width: 22px; height: 2px; background: white; border-radius: 2px; transition: all 0.2s; }

/* ---- MOBILE DRAWER ---- */
.drawer-overlay { display: none; position: fixed; inset: 0; background: rgba(0,0,0,0.5); z-index: 300; }
.drawer-overlay.open { display: block; }
.mobile-drawer { position: fixed; top: 0; left: -100%; width: 260px; height: 100vh; background: var(--primary); z-index: 400; transition: left 0.28s cubic-bezier(.4,0,.2,1); display: flex; flex-direction: column; padding: 0; overflow-y: auto; box-shadow: 4px 0 24px rgba(0,0,0,0.3); }
.mobile-drawer.open { left: 0; }
.drawer-header { padding: 20px 16px 12px; border-bottom: 1px solid rgba(255,255,255,0.1); }
.drawer-nav { flex: 1; padding: 8px 12px; }
.drawer-footer { padding: 12px; border-top: 1px solid rgba(255,255,255,0.1); }

/* ---- MOBILE BOTTOM NAV ---- */
.mobile-bottomnav { display: none; position: fixed; bottom: 0; left: 0; right: 0; height: var(--bottomnav-h); background: var(--surface); border-top: 1px solid var(--border); z-index: 200; align-items: stretch; box-shadow: 0 -4px 16px rgba(0,0,0,0.08); }
.bottomnav-item { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; border: none; background: none; cursor: pointer; padding: 8px 4px; color: var(--text-muted); transition: color 0.15s; font-size: 11px; font-weight: 600; }
.bottomnav-item.active { color: var(--primary); }
.bottomnav-item.active .bottomnav-icon { background: var(--primary-light); }
.bottomnav-icon { font-size: 18px; width: 36px; height: 28px; display: flex; align-items: center; justify-content: center; border-radius: 8px; transition: background 0.15s; }
.bottomnav-more { position: relative; }

/* ---- BADGES ---- */
.badge { display: inline-flex; align-items: center; padding: 3px 9px; border-radius: 999px; font-size: 11px; font-weight: 600; letter-spacing: 0.03em; }
.badge-assigned { background: #fef3c7; color: #92400e; }
.badge-progress { background: var(--primary-light); color: var(--primary); }
.badge-submitted { background: #e0e7ff; color: #3730a3; }
.badge-approved { background: var(--accent-muted); color: #065f46; }
.badge-rejected { background: var(--danger-soft); color: #991b1b; }
.badge-pending { background: #f1f5f9; color: #475569; }
.badge-confirmed { background: var(--accent-muted); color: #065f46; }
.badge-admin { background: var(--primary-light); color: var(--primary); }

/* ---- STAT CARDS ---- */
.stat-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 20px; position: relative; overflow: hidden; }
.stat-card::after { content: ''; position: absolute; top: 0; left: 0; width: 3px; height: 100%; background: var(--primary); }
.stat-card.green::after { background: var(--accent); }
.stat-card.red::after { background: var(--danger); }
.stat-card.blue::after { background: #3b82f6; }
.stat-card.orange::after { background: var(--warning); }

/* ---- MODAL ---- */
.modal-overlay { position: fixed; inset: 0; background: rgba(0,0,0,0.45); display: flex; align-items: center; justify-content: center; z-index: 1000; padding: 20px; backdrop-filter: blur(2px); }
.modal { background: var(--surface); border-radius: var(--radius-lg); padding: 28px; width: 100%; max-width: 540px; max-height: 90vh; overflow-y: auto; box-shadow: var(--shadow-md); animation: modalIn 0.2s ease-out; }
@keyframes modalIn { from { opacity:0; transform:scale(0.95) translateY(8px); } to { opacity:1; transform:scale(1) translateY(0); } }
.modal-lg { max-width: 720px; }
.modal-xl { max-width: 900px; }
.modal-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 20px; }
.modal-title { font-size: 17px; font-weight: 700; color: var(--text); }
.modal-close { background: none; border: none; font-size: 20px; cursor: pointer; color: var(--text-muted); width: 32px; height: 32px; display: flex; align-items: center; justify-content: center; border-radius: 6px; }
.modal-close:hover { background: var(--bg); }

/* ---- FORMS ---- */
.form-group { margin-bottom: 14px; }
.form-label { display: block; font-size: 12px; font-weight: 600; color: var(--text-muted); margin-bottom: 5px; text-transform: uppercase; letter-spacing: 0.05em; }
.form-row { display: grid; gap: 12px; }
.form-row.cols-2 { grid-template-columns: 1fr 1fr; }
.form-row.cols-3 { grid-template-columns: 1fr 1fr 1fr; }

/* ---- MISC ---- */
.fade-in { animation: fadeIn 0.2s ease-out; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: translateY(0); } }
.loading { width: 20px; height: 20px; border: 2px solid var(--border); border-top-color: var(--primary); border-radius: 50%; animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.empty-state { text-align: center; padding: 60px 20px; color: var(--text-light); }
.tab-bar { display: flex; gap: 4px; border-bottom: 2px solid var(--border); margin-bottom: 20px; overflow-x: auto; }
.tab { padding: 9px 16px; font-size: 13px; font-weight: 600; color: var(--text-muted); cursor: pointer; border-bottom: 2px solid transparent; margin-bottom: -2px; transition: all 0.15s; border-radius: 6px 6px 0 0; white-space: nowrap; }
.tab:hover { color: var(--primary); background: var(--primary-light); }
.tab.active { color: var(--primary); border-bottom-color: var(--primary); }
.progress-bar { background: var(--border); border-radius: 999px; height: 8px; overflow: hidden; }
.progress-bar-sm { height: 6px; }
.progress-fill { background: var(--accent); height: 100%; border-radius: 999px; transition: width 0.5s ease; }
.section-label { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.08em; color: rgba(255,255,255,0.4); padding: 14px 12px 6px; }
.divider { height: 1px; background: rgba(255,255,255,0.1); margin: 8px 0; }
.alert { border-radius: var(--radius); padding: 12px 16px; font-size: 13px; font-weight: 500; }
.alert-info { background: var(--primary-light); color: var(--primary); border: 1px solid rgba(0,11,126,0.15); }
.alert-success { background: var(--accent-muted); color: #065f46; border: 1px solid rgba(32,218,46,0.2); }
.alert-warning { background: var(--warning-soft); color: #92400e; border: 1px solid rgba(245,158,11,0.2); }
.customer-detail-tab { padding: 6px 14px; font-size: 12px; font-weight: 600; border-radius: 6px; cursor: pointer; color: var(--text-muted); transition: all 0.15s; }
.customer-detail-tab.active { background: var(--primary); color: white; }
.doc-section { padding: 20px 0; border-bottom: 1px solid var(--border); }
.doc-heading { font-size: 16px; font-weight: 700; color: var(--primary); margin-bottom: 8px; display: flex; align-items: center; gap: 8px; }
.doc-text { font-size: 14px; color: var(--text-muted); line-height: 1.7; }
.doc-list { list-style: none; padding: 0; margin: 8px 0 0; }
.doc-list li { padding: 4px 0; font-size: 13px; color: var(--text-muted); display: flex; align-items: flex-start; gap: 8px; }
.doc-list li::before { content: '→'; color: var(--accent); flex-shrink: 0; margin-top: 1px; }

/* ---- FINANCE TRACKER ---- */
.ft-budget-bar { display: flex; align-items: center; gap: 10px; padding: 12px 0; border-bottom: 1px solid var(--border); }
.ft-budget-bar:last-child { border-bottom: none; }
.ft-budget-label { width: 130px; font-size: 13px; font-weight: 600; flex-shrink: 0; }
.ft-budget-track { flex: 1; }
.ft-budget-amounts { font-size: 12px; color: var(--text-muted); display: flex; justify-content: space-between; margin-bottom: 4px; }
.ft-goal-card { background: linear-gradient(135deg, var(--primary) 0%, #1a2a9c 100%); border-radius: var(--radius-lg); padding: 20px; color: white; position: relative; overflow: hidden; }
.ft-goal-card::before { content: ''; position: absolute; top: -20px; right: -20px; width: 80px; height: 80px; background: rgba(255,255,255,0.05); border-radius: 50%; }
.ft-kpi { background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 16px; }
.ft-kpi-label { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; color: var(--text-muted); }
.ft-kpi-value { font-size: 22px; font-weight: 800; margin-top: 4px; }
.ft-kpi-sub { font-size: 11px; color: var(--text-muted); margin-top: 2px; }
.ft-transaction-row { display: flex; align-items: center; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--border); }
.ft-transaction-row:last-child { border-bottom: none; }
.ft-tx-icon { width: 36px; height: 36px; border-radius: 10px; display: flex; align-items: center; justify-content: center; font-size: 16px; flex-shrink: 0; }
.ft-tx-income { background: var(--accent-muted); }
.ft-tx-expense { background: var(--danger-soft); }

/* ---- MOBILE CARD TABLE (replaces table on phone) ---- */
.mobile-card-list { display: none; }
.m-card { background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 14px 16px; margin-bottom: 10px; }
.m-card-title { font-weight: 700; font-size: 14px; margin-bottom: 4px; }
.m-card-row { display: flex; justify-content: space-between; align-items: center; margin-top: 4px; font-size: 13px; color: var(--text-muted); }
.m-card-actions { display: flex; gap: 8px; margin-top: 10px; flex-wrap: wrap; }

/* ---- PRINT ---- */
@media print {
  body * { visibility: hidden; }
  .printable, .printable * { visibility: visible; }
  .printable { position: absolute; left: 0; top: 0; width: 100%; background: #fff; color: #000; }
}

/* ================================================================
   MOBILE RESPONSIVE (≤ 768px)
   ================================================================ */
@media (max-width: 768px) {
  .mobile-topbar { display: flex !important; }
  .mobile-bottomnav { display: flex !important; }
  .app-shell { grid-template-columns: 1fr !important; }
  .sidebar { display: none !important; }
  .app-main { padding-top: var(--topbar-h) !important; padding-bottom: var(--bottomnav-h) !important; min-height: 100vh; }
  #content { padding: 14px !important; }
  .card { padding: 16px; }
  [style*="grid-template-columns"] { grid-template-columns: 1fr !important; }
  .form-row.cols-2, .form-row.cols-3 { grid-template-columns: 1fr !important; }
  .desktop-table { display: none !important; }
  .mobile-card-list { display: block !important; }
  .table-wrap { overflow-x: auto; }
  .card.table-card { padding: 0; overflow: hidden; }
  .card.table-card table { min-width: 600px; }
  .modal-overlay { padding: 0; align-items: flex-end; }
  .modal, .modal-lg, .modal-xl { max-width: 100%; border-radius: 20px 20px 0 0; max-height: 88vh; padding: 20px; }
  .section-title-row { flex-direction: column; align-items: flex-start !important; gap: 8px; }
  .btn-sm { padding: 8px 12px; font-size: 12px; }
  .action-bar { flex-wrap: wrap; gap: 8px; }
  .stat-grid { grid-template-columns: 1fr 1fr !important; }
  .chart-container { height: 180px !important; }
  .ft-budget-label { width: 100px; }
  .ft-kpi-grid { grid-template-columns: 1fr 1fr !important; }
}

@media (max-width: 480px) {
  .stat-grid { grid-template-columns: 1fr !important; }
  .m-card-actions .btn-sm { flex: 1; justify-content: center; font-size: 11px; padding: 7px 8px; }
}
