/* ==========================================================================
   CloudLedgerAI — Day Book & Ledger Books Modules CSS
   Sleek, High-Density Professional ERP Styling
   ========================================================================== */

/* ── Common Module Wrapper ───────────────────────────────────────────────── */
.dbl-workspace {
  display: flex;
  flex-direction: column;
  gap: 16px;
  min-height: calc(100vh - 120px);
}

/* ── Top Header Banner ───────────────────────────────────────────────────── */
.dbl-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 16px;
  background: #ffffff;
  padding: 16px 20px;
  border-radius: 10px;
  border: 1px solid #e2e8f0;
  box-shadow: 0 1px 3px rgba(15, 23, 42, 0.04);
}

.dbl-title-wrap {
  display: flex;
  align-items: center;
  gap: 12px;
}

.dbl-icon {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  color: #ffffff;
  flex-shrink: 0;
}

.dbl-icon-daybook {
  background: linear-gradient(135deg, #0284c7 0%, #0369a1 100%);
  box-shadow: 0 4px 10px rgba(2, 132, 199, 0.25);
}

.dbl-icon-ledger {
  background: linear-gradient(135deg, #4f46e5 0%, #3730a3 100%);
  box-shadow: 0 4px 10px rgba(79, 70, 229, 0.25);
}

.dbl-title {
  font-size: 19px;
  font-weight: 700;
  color: #0f172a;
  margin: 0;
  line-height: 1.2;
}

.dbl-subtitle {
  font-size: 12.5px;
  color: #64748b;
  margin-top: 3px;
}

.dbl-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

/* ── Toolbar & Date Navigation ───────────────────────────────────────────── */
.dbl-toolbar {
  background: #ffffff;
  padding: 12px 18px;
  border-radius: 10px;
  border: 1px solid #e2e8f0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.03);
}

.dbl-nav-group {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.dbl-date-nav {
  display: inline-flex;
  align-items: center;
  background: #f8fafc;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  padding: 2px;
  gap: 2px;
}

.dbl-date-btn {
  background: transparent;
  border: none;
  font-size: 12.5px;
  font-weight: 600;
  color: #334155;
  padding: 5px 10px;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.15s ease;
  display: flex;
  align-items: center;
  gap: 4px;
}

.dbl-date-btn:hover {
  background: #e2e8f0;
  color: #0f172a;
}

.dbl-date-btn.active {
  background: #ffffff;
  color: #0284c7;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
}

.dbl-input {
  font-size: 12.5px;
  padding: 5px 10px;
  border: 1px solid #cbd5e1;
  border-radius: 6px;
  background: #ffffff;
  color: #0f172a;
  font-family: inherit;
}

.dbl-input:focus {
  outline: none;
  border-color: #0284c7;
  box-shadow: 0 0 0 2px rgba(2, 132, 199, 0.15);
}

.dbl-select {
  font-size: 12.5px;
  padding: 6px 12px;
  border: 1px solid #cbd5e1;
  border-radius: 6px;
  background: #ffffff;
  color: #0f172a;
  cursor: pointer;
}

.dbl-search {
  position: relative;
  min-width: 220px;
}

.dbl-search svg {
  position: absolute;
  left: 9px;
  top: 50%;
  transform: translateY(-50%);
  width: 15px;
  height: 15px;
  color: #94a3b8;
  pointer-events: none;
}

.dbl-search input {
  padding-left: 30px;
  width: 100%;
  font-size: 12.5px;
  height: 32px;
  border: 1px solid #cbd5e1;
  border-radius: 6px;
  box-sizing: border-box;
}

.dbl-search input:focus {
  outline: none;
  border-color: #0284c7;
  box-shadow: 0 0 0 2px rgba(2, 132, 199, 0.12);
}

/* ── KPI Summary Cards Grid ──────────────────────────────────────────────── */
.dbl-kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 12px;
}

.dbl-kpi-card {
  background: #ffffff;
  border: 1px solid #e2e8f0;
  border-radius: 10px;
  padding: 14px 16px;
  box-shadow: 0 1px 3px rgba(15, 23, 42, 0.03);
  display: flex;
  flex-direction: column;
  position: relative;
  overflow: hidden;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.dbl-kpi-card:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 6px -1px rgba(15, 23, 42, 0.06);
}

.dbl-kpi-card::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  width: 4px;
  height: 100%;
  background: #cbd5e1;
}

.dbl-kpi-card.kpi-blue::before { background: #0284c7; }
.dbl-kpi-card.kpi-green::before { background: #10b981; }
.dbl-kpi-card.kpi-purple::before { background: #8b5cf6; }
.dbl-kpi-card.kpi-amber::before { background: #f59e0b; }
.dbl-kpi-card.kpi-red::before { background: #ef4444; }

.dbl-kpi-label {
  font-size: 11.5px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: #64748b;
  margin-bottom: 6px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.dbl-kpi-val {
  font-size: 20px;
  font-weight: 700;
  color: #0f172a;
  font-family: 'SF Mono', Monaco, Consolas, monospace;
  line-height: 1.2;
}

.dbl-kpi-sub {
  font-size: 11.5px;
  color: #94a3b8;
  margin-top: 4px;
}

.dbl-kpi-pill {
  font-size: 10.5px;
  font-weight: 700;
  padding: 1px 6px;
  border-radius: 4px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.dbl-kpi-pill.dr {
  background: #dbeafe;
  color: #1d4ed8;
}

.dbl-kpi-pill.cr {
  background: #fef3c7;
  color: #b45309;
}

/* ── Filter Pills Bar ────────────────────────────────────────────────────── */
.dbl-chips-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 2px;
}

.dbl-chip {
  font-size: 11.5px;
  font-weight: 600;
  padding: 5px 12px;
  border-radius: 20px;
  background: #f1f5f9;
  color: #475569;
  border: 1px solid transparent;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.15s ease;
  display: flex;
  align-items: center;
  gap: 6px;
}

.dbl-chip:hover {
  background: #e2e8f0;
  color: #0f172a;
}

.dbl-chip.active {
  background: #0f172a;
  color: #ffffff;
  border-color: #0f172a;
}

.dbl-chip-count {
  font-size: 10px;
  background: rgba(255, 255, 255, 0.25);
  color: inherit;
  padding: 1px 6px;
  border-radius: 10px;
}

.dbl-chip:not(.active) .dbl-chip-count {
  background: #cbd5e1;
  color: #334155;
}

/* ── Data Tables ─────────────────────────────────────────────────────────── */
.dbl-card {
  background: #ffffff;
  border-radius: 10px;
  border: 1px solid #e2e8f0;
  box-shadow: 0 1px 3px rgba(15, 23, 42, 0.04);
  overflow: hidden;
}

.dbl-table-wrap {
  overflow-x: auto;
  max-width: 100%;
}

.dbl-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12.5px;
  text-align: left;
}

.dbl-table th {
  background: #f8fafc;
  color: #475569;
  font-weight: 600;
  font-size: 11.5px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  padding: 10px 14px;
  border-bottom: 1px solid #e2e8f0;
  white-space: nowrap;
}

.dbl-table td {
  padding: 10px 14px;
  border-bottom: 1px solid #f1f5f9;
  color: #1e293b;
  vertical-align: middle;
}

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

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

/* Voucher Type Badges */
.vbadge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 11px;
  font-weight: 600;
  padding: 3px 8px;
  border-radius: 5px;
  text-transform: capitalize;
  white-space: nowrap;
}

.vbadge-sales_invoice { background: #dcfce7; color: #15803d; border: 1px solid #bbf7d0; }
.vbadge-purchase_bill { background: #fef3c7; color: #b45309; border: 1px solid #fde68a; }
.vbadge-payment, .vbadge-bill_payment { background: #e0e7ff; color: #4338ca; border: 1px solid #c7d2fe; }
.vbadge-customer_payment { background: #e0f2fe; color: #0369a1; border: 1px solid #bae6fd; }
.vbadge-expense { background: #ffe4e6; color: #be123c; border: 1px solid #fecdd3; }
.vbadge-manual { background: #f3e8ff; color: #7e22ce; border: 1px solid #e9d5ff; }
.vbadge-credit_note, .vbadge-vendor_credit { background: #f1f5f9; color: #334155; border: 1px solid #cbd5e1; }
.vbadge-opening_balance { background: #ecfdf5; color: #047857; border: 1px solid #a7f3d0; }

/* ── Ledger Books Dual Pane ──────────────────────────────────────────────── */
.dbl-split-layout {
  display: grid;
  grid-template-columns: 310px 1fr;
  gap: 16px;
  align-items: start;
}

@media (max-width: 992px) {
  .dbl-split-layout {
    grid-template-columns: 1fr;
  }
}

.dbl-accounts-sidebar {
  background: #ffffff;
  border: 1px solid #e2e8f0;
  border-radius: 10px;
  overflow: hidden;
  box-shadow: 0 1px 3px rgba(15, 23, 42, 0.04);
  display: flex;
  flex-direction: column;
  max-height: calc(100vh - 180px);
}

.dbl-acc-search-header {
  padding: 12px 14px;
  border-bottom: 1px solid #e2e8f0;
  background: #f8fafc;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.dbl-cat-tabs {
  display: flex;
  gap: 4px;
  overflow-x: auto;
  padding-bottom: 2px;
}

.dbl-cat-tab {
  background: transparent;
  border: none;
  font-size: 11px;
  font-weight: 600;
  color: #64748b;
  padding: 4px 8px;
  border-radius: 4px;
  cursor: pointer;
  white-space: nowrap;
}

.dbl-cat-tab:hover {
  background: #e2e8f0;
  color: #0f172a;
}

.dbl-cat-tab.active {
  background: #0f172a;
  color: #ffffff;
}

.dbl-accounts-list {
  overflow-y: auto;
  flex: 1;
}

.dbl-acc-item {
  padding: 10px 14px;
  border-bottom: 1px solid #f1f5f9;
  cursor: pointer;
  transition: all 0.15s ease;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.dbl-acc-item:hover {
  background: #f8fafc;
}

.dbl-acc-item.active {
  background: #eff6ff;
  border-left: 3px solid #2563eb;
}

.dbl-acc-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.dbl-acc-code-name {
  font-size: 12.5px;
  font-weight: 600;
  color: #0f172a;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.dbl-acc-meta {
  font-size: 11px;
  color: #64748b;
  display: flex;
  align-items: center;
  gap: 6px;
}

.dbl-acc-bal {
  font-size: 12.5px;
  font-weight: 600;
  font-family: monospace;
  text-align: right;
  flex-shrink: 0;
}

/* ══════════════════════════════════════════════════════════════════
   DARK MODE OVERRIDES (Daybook & General Ledger)
   ══════════════════════════════════════════════════════════════════ */
[data-theme="dark"] .dbl-card,
[data-theme="dark"] .dbl-search-box,
[data-theme="dark"] .dbl-summary-card {
  background: #1e293b !important;
  border-color: #334155 !important;
  color: #f8fafc !important;
}
[data-theme="dark"] .dbl-filter-bar,
[data-theme="dark"] .dbl-toolbar {
  background: #0f172a !important;
  border-color: #334155 !important;
}
[data-theme="dark"] .dbl-acc-item:hover {
  background: rgba(51, 65, 85, 0.45) !important;
}
[data-theme="dark"] .dbl-acc-item.active {
  background: rgba(37, 99, 235, 0.2) !important;
  border-left-color: #2563eb !important;
}

/* ── Print Media Formatting ──────────────────────────────────────────────── */
@media print {
  body * {
    visibility: hidden;
  }
  .printable-area, .printable-area * {
    visibility: visible;
  }
  .printable-area {
    position: absolute;
    left: 0;
    top: 0;
    width: 100%;
    padding: 20px;
    background: #ffffff;
    color: #000000;
  }
  .no-print, button, input, select, .dbl-actions, .dbl-toolbar {
    display: none !important;
  }
}
