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

:root {
  --bg-dark: #0f172a;
  --bg-sidebar: #1a1f35;
  --bg-card: #1e293b;
  --bg-card-hover: #263548;
  --bg-input: #0f172a;
  --border: #2d3a50;
  --border-light: #334155;
  --accent: #38bdf8;
  --accent-2: #6366f1;
  --accent-green: #4ade80;
  --accent-orange: #fb923c;
  --accent-red: #f87171;
  --accent-yellow: #fbbf24;
  --text-primary: #e2e8f0;
  --text-secondary: #94a3b8;
  --text-muted: #475569;
  --sidebar-width: 260px;
  --topbar-height: 64px;
  --radius: 10px;
  --radius-lg: 16px;
  --shadow: 0 4px 24px rgba(0,0,0,0.3);
  --transition: all 0.2s ease;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: 'Inter', sans-serif;
  background: var(--bg-dark);
  color: var(--text-primary);
  font-size: 14px;
  line-height: 1.6;
}

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

/* ===== LAYOUT ===== */
.app-layout {
  display: flex;
  min-height: 100vh;
}

/* ===== SIDEBAR ===== */
.sidebar {
  width: var(--sidebar-width);
  background: var(--bg-sidebar);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  z-index: 100;
  transition: var(--transition);
  overflow-y: auto;
}

.sidebar-logo {
  padding: 24px 20px 16px;
  border-bottom: 1px solid var(--border);
}
.sidebar-logo h2 {
  color: var(--accent);
  font-size: 1.1rem;
  font-weight: 700;
  letter-spacing: -0.3px;
}
.sidebar-logo p {
  color: var(--text-muted);
  font-size: 0.72rem;
  margin-top: 2px;
}

.sidebar-nav {
  flex: 1;
  padding: 16px 12px;
}

.nav-section-label {
  color: var(--text-muted);
  font-size: 0.68rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 1px;
  padding: 12px 8px 6px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 12px;
  border-radius: 8px;
  color: var(--text-secondary);
  font-size: 0.88rem;
  font-weight: 500;
  transition: var(--transition);
  margin-bottom: 2px;
  cursor: pointer;
  text-decoration: none;
}
.nav-item:hover {
  background: rgba(56,189,248,0.08);
  color: var(--accent);
  text-decoration: none;
}
.nav-item.active {
  background: rgba(56,189,248,0.15);
  color: var(--accent);
  border-left: 3px solid var(--accent);
}
.nav-item .icon { font-size: 1.1rem; width: 22px; text-align: center; }

.sidebar-footer {
  padding: 16px 12px;
  border-top: 1px solid var(--border);
}
.user-info { display:flex; align-items:center; gap: 10px; }
.user-avatar {
  width: 36px; height: 36px; background: linear-gradient(135deg, var(--accent), var(--accent-2));
  border-radius: 50%; display:flex; align-items:center; justify-content:center;
  font-weight: 700; font-size: 0.85rem; color:#fff; flex-shrink:0;
}
.user-name { font-size: 0.85rem; font-weight: 600; color: var(--text-primary); }
.user-role { font-size: 0.72rem; color: var(--text-muted); }
.logout-btn {
  display: block; margin-top: 10px; padding: 8px 12px; background: rgba(248,113,113,0.1);
  border: 1px solid rgba(248,113,113,0.2); border-radius: 8px; color: #f87171;
  font-size: 0.82rem; font-weight: 500; text-align: center; transition: var(--transition);
  text-decoration: none;
}
.logout-btn:hover { background: rgba(248,113,113,0.2); text-decoration: none; }

/* ===== MAIN CONTENT ===== */
.main-content {
  margin-left: var(--sidebar-width);
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.topbar {
  height: var(--topbar-height);
  background: var(--bg-card);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 28px;
  gap: 16px;
  position: sticky;
  top: 0;
  z-index: 50;
}
.topbar-title {
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--text-primary);
  flex: 1;
}
.topbar-actions { display: flex; gap: 10px; align-items: center; }

.page-content {
  padding: 28px;
  flex: 1;
}

/* ===== CARDS ===== */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 24px;
  box-shadow: var(--shadow);
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 18px;
  margin-bottom: 28px;
}

.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 22px 24px;
  display: flex;
  align-items: center;
  gap: 16px;
  transition: var(--transition);
}
.stat-card:hover { border-color: var(--accent); transform: translateY(-2px); }
.stat-icon {
  width: 50px; height: 50px;
  border-radius: 12px;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.5rem;
  flex-shrink: 0;
}
.stat-icon.blue { background: rgba(56,189,248,0.15); }
.stat-icon.green { background: rgba(74,222,128,0.15); }
.stat-icon.orange { background: rgba(251,146,60,0.15); }
.stat-icon.purple { background: rgba(99,102,241,0.15); }
.stat-icon.red { background: rgba(248,113,113,0.15); }
.stat-value { font-size: 1.8rem; font-weight: 800; color: var(--text-primary); line-height: 1; }
.stat-label { color: var(--text-secondary); font-size: 0.82rem; margin-top: 4px; }

/* ===== BUTTONS ===== */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 9px 18px; border-radius: 8px; font-size: 0.875rem;
  font-weight: 500; cursor: pointer; border: none; font-family: inherit;
  transition: var(--transition); text-decoration: none; line-height: 1.4;
  white-space: nowrap;
}
.btn:hover { text-decoration: none; transform: translateY(-1px); }
.btn-primary { background: linear-gradient(135deg, #0ea5e9, #6366f1); color: #fff; }
.btn-primary:hover { box-shadow: 0 6px 20px rgba(14,165,233,0.4); }
.btn-success { background: linear-gradient(135deg, #10b981, #059669); color: #fff; }
.btn-warning { background: linear-gradient(135deg, #f59e0b, #d97706); color: #fff; }
.btn-danger { background: rgba(248,113,113,0.15); border: 1px solid rgba(248,113,113,0.3); color: #f87171; }
.btn-danger:hover { background: rgba(248,113,113,0.25); box-shadow: none; }
.btn-secondary { background: var(--bg-card-hover); border: 1px solid var(--border); color: var(--text-secondary); }
.btn-secondary:hover { color: var(--text-primary); box-shadow: none; }
.btn-print { background: linear-gradient(135deg, #4ade80, #16a34a); color: #fff; }
.btn-sm { padding: 5px 12px; font-size: 0.8rem; border-radius: 6px; }

/* ===== TABLE ===== */
.table-wrapper {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
}
.table-header {
  padding: 18px 24px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}
.table-header h2 { font-size: 1rem; font-weight: 600; }

.data-table {
  width: 100%;
  border-collapse: collapse;
}
.data-table th {
  background: rgba(15,23,42,0.6);
  padding: 12px 16px;
  text-align: left;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  border-bottom: 1px solid var(--border);
}
.data-table td {
  padding: 14px 16px;
  border-bottom: 1px solid rgba(45,58,80,0.5);
  color: var(--text-primary);
  font-size: 0.875rem;
}
.data-table tr:last-child td { border-bottom: none; }
.data-table tr:hover td { background: rgba(56,189,248,0.04); }
.data-table .actions { display: flex; gap: 6px; flex-wrap: wrap; }

/* ===== STATUS BADGE ===== */
.badge {
  display: inline-block; padding: 3px 10px; border-radius: 20px;
  font-size: 0.72rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.5px;
}
.badge-draft { background: rgba(100,116,139,0.2); color: #94a3b8; }
.badge-sent { background: rgba(56,189,248,0.15); color: #38bdf8; }
.badge-accepted { background: rgba(74,222,128,0.15); color: #4ade80; }
.badge-declined { background: rgba(248,113,113,0.15); color: #f87171; }
.badge-paid { background: rgba(74,222,128,0.15); color: #4ade80; }
.badge-unpaid { background: rgba(251,146,60,0.15); color: #fb923c; }
.badge-partial { background: rgba(251,191,36,0.15); color: #fbbf24; }
.badge-overdue { background: rgba(248,113,113,0.15); color: #f87171; }

/* ===== FORM ===== */
.form-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 28px;
  margin-bottom: 20px;
}
.form-card h3 {
  font-size: 0.95rem; font-weight: 600; color: var(--text-secondary);
  margin-bottom: 20px; padding-bottom: 12px; border-bottom: 1px solid var(--border);
  display: flex; align-items: center; gap: 8px;
}
.form-row { display: grid; gap: 18px; }
.form-row.cols-2 { grid-template-columns: repeat(2, 1fr); }
.form-row.cols-3 { grid-template-columns: repeat(3, 1fr); }
.form-row.cols-4 { grid-template-columns: repeat(4, 1fr); }
.form-group { display: flex; flex-direction: column; gap: 6px; }
.form-group label {
  font-size: 0.8rem; font-weight: 500; color: var(--text-secondary);
  text-transform: uppercase; letter-spacing: 0.4px;
}
.form-group input, .form-group select, .form-group textarea {
  padding: 10px 14px; background: var(--bg-input);
  border: 1px solid var(--border-light); border-radius: 8px;
  color: var(--text-primary); font-size: 0.9rem; font-family: inherit;
  transition: var(--transition); outline: none; width: 100%;
}
.form-group input:focus, .form-group select:focus, .form-group textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(56,189,248,0.1);
}
.form-group textarea { resize: vertical; min-height: 90px; }
.form-group select option { background: var(--bg-dark); }

/* ===== LINE ITEMS TABLE ===== */
.line-items-section {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow-x: auto;
  margin-bottom:20px;
}
.line-items-section .section-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  font-weight: 600; font-size: 0.9rem;
  display:flex; justify-content:space-between; align-items:center;
}
.line-table { width: 100%; border-collapse: collapse; }
.line-table th {
  background: rgba(15,23,42,0.6);
  padding: 10px 12px;
  text-align:left; font-size:0.72rem;
  font-weight:600; color:var(--text-muted);
  text-transform:uppercase; letter-spacing:0.4px;
  border-bottom: 1px solid var(--border);
}
.line-table td {
  padding: 6px 8px;
  border-bottom: 1px solid rgba(45,58,80,0.4);
  vertical-align: middle;
}
.line-table tr:last-child td { border-bottom: none; }
.line-table input, .line-table select {
  width:100%; padding: 7px 10px;
  background: var(--bg-input); border: 1px solid var(--border-light);
  border-radius: 6px; color:var(--text-primary); font-size:0.85rem;
  font-family: inherit; outline:none; transition:var(--transition);
}
.line-table input:focus, .line-table select:focus {
  border-color:var(--accent);
  box-shadow: 0 0 0 2px rgba(56,189,248,0.1);
}
.line-table textarea {
  width:100%; padding: 7px 10px; min-width: 250px;
  background: var(--bg-input); border: 1px solid var(--border-light);
  border-radius: 6px; color:var(--text-primary); font-size:0.85rem;
  font-family: inherit; outline:none; resize:vertical; min-height:52px;
}

/* Ensure text inputs don't squeeze too small */
.line-table input[type="text"], .line-table input[type="date"] {
  min-width: 80px;
}

/* Hide number input spinners globally */
input[type="number"]::-webkit-inner-spin-button,
input[type="number"]::-webkit-outer-spin-button {
  -webkit-appearance: none;
  margin: 0;
}
input[type="number"] {
  -moz-appearance: textfield;
  appearance: textfield;
}

/* Adjust sizes for Qty, Rate, and Amount fields */
.line-table input.qty-input,
.line-table input.rate-input,
.line-table input.amount-input {
  font-size: 0.95rem;
  padding: 10px 12px;
  text-align: right;
}

.btn-remove-row {
  background: rgba(248,113,113,0.1); border:1px solid rgba(248,113,113,0.2);
  color:#f87171; border-radius:5px; cursor:pointer; padding:5px 8px;
  font-size:0.8rem; transition:var(--transition); font-family:inherit;
  white-space:nowrap;
}
.btn-remove-row:hover { background:rgba(248,113,113,0.2); }
.line-items-footer {
  padding: 16px 20px;
  display:flex; justify-content:flex-end;
}

/* ===== TOTALS ===== */
.totals-box {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px 24px;
  margin-bottom: 20px;
  min-width: 280px;
  width: 100%;
}
.totals-row {
  display:flex; justify-content:space-between;
  padding: 8px 0; border-bottom: 1px solid var(--border);
  font-size:0.9rem;
}
.totals-row:last-child { border-bottom: none; }
.totals-row.grand {
  font-weight:700; font-size:1.1rem; color:var(--accent);
  padding-top: 12px; margin-top:4px;
}
.totals-row label { color:var(--text-secondary); }
.totals-row .form-group { margin:0; }
.totals-row input {
  width:120px; padding:5px 8px;
  background:var(--bg-input); border:1px solid var(--border-light);
  border-radius:6px; color:var(--text-primary); font-size:0.9rem;
  text-align:right; font-family:inherit;
}

/* ===== SEARCH BAR ===== */
.search-bar {
  padding: 10px 14px; background: var(--bg-input);
  border: 1px solid var(--border-light); border-radius: 8px;
  color: var(--text-primary); font-size:0.875rem; font-family:inherit;
  outline:none; min-width:220px; transition:var(--transition);
}
.search-bar:focus { border-color:var(--accent); box-shadow: 0 0 0 3px rgba(56,189,248,0.1); }

/* ===== ALERTS ===== */
.alert {
  padding: 12px 16px; border-radius: 8px; margin-bottom:20px; font-size:0.9rem;
}
.alert-success { background:rgba(74,222,128,0.1); border:1px solid rgba(74,222,128,0.2); color:#4ade80; }
.alert-error { background:rgba(248,113,113,0.1); border:1px solid rgba(248,113,113,0.2); color:#f87171; }
.alert-info { background:rgba(56,189,248,0.1); border:1px solid rgba(56,189,248,0.2); color:#38bdf8; }

/* ===== EMPTY STATE ===== */
.empty-state {
  text-align:center; padding: 50px 20px; color:var(--text-muted);
}
.empty-state .icon { font-size:3rem; margin-bottom:12px; opacity:0.5; }
.empty-state p { font-size:0.9rem; }

/* ===== RESPONSIVE ===== */
@media (max-width: 768px) {
  .sidebar { transform: translateX(-100%); }
  .main-content { margin-left: 0; }
  .form-row.cols-2, .form-row.cols-3, .form-row.cols-4 { grid-template-columns: 1fr; }
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
}

/* ===== UTILITY ===== */
.text-right { text-align:right; }
.text-center { text-align:center; }
.clearfix::after { content:''; display:table; clear:both; }
.mt-0 { margin-top:0; }
.mb-16 { margin-bottom:16px; }
.mb-20 { margin-bottom:20px; }
.flex { display:flex; }
.gap-10 { gap:10px; }
.items-center { align-items:center; }
.justify-between { justify-content:space-between; }
.flex-wrap { flex-wrap:wrap; }

/* ===== MODAL ===== */
.modal-overlay {
  display: none; position: fixed; top: 0; left: 0; width: 100%; height: 100%;
  background: rgba(0,0,0,0.7); z-index: 1000; justify-content: center; align-items: center;
  backdrop-filter: blur(2px);
}
.modal-overlay.active { display: flex; }
.modal-content {
  background: var(--bg-card); border-radius: var(--radius-lg);
  padding: 30px; width: 90%; max-width: 500px; position: relative;
  box-shadow: 0 20px 60px rgba(0,0,0,0.5); border: 1px solid var(--border);
  animation: modalIn 0.2s ease-out forwards;
}
@keyframes modalIn {
  from { opacity: 0; transform: scale(0.95); }
  to { opacity: 1; transform: scale(1); }
}
.modal-close {
  position: absolute; top: 20px; right: 20px; background: none; border: none;
  color: var(--text-muted); font-size: 1.5rem; cursor: pointer; transition: 0.2s;
  line-height:1;
}
.modal-close:hover { color: var(--text-primary); }
