/* ================================================
   Ali Book Centre — ABC Inventory System
   Design: Deep Blue #1a3c5e + Orange #f57c00
   ================================================ */

:root {
  --abc-blue:        #1a3c5e;
  --abc-blue-dark:   #122c46;
  --abc-blue-light:  #2a5a8a;
  --abc-orange:      #f57c00;
  --abc-orange-dark: #e65100;
  --abc-orange-light:#ff9800;
  --sidebar-width:   240px;
  --sidebar-collapsed: 64px;
  --navbar-height:   58px;
  --text-muted-custom: #6c757d;
}

* { box-sizing: border-box; }

body {
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
  background: #f0f4f8;
  color: #2d3748;
  padding-top: var(--navbar-height);
}

/* ---- Scrollbar ---- */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: #f1f1f1; }
::-webkit-scrollbar-thumb { background: #c1c1c1; border-radius: 3px; }

/* ================================================
   NAVBAR
   ================================================ */
.abc-navbar {
  background: linear-gradient(135deg, var(--abc-blue-dark) 0%, var(--abc-blue) 100%);
  height: var(--navbar-height);
  border-bottom: 3px solid var(--abc-orange);
  z-index: 1050;
  box-shadow: 0 2px 12px rgba(0,0,0,.25);
}

.brand-icon {
  width: 36px; height: 36px;
  background: var(--abc-orange);
  border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.2rem; color: #fff;
  flex-shrink: 0;
}

.brand-name  { font-weight: 700; font-size: .95rem; line-height: 1.1; }
.brand-sub   { font-size: .68rem; opacity: .65; line-height: 1; }

.user-avatar {
  width: 32px; height: 32px;
  background: var(--abc-orange);
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: .85rem; color: #fff;
  flex-shrink: 0;
}

/* ================================================
   SIDEBAR
   ================================================ */
.sidebar {
  width: var(--sidebar-width);
  min-height: calc(100vh - var(--navbar-height));
  background: linear-gradient(180deg, var(--abc-blue) 0%, var(--abc-blue-dark) 100%);
  position: fixed;
  top: var(--navbar-height);
  left: 0;
  display: flex;
  flex-direction: column;
  transition: width .25s ease;
  z-index: 1040;
  overflow: hidden;
  box-shadow: 2px 0 12px rgba(0,0,0,.15);
}

.sidebar.collapsed { width: var(--sidebar-collapsed); }

.sidebar-nav  { padding: .5rem 0; overflow-y: auto; overflow-x: hidden; height: calc(100vh - var(--navbar-height)); }

/* Section labels */
.sidebar-section {
  padding: 1rem 1.1rem .3rem;
  font-size: .68rem;
  font-weight: 700;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: rgba(255,255,255,.35);
  pointer-events: none;
  white-space: nowrap;
  overflow: hidden;
}

.sidebar.collapsed .sidebar-section {
  height: 1px;
  padding: 0;
  margin: .5rem .75rem;
  background: rgba(255,255,255,.12);
  overflow: hidden;
}

.sidebar-link {
  display: flex;
  align-items: center;
  gap: .85rem;
  padding: .6rem 1.1rem;
  color: rgba(255,255,255,.75);
  text-decoration: none;
  font-size: .875rem;
  border-left: 3px solid transparent;
  transition: background .15s, color .15s, border-color .15s;
  white-space: nowrap;
}

.sidebar-link:hover {
  background: rgba(255,255,255,.08);
  color: #fff;
  border-left-color: var(--abc-orange-light);
}

.sidebar-link.active {
  background: rgba(245,124,0,.18);
  color: #fff;
  border-left-color: var(--abc-orange);
  font-weight: 600;
}

.sidebar-link-danger { color: rgba(255,100,100,.8); }
.sidebar-link-danger:hover { color: #ff6464; background: rgba(220,53,69,.12); border-left-color: #dc3545; }

.sidebar-icon  { font-size: 1.05rem; flex-shrink: 0; width: 20px; text-align: center; }
.sidebar-label { flex: 1; }

/* ---- Collapsed state ---- */
.sidebar.collapsed .sidebar-label { display: none; }
.sidebar.collapsed .sidebar-link  { justify-content: center; padding: .7rem; border-left-color: transparent !important; }

/* ================================================
   MAIN CONTENT
   ================================================ */
.wrapper { margin-top: 0; }

.main-content {
  margin-left: var(--sidebar-width);
  min-height: calc(100vh - var(--navbar-height));
  transition: margin-left .25s ease;
  padding: 0;
}

.main-content.expanded { margin-left: var(--sidebar-collapsed); }

/* ================================================
   PAGE HEADER
   ================================================ */
.page-header {
  background: #fff;
  border-radius: 12px;
  padding: 1rem 1.5rem;
  box-shadow: 0 1px 6px rgba(0,0,0,.07);
  border-left: 4px solid var(--abc-orange);
}

.page-title {
  font-weight: 700;
  color: var(--abc-blue);
  font-size: 1.2rem;
}

.breadcrumb-item a { color: var(--abc-blue-light); text-decoration: none; }
.breadcrumb-item a:hover { color: var(--abc-orange); }

/* ================================================
   STAT CARDS (Dashboard)
   ================================================ */
.stat-card {
  border: none;
  border-radius: 14px;
  box-shadow: 0 2px 12px rgba(0,0,0,.08);
  overflow: hidden;
  transition: transform .2s, box-shadow .2s;
}
.stat-card:hover { transform: translateY(-3px); box-shadow: 0 6px 20px rgba(0,0,0,.13); }

.stat-card .card-body { padding: 1.4rem; }

.stat-icon {
  width: 52px; height: 52px;
  border-radius: 12px;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.5rem;
}

.stat-value { font-size: 1.8rem; font-weight: 700; line-height: 1; }
.stat-label { font-size: .8rem; text-transform: uppercase; letter-spacing: .05em; opacity: .7; }

.bg-blue-soft  { background: rgba(26,60,94,.1); color: var(--abc-blue); }
.bg-orange-soft{ background: rgba(245,124,0,.12); color: var(--abc-orange-dark); }
.bg-green-soft { background: rgba(40,167,69,.12); color: #155724; }
.bg-red-soft   { background: rgba(220,53,69,.12); color: #721c24; }
.bg-purple-soft{ background: rgba(108,99,255,.12); color: #4a3f9e; }
.bg-teal-soft  { background: rgba(32,201,151,.12); color: #0d6e53; }

/* ================================================
   CARDS
   ================================================ */
.card {
  border: none;
  border-radius: 12px;
  box-shadow: 0 1px 8px rgba(0,0,0,.07);
  overflow: hidden;
}

.card-header-custom {
  background: var(--abc-blue);
  color: #fff;
  border-radius: 12px 12px 0 0 !important;
  padding: .85rem 1.25rem;
  font-weight: 600;
  font-size: .95rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

/* ================================================
   TABLES
   ================================================ */
.table-abc thead th {
  background: var(--abc-blue);
  color: #fff;
  font-weight: 500;
  font-size: .82rem;
  text-transform: uppercase;
  letter-spacing: .04em;
  border: none;
  padding: .75rem 1rem;
}

.table-abc tbody tr { transition: background .15s; }
.table-abc tbody tr:hover { background: rgba(26,60,94,.04); }
.table-abc tbody td { vertical-align: middle; padding: .7rem 1rem; font-size: .88rem; }

/* ================================================
   BADGES & STATUS
   ================================================ */
.badge-status {
  font-size: .75rem;
  padding: .35em .65em;
  border-radius: 20px;
  font-weight: 500;
}

.status-paid     { background: #d1fae5; color: #065f46; }
.status-partial  { background: #fef3c7; color: #92400e; }
.status-pending  { background: #dbeafe; color: #1e40af; }
.status-overdue  { background: #fee2e2; color: #991b1b; }
.status-draft    { background: #f3f4f6; color: #374151; }
.status-sent     { background: #e0e7ff; color: #3730a3; }
.status-cancelled{ background: #f3f4f6; color: #6b7280; }
.status-confirmed{ background: #d1fae5; color: #065f46; }

.stock-ok      { color: #15803d; font-weight: 600; }
.stock-low     { color: #c05621; font-weight: 600; }
.stock-critical{ color: #dc2626; font-weight: 700; }

/* ================================================
   FORMS
   ================================================ */
.form-control:focus,
.form-select:focus {
  border-color: var(--abc-blue-light);
  box-shadow: 0 0 0 .2rem rgba(26,60,94,.15);
}

.form-label { font-weight: 500; font-size: .88rem; color: #374151; }

/* ================================================
   BUTTONS
   ================================================ */
.btn-abc-primary {
  background: var(--abc-blue);
  color: #fff;
  border: none;
}
.btn-abc-primary:hover { background: var(--abc-blue-dark); color: #fff; }

.btn-abc-orange {
  background: var(--abc-orange);
  color: #fff;
  border: none;
}
.btn-abc-orange:hover { background: var(--abc-orange-dark); color: #fff; }

.btn-action {
  padding: .25rem .5rem;
  font-size: .78rem;
  border-radius: 6px;
}

/* ================================================
   LOGIN PAGE
   ================================================ */
.login-body {
  background: linear-gradient(135deg, var(--abc-blue-dark) 0%, var(--abc-blue) 50%, var(--abc-blue-light) 100%);
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  padding-top: 0;
}

.login-wrapper { width: 100%; max-width: 420px; }

.login-card { border-radius: 16px; overflow: hidden; }

.login-header {
  background: linear-gradient(135deg, var(--abc-blue-dark), var(--abc-blue));
  color: #fff;
  padding: 2rem 1.5rem 1.5rem;
  border-bottom: 3px solid var(--abc-orange);
}

.login-logo {
  width: 64px; height: 64px;
  background: var(--abc-orange);
  border-radius: 16px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 2rem;
  color: #fff;
}

/* ================================================
   ALERT BANNER (low stock / overdue)
   ================================================ */
.alert-banner {
  border-left: 4px solid;
  border-radius: 8px;
}

/* ================================================
   PAYMENT PLAN BUILDER
   ================================================ */
.installment-row { background: #f8fafc; border-radius: 8px; padding: .75rem; margin-bottom: .5rem; }

/* ================================================
   Form helpers
   ================================================ */
.form-section-title {
  font-size: .72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .07em;
  color: var(--abc-blue-light);
  display: flex;
  align-items: center;
  gap: .6rem;
}
.form-section-title::after {
  content: '';
  flex: 1;
  height: 1px;
  background: #e9ecef;
}
.form-section-title i { font-size: .85rem; }

.perm-check { padding: .4rem .75rem; border-radius: 8px; transition: background .12s; }
.perm-check:hover { background: #f0f4f8; }
.perm-check .form-check-input:checked ~ .form-check-label { color: var(--abc-blue); font-weight: 500; }

.user-avatar-super { background: linear-gradient(135deg, var(--abc-blue) 0%, #0a1f35 100%); border: 2px solid #f59e0b; }

/* ================================================
   Navbar alerts
   ================================================ */
.navbar-alert-btn {
  background: transparent;
  border: none;
  color: rgba(255,255,255,.8);
  padding: .35rem .5rem;
  border-radius: 8px;
  transition: background .15s, color .15s;
  line-height: 1;
  cursor: pointer;
}
.navbar-alert-btn:hover { background: rgba(255,255,255,.1); color: #fff; }

.navbar-alert-badge {
  position: absolute;
  top: -2px;
  right: -4px;
  min-width: 18px;
  height: 18px;
  padding: 0 4px;
  background: var(--abc-orange);
  color: #fff;
  border-radius: 10px;
  font-size: .65rem;
  font-weight: 700;
  line-height: 18px;
  text-align: center;
  pointer-events: none;
}

.alert-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
  display: inline-block;
}

.x-small { font-size: .72rem; }

/* ================================================
   DataTables overrides — Bootstrap 5 compliant
   ================================================ */

.dataTables_wrapper.dt-bootstrap5 { padding: 0; }
.dataTables_wrapper > .row        { margin-right: 0 !important; margin-left: 0 !important; }

/* ── Top controls strip ─────────────────────── */
.dataTables_wrapper > .row:first-child {
  background: #f7f8fa;
  border-bottom: 1px solid #e8eaed;
  padding: .6rem 1rem;
  align-items: center;
}

.dataTables_wrapper .dataTables_length { padding: .1rem 0; }
.dataTables_wrapper .dataTables_length label {
  font-size: .82rem;
  color: #6b7280;
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: .5rem;
  margin: 0;
  white-space: nowrap;
}

/* Override Bootstrap form-select that DataTables adds */
.dataTables_wrapper .dataTables_length select,
.dataTables_wrapper .dataTables_length select.form-select,
.dataTables_wrapper .dataTables_length select.form-select-sm {
  display: inline-block !important;
  width: auto !important;
  min-width: 68px;
  padding: .28rem .5rem !important;
  font-size: .82rem !important;
  font-weight: 600 !important;
  line-height: 1.5;
  color: var(--abc-blue) !important;
  background-color: #fff !important;
  border: 1.5px solid #cbd5e1 !important;
  border-radius: 8px !important;
  box-shadow: none !important;
  cursor: pointer;
  transition: border-color .15s;
  appearance: auto !important;
  -webkit-appearance: auto !important;
}
.dataTables_wrapper .dataTables_length select:focus {
  border-color: var(--abc-blue-light) !important;
  outline: none !important;
  box-shadow: 0 0 0 3px rgba(26,60,94,.1) !important;
}

.dataTables_wrapper .dataTables_filter { padding: .1rem 0; text-align: right; }
.dataTables_wrapper .dataTables_filter label {
  display: inline-flex;
  align-items: center;
  gap: .4rem;
  font-size: .82rem;
  color: #6b7280;
  margin: 0;
}
.dataTables_wrapper .dataTables_filter input[type="search"],
.dataTables_wrapper .dataTables_filter input.form-control {
  border: 1.5px solid #cbd5e1;
  border-radius: 20px !important;
  padding: .32rem 1rem .32rem 2.1rem;
  font-size: .83rem;
  min-width: 210px;
  background: #fff url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='13' height='13' fill='%239ca3af' viewBox='0 0 16 16'%3E%3Cpath d='M11.742 10.344a6.5 6.5 0 1 0-1.397 1.398h-.001l3.85 3.85a1 1 0 0 0 1.415-1.414l-3.85-3.85a1.007 1.007 0 0 0-.115-.1zM12 6.5a5.5 5.5 0 1 1-11 0 5.5 5.5 0 0 1 11 0z'/%3E%3C/svg%3E") no-repeat .72rem center;
  box-shadow: none;
  transition: border-color .15s, box-shadow .15s;
  outline: none;
}
.dataTables_wrapper .dataTables_filter input[type="search"]:focus {
  border-color: var(--abc-blue-light);
  box-shadow: 0 0 0 3px rgba(26,60,94,.1);
}

/* ── Bottom controls strip ──────────────────── */
.dataTables_wrapper > .row:last-child {
  background: #f7f8fa;
  border-top: 1px solid #e8eaed;
  padding: .5rem 1rem;
  align-items: center;
}

.dataTables_wrapper .dataTables_info {
  font-size: .78rem;
  color: #9ca3af;
  padding: .35rem 0;
}

.dataTables_wrapper .dataTables_paginate { padding: .25rem 0; text-align: right; }

/* Bootstrap 5 pagination — correct selectors for DataTables 1.13.x */
.dataTables_wrapper .pagination {
  justify-content: flex-end;
  gap: 3px;
  margin: 0;
  flex-wrap: nowrap;
}
.dataTables_wrapper .pagination .page-item .page-link {
  border-radius: 8px !important;
  border: 1.5px solid #e2e8f0 !important;
  color: #374151 !important;
  font-size: .78rem !important;
  font-weight: 500;
  padding: .3rem .65rem !important;
  min-width: 34px;
  text-align: center;
  background: #fff !important;
  box-shadow: none !important;
  transition: all .15s;
  line-height: 1.5;
}
.dataTables_wrapper .pagination .page-item:not(.active):not(.disabled) .page-link:hover {
  background: var(--abc-blue) !important;
  border-color: var(--abc-blue) !important;
  color: #fff !important;
}
.dataTables_wrapper .pagination .page-item.active .page-link {
  background: var(--abc-orange) !important;
  border-color: var(--abc-orange) !important;
  color: #fff !important;
  font-weight: 700 !important;
  box-shadow: 0 2px 8px rgba(245,124,0,.3) !important;
}
.dataTables_wrapper .pagination .page-item.disabled .page-link {
  background: #f9fafb !important;
  border-color: #e9ecef !important;
  color: #c4c9d4 !important;
  cursor: default !important;
}

/* Table cell padding reset */
.dataTables_wrapper .table > :not(caption) > * > * { padding: .7rem 1rem; }

/* ================================================
   Utility
   ================================================ */
.text-abc-blue   { color: var(--abc-blue) !important; }
.text-abc-orange { color: var(--abc-orange) !important; }
.bg-abc-blue     { background: var(--abc-blue) !important; }
.bg-abc-orange   { background: var(--abc-orange) !important; }
.border-orange   { border-color: var(--abc-orange) !important; }

.shadow-sm-hover:hover { box-shadow: 0 4px 16px rgba(0,0,0,.12); }

/* ================================================
   Responsive
   ================================================ */
@media (max-width: 768px) {
  .sidebar { width: var(--sidebar-collapsed); }
  .sidebar .sidebar-label { display: none; }
  .sidebar .sidebar-link  { justify-content: center; padding: .75rem; }
  .main-content { margin-left: var(--sidebar-collapsed); }
  .stat-value { font-size: 1.4rem; }
}
