/* ============================================================
   SMG-Accounce — app.css
   Clean Light SaaS design system (Linear / Vercel / Notion)
   ============================================================ */

/* CSS Custom Properties
   ------------------------------------------------------------ */
:root {
  --bg:            #f8fafc;
  --surface:       #ffffff;
  --border:        #e2e8f0;
  --text:          #0f172a;
  --text-2:        #64748b;
  --text-3:        #94a3b8;
  --primary:       #6366f1;
  --primary-hover: #4f46e5;
  --primary-light: #eef2ff;
  --success:       #10b981;
  --danger:        #ef4444;
  --warning:       #f59e0b;
  --info:          #0ea5e9;
  --radius:        10px;
  --shadow:        0 1px 3px rgba(0,0,0,.06), 0 1px 2px -1px rgba(0,0,0,.06);
  --shadow-md:     0 4px 6px -1px rgba(0,0,0,.07), 0 2px 4px -2px rgba(0,0,0,.07);
}

/* Reset & Base
   ------------------------------------------------------------ */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

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

a {
  color: var(--primary);
  text-decoration: none;
}

a:hover {
  color: var(--primary-hover);
}

/* ============================================================
   LAYOUT
   ============================================================ */

.app-sidebar {
  position: fixed;
  top: 0;
  left: 0;
  width: 240px;
  height: 100vh;
  background: var(--surface);
  border-right: 1px solid var(--border);
  z-index: 200;
  transition: width .2s ease, transform .2s ease;
  overflow: hidden;
}

.app-navbar {
  position: fixed;
  top: 0;
  left: 240px;
  right: 0;
  height: 60px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  z-index: 100;
  display: flex;
  align-items: center;
  padding: 0 24px;
  transition: left .2s ease;
}

.app-content {
  margin-left: 240px;
  padding-top: 60px;
  min-height: 100vh;
  background: var(--bg);
  transition: margin-left .2s ease;
}

.content-wrapper {
  padding: 24px;
  max-width: none;
}

/* ============================================================
   SIDEBAR
   ============================================================ */

.sidebar-brand {
  height: 60px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 16px;
  flex-shrink: 0;
  white-space: nowrap;
  overflow: hidden;
}

.sidebar-brand-text {
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
}

.sidebar-nav {
  overflow-y: auto;
  height: calc(100vh - 60px);
  padding: 8px 0;
}

/* Thin scrollbar */
.sidebar-nav::-webkit-scrollbar { width: 4px; }
.sidebar-nav::-webkit-scrollbar-track { background: transparent; }
.sidebar-nav::-webkit-scrollbar-thumb { background: var(--border); border-radius: 99px; }

.sidebar-section-label {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-3);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  padding: 16px 16px 6px;
  white-space: nowrap;
  overflow: hidden;
}

.sidebar-item {
  display: flex;
  align-items: center;
  height: 36px;
  padding: 0 12px;
  border-radius: 8px;
  color: var(--text-2);
  gap: 10px;
  cursor: pointer;
  margin: 1px 8px;
  font-size: 13.5px;
  transition: background .12s, color .12s;
  white-space: nowrap;
  overflow: hidden;
  text-decoration: none;
}

.sidebar-item:hover {
  background: #f8fafc;
  color: var(--text);
  text-decoration: none;
}

.sidebar-item.active {
  background: var(--primary-light);
  color: var(--primary);
  font-weight: 500;
  text-decoration: none;
}

.sidebar-item .icon,
.sidebar-item > i:first-child {
  font-size: 18px;
  flex-shrink: 0;
  opacity: 0.7;
  width: 18px;
  text-align: center;
}

.sidebar-item.active .icon,
.sidebar-item.active > i:first-child {
  opacity: 1;
}

/* Submenu */
.sidebar-sub {
  padding-left: 16px;
  display: none;
}

.sidebar-sub.open {
  display: block;
}

.sidebar-sub .sidebar-item {
  font-size: 13px;
  height: 33px;
  color: var(--text-3);
  margin: 0 8px;
}

.sidebar-sub .sidebar-item:hover {
  color: var(--text);
}

.sidebar-sub .sidebar-item.active {
  color: var(--primary);
  background: var(--primary-light);
}

/* Toggle chevron */
.sidebar-toggle-icon {
  font-size: 16px;
  transition: transform .2s ease;
  opacity: 0.5;
  flex-shrink: 0;
}

/* ============================================================
   NAVBAR
   ============================================================ */

.navbar-brand-title {
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
}

.navbar-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.nav-btn {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: white;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: var(--text-2);
  transition: background .12s;
  padding: 0;
  text-decoration: none;
}

.nav-btn:hover {
  background: var(--border);
  color: var(--text);
}

/* ============================================================
   CARDS
   ============================================================ */

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.card-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  font-weight: 600;
  font-size: 14px;
  color: var(--text);
  background: transparent;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.card-body {
  padding: 20px;
}

.card-footer {
  padding: 14px 20px;
  border-top: 1px solid var(--border);
  background: transparent;
}

/* ============================================================
   TABLES (DataTables)
   ============================================================ */

table.dataTable thead th {
  background: var(--bg);
  color: var(--text-2);
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  border-bottom: 1px solid var(--border);
  padding: 10px 12px;
}

table.dataTable tbody td {
  padding: 12px;
  border-bottom: 1px solid var(--border);
  color: var(--text);
  vertical-align: middle;
}

table.dataTable tbody tr:last-child td {
  border-bottom: none;
}

table.dataTable tbody tr:hover td {
  background: #f8fafc;
}

div.dataTables_wrapper .dataTables_filter input {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 6px 12px;
  font-size: 13px;
  outline: none;
  font-family: 'Inter', sans-serif;
}

div.dataTables_wrapper .dataTables_filter input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-light);
}

div.dataTables_wrapper .dataTables_paginate .paginate_button.current,
div.dataTables_wrapper .dataTables_paginate .paginate_button.current:hover {
  background: var(--primary) !important;
  color: white !important;
  border-radius: 6px;
  border: none !important;
}

div.dataTables_wrapper .dataTables_paginate .paginate_button:hover {
  background: var(--primary-light) !important;
  color: var(--primary) !important;
  border: none !important;
  border-radius: 6px;
}

div.dataTables_wrapper .dataTables_info,
div.dataTables_wrapper .dataTables_length {
  color: var(--text-2);
  font-size: 13px;
}

div.dataTables_wrapper .dataTables_length select {
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 4px 8px;
  font-size: 13px;
  font-family: 'Inter', sans-serif;
}

/* Bootstrap5 DataTables override */
table.dataTable.table-striped > tbody > tr.odd > * {
  background-color: #fafafa;
  box-shadow: none;
}

/* ============================================================
   BUTTONS
   ============================================================ */

.btn-primary {
  background: var(--primary);
  border-color: var(--primary);
  color: white;
  border-radius: 8px;
  font-weight: 500;
  font-size: 13px;
  padding: 7px 14px;
  transition: background .15s, border-color .15s;
  font-family: 'Inter', sans-serif;
}

.btn-primary:hover,
.btn-primary:focus,
.btn-primary:active,
.btn-primary.active {
  background: var(--primary-hover) !important;
  border-color: var(--primary-hover) !important;
  color: white !important;
}

.btn-secondary {
  background: white;
  border-color: var(--border);
  color: var(--text);
  border-radius: 8px;
  font-weight: 500;
  font-size: 13px;
  padding: 7px 14px;
  font-family: 'Inter', sans-serif;
}

.btn-secondary:hover {
  background: var(--bg);
  border-color: var(--border);
  color: var(--text);
}

.btn-sm {
  padding: 4px 10px;
  font-size: 12px;
}

.btn-danger {
  background: var(--danger);
  border-color: var(--danger);
  border-radius: 8px;
  font-weight: 500;
  font-family: 'Inter', sans-serif;
}

.btn-danger:hover {
  background: #dc2626;
  border-color: #dc2626;
}

.btn-warning {
  background: var(--warning);
  border-color: var(--warning);
  border-radius: 8px;
  font-weight: 500;
  font-family: 'Inter', sans-serif;
}

.btn-warning:hover {
  background: #d97706;
  border-color: #d97706;
}

.btn-success {
  background: var(--success);
  border-color: var(--success);
  border-radius: 8px;
  font-weight: 500;
  font-family: 'Inter', sans-serif;
}

.btn-success:hover {
  background: #059669;
  border-color: #059669;
}

.btn-info {
  background: var(--info);
  border-color: var(--info);
  border-radius: 8px;
  font-weight: 500;
  color: white;
  font-family: 'Inter', sans-serif;
}

.btn-info:hover {
  background: #0284c7;
  border-color: #0284c7;
  color: white;
}

/* Icon-only action buttons in table rows */
.btn-action {
  width: 30px;
  height: 30px;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 6px;
  font-size: 13px;
}

/* ============================================================
   BADGES
   ============================================================ */

.badge {
  border-radius: 6px;
  font-size: 11px;
  font-weight: 500;
  padding: 3px 8px;
}

.badge-success, .bg-success {
  background: #dcfce7 !important;
  color: #15803d !important;
  border: none !important;
}

.badge-danger, .bg-danger {
  background: #fee2e2 !important;
  color: #dc2626 !important;
  border: none !important;
}

.badge-warning, .bg-warning {
  background: #fef3c7 !important;
  color: #d97706 !important;
  border: none !important;
}

.badge-info, .bg-info {
  background: #e0f2fe !important;
  color: #0369a1 !important;
  border: none !important;
}

.badge-primary, .bg-primary {
  background: var(--primary-light) !important;
  color: var(--primary) !important;
  border: none !important;
}

.badge-secondary, .bg-secondary {
  background: #f1f5f9 !important;
  color: var(--text-2) !important;
  border: none !important;
}

/* ============================================================
   PAGE HEADER
   ============================================================ */

.page-header {
  margin-bottom: 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
}

.page-title {
  font-size: 18px;
  font-weight: 600;
  color: var(--text);
  margin: 0;
}

/* ============================================================
   FORMS & INPUTS
   ============================================================ */

.form-control,
.form-select {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 12px;
  font-size: 14px;
  color: var(--text);
  background: white;
  transition: border-color .15s, box-shadow .15s;
  font-family: 'Inter', sans-serif;
}

.form-control:focus,
.form-select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-light);
  outline: none;
}

.form-label {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-2);
  margin-bottom: 6px;
}

.form-text {
  font-size: 12px;
  color: var(--text-3);
}

.input-group-text {
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text-2);
  font-size: 14px;
}

/* ============================================================
   MODALS
   ============================================================ */

.modal-content {
  border: none;
  border-radius: 16px;
  box-shadow: 0 20px 60px rgba(0,0,0,.15);
}

.modal-header {
  border-bottom: 1px solid var(--border);
  padding: 18px 24px;
}

.modal-title {
  font-size: 16px;
  font-weight: 600;
  color: var(--text);
}

.modal-body {
  padding: 20px 24px;
}

.modal-footer {
  border-top: 1px solid var(--border);
  padding: 14px 24px;
}

.btn-close {
  opacity: 0.4;
}

.btn-close:hover {
  opacity: 0.8;
}

/* ============================================================
   KPI CARDS
   ============================================================ */

.kpi-card {
  background: white;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  box-shadow: var(--shadow);
  transition: box-shadow .2s;
}

.kpi-card:hover {
  box-shadow: var(--shadow-md);
}

.kpi-card .kpi-label {
  font-size: 12px;
  font-weight: 500;
  color: var(--text-2);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.kpi-card .kpi-value {
  font-size: 28px;
  font-weight: 700;
  color: var(--text);
  line-height: 1;
}

.kpi-card .kpi-icon {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
}

.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

/* ============================================================
   FOOTER
   ============================================================ */

.footer {
  padding: 16px 24px;
  border-top: 1px solid var(--border);
  background: white;
  color: var(--text-2);
  font-size: 13px;
}

/* ============================================================
   ALERTS
   ============================================================ */

.alert {
  border-radius: var(--radius);
  border: none;
  font-size: 13px;
  padding: 12px 16px;
}

.alert-success {
  background: #dcfce7;
  color: #15803d;
}

.alert-danger {
  background: #fee2e2;
  color: #dc2626;
}

.alert-warning {
  background: #fef3c7;
  color: #d97706;
}

.alert-info {
  background: #e0f2fe;
  color: #0369a1;
}

/* ============================================================
   MISC UTILITIES
   ============================================================ */

/* Remove Bootstrap's default box shadow on cards */
.shadow,
.shadow-sm {
  box-shadow: var(--shadow) !important;
}

/* Clean progress bars */
.progress {
  height: 6px;
  border-radius: 99px;
  background: var(--border);
}

.progress-bar {
  border-radius: 99px;
  background: var(--primary);
}

/* Nav tabs clean style */
.nav-tabs {
  border-bottom: 1px solid var(--border);
}

.nav-tabs .nav-link {
  color: var(--text-2);
  font-size: 13px;
  font-weight: 500;
  border: none;
  border-bottom: 2px solid transparent;
  border-radius: 0;
  padding: 8px 14px;
  transition: color .12s, border-color .12s;
}

.nav-tabs .nav-link:hover {
  color: var(--text);
  border-color: transparent;
}

.nav-tabs .nav-link.active {
  color: var(--primary);
  border-bottom-color: var(--primary);
  background: transparent;
}

/* Accordion clean style */
.accordion-button {
  font-weight: 600;
  font-size: 14px;
  color: var(--text);
  background: var(--surface);
  box-shadow: none;
}

.accordion-button:not(.collapsed) {
  color: var(--primary);
  background: var(--primary-light);
  box-shadow: none;
}

.accordion-button:focus {
  box-shadow: none;
  border-color: var(--border);
}

.accordion-item {
  border: 1px solid var(--border);
  border-radius: var(--radius) !important;
  margin-bottom: 8px;
  overflow: hidden;
}

.accordion-item:first-of-type .accordion-button,
.accordion-item:last-of-type .accordion-button.collapsed {
  border-radius: var(--radius);
}

/* Dropdown clean style */
.dropdown-menu {
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: var(--shadow-md);
  font-size: 13px;
  padding: 6px;
}

.dropdown-item {
  border-radius: 6px;
  padding: 7px 12px;
  color: var(--text);
  font-size: 13px;
}

.dropdown-item:hover {
  background: var(--bg);
  color: var(--text);
}

.dropdown-divider {
  border-color: var(--border);
  margin: 4px 0;
}

/* ============================================================
   SELECT2 OVERRIDES
   ============================================================ */

.select2-container--default .select2-selection--single {
  border: 1px solid var(--border);
  border-radius: 8px;
  height: 38px;
  display: flex;
  align-items: center;
}

.select2-container--default .select2-selection--single .select2-selection__rendered {
  line-height: normal;
  padding: 0 12px;
  color: var(--text);
  font-size: 14px;
}

.select2-container--default .select2-selection--single .select2-selection__arrow {
  height: 36px;
}

.select2-container--default .select2-selection--single:focus,
.select2-container--default.select2-container--open .select2-selection--single {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-light);
  outline: none;
}

.select2-dropdown {
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: var(--shadow-md);
  font-family: 'Inter', sans-serif;
  font-size: 14px;
}

.select2-container--default .select2-search--dropdown .select2-search__field {
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 6px 10px;
  font-family: 'Inter', sans-serif;
}

.select2-container--default .select2-results__option--highlighted[aria-selected] {
  background: var(--primary-light);
  color: var(--primary);
}

.select2-results__option {
  padding: 8px 12px;
  font-size: 13px;
}

/* ============================================================
   TOAST OVERRIDES
   ============================================================ */

.jq-toast-wrap {
  font-family: 'Inter', sans-serif !important;
}

.jq-toast-single {
  border-radius: var(--radius) !important;
  font-size: 13px !important;
  font-family: 'Inter', sans-serif !important;
}

/* ============================================================
   DASHBOARD SPECIFICS
   ============================================================ */

.charts-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(400px, 1fr));
  gap: 20px;
  margin-bottom: 24px;
}

.chart-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow);
}

.chart-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 16px;
}

.chart-container {
  position: relative;
  height: 300px;
}

/* Status badges (dashboard tables) */
.status-badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 6px;
  font-size: 11px;
  font-weight: 600;
}

.status-completed    { background: #dcfce7; color: #15803d; }
.status-in-progress  { background: #fef3c7; color: #d97706; }
.status-pending      { background: #fee2e2; color: #dc2626; }
.status-on-hold      { background: #f1f5f9; color: var(--text-2); }

.amount {
  font-weight: 600;
  color: var(--success);
}

/* ============================================================
   SIDEBAR COLLAPSED STATE
   ============================================================ */

/* Desktop collapse (toggle button) */
.app-sidebar.collapsed {
  width: 60px;
}

.app-sidebar.collapsed .sidebar-brand-text,
.app-sidebar.collapsed .sidebar-section-label,
.app-sidebar.collapsed .sidebar-item > span,
.app-sidebar.collapsed .sidebar-toggle-icon {
  display: none;
}

.app-sidebar.collapsed .sidebar-item {
  justify-content: center;
  padding: 0;
  width: 44px;
  margin: 1px auto;
}

.app-sidebar.collapsed .sidebar-sub {
  display: none !important;
}

.app-content.expanded,
.app-navbar.expanded {
  margin-left: 60px;
  left: 60px;
}

/* Mobile: sidebar slides in from left */
@media (max-width: 768px) {
  .app-sidebar {
    transform: translateX(-240px);
    transition: transform .2s ease;
  }

  .app-navbar {
    left: 0;
    transition: none;
  }

  .app-content {
    margin-left: 0;
    transition: none;
  }

  .app-sidebar.mobile-open {
    transform: translateX(0);
  }

  .sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.35);
    z-index: 199;
  }

  .sidebar-overlay.active {
    display: block;
  }

  .sidebar-close-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    cursor: pointer;
  }

  .app-content.expanded,
  .app-navbar.expanded {
    margin-left: 0;
    left: 0;
  }

  .charts-grid {
    grid-template-columns: 1fr;
  }

  .kpi-grid {
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  }
}

/* ============================================================
   TABLE — generic (non-DataTables)
   ============================================================ */

.table {
  font-size: 13px;
  color: var(--text);
}

.table th {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-2);
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  padding: 10px 12px;
  vertical-align: middle;
}

.table td {
  padding: 11px 12px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}

.table tbody tr:last-child td {
  border-bottom: none;
}

.table-hover tbody tr:hover td {
  background: #f8fafc;
}

.table-striped > tbody > tr:nth-of-type(odd) > * {
  background-color: #fafafa;
  color: var(--text);
  --bs-table-accent-bg: #fafafa;
}

.table-bordered th,
.table-bordered td {
  border: 1px solid var(--border);
}

/* Overwrite gradient table headers from dashboard */
table th {
  background: var(--bg) !important;
  color: var(--text-2) !important;
}

/* ============================================================
   LEGACY OVERRIDES — remove old backdesk theme artifacts
   ============================================================ */

/* Ensure no old sidebar/navbar bleed through */
.sidebar { display: none !important; }
.navbar.default-layout-navbar { display: none !important; }

/* Legacy layout class compatibility — views that still use old backdesk wrappers */
.container-scroller {
  min-height: 100vh;
  background: var(--bg);
}
.container-fluid.page-body-wrapper,
.page-body-wrapper {
  margin-left: 240px !important;
  padding-top: 60px !important;
  min-height: 100vh;
  width: auto !important;
  max-width: none !important;
  padding-left: 0 !important;
  padding-right: 0 !important;
  display: block !important;
}
.main-panel {
  width: 100% !important;
  min-height: 100vh;
  display: block !important;
  float: none !important;
}
.content-wrapper {
  padding: 24px !important;
  background: var(--bg) !important;
  min-height: calc(100vh - 60px);
  display: block !important;
}

/* Collapsed sidebar — legacy layouts */
body.sidebar-collapsed .container-fluid.page-body-wrapper,
body.sidebar-collapsed .page-body-wrapper {
  margin-left: 60px !important;
}

/* Mobile — legacy layouts */
@media (max-width: 991px) {
  .container-fluid.page-body-wrapper,
  .page-body-wrapper {
    margin-left: 0 !important;
  }
}
