/* ============================================================
   TradeApp Integration — Premium Dark UI
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&display=swap');

:root {
  --bg-primary:    #f8fafc;
  --bg-secondary:  #ffffff;
  --bg-card:       #ffffff;
  --bg-card-hover: #f1f5f9;
  --accent:        #2563eb;
  --accent-dark:   #1d4ed8;
  --accent-light:  #3b82f6;
  --success:       #16a34a;
  --warning:       #d97706;
  --danger:        #dc2626;
  --text-primary:  #0f172a;
  --text-secondary:#334155;
  --text-muted:    #64748b;
  --border:        #e2e8f0;
  --border-accent: rgba(37,99,235,0.2);
  --shadow-sm:     0 1px 3px rgba(0,0,0,0.1);
  --shadow-md:     0 4px 6px -1px rgba(0,0,0,0.1), 0 2px 4px -1px rgba(0,0,0,0.06);
  --shadow-lg:     0 10px 15px -3px rgba(0,0,0,0.1), 0 4px 6px -2px rgba(0,0,0,0.05);
  --shadow-accent: 0 0 15px rgba(37,99,235,0.08);
  --radius-sm:     6px;
  --radius-md:     10px;
  --radius-lg:     16px;
  --sidebar-w:     240px;
  --topbar-h:      60px;
  --transition:    all 0.25s cubic-bezier(0.4,0,0.2,1);
}

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

html, body {
  height: 100%;
  font-family: 'Inter', system-ui, sans-serif;
  background-color: var(--bg-primary);
  color: var(--text-primary);
  font-size: 14px;
  line-height: 1.6;
  overflow-x: hidden;
}

a { color: var(--accent); text-decoration: none; transition: var(--transition); }
a:hover { color: var(--accent-light); text-decoration: none; }

/* ── Sidebar ── */
.sidebar {
  position: fixed;
  top: 0; left: 0;
  width: var(--sidebar-w);
  height: 100vh;
  background: var(--bg-secondary);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  z-index: 1000;
  overflow-y: auto;
  box-shadow: var(--shadow-md);
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 18px 20px;
  border-bottom: 1px solid var(--border);
  min-height: var(--topbar-h);
}

.sidebar-brand-icon {
  width: 34px; height: 34px;
  background: linear-gradient(135deg, var(--accent), var(--accent-dark));
  border-radius: var(--radius-sm);
  display: flex; align-items: center; justify-content: center;
  font-size: 16px;
  box-shadow: var(--shadow-accent);
  flex-shrink: 0;
}

.sidebar-brand-text {
  font-size: 15px;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: 0.3px;
}

.sidebar-section {
  padding: 14px 12px 4px;
}

.sidebar-section-label {
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 1.2px;
  color: var(--text-muted);
  padding: 0 8px;
  margin-bottom: 6px;
}

.sidebar-nav { list-style: none; display: flex; flex-direction: column; gap: 2px; }

.sidebar-nav li a,
.sidebar-nav li button {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  border-radius: var(--radius-sm);
  font-size: 13.5px;
  font-weight: 500;
  color: var(--text-secondary);
  transition: var(--transition);
  width: 100%;
  background: none;
  border: none;
  cursor: pointer;
  text-align: left;
}

.sidebar-nav li a:hover,
.sidebar-nav li button:hover {
  background: rgba(37,99,235,0.06);
  color: var(--accent);
}

.sidebar-nav li.active a {
  background: rgba(37,99,235,0.1);
  color: var(--accent);
  border: 1px solid var(--border-accent);
}

.sidebar-nav li a .nav-icon {
  font-size: 15px;
  width: 20px;
  text-align: center;
  flex-shrink: 0;
}

.sidebar-footer {
  margin-top: auto;
  padding: 14px 16px;
  border-top: 1px solid var(--border);
  font-size: 11px;
  color: var(--text-muted);
  text-align: center;
}

/* ── Company Badge in sidebar ── */
.sidebar-company-info {
  margin: 10px 12px;
  background: rgba(37,99,235,0.04);
  border: 1px solid var(--border-accent);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
}
.sidebar-company-info .company-label {
  font-size: 10px; color: var(--text-muted); text-transform: uppercase; letter-spacing: 1px;
}
.sidebar-company-info .company-name {
  font-size: 13px; font-weight: 600; color: var(--accent); margin-top: 2px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

/* ── Main Wrapper ── */
.app-wrapper {
  margin-left: var(--sidebar-w);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* ── Top Bar ── */
.topbar {
  height: var(--topbar-h);
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 24px;
  gap: 16px;
  position: sticky;
  top: 0;
  z-index: 500;
}

.topbar-title {
  font-size: 16px;
  font-weight: 600;
  color: var(--text-primary);
  flex: 1;
}

.topbar-badge {
  background: rgba(37,99,235,0.08);
  color: var(--accent);
  border: 1px solid var(--border-accent);
  border-radius: 20px;
  padding: 3px 12px;
  font-size: 12px;
  font-weight: 500;
}

/* ── Page Content ── */
.page-content {
  padding: 24px;
  flex: 1;
}

/* ── Cards ── */
.card-glass {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
  transition: var(--transition);
}

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

.card-header-bar {
  padding: 14px 20px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.card-header-title {
  font-size: 15px;
  font-weight: 600;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: 8px;
}

.card-header-title .title-icon {
  width: 28px; height: 28px;
  background: linear-gradient(135deg, var(--accent), var(--accent-dark));
  border-radius: var(--radius-sm);
  display: flex; align-items: center; justify-content: center;
  font-size: 13px;
}

.record-count {
  font-size: 12px;
  color: var(--text-muted);
  background: #f1f5f9;
  padding: 3px 10px;
  border-radius: 20px;
}

/* ── Filter Bar ── */
.filter-bar {
  padding: 12px 20px;
  background: #fcfcfc;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.filter-bar label {
  font-size: 12px;
  color: var(--text-secondary);
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 6px;
}

.filter-input {
  background: var(--bg-primary);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  padding: 6px 10px;
  font-size: 13px;
  font-family: inherit;
  outline: none;
  transition: var(--transition);
}

.filter-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(79,142,247,0.15);
}

.filter-input[type="date"]::-webkit-calendar-picker-indicator {
  cursor: pointer;
}

.search-box {
  position: relative;
  flex: 1;
  min-width: 200px;
  max-width: 320px;
}

.search-box input {
  width: 100%;
  padding-left: 32px;
}

.search-box .search-icon {
  position: absolute;
  left: 10px; top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  font-size: 13px;
  pointer-events: none;
}

/* ── Buttons ── */
.btn-primary-custom {
  background: linear-gradient(135deg, var(--accent), var(--accent-dark));
  color: #fff;
  border: none;
  border-radius: var(--radius-sm);
  padding: 7px 18px;
  font-size: 13px;
  font-weight: 500;
  font-family: inherit;
  cursor: pointer;
  transition: var(--transition);
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.btn-primary-custom:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 16px rgba(79,142,247,0.4);
}

.btn-secondary-custom {
  background: #ffffff;
  color: var(--text-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 7px 18px;
  font-size: 13px;
  font-weight: 500;
  font-family: inherit;
  cursor: pointer;
  transition: var(--transition);
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.btn-secondary-custom:hover {
  background: #f8fafc;
  border-color: #cbd5e1;
  color: var(--text-primary);
}

/* ── Data Table ── */
.data-table-wrap {
  overflow-x: auto;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13.5px;
}

.data-table thead th {
  background: #f8fafc;
  padding: 11px 16px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
  position: sticky;
  top: 0;
}

.data-table thead th.sortable { cursor: pointer; user-select: none; }
.data-table thead th.sortable:hover { color: var(--accent-light); }

.data-table tbody tr {
  border-bottom: 1px solid #f1f5f9;
  transition: background 0.15s ease;
}

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

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

.data-table td {
  padding: 11px 16px;
  color: var(--text-primary);
  vertical-align: middle;
}

.data-table td.text-right { text-align: right; }
.data-table td.text-center { text-align: center; }

.data-table .amount-cell {
  font-variant-numeric: tabular-nums;
  font-weight: 500;
  text-align: right;
  font-family: 'Inter', monospace;
}

.data-table .amount-dr { color: var(--danger); }
.data-table .amount-cr { color: var(--success); }

.table-link {
  color: var(--accent);
  font-weight: 500;
  transition: var(--transition);
}
.table-link:hover {
  color: var(--accent-light);
  text-decoration: underline;
}

/* ── Empty State ── */
.empty-state {
  padding: 48px 24px;
  text-align: center;
}
.empty-state .empty-icon { font-size: 40px; margin-bottom: 12px; opacity: 0.4; }
.empty-state p { color: var(--text-muted); font-size: 14px; }

/* ── Company List Cards ── */
.company-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 16px;
  padding: 20px;
}

.company-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 18px 20px;
  display: flex;
  align-items: center;
  gap: 16px;
  transition: var(--transition);
  cursor: pointer;
}

.company-card:hover {
  border-color: var(--border-accent);
  background: var(--bg-card-hover);
  box-shadow: var(--shadow-accent);
  transform: translateY(-2px);
}

.company-card-icon {
  width: 44px; height: 44px;
  background: linear-gradient(135deg, var(--accent), var(--accent-dark));
  border-radius: var(--radius-md);
  display: flex; align-items: center; justify-content: center;
  font-size: 18px;
  flex-shrink: 0;
  box-shadow: var(--shadow-accent);
}

.company-card-name {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
  line-height: 1.4;
}

.company-card-period {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 2px;
}

.company-card-num {
  margin-left: auto;
  background: #f1f5f9;
  padding: 3px 8px;
  border-radius: 20px;
  font-size: 11px;
  color: var(--text-muted);
  white-space: nowrap;
}

/* ── Stats Row ── */
.stats-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 14px;
  padding: 0 0 20px;
}

.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 16px 18px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.stat-card .stat-label { font-size: 11px; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.8px; }
.stat-card .stat-value { font-size: 22px; font-weight: 700; color: var(--text-primary); }
.stat-card .stat-sub { font-size: 11px; color: var(--success); }

/* ── Badge ── */
.badge-type {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.badge-sales { background: #dcfce7; color: var(--success); }
.badge-purchase { background: #fef3c7; color: var(--warning); }
.badge-journal { background: #dbeafe; color: var(--accent); }
.badge-payment { background: #fee2e2; color: var(--danger); }
.badge-receipt { background: #dcfce7; color: var(--success); }
.badge-default { background: #f1f5f9; color: var(--text-secondary); }

/* ── Voucher Detail ── */
.voucher-header-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 18px 22px;
  margin-bottom: 16px;
}
.voucher-meta-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 14px;
  margin-top: 12px;
}
.voucher-meta-item .meta-label { font-size: 11px; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.8px; }
.voucher-meta-item .meta-value { font-size: 14px; font-weight: 600; color: var(--text-primary); margin-top: 2px; }

.net-amount-row td {
  font-size: 15px !important;
  font-weight: 700 !important;
  color: var(--accent) !important;
  border-top: 1px solid var(--border) !important;
}

/* ── No sidebar pages (company list) ── */
.full-page-wrap {
  min-height: 100vh;
  padding: 32px 24px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.page-hero {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 20px 0 10px;
}
.page-hero-icon {
  width: 48px; height: 48px;
  background: linear-gradient(135deg, var(--accent), var(--accent-dark));
  border-radius: var(--radius-md);
  display: flex; align-items: center; justify-content: center;
  font-size: 22px;
  box-shadow: var(--shadow-accent);
}
.page-hero-title { font-size: 22px; font-weight: 700; color: var(--text-primary); }
.page-hero-sub { font-size: 13px; color: var(--text-muted); margin-top: 2px; }

/* ── Scrollbar ── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: #94a3b8; }

/* ── Animations ── */
@keyframes fadeInUp {
  from { opacity:0; transform:translateY(16px); }
  to   { opacity:1; transform:translateY(0); }
}
.fade-in-up { animation: fadeInUp 0.35s ease both; }

@keyframes fadeIn {
  from { opacity:0; }
  to   { opacity:1; }
}
.fade-in { animation: fadeIn 0.3s ease both; }

/* ── Responsive ── */
@media (max-width: 768px) {
  .sidebar { transform: translateX(-100%); }
  .app-wrapper { margin-left: 0; }
}

/* ── Override Bootstrap remnants ── */
.container-fluid, .container { max-width: 100%; padding: 0; }
body > header, body > footer { display: none !important; }
body { margin-bottom: 0 !important; }