/* c:\Users\PROCAM\Desktop\EQL\TallyApp\TallyApp.Web\wwwroot\css\erp-theme.css */
@import url('https://fonts.googleapis.com/css2?family=Geist:wght@300;400;500;600;700&family=Geist+Mono:wght@400;500&display=swap');

:root {
  /* Surface */
  --bg:              #F7F7F5;   /* Warm off-white — page background */
  --surface:         #FFFFFF;   /* Elevated cards and panels */
  --surface-hover:   #FAFAFA;   /* Subtle hover on list items */
  --surface-raised:  #FFFFFF;   /* Modals, dropdowns */

  /* Border */
  --border:          #E8E8E5;   /* Default border — warm */
  --border-strong:   #D1D1CE;   /* Stronger dividers */
  --border-focus:    #0A0A0A;   /* Input focus ring — black */

  /* Text */
  --text-primary:    #0A0A0A;   /* Near-black */
  --text-secondary:  #6B6B6B;   /* Muted labels */
  --text-tertiary:   #9B9B9B;   /* Placeholders, disabled */
  --text-inverse:    #FFFFFF;   /* Text on black */

  /* Accent — monochrome */
  --accent:          #0A0A0A;   /* Primary action — black */
  --accent-hover:    #2A2A2A;   /* Button hover */
  --accent-subtle:   #F0F0EE;   /* Tinted backgrounds for tags, badges */

  /* Semantic */
  --success:         #1A7A4A;   /* Dark green */
  --success-bg:      #F0FAF4;
  --warning:         #8A6000;   /* Dark amber */
  --warning-bg:      #FFFBEB;
  --danger:          #C0392B;   /* Dark red */
  --danger-bg:       #FEF2F0;
  --info:            #1A5276;
  --info-bg:         #EEF4FB;

  /* Radius */
  --radius-sm:       6px;
  --radius-md:       10px;
  --radius-lg:       14px;
  --radius-xl:       18px;
  --radius-full:     9999px;

  /* Shadow */
  --shadow-sm:       0 1px 3px rgba(0,0,0,0.06), 0 1px 2px rgba(0,0,0,0.04);
  --shadow-md:       0 4px 12px rgba(0,0,0,0.07), 0 2px 4px rgba(0,0,0,0.04);
  --shadow-lg:       0 8px 24px rgba(0,0,0,0.08), 0 4px 8px rgba(0,0,0,0.04);
  --shadow-focus:    0 0 0 3px rgba(10,10,10,0.12);

  /* Sidebar */
  --sidebar-width:        240px;
  --sidebar-width-collapsed: 60px;
  --sidebar-bg:      #FFFFFF;
  --sidebar-border:  #E8E8E5;

  /* Spacing scale */
  --space-1: 4px;  --space-2: 8px;   --space-3: 12px;
  --space-4: 16px; --space-5: 20px;  --space-6: 24px;
  --space-8: 32px; --space-10: 40px; --space-12: 48px;

  /* Transition */
  --transition: 150ms cubic-bezier(0.4, 0, 0.2, 1);
  --transition-slow: 250ms cubic-bezier(0.4, 0, 0.2, 1);
}

* {
  box-sizing: border-box;
}

body {
  font-family: 'Geist', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  font-size: 14px;
  line-height: 1.5;
  color: var(--text-primary);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  margin: 0;
  padding: 0;
}

/* ── Typography System ───────────────────────────────────────────── */
.text-display  { font-size: 28px; font-weight: 700; letter-spacing: -0.6px; line-height: 1.2; }
.text-heading  { font-size: 20px; font-weight: 600; letter-spacing: -0.4px; }
.text-title    { font-size: 16px; font-weight: 600; letter-spacing: -0.2px; }
.text-label    { font-size: 13px; font-weight: 500; letter-spacing: 0.1px; }
.text-body     { font-size: 14px; font-weight: 400; }
.text-small    { font-size: 12px; font-weight: 400; color: var(--text-secondary); }
.text-caption  { font-size: 11px; font-weight: 500; letter-spacing: 0.4px; text-transform: uppercase; color: var(--text-tertiary); }
.text-mono     { font-family: 'Geist Mono', monospace; font-size: 13px; }

/* Amount Display Rule */
.amount-cell, .text-amount {
  font-family: 'Geist Mono', monospace;
  text-align: right;
  white-space: nowrap;
}
.amount-positive { color: var(--success) !important; }
.amount-negative { color: var(--danger) !important; }
.amount-neutral { color: var(--text-primary) !important; }

/* Focus Styling */
*:focus-visible {
  outline: none;
  box-shadow: var(--shadow-focus);
}

/* ── Custom Cards ────────────────────────────────────────────────── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  padding: var(--space-6);
  transition: box-shadow var(--transition), transform var(--transition);
  margin-bottom: var(--space-6);
}
.card:hover {
  box-shadow: var(--shadow-md);
}

/* ── Buttons ─────────────────────────────────────────────────────── */
.btn-primary {
  background: var(--accent);
  color: var(--text-inverse);
  border: 1px solid var(--accent);
  border-radius: var(--radius-md);
  padding: 8px 16px;
  font-size: 13px;
  font-weight: 500;
  letter-spacing: 0.1px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  transition: background var(--transition), transform var(--transition), box-shadow var(--transition);
  text-decoration: none;
}
.btn-primary:hover {
  background: var(--accent-hover);
  border-color: var(--accent-hover);
  color: var(--text-inverse);
  transform: translateY(-1px);
  box-shadow: var(--shadow-sm);
}
.btn-primary:active {
  transform: translateY(0);
}

.btn-secondary {
  background: transparent;
  color: var(--text-primary);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-md);
  padding: 8px 16px;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  transition: background var(--transition), border-color var(--transition);
  text-decoration: none;
}
.btn-secondary:hover {
  background: var(--surface-hover);
  border-color: var(--text-secondary);
  color: var(--text-primary);
}

/* ── Inputs ──────────────────────────────────────────────────────── */
.form-input {
  width: 100%;
  height: 36px;
  padding: 0 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  font-family: inherit;
  font-size: 14px;
  color: var(--text-primary);
  outline: none;
  transition: border-color var(--transition), box-shadow var(--transition);
}
.form-input:focus {
  border-color: var(--border-focus);
  box-shadow: var(--shadow-focus);
}
.form-input::placeholder {
  color: var(--text-tertiary);
}

/* Select-specific fix: push content left so arrow doesn't sit at the edge */
select.form-input {
  appearance: none;
  -webkit-appearance: none;
  padding-right: 36px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%236B6B6B' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  background-size: 16px 16px;
  cursor: pointer;
}
select.form-input:focus {
  border-color: var(--border-focus);
  box-shadow: var(--shadow-focus);
}

.form-group {
  margin-bottom: var(--space-4);
}
.form-label {
  display: block;
  font-size: 12px;
  font-weight: 500;
  color: var(--text-secondary);
  margin-bottom: var(--space-2);
}


/* ── Badges & Status Pills ───────────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  border-radius: var(--radius-full);
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.2px;
}
.badge-success  { background: var(--success-bg); color: var(--success); }
.badge-warning  { background: var(--warning-bg); color: var(--warning); }
.badge-danger   { background: var(--danger-bg);  color: var(--danger);  }
.badge-neutral  { background: var(--accent-subtle); color: var(--text-secondary); }

/* ── Clean Data Tables ───────────────────────────────────────────── */
.data-table {
  width: 100%;
  border-collapse: collapse;
}
.data-table thead tr {
  border-bottom: 1px solid var(--border);
}
.data-table thead th {
  padding: 8px 12px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.4px;
  text-transform: uppercase;
  color: var(--text-tertiary);
  text-align: left;
}
.data-table tbody tr {
  border-bottom: 1px solid var(--border);
  transition: background var(--transition);
  cursor: pointer;
}
.data-table tbody tr:hover {
  background: var(--surface-hover);
}
.data-table tbody td {
  padding: 12px;
  font-size: 14px;
  color: var(--text-primary);
  vertical-align: middle;
}

/* ── Sidebar and Layout ──────────────────────────────────────────── */
.app-shell {
  display: flex;
  min-height: 100vh;
  width: 100vw;
  overflow: hidden;
}

.sidebar {
  width: var(--sidebar-width);
  background: var(--sidebar-bg);
  border-right: 1px solid var(--sidebar-border);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  height: 100vh;
  position: sticky;
  top: 0;
  z-index: 100;
  transition: width var(--transition-slow);
  overflow: hidden;
}

/* Collapsed state — shrink to icon-only strip */
.sidebar.collapsed {
  width: var(--sidebar-width-collapsed);
}

.sidebar.collapsed .sidebar-header {
  justify-content: center;
  padding: 16px 0;
}

.sidebar.collapsed .nav-item {
  justify-content: center;
  padding: 10px 0;
}

.sidebar.collapsed .nav-section-label,
.sidebar.collapsed .nav-submenu {
  display: none !important;
}

.sidebar.collapsed .sidebar-footer {
  align-items: center;
  padding: 16px 8px;
}

.sidebar.collapsed .sidebar-footer .user-block {
  justify-content: center;
  width: 100%;
}

.sidebar.collapsed .sidebar-footer > div {
  justify-content: center !important;
}

.sidebar.collapsed .sidebar-nav {
  scrollbar-width: none;
  -ms-overflow-style: none;
}
.sidebar.collapsed .sidebar-nav::-webkit-scrollbar {
  display: none;
}


.sidebar-header {
  padding: 16px 20px;
  display: flex;
  align-items: center;
  gap: 10px;
  border-bottom: 1px solid var(--border);
}

.sidebar-logo-text {
  font-size: 16px;
  font-weight: 700;
  letter-spacing: -0.4px;
  color: var(--text-primary);
}

.sidebar-nav {
  flex: 1;
  overflow-y: auto;
  padding: var(--space-4) var(--space-2);
}

/* Custom scrollbars for modern look */
.sidebar-nav::-webkit-scrollbar {
  width: 4px;
}
.sidebar-nav::-webkit-scrollbar-track {
  background: transparent;
}
.sidebar-nav::-webkit-scrollbar-thumb {
  background: var(--border-strong);
  border-radius: var(--radius-full);
}
.sidebar-nav::-webkit-scrollbar-thumb:hover {
  background: var(--text-tertiary);
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  border-radius: var(--radius-md);
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
  cursor: pointer;
  transition: background var(--transition), color var(--transition), padding var(--transition-slow);
  text-decoration: none;
  margin-bottom: 2px;
  white-space: nowrap;
  overflow: hidden;
}
.nav-item:hover {
  background: var(--accent-subtle);
  color: var(--text-primary);
}
.nav-item.active {
  background: var(--accent-subtle);
  color: var(--text-primary);
  font-weight: 600;
}

.nav-submenu {
  display: flex;
  flex-direction: column;
  padding-left: 28px;
  margin-top: 2px;
  margin-bottom: 4px;
}

.nav-submenu-item {
  display: block;
  padding: 6px 12px;
  font-size: 12px;
  color: var(--text-secondary);
  text-decoration: none;
  border-radius: var(--radius-sm);
  transition: background var(--transition), color var(--transition);
}
.nav-submenu-item:hover, .nav-submenu-item.active {
  background: var(--accent-subtle);
  color: var(--text-primary);
}

.nav-section-label {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.8px;
  text-transform: uppercase;
  color: var(--text-tertiary);
  padding: 16px 12px 4px;
}

.sidebar-footer {
  padding: 16px;
  border-top: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.user-block {
  display: flex;
  align-items: center;
  gap: 10px;
}
.user-avatar {
  width: 28px;
  height: 28px;
  border-radius: var(--radius-full);
  background: var(--accent);
  color: var(--text-inverse);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 600;
}

.main-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  height: 100vh;
  overflow-y: auto;
  background: var(--bg);
}

.top-bar {
  height: 48px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 var(--space-6);
  flex-shrink: 0;
  position: sticky;
  top: 0;
  z-index: 99;
}

.top-bar-search {
  width: 240px;
  height: 28px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-full);
  padding: 0 12px;
  font-size: 12px;
  outline: none;
}
.top-bar-search:focus {
  border-color: var(--border-focus);
  background: var(--surface);
}

.top-bar-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

.select-pill {
  border: 1px solid var(--border);
  background: var(--surface);
  font-size: 11px;
  font-weight: 500;
  padding: 4px 10px;
  border-radius: var(--radius-full);
  cursor: pointer;
  outline: none;
  transition: border-color var(--transition);
}
.select-pill:focus {
  border-color: var(--border-focus);
}

.page-container {
  padding: var(--space-8);
  flex: 1;
}

.page-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: var(--space-8);
}
.page-header-info h1 {
  margin: 0 0 var(--space-1) 0;
}
.page-header-actions {
  display: flex;
  gap: var(--space-3);
}

/* ── AG Grid Overrides ───────────────────────────────────────────── */
.ag-theme-custom {
  font-family: inherit !important;
}
.ag-theme-custom .ag-root-wrapper {
  border: 1px solid var(--border) !important;
  border-radius: var(--radius-lg) !important;
  box-shadow: var(--shadow-sm);
  background: var(--surface) !important;
}
.ag-theme-custom .ag-header {
  background: var(--bg) !important;
  border-bottom: 1px solid var(--border) !important;
  font-family: inherit !important;
}
.ag-theme-custom .ag-header-cell-label {
  font-size: 11px !important;
  font-weight: 600 !important;
  letter-spacing: 0.4px !important;
  text-transform: uppercase !important;
  color: var(--text-tertiary) !important;
}
.ag-theme-custom .ag-row {
  border-bottom: 1px solid var(--border) !important;
}
.ag-theme-custom .ag-row:hover {
  background: var(--surface-hover) !important;
}
.ag-theme-custom .ag-cell {
  font-size: 14px !important;
  font-family: inherit !important;
  color: var(--text-primary) !important;
  display: flex;
  align-items: center;
}
.ag-theme-custom .ag-cell.amount-cell {
  font-family: 'Geist Mono', monospace !important;
  justify-content: flex-end;
  text-align: right;
}
.ag-theme-custom .ag-cell-focus:not(.ag-cell-range-selected) {
  border: 1px solid var(--border-focus) !important;
}

/* Custom dropdown editor for ledger */
.ledger-dropdown-editor {
  width: 100%;
  height: 100%;
  position: relative;
}
.ledger-dropdown-editor input {
  width: 100%;
  height: 100%;
  border: none;
  padding: 0 8px;
  outline: none;
  font-family: inherit;
  font-size: 14px;
}
.ledger-results {
  position: absolute;
  top: 100%;
  left: 0;
  width: 100%;
  background: var(--surface-raised);
  border: 1px solid var(--border-strong);
  border-radius: 0 0 var(--radius-md) var(--radius-md);
  box-shadow: var(--shadow-lg);
  z-index: 10000;
  max-height: 200px;
  overflow-y: auto;
}
.ledger-result-item {
  padding: 8px 12px;
  font-size: 13px;
  cursor: pointer;
  border-bottom: 1px solid var(--border);
}
.ledger-result-item:hover, .ledger-result-item.selected {
  background: var(--surface-hover);
}

/* ── Voucher Balance Footer ──────────────────────────────────────── */
.balance-footer {
  margin-top: var(--space-4);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  background: var(--surface);
  box-shadow: var(--shadow-sm);
}
.balance-row {
  display: flex;
  justify-content: space-between;
  padding: 12px var(--space-6);
  border-bottom: 1px solid var(--border);
}
.balance-row:last-child {
  border-bottom: none;
}
.balance-row span {
  flex: 1;
}
.balance-row span:nth-child(2), .balance-row span:nth-child(3) {
  text-align: right;
  font-family: 'Geist Mono', monospace;
}
.balance-diff {
  display: flex;
  align-items: center;
}
.balance-diff.balanced {
  background: var(--success-bg);
  color: var(--success);
}
.balance-diff.unbalanced {
  background: var(--danger-bg);
  color: var(--danger);
}

/* Keyboard Shortcut hints bar */
.shortcuts-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 11px;
  color: var(--text-tertiary);
  margin-top: 12px;
}

/* ── Animations ──────────────────────────────────────────────────── */
/* KPI Card staggered reveal */
.kpi-card {
  opacity: 0;
  transform: translateY(8px);
  animation: fadeUp 300ms ease forwards;
}
.kpi-card:nth-child(1) { animation-delay: 0ms; }
.kpi-card:nth-child(2) { animation-delay: 60ms; }
.kpi-card:nth-child(3) { animation-delay: 120ms; }
.kpi-card:nth-child(4) { animation-delay: 180ms; }
.kpi-card:nth-child(5) { animation-delay: 240ms; }

@keyframes fadeUp {
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Shake animation */
@keyframes shake {
  0%, 100% { transform: translateX(0); }
  20%, 60% { transform: translateX(-4px); }
  40%, 80% { transform: translateX(4px); }
}
.shake {
  animation: shake 300ms ease;
}

/* Toast Animation */
@keyframes slideIn {
  from { opacity: 0; transform: translateX(16px); }
  to   { opacity: 1; transform: translateX(0); }
}

/* ── Two-Panel split layouts ─────────────────────────────────────── */
.split-layout {
  display: flex;
  gap: var(--space-6);
}
.split-left {
  flex: 1.2;
}
.split-right {
  flex: 0.8;
}

/* ── Chevron animation ───────────────────────────────────────────── */
.chevron-rotate {
  transition: transform var(--transition);
}
.chevron-rotate.open {
  transform: rotate(90deg);
}

/* ── Responsive rules ────────────────────────────────────────────── */
@media (max-width: 1280px) {
  .split-layout {
    flex-direction: column;
  }
  .split-left, .split-right {
    flex: 1;
  }
}

@media (max-width: 768px) {
  .sidebar {
    display: none;
  }
  .sidebar.mobile-open {
    display: flex;
    position: fixed;
    z-index: 999;
    width: var(--sidebar-width);
    height: 100vh;
    box-shadow: var(--shadow-lg);
  }
  .main-content {
    margin-left: 0 !important;
  }
  .kpi-grid {
    grid-template-columns: 1fr 1fr;
  }
  .analytics-row {
    flex-direction: column;
  }
  .ag-root-wrapper {
    overflow-x: auto;
  }
}
