/* rekini — shared look for the app shell, tables, forms and auth pages. */

:root {
  --app-sidebar-w: 252px;
  --app-topbar-h: 60px;
  --app-border: #e5e7eb;
  --app-muted: #6b7280;
  --app-subtle: #f8fafc;
  --app-hover: #f1f5f9;
  --app-brand: #2563eb;
  --app-brand-dark: #1d4ed8;
  --app-brand-soft: #eff6ff;

  --bs-body-font-family: "Inter Variable", "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --bs-body-font-size: .9375rem;
  --bs-body-color: #111827;
  --bs-body-color-rgb: 17, 24, 39;
  --bs-secondary-color: #6b7280;
  --bs-border-color: var(--app-border);
  --bs-border-radius: .5rem;
  --bs-border-radius-sm: .375rem;
  --bs-border-radius-lg: .75rem;
  --bs-primary: #2563eb;
  --bs-primary-rgb: 37, 99, 235;
  --bs-link-color: #2563eb;
  --bs-link-color-rgb: 37, 99, 235;
  --bs-link-hover-color: #1d4ed8;
  --bs-link-hover-color-rgb: 29, 78, 216;
  --bs-focus-ring-color: rgba(37, 99, 235, .2);
}

body { -webkit-font-smoothing: antialiased; }

/* ---------- Buttons ---------- */
.btn { font-weight: 500; border-radius: var(--bs-border-radius); }
.btn-primary, .btn-success {
  --bs-btn-bg: var(--app-brand);
  --bs-btn-border-color: var(--app-brand);
  --bs-btn-hover-bg: var(--app-brand-dark);
  --bs-btn-hover-border-color: var(--app-brand-dark);
  --bs-btn-active-bg: var(--app-brand-dark);
  --bs-btn-active-border-color: var(--app-brand-dark);
  --bs-btn-disabled-bg: var(--app-brand);
  --bs-btn-disabled-border-color: var(--app-brand);
  --bs-btn-focus-shadow-rgb: 37, 99, 235;
}
.btn-secondary, .btn-outline-secondary, .btn-light {
  --bs-btn-color: #374151;
  --bs-btn-bg: #fff;
  --bs-btn-border-color: var(--app-border);
  --bs-btn-hover-color: #111827;
  --bs-btn-hover-bg: var(--app-hover);
  --bs-btn-hover-border-color: #d1d5db;
  --bs-btn-active-color: #111827;
  --bs-btn-active-bg: #e5e7eb;
  --bs-btn-active-border-color: #d1d5db;
}
.btn-danger { --bs-btn-bg: #dc2626; --bs-btn-border-color: #dc2626; --bs-btn-hover-bg: #b91c1c; --bs-btn-hover-border-color: #b91c1c; }
.btn-icon {
  display: inline-flex; align-items: center; justify-content: center;
  width: 2.25rem; height: 2.25rem; padding: 0; font-size: 1.25rem;
  border: 1px solid var(--app-border); background: #fff; color: #374151;
}
.btn-icon:hover { background: var(--app-hover); }

/* ---------- Forms ---------- */
.form-control, .form-select { border-color: #d1d5db; }
.form-control:focus, .form-select:focus { border-color: #93c5fd; box-shadow: 0 0 0 .2rem var(--bs-focus-ring-color); }
.form-label, label { font-weight: 500; color: #374151; }
.form-check-input:checked { background-color: var(--app-brand); border-color: var(--app-brand); }
.input-group-text { background: var(--app-subtle); color: var(--app-muted); border-color: #d1d5db; }

/* ---------- Badges ---------- */
.badge { font-weight: 600; padding: .35em .65em; border-radius: 999px; letter-spacing: .01em; }
.badge.bg-success { background-color: #dcfce7 !important; color: #166534; }
.badge.bg-danger { background-color: #fee2e2 !important; color: #991b1b; }
.badge.bg-warning { background-color: #fef3c7 !important; color: #92400e; }
.badge.bg-primary, .badge.bg-info { background-color: #dbeafe !important; color: #1e40af; }
.badge.bg-secondary { background-color: #f1f5f9 !important; color: #475569; }
.badge.bg-dark { background-color: #e5e7eb !important; color: #111827; }

/* ---------- App shell (logged-in pages; html.app is set by inc/head.php) ---------- */
html.app body { padding-left: var(--app-sidebar-w); background: #fff; }

.app-sidebar {
  position: fixed; top: 0; bottom: 0; left: 0; z-index: 1045;
  width: var(--app-sidebar-w);
  display: flex; flex-direction: column;
  background: var(--app-subtle);
  border-right: 1px solid var(--app-border);
  overflow-y: auto;
  transition: transform .2s ease;
}
.app-brand {
  display: flex; align-items: center; gap: .6rem;
  height: var(--app-topbar-h); padding: 0 1.25rem; flex-shrink: 0;
  font-weight: 700; font-size: 1.1rem; color: #111827; text-decoration: none;
}
.app-brand:hover { color: #111827; }
.app-brand-mark {
  display: inline-flex; align-items: center; justify-content: center;
  width: 2rem; height: 2rem; border-radius: .55rem;
  background: var(--app-brand); color: #fff; font-size: 1rem;
}
.app-brand small { font-weight: 500; color: var(--app-muted); }
.app-org {
  margin: .25rem .75rem 1rem; padding: .6rem .75rem;
  background: #fff; border: 1px solid var(--app-border); border-radius: .6rem;
  font-size: .8125rem; font-weight: 600; color: #374151;
  display: flex; align-items: center; gap: .5rem;
}
.app-org i { color: var(--app-muted); }
.app-nav { padding: 0 .75rem 1.5rem; }
.app-nav-heading {
  margin: 1.25rem .75rem .35rem;
  font-size: .6875rem; font-weight: 600; letter-spacing: .06em; text-transform: uppercase;
  color: #9ca3af;
}
.app-nav-link {
  display: flex; align-items: center; gap: .7rem;
  padding: .5rem .75rem; margin-bottom: 2px; border-radius: .5rem;
  color: #374151; font-weight: 500; font-size: .875rem; text-decoration: none;
}
.app-nav-link i { font-size: 1.05rem; color: #9ca3af; width: 1.1rem; text-align: center; }
.app-nav-link:hover { background: var(--app-hover); color: #111827; }
.app-nav-link:hover i { color: #6b7280; }
.app-nav-link.active { background: #fff; color: var(--app-brand); box-shadow: 0 1px 2px rgba(16, 24, 40, .06), 0 0 0 1px var(--app-border); }
.app-nav-link.active i { color: var(--app-brand); }

/* Top bar: pages wrap inc/topnav.php in <nav>. */
html.app body > nav {
  position: sticky; top: 0; z-index: 1030;
  background: rgba(255, 255, 255, .88);
  backdrop-filter: saturate(180%) blur(8px);
  border-bottom: 1px solid var(--app-border);
}
.app-topbar { height: var(--app-topbar-h); display: flex; align-items: center; gap: .75rem; padding: 0 2rem; }
.app-topbar .dropdown-menu { font-size: .875rem; border-color: var(--app-border); box-shadow: 0 10px 30px rgba(16, 24, 40, .12); border-radius: .6rem; padding: .35rem; }
.app-topbar .dropdown-item { border-radius: .4rem; padding: .45rem .7rem; display: flex; align-items: center; gap: .6rem; }
.app-topbar .dropdown-item i { color: var(--app-muted); }
.app-user { display: inline-flex; align-items: center; gap: .55rem; padding: .25rem .5rem .25rem .25rem; border: 1px solid transparent; border-radius: 999px; background: none; color: #111827; font-weight: 500; font-size: .875rem; }
.app-user:hover, .app-user[aria-expanded="true"] { background: var(--app-hover); }
.app-avatar { display: inline-flex; align-items: center; justify-content: center; width: 2rem; height: 2rem; border-radius: 50%; background: var(--app-brand-soft); color: var(--app-brand); font-weight: 700; font-size: .85rem; }

/* Existing page wrapper: main > .container-fluid > .row.flex-nowrap > (.col-auto sidebar, .col content) */
html.app main > .container-fluid { padding: 0; }
html.app main > .container-fluid > .row.flex-nowrap { margin: 0; }
html.app main > .container-fluid > .row.flex-nowrap > .col-auto:first-child { flex: 0 0 0; width: 0; padding: 0; }
html.app main > .container-fluid > .row.flex-nowrap > .col {
  padding: 1.75rem 2rem 4rem !important;
  min-width: 0; max-width: 1680px;
}
html.app a[data-bs-target="#sidebar"] { display: none !important; }

/* Page headings */
html.app main h1, html.app main h2, html.app main h3, html.app main h4 { letter-spacing: -.01em; }
html.app main .page-title { font-size: 1.5rem; font-weight: 700; margin: 0 0 1.25rem; }
html.app main h2:not(.page-title), html.app main h3, html.app main h4:not(.card-title) { font-size: 1.0625rem; font-weight: 600; }
.page-head .page-title { margin: 0; }
.page-head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 1rem; margin-bottom: 1.5rem; }
.page-head h1 { font-size: 1.5rem; font-weight: 700; margin: 0; }
.page-head .page-sub { color: var(--app-muted); font-size: .875rem; margin-top: .25rem; }
.page-head .page-actions { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem; }

/* Toolbar of filters above lists */
.list-toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: .75rem 1.25rem; margin-bottom: 1rem; }
.list-toolbar label { font-size: .8125rem; font-weight: 500; color: var(--app-muted); margin: 0 .4rem 0 0; }
.list-toolbar input[type="text"] { width: 9.5rem; }

/* Year filter component (inc/year_filter.php) */
#yearFilter { min-width: 6.5rem; }

/* Cards */
html.app .card { border-color: var(--app-border); border-radius: .75rem; box-shadow: 0 1px 2px rgba(16, 24, 40, .04); }
html.app .card-header { background: var(--app-subtle); border-bottom-color: var(--app-border); font-weight: 600; }
.stat-card { padding: 1rem 1.25rem; }
.stat-card .stat-label { font-size: .8125rem; color: var(--app-muted); font-weight: 500; }
.stat-card .stat-value { font-size: clamp(1.05rem, 3.6vw, 1.375rem); white-space: nowrap; font-weight: 700; margin-top: .15rem; font-variant-numeric: tabular-nums; }

/* ---------- Tables ---------- */
html.app .table { --bs-table-striped-bg: transparent; --bs-table-hover-bg: #f8fafc; margin-bottom: 0; font-size: .875rem; }
html.app .table > thead > tr > th {
  background: var(--app-subtle);
  color: #6b7280; font-size: .75rem; font-weight: 600; text-transform: uppercase; letter-spacing: .04em;
  border-bottom: 1px solid var(--app-border); white-space: nowrap; padding: .7rem .75rem;
}
html.app .table > thead > tr > th a { color: inherit; text-decoration: none; }
html.app .table > tbody > tr > td { padding: .7rem .75rem; vertical-align: middle; border-bottom-color: #f1f5f9; }
html.app .table > tbody > tr:hover > td { background: #f8fafc; }
html.app .table td a .fas, html.app .table td a .bi { font-size: 1rem; }
.table .num, .table td.num, .table th.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.table .nowrap { white-space: nowrap; }
.table .muted { color: var(--app-muted); }
.table-wrap { border: 1px solid var(--app-border); border-radius: .75rem; overflow: hidden; background: #fff; }
.table-wrap > .table-responsive { margin: 0; }

html.app .table > tbody > tr.table-success > td { --bs-table-bg: #f0fdf4; --bs-table-color: inherit; }
html.app .table > tbody > tr.table-danger > td { --bs-table-bg: #fef2f2; --bs-table-color: inherit; }
html.app .table > tbody > tr.table-warning > td { --bs-table-bg: #fffbeb; --bs-table-color: inherit; }
html.app .table > tbody > tr.table-secondary > td { --bs-table-bg: #f8fafc; --bs-table-color: #6b7280; }
html.app .table > tbody > tr.table-info > td { --bs-table-bg: #eff6ff; --bs-table-color: inherit; }

/* DataTables 1.13 default theme, restyled to match */
html.app .dataTables_wrapper { font-size: .875rem; }
html.app .dataTables_wrapper .dataTables_length,
html.app .dataTables_wrapper .dataTables_filter { margin-bottom: .75rem; color: var(--app-muted); }
html.app .dataTables_wrapper .dataTables_length select,
html.app .dataTables_wrapper .dataTables_filter input {
  border: 1px solid #d1d5db; border-radius: .5rem; padding: .35rem .6rem; background-color: #fff; margin: 0 .35rem;
}
html.app .dataTables_wrapper .dataTables_filter input { width: 16rem; margin-right: 0; }
html.app .dataTables_wrapper .dataTables_filter input:focus { outline: none; border-color: #93c5fd; box-shadow: 0 0 0 .2rem var(--bs-focus-ring-color); }
html.app table.dataTable { border: 1px solid var(--app-border) !important; border-radius: .75rem; border-collapse: separate !important; border-spacing: 0; overflow: hidden; width: 100% !important; }
html.app table.dataTable.no-footer { border-bottom: 1px solid var(--app-border) !important; }
html.app table.dataTable thead th, html.app table.dataTable thead td { border-bottom: 1px solid var(--app-border) !important; }
html.app table.dataTable tbody tr:last-child td { border-bottom: 0; }
html.app .dataTables_wrapper .dataTables_info { color: var(--app-muted); padding-top: 1rem; }
html.app .dataTables_wrapper .dataTables_paginate { padding-top: .75rem; }
html.app .dataTables_wrapper .dataTables_paginate .paginate_button {
  border: 1px solid var(--app-border) !important; border-radius: .5rem !important; background: #fff !important;
  color: #374151 !important; padding: .3rem .75rem !important; margin-left: .25rem;
}
html.app .dataTables_wrapper .dataTables_paginate .paginate_button:hover { background: var(--app-hover) !important; color: #111827 !important; }
html.app .dataTables_wrapper .dataTables_paginate .paginate_button.current,
html.app .dataTables_wrapper .dataTables_paginate .paginate_button.current:hover { background: var(--app-brand) !important; border-color: var(--app-brand) !important; color: #fff !important; }
html.app .dataTables_wrapper .dataTables_paginate .paginate_button.disabled { opacity: .5; }
html.app table.dataTable > thead .sorting:before, html.app table.dataTable > thead .sorting:after,
html.app table.dataTable > thead .sorting_asc:before, html.app table.dataTable > thead .sorting_asc:after,
html.app table.dataTable > thead .sorting_desc:before, html.app table.dataTable > thead .sorting_desc:after { font-size: .7em; }
html.app .dataTables_scroll, html.app .dataTables_wrapper .dt-scroll-x { overflow-x: auto; }
.dt-table-scroll { overflow-x: auto; }

/* DataTables DateTime picker input */
html.app .dtdt-input, html.app input#min, html.app input#max { border: 1px solid #d1d5db; border-radius: .5rem; padding: .35rem .6rem; }

/* ---------- Mobile ---------- */
.sidebar-backdrop { display: none; }
@media (max-width: 991.98px) {
  html.app body { padding-left: 0; }
  .app-sidebar { transform: translateX(-100%); box-shadow: none; }
  html.sidebar-open .app-sidebar { transform: none; box-shadow: 0 20px 50px rgba(16, 24, 40, .25); }
  html.sidebar-open .sidebar-backdrop { display: block; position: fixed; inset: 0; z-index: 1040; background: rgba(15, 23, 42, .35); }
  .app-topbar { padding: 0 1rem; }
  html.app main > .container-fluid > .row.flex-nowrap > .col { padding: 1.25rem 1rem 3rem !important; }
  html.app .dataTables_wrapper .dataTables_filter { text-align: left; }
  html.app .dataTables_wrapper .dataTables_filter input { width: 100%; margin: .35rem 0 0; }
  html.app .dataTables_wrapper { overflow-x: auto; }
}

/* ---------- Auth pages (sign-in, verification, password reset) ---------- */
.auth-body {
  min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 2rem 1rem;
  background: radial-gradient(1200px 600px at 10% -10%, #dbeafe 0%, transparent 60%),
              radial-gradient(900px 500px at 110% 110%, #e0e7ff 0%, transparent 55%), #f8fafc;
}
.auth-card {
  width: 100%; max-width: 400px; background: #fff; border: 1px solid var(--app-border);
  border-radius: 1rem; box-shadow: 0 20px 50px rgba(16, 24, 40, .08); padding: 2rem;
}
.auth-brand { display: flex; align-items: center; gap: .6rem; font-weight: 700; font-size: 1.15rem; margin-bottom: 1.5rem; color: #111827; }
.auth-card h1 { font-size: 1.375rem; font-weight: 700; margin-bottom: .35rem; }
.auth-card .auth-sub { color: var(--app-muted); font-size: .9rem; margin-bottom: 1.5rem; }
.auth-card .form-control { padding: .6rem .8rem; }
.auth-card .btn-lg { font-size: 1rem; padding: .65rem 1rem; }
.auth-password { position: relative; }
.auth-password .toggle-password {
  position: absolute; right: .5rem; top: 50%; transform: translateY(-50%);
  border: 0; background: none; color: var(--app-muted); padding: .25rem .4rem; font-size: 1.1rem;
}
.auth-foot { text-align: center; color: var(--app-muted); font-size: .8125rem; margin-top: 1.5rem; }

/* ---------- Invoice / quotation forms ---------- */
.hidden { display: none; } /* Bootstrap 3 class still used in markup; JS calls .show() */
html.app .content-invoice p { margin-bottom: .3rem; }
html.app .content-invoice h3 { margin-bottom: .75rem; }
html.app #invoiceItem { border-radius: .5rem; overflow: hidden; }
html.app #invoiceItem th {
  background: var(--app-subtle); color: #6b7280; font-size: .75rem; font-weight: 600;
  text-transform: uppercase; letter-spacing: .04em; border-color: var(--app-border);
}
html.app #invoiceItem td { border-color: var(--app-border); }
html.app #clientDetails td:first-child { color: var(--app-muted); width: 35%; }
html.app .invoice-save-btm { padding-left: 1.5rem; padding-right: 1.5rem; }

/* Received invoices: upload area, file preview and fields filled from the file */
.dropzone { border: 2px dashed #cbd5e1; border-radius: .75rem; padding: 2.5rem 1rem; text-align: center; cursor: pointer; color: #374151; background: var(--app-subtle); transition: border-color .15s, background .15s; }
.dropzone i { font-size: 2rem; color: var(--app-brand); display: block; margin-bottom: .4rem; }
.dropzone:hover, .dropzone:focus, .dropzone.dragover { border-color: var(--app-brand); background: #eff6ff; outline: none; }
.doc-preview { min-height: 420px; border: 1px solid var(--app-border); border-radius: .5rem; overflow: hidden; background: #f8fafc; }
.doc-preview iframe { width: 100%; height: 100%; min-height: 640px; border: 0; display: block; }
.doc-preview img { width: 100%; display: block; }
.doc-text { white-space: pre-wrap; font-size: .75rem; max-height: 22rem; overflow: auto; background: var(--app-subtle); padding: .75rem; border-radius: .5rem; margin: 0; }
.doc-preview .doc-text { max-height: none; height: 100%; border-radius: 0; }
.ocr-filled { background-color: #fefce8 !important; border-color: #facc15 !important; }
