/* Accounting UI polish — dashboard widget-cards, KPI strips, charts, tables, settings */

/* ------------------------------------------------------------------ */
/* Dashboard / panel widget-cards (Cash Flow, P&L, Invoices, etc.)     */
/* These classes had layout obfuscation (acct-is-*) but no card chrome */
/* ------------------------------------------------------------------ */

.widget-card {
  display: flex;
  flex-direction: column;
  background: #ffffff;
  border: 1px solid #c7d2e0;
  border-radius: 14px;
  box-shadow:
    0 1px 2px rgba(15, 23, 42, 0.06),
    0 10px 28px rgba(15, 23, 42, 0.1);
  padding: 1.15rem 1.3rem;
  margin-bottom: 0;
  min-width: 0;
  overflow: hidden;
  position: relative;
  transition: box-shadow 0.2s ease, transform 0.2s ease, border-color 0.2s ease;
}

.widget-card::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 4px;
  background: linear-gradient(90deg, #6366f1 0%, #0ea5e9 55%, #14b8a6 100%);
  opacity: 1;
}

.widget-card:hover {
  box-shadow:
    0 4px 10px rgba(15, 23, 42, 0.08),
    0 16px 36px rgba(15, 23, 42, 0.12);
  border-color: #94a3b8;
  transform: translateY(-1px);
}

.widget-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
  margin-bottom: 0.85rem;
  padding-bottom: 0.65rem;
  border-bottom: 1px solid rgba(148, 163, 184, 0.28);
}

.widget-title {
  margin: 0;
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--text, #0f172a);
  letter-spacing: -0.01em;
  line-height: 1.25;
}

.widget-actions {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  flex-wrap: wrap;
}

/* Replace raw blue <a> chrome with ERP action buttons */
.widget-actions a,
.widget-actions a:link,
.widget-actions a:visited {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
  padding: 0.35rem 0.85rem;
  font-size: 0.78rem;
  font-weight: 650;
  line-height: 1.3;
  color: #312e81 !important;
  background: #eef2ff !important;
  border: 1px solid #a5b4fc !important;
  border-radius: 999px;
  text-decoration: none !important;
  white-space: nowrap;
  box-shadow: 0 1px 2px rgba(79, 70, 229, 0.12);
  transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease;
}

.widget-actions a:hover,
.widget-actions a:focus {
  color: #fff !important;
  background: #4f46e5 !important;
  border-color: #4f46e5 !important;
  text-decoration: none !important;
  box-shadow: 0 2px 8px rgba(79, 70, 229, 0.35);
}

.widget-actions a.btn-primary,
.widget-actions a.btn-primary:link,
.widget-actions a.btn-primary:visited {
  color: #fff !important;
  background: #4f46e5 !important;
  border-color: #4338ca !important;
}

.widget-actions a.btn-primary:hover,
.widget-actions a.btn-primary:focus {
  background: #3730a3 !important;
  border-color: #312e81 !important;
}

.widget-actions a.btn-outline-secondary,
.widget-actions a.btn-outline-secondary:link,
.widget-actions a.btn-outline-secondary:visited {
  color: #334155 !important;
  background: #fff !important;
  border-color: #cbd5e1 !important;
}

.widget-actions a.btn-outline-secondary:hover,
.widget-actions a.btn-outline-secondary:focus {
  color: #0f172a !important;
  background: #f1f5f9 !important;
  border-color: #94a3b8 !important;
}

.widget-actions a.btn,
.widget-actions .btn {
  text-decoration: none !important;
}

.chart-placeholder {
  position: relative;
  width: 100%;
  min-height: 220px;
  height: 240px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(180deg, #f8fafc 0%, #ffffff 100%);
  border: 1px dashed #e2e8f0;
  border-radius: 10px;
  overflow: hidden;
}

.chart-placeholder canvas {
  width: 100% !important;
  height: 100% !important;
  max-height: 240px;
}

.widget-card .account-list {
  list-style: none;
  margin: 0;
  padding: 0.15rem 0 0;
}

.widget-card .account-list .account-item {
  display: flex !important;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.7rem 0.65rem;
  margin: 0.15rem 0;
  border-radius: 8px;
  border-bottom: none;
  background: #f8fafc;
  font-size: 0.9rem;
  color: #334155;
}

.widget-card .account-list .account-item:nth-child(even) {
  background: #f1f5f9;
}

.widget-card .account-list .account-item:last-child {
  border-bottom: 0;
}

.widget-card .account-balance {
  flex: 0 0 auto;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
  font-weight: 700;
  font-size: 0.92rem;
}

/* Unified Transactions + any tables inside widget-cards */
.widget-card .table,
#dashboard .table,
.content-section .table {
  width: 100%;
  margin-bottom: 0;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 0.875rem;
}

.widget-card .table thead th,
#dashboard .table thead th,
.content-section .table thead th {
  background: #f1f5f9;
  color: #334155;
  font-weight: 700;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  border-bottom: 1px solid #e2e8f0;
  padding: 0.65rem 0.75rem;
  white-space: nowrap;
}

.widget-card .table tbody td,
#dashboard .table tbody td,
.content-section .table tbody td {
  padding: 0.7rem 0.75rem;
  border-bottom: 1px solid #f1f5f9;
  color: #334155;
  vertical-align: middle;
}

.widget-card .table tbody tr:hover,
#dashboard .table.table-hover tbody tr:hover,
.content-section .table.table-hover tbody tr:hover {
  background: #f8fafc;
}

.widget-card .table .badge,
.content-section .table .badge {
  font-weight: 600;
  font-size: 0.7rem;
  letter-spacing: 0.02em;
  padding: 0.28em 0.55em;
  border-radius: 6px;
}

.acct-is-0100 {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.28rem 0.7rem;
  font-size: 0.75rem;
  font-weight: 600;
  color: #3730a3 !important;
  background: #eef2ff;
  border: 1px solid #c7d2fe;
  border-radius: 8px;
  text-decoration: none !important;
  white-space: nowrap;
}

.acct-is-0100:hover {
  color: #fff !important;
  background: #4f46e5;
  border-color: #4f46e5;
  text-decoration: none !important;
}


#dashboard-kpi-row .widget-card::before {
  background: linear-gradient(90deg, #6366f1 0%, #a855f7 100%);
}

#dashboard-outer-grid {
  width: 100%;
  max-width: 100%;
}

#dashboard-outer-grid .acct-is-0101 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 18px;
  width: 100%;
}

@media (max-width: 992px) {
  #dashboard-outer-grid .acct-is-0101 {
    grid-template-columns: 1fr;
  }
  .acct-is-0102 {
    grid-column: auto !important;
  }
}

/* ------------------------------------------------------------------ */
/* Metric widgets used by Sales / Credit Notes / AP panels             */
/* ------------------------------------------------------------------ */

.accounting-module .widget,
.content-section .widget,
#credit-notes .widget,
.widget {
  display: flex;
  align-items: center;
  gap: 0.85rem;
  padding: 1rem 1.1rem;
  border-radius: 12px;
  background: #fff;
  border: 1px solid #e5e7eb;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04);
  min-height: 92px;
  height: 100%;
}

.widget .widget-icon {
  width: 44px;
  height: 44px;
  border-radius: 10px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  font-size: 1.15rem;
  color: #fff;
  background: #6366f1;
}

.widget .widget-content {
  min-width: 0;
  flex: 1;
}

.widget .widget-content h3 {
  margin: 0;
  font-size: 1.35rem;
  font-weight: 700;
  line-height: 1.2;
  color: #0f172a;
}

.widget .widget-content p {
  margin: 0.2rem 0 0;
  font-size: 0.8rem;
  color: #64748b;
  font-weight: 500;
}

.widget-blue .widget-icon { background: linear-gradient(135deg, #3b82f6, #2563eb); }
.widget-green .widget-icon { background: linear-gradient(135deg, #22c55e, #16a34a); }
.widget-orange .widget-icon { background: linear-gradient(135deg, #f59e0b, #d97706); }
.widget-red .widget-icon { background: linear-gradient(135deg, #ef4444, #dc2626); }
.widget-purple .widget-icon { background: linear-gradient(135deg, #a855f7, #7c3aed); }
.widget-teal .widget-icon { background: linear-gradient(135deg, #14b8a6, #0d9488); }

.widget-blue { border-color: #dbeafe; background: linear-gradient(180deg, #eff6ff 0%, #fff 70%); }
.widget-green { border-color: #dcfce7; background: linear-gradient(180deg, #f0fdf4 0%, #fff 70%); }
.widget-orange { border-color: #ffedd5; background: linear-gradient(180deg, #fff7ed 0%, #fff 70%); }
.widget-red { border-color: #fee2e2; background: linear-gradient(180deg, #fef2f2 0%, #fff 70%); }

/* Banking / KPI summary strips (obfuscated panel classes) */
.acct-is-0131,
.acct-kpi-strip {
  display: flex;
  gap: 0.85rem;
  flex-wrap: wrap;
  margin-bottom: 1.25rem;
  width: 100%;
}

.acct-is-0132 {
  background: linear-gradient(180deg, #ffffff 0%, #f8fafc 100%);
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  padding: 1rem 1.2rem;
  min-width: 160px;
  flex: 1 1 180px;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04);
}

.acct-is-0133 {
  font-size: 0.75rem;
  color: #64748b;
  margin-bottom: 0.35rem;
  font-weight: 600;
  letter-spacing: 0.01em;
}

.acct-is-0134,
.acct-is-0135,
.acct-is-0136 {
  font-size: 1.5rem;
  font-weight: 700;
  color: #0f172a;
  line-height: 1.15;
}

.acct-is-0135 { color: #16a34a; }
.acct-is-0136 { color: #dc2626; }

/* Chart containers: never collapse to empty white slabs */
.chart-container,
.acct-is-0200 {
  position: relative;
  width: 100%;
  min-height: 260px;
  height: 300px;
}

.chart-container canvas,
.acct-is-0200 canvas {
  width: 100% !important;
  height: 100% !important;
  max-height: 300px;
}

/* Bootstrap cards inside Accounting panels */
.content-section .card {
  background: var(--card, #fff);
  border: 1px solid var(--border, #e2e8f0);
  border-radius: 14px;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04), 0 8px 24px rgba(15, 23, 42, 0.04);
  overflow: hidden;
  margin-bottom: 1.25rem;
}

.content-section .card .card-body {
  padding: 1rem 1.15rem;
}

.content-section .card .card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  flex-wrap: wrap;
  padding: 0.85rem 1.15rem;
  background: #f8fafc;
  border-bottom: 1px solid #e2e8f0;
}

.content-section .card .card-title,
.content-section .card-header h3,
.content-section .card-header h5,
.content-section .card-header h6 {
  margin: 0;
  font-size: 1.05rem;
  font-weight: 700;
  color: #0f172a;
}

.content-section .card-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.content-section .table-container,
.content-section .table-responsive {
  width: 100%;
  overflow-x: auto;
}

.content-section .search-bar {
  position: relative;
  min-width: 200px;
  max-width: 280px;
}

.content-section .search-bar i {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: #94a3b8;
  pointer-events: none;
}

.content-section .search-bar input {
  width: 100%;
  padding: 0.4rem 0.75rem 0.4rem 2rem;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  background: #fff;
  font-size: 0.875rem;
}

.content-section .pagination {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 0.5rem;
  flex-wrap: wrap;
  padding: 0.85rem 1.15rem;
  border-top: 1px solid #f1f5f9;
  background: #fafbfc;
}

/* Main content fills remaining width beside sidebar */
.main-content {
  width: auto;
  max-width: none;
  box-sizing: border-box;
  background: #f1f5f9;
}

.main-content > .content-section.active {
  width: 100%;
  max-width: 100%;
}

.page-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  flex-wrap: wrap;
  gap: 1rem;
  margin-bottom: 1.35rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid #e2e8f0;
  position: relative;
}

.page-header::after {
  content: "";
  position: absolute;
  bottom: -1px;
  left: 0;
  width: 72px;
  height: 3px;
  border-radius: 2px;
  background: linear-gradient(90deg, #f97316, #ef4444);
}

.page-header h1 {
  margin: 0 0 0.35rem;
  font-size: 1.75rem;
  font-weight: 750;
  color: #0f172a;
  letter-spacing: -0.02em;
}

.page-header p {
  margin: 0;
  color: #64748b;
  font-size: 0.95rem;
}

/* Settings tab active contrast */
.settings-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}

.settings-nav-btn {
  border: 1px solid #e2e8f0;
  background: #f8fafc;
  color: #334155;
  border-radius: 8px;
  padding: 0.55rem 0.9rem;
  font-weight: 600;
}

.settings-nav-btn:hover {
  background: #eef2ff;
  color: #3730a3;
}

.settings-nav-btn.active {
  background: #4f46e5;
  border-color: #4f46e5;
  color: #fff;
  box-shadow: 0 1px 3px rgba(79, 70, 229, 0.35);
}

.settings-nav-btn.active i {
  color: #fff;
}

/* Sidebar category active state (in addition to expanded) */
.sidebar-nav .nav-item-header.active {
  background: linear-gradient(90deg, rgba(99, 102, 241, 0.35), transparent) !important;
  color: #fff !important;
  border-left: 3px solid #a5b4fc;
}

.sidebar-nav .nav-item-header.active i.menu-icon {
  opacity: 1;
}

/* Dark mode */
[data-theme="dark"] .widget-card,
body.dark-mode .widget-card,
[data-theme="dark"] .content-section .card,
body.dark-mode .content-section .card,
[data-theme="dark"] .widget,
body.dark-mode .widget {
  background: #16213e;
  border-color: #0f3460;
  color: #eaeaea;
  box-shadow: none;
}

[data-theme="dark"] .widget-title,
body.dark-mode .widget-title,
[data-theme="dark"] .page-header h1,
body.dark-mode .page-header h1,
[data-theme="dark"] .content-section .card-title,
body.dark-mode .content-section .card-title {
  color: #eaeaea;
}

[data-theme="dark"] .widget-header,
body.dark-mode .widget-header,
[data-theme="dark"] .content-section .card .card-header,
body.dark-mode .content-section .card .card-header {
  background: #1a2744;
  border-color: #0f3460;
}

[data-theme="dark"] .chart-placeholder,
body.dark-mode .chart-placeholder {
  background: linear-gradient(180deg, #1a2744 0%, #16213e 100%);
  border-color: #0f3460;
}

[data-theme="dark"] .widget-card .table thead th,
body.dark-mode .widget-card .table thead th,
[data-theme="dark"] .content-section .table thead th,
body.dark-mode .content-section .table thead th {
  background: #1a2744;
  color: #cbd5e1;
  border-color: #0f3460;
}

[data-theme="dark"] .widget-card .table tbody td,
body.dark-mode .widget-card .table tbody td,
[data-theme="dark"] .content-section .table tbody td,
body.dark-mode .content-section .table tbody td {
  color: #e2e8f0;
  border-color: #0f3460;
}

@media (max-width: 768px) {
  .widget {
    min-height: 80px;
    padding: 0.85rem;
  }
  .widget-card {
    padding: 0.95rem 1rem;
  }
  .chart-placeholder {
    min-height: 180px;
    height: 200px;
  }
  .chart-container,
  .acct-is-0200 {
    min-height: 220px;
    height: 240px;
  }
  .page-header h1 {
    font-size: 1.4rem;
  }
}

/* Keep open Sales (and other) submenu links clickable above sibling group headers. */
.accounting-sidebar .sidebar-nav > li {
  position: relative;
  z-index: 1;
}
.accounting-sidebar .sidebar-nav > li:has(.submenu.open),
.accounting-sidebar .sidebar-nav > li:has(.nav-item-header.expanded) {
  z-index: 6;
}
.accounting-sidebar .submenu:not(.open) {
  pointer-events: none !important;
}
.accounting-sidebar .submenu:not(.open) a {
  pointer-events: none !important;
}
.accounting-sidebar .submenu.open {
  position: relative;
  z-index: 7;
  pointer-events: auto !important;
  overflow: visible;
}
.accounting-sidebar .submenu.open a[data-section] {
  position: relative;
  z-index: 8;
  pointer-events: auto !important;
}
.accounting-sidebar.collapsed .submenu,
.accounting-sidebar.collapsed .submenu.open {
  pointer-events: none !important;
}

/* Dashboard: keep bottom cards clear of the fixed AI advisor strip */
#dashboard #dashboard-outer-grid {
  padding-bottom: 88px;
}

@media (max-width: 1024px) {
  #ai-insights-widget.acct-is-0105 {
    width: min(340px, calc(100vw - 16px));
    right: 0;
  }
}

