/* app.css — small overrides on top of Tailwind CDN.
 * Keep this under ~50 lines. Heavy styling lives in utility classes.
 */

* { font-family: 'Cairo', sans-serif; font-feature-settings: "lnum" 1; }

/* Force Latin (0-9) digits everywhere — dates, numeric inputs, totals */
html, body, input, button, select, textarea { -moz-font-feature-settings: "lnum"; font-variant-numeric: lining-nums; }
input[type="date"], input[type="number"], input[type="time"], input[type="datetime-local"] {
  font-feature-settings: "lnum" 1;
}

body { background-color: #f8fafc; }

/* Hide native number-input spinner arrows. The accidental click that turned
 * 100 into 99.99 was making people lose money to typos. Apply globally. */
input[type=number]::-webkit-outer-spin-button,
input[type=number]::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}
input[type=number] {
  -moz-appearance: textfield;
  appearance: textfield;
}

/* Sidebar link hover/active states (Tailwind can't target `.active` dynamically) */
.sidebar-link { transition: all 0.15s; }
.sidebar-link:hover { background-color: rgba(255, 255, 255, 0.08); }
.sidebar-link.active {
  background-color: rgba(99, 102, 241, 0.25);
  border-right: 3px solid #a5b4fc;
}

/* Stat card hover lift */
.stat-card { transition: transform 0.2s, box-shadow 0.2s; }
.stat-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.1);
}

/* Login gradient */
.gradient-bg {
  background: linear-gradient(135deg, #1e3a8a 0%, #4338ca 50%, #6d28d9 100%);
}
.card-shadow { box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25); }

/* Thin rounded scrollbar (Webkit) */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: #94a3b8; }

/* Collapsible sidebar — keeps icons, hides labels, widens main area. */
.app-sidebar, .app-main { transition: width 0.2s ease, margin-right 0.2s ease; }
html.sidebar-collapsed .app-sidebar { width: 4rem; }
html.sidebar-collapsed .app-main { margin-right: 4rem; }
html.sidebar-collapsed .sidebar-label { display: none; }
html.sidebar-collapsed .sidebar-link { justify-content: center; padding-left: 0; padding-right: 0; gap: 0; }
html.sidebar-collapsed .app-sidebar > div:first-child { padding: 1rem 0; justify-content: center; }
html.sidebar-collapsed .app-sidebar > div:first-child a { justify-content: center; }
html.sidebar-collapsed .app-sidebar > div:last-child { padding: 0.75rem 0; justify-content: center; }
html.sidebar-collapsed .sidebar-toggle-icon { transform: scaleX(-1); }

/* Mobile: auto-collapse sidebar to icon-only and tighten main padding.
 * Triggered purely by viewport — does NOT touch the localStorage flag, so the
 * desktop user's manual collapse preference is preserved when they go back. */
@media (max-width: 767px) {
  .app-sidebar { width: 4rem; }
  .app-main { margin-right: 4rem !important; padding: 0.75rem !important; }
  .sidebar-label { display: none; }
  .sidebar-link { justify-content: center; padding-left: 0; padding-right: 0; gap: 0; }
  .app-sidebar > div:first-child { padding: 1rem 0; justify-content: center; }
  .app-sidebar > div:first-child a { justify-content: center; }
  .app-sidebar > div:last-child { padding: 0.75rem 0; justify-content: center; }
  #sidebar-toggle { display: none; }
  /* Tables that overflow get a horizontal scrollbar instead of breaking layout */
  table { font-size: 0.8125rem; }
}

/* DataTables 2.x overrides — match Tailwind palette + rounded-xl card shell.
 * DT 2.x uses .dt-container / .dt-input / .dt-length / .dt-search / .dt-info
 * / .dt-paging  (NOT the legacy .dataTables_xxx selectors from DT 1.x). */
.dt-container { padding: 0.75rem 1rem 0.5rem; font-size: 0.875rem; }
.dt-container .dt-search { margin-bottom: 0.5rem; }
.dt-container .dt-length { margin-bottom: 0.5rem; }
.dt-container .dt-input,
.dt-container .dt-search input,
.dt-container .dt-length select {
  border: 1px solid #e2e8f0; border-radius: 0.5rem;
  padding: 0.375rem 0.625rem; font-size: 0.8125rem; margin: 0 0.375rem;
  background-color: #fff; outline: none;
}
.dt-container .dt-input:focus,
.dt-container .dt-search input:focus,
.dt-container .dt-length select:focus {
  border-color: #6366f1; box-shadow: 0 0 0 3px rgba(99,102,241,0.15);
}
.dt-container .dt-info { padding-top: 0.75rem; color: #64748b; font-size: 0.75rem; }
.dt-container .dt-paging { padding-top: 0.5rem; }
.dt-container .dt-paging button.dt-paging-button {
  padding: 0.25rem 0.625rem; margin: 0 0.125rem; border-radius: 0.375rem;
  border: 1px solid #e2e8f0; background: #fff; color: #475569 !important;
  cursor: pointer; font-size: 0.8125rem;
}
.dt-container .dt-paging button.dt-paging-button.current,
.dt-container .dt-paging button.dt-paging-button.current:hover {
  background: #4f46e5 !important; color: #fff !important; border-color: #4f46e5 !important;
}
.dt-container .dt-paging button.dt-paging-button:hover:not(.disabled) {
  background: #f1f5f9; color: #1e293b !important;
}
.dt-container .dt-paging button.dt-paging-button.disabled {
  opacity: 0.4; cursor: not-allowed;
}
table.dataTable thead th {
  border-bottom: 1px solid #e2e8f0 !important; background: #f8fafc;
  font-weight: 600; color: #475569; font-size: 0.75rem;
  text-align: right; padding: 0.625rem 1rem !important;
}
table.dataTable tbody td { padding: 0.625rem 1rem !important; vertical-align: middle; }
table.dataTable tbody tr:hover { background-color: #f8fafc !important; }
table.dataTable.no-footer { border-bottom: none !important; }
/* Sort icons are subtle by default; click still works */
table.dataTable thead th.dt-orderable-asc::before,
table.dataTable thead th.dt-orderable-desc::after { opacity: 0.35; }

/* Action dropdown menus — hide native details marker, add subtle glow on "+" */
details.action-menu > summary { list-style: none; }
details.action-menu > summary::-webkit-details-marker { display: none; }
details.action-menu > summary::marker { display: none; content: ""; }
details.action-menu[open] > summary > span {
  transform: rotate(45deg);
  background-color: #4f46e5;
  box-shadow: 0 0 0 4px rgba(99, 102, 241, 0.2);
}
details.action-menu > summary > span { transition: transform 0.15s ease, box-shadow 0.15s ease, background-color 0.15s ease; }
/* Close-on-click-outside is handled by a tiny global handler in app.js */
