/* assets/css/app.css — Invoice App Styles */
@import url('https://fonts.googleapis.com/css2?family=DM+Sans:wght@300;400;500;600&family=DM+Mono:wght@400;500&display=swap');

:root {
  --primary: #1a1a2e;
  --primary-light: #16213e;
  --accent: #e94560;
  --accent-hover: #c73652;
  --success: #0f9b58;
  --success-bg: #e8f8f0;
  --warning: #d97706;
  --warning-bg: #fef3c7;
  --danger: #dc2626;
  --danger-bg: #fee2e2;
  --info: #2563eb;
  --info-bg: #dbeafe;
  --bg: #f8f7f4;
  --bg-white: #ffffff;
  --border: #e5e2db;
  --border-strong: #d1cec6;
  --text: #1a1a1a;
  --text-muted: #6b6760;
  --text-light: #9c9894;
  --sidebar-w: 240px;
  --radius: 8px;
  --radius-lg: 12px;
  --shadow: 0 1px 3px rgba(0,0,0,0.08), 0 1px 2px rgba(0,0,0,0.04);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.08);
}

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

body {
  font-family: 'DM Sans', sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
  line-height: 1.6;
  min-height: 100vh;
}

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

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

.sidebar {
  width: var(--sidebar-w);
  background: var(--primary);
  color: #e8e6e0;
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  z-index: 100;
  overflow-y: auto;
}

.sidebar-brand {
  padding: 1.5rem 1.25rem 1rem;
  border-bottom: 1px solid rgba(255,255,255,0.06);
}

.sidebar-brand .brand-name {
  font-size: 18px;
  font-weight: 600;
  color: #fff;
  letter-spacing: -0.3px;
}

.sidebar-brand .brand-sub {
  font-size: 11px;
  color: rgba(255,255,255,0.35);
  margin-top: 2px;
  font-family: 'DM Mono', monospace;
}

.sidebar-nav { padding: 1rem 0; flex: 1; }

.nav-section-label {
  font-size: 10px;
  font-weight: 500;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: rgba(255,255,255,0.25);
  padding: 0.75rem 1.25rem 0.25rem;
}

.sidebar-nav a {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0.6rem 1.25rem;
  color: rgba(255,255,255,0.6);
  font-size: 14px;
  font-weight: 400;
  transition: all 0.15s;
  border-left: 3px solid transparent;
  text-decoration: none;
}

.sidebar-nav a:hover, .sidebar-nav a.active {
  color: #fff;
  background: rgba(255,255,255,0.06);
  border-left-color: var(--accent);
}

.sidebar-nav a .nav-icon { width: 16px; height: 16px; opacity: 0.7; flex-shrink: 0; }
.sidebar-nav a.active .nav-icon, .sidebar-nav a:hover .nav-icon { opacity: 1; }

.sidebar-footer {
  padding: 1rem 1.25rem;
  border-top: 1px solid rgba(255,255,255,0.06);
  font-size: 13px;
  color: rgba(255,255,255,0.4);
}

.sidebar-footer strong { color: rgba(255,255,255,0.7); display: block; font-weight: 500; }

.main-content {
  margin-left: var(--sidebar-w);
  flex: 1;
  display: flex;
  flex-direction: column;
}

.topbar {
  background: var(--bg-white);
  border-bottom: 1px solid var(--border);
  padding: 0 2rem;
  height: 56px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 50;
}

.topbar-title { font-size: 16px; font-weight: 500; color: var(--text); }

.topbar-actions { display: flex; align-items: center; gap: 0.75rem; }

.page-body { padding: 2rem; flex: 1; }

/* ── Auth Pages ── */
.auth-page {
  min-height: 100vh;
  background: var(--primary);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2rem;
}

.auth-card {
  background: var(--bg-white);
  border-radius: var(--radius-lg);
  padding: 2.5rem;
  width: 100%;
  max-width: 420px;
  box-shadow: var(--shadow-md);
}

.auth-logo {
  font-size: 22px;
  font-weight: 600;
  color: var(--primary);
  margin-bottom: 0.25rem;
}

.auth-tagline { font-size: 13px; color: var(--text-muted); margin-bottom: 2rem; }

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

.card-header {
  padding: 1rem 1.5rem;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.card-title { font-size: 15px; font-weight: 500; color: var(--text); }
.card-body { padding: 1.5rem; }

/* ── Stat Cards ── */
.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 1rem; margin-bottom: 2rem; }

.stat-card {
  background: var(--bg-white);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.25rem 1.5rem;
  box-shadow: var(--shadow);
}

.stat-label { font-size: 12px; color: var(--text-muted); font-weight: 500; text-transform: uppercase; letter-spacing: 0.04em; margin-bottom: 0.4rem; }
.stat-value { font-size: 26px; font-weight: 600; color: var(--text); font-family: 'DM Mono', monospace; }
.stat-value.green { color: var(--success); }
.stat-value.red { color: var(--danger); }
.stat-value.orange { color: var(--warning); }

/* ── Tables ── */
.table-wrap { overflow-x: auto; }

table { width: 100%; border-collapse: collapse; font-size: 14px; }
thead th {
  text-align: left;
  padding: 0.6rem 1rem;
  font-size: 11px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border);
  background: #faf9f7;
}

tbody td {
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--border);
  color: var(--text);
  vertical-align: middle;
}

tbody tr:last-child td { border-bottom: none; }
tbody tr:hover { background: #faf9f7; }

/* ── Forms ── */
.form-group { margin-bottom: 1.25rem; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
.form-row-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 1rem; }

label {
  display: block;
  font-size: 13px;
  font-weight: 500;
  color: var(--text);
  margin-bottom: 0.35rem;
}

input[type="text"],
input[type="email"],
input[type="password"],
input[type="number"],
input[type="date"],
input[type="tel"],
select,
textarea {
  width: 100%;
  padding: 0.55rem 0.875rem;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  font-size: 14px;
  font-family: 'DM Sans', sans-serif;
  color: var(--text);
  background: var(--bg-white);
  transition: border-color 0.15s, box-shadow 0.15s;
  outline: none;
}

input:focus, select:focus, textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(233,69,96,0.1);
}

textarea { resize: vertical; min-height: 80px; }
select { cursor: pointer; }

.input-hint { font-size: 12px; color: var(--text-light); margin-top: 0.25rem; }

/* ── Buttons ── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 0.5rem 1.125rem;
  border-radius: var(--radius);
  font-size: 14px;
  font-weight: 500;
  font-family: 'DM Sans', sans-serif;
  cursor: pointer;
  border: 1px solid transparent;
  transition: all 0.15s;
  text-decoration: none;
  white-space: nowrap;
}

.btn:hover { text-decoration: none; }

.btn-primary { background: var(--accent); color: #fff; border-color: var(--accent); }
.btn-primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }

.btn-secondary { background: var(--bg-white); color: var(--text); border-color: var(--border-strong); }
.btn-secondary:hover { background: var(--bg); }

.btn-danger { background: var(--danger-bg); color: var(--danger); border-color: #fca5a5; }
.btn-danger:hover { background: #fee2e2; }

.btn-success { background: var(--success-bg); color: var(--success); border-color: #6ee7b7; }
.btn-success:hover { background: #d1fae5; }

.btn-sm { padding: 0.3rem 0.75rem; font-size: 13px; }
.btn-icon { padding: 0.4rem 0.5rem; }

/* ── Badges ── */
.badge {
  display: inline-block;
  padding: 0.2rem 0.65rem;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.02em;
}

.badge-draft   { background: #f3f0eb; color: #78716c; }
.badge-sent    { background: var(--info-bg); color: var(--info); }
.badge-paid    { background: var(--success-bg); color: var(--success); }
.badge-overdue { background: var(--danger-bg); color: var(--danger); }

/* ── Alerts / Flash ── */
.alert {
  padding: 0.75rem 1rem;
  border-radius: var(--radius);
  font-size: 14px;
  margin-bottom: 1.25rem;
  border: 1px solid transparent;
}

.alert-success { background: var(--success-bg); color: #065f3c; border-color: #6ee7b7; }
.alert-error   { background: var(--danger-bg); color: #991b1b; border-color: #fca5a5; }
.alert-info    { background: var(--info-bg); color: #1e40af; border-color: #93c5fd; }

/* ── Line Items ── */
.items-table { width: 100%; border-collapse: collapse; }

.items-table th {
  font-size: 12px;
  font-weight: 500;
  color: var(--text-muted);
  text-align: left;
  padding: 0.4rem 0.6rem;
  border-bottom: 1px solid var(--border);
}

.items-table td { padding: 0.4rem 0.4rem; vertical-align: middle; }

.items-table input {
  padding: 0.4rem 0.6rem;
  font-size: 13px;
  border: 1px solid var(--border);
  border-radius: 6px;
}

.items-table input:focus { border-color: var(--accent); }

.remove-row {
  background: none;
  border: none;
  color: var(--text-light);
  cursor: pointer;
  font-size: 18px;
  padding: 0.2rem 0.4rem;
  line-height: 1;
  border-radius: 4px;
  transition: color 0.15s;
}
.remove-row:hover { color: var(--danger); }

.totals-box {
  background: #faf9f7;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem 1.25rem;
  max-width: 320px;
  margin-left: auto;
  margin-top: 1rem;
}

.totals-row {
  display: flex;
  justify-content: space-between;
  font-size: 14px;
  padding: 0.3rem 0;
  color: var(--text-muted);
}

.totals-row.grand {
  border-top: 1px solid var(--border-strong);
  margin-top: 0.5rem;
  padding-top: 0.6rem;
  font-size: 17px;
  font-weight: 600;
  color: var(--text);
  font-family: 'DM Mono', monospace;
}

/* ── Invoice/Receipt print view ── */
.invoice-doc {
  background: var(--bg-white);
  max-width: 760px;
  margin: 0 auto;
  padding: 3rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
}

.invoice-header { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 3rem; }
.invoice-logo { max-height: 60px; max-width: 180px; object-fit: contain; }
.invoice-company { font-size: 22px; font-weight: 600; color: var(--primary); }
.invoice-number-block { text-align: right; }
.invoice-number-block .num { font-size: 22px; font-weight: 600; color: var(--accent); font-family: 'DM Mono', monospace; }
.invoice-number-block .status-large { margin-top: 0.5rem; }

.invoice-parties { display: grid; grid-template-columns: 1fr 1fr; gap: 2rem; margin-bottom: 2rem; }
.invoice-party-label { font-size: 10px; font-weight: 500; text-transform: uppercase; letter-spacing: 0.08em; color: var(--text-muted); margin-bottom: 0.4rem; }
.invoice-party-name { font-size: 16px; font-weight: 600; color: var(--text); }
.invoice-party-detail { font-size: 13px; color: var(--text-muted); margin-top: 0.2rem; }

.invoice-meta { display: flex; gap: 2rem; padding: 1rem 0; border-top: 1px solid var(--border); border-bottom: 1px solid var(--border); margin-bottom: 2rem; }
.invoice-meta-item { font-size: 13px; }
.invoice-meta-item .meta-label { color: var(--text-muted); font-size: 11px; text-transform: uppercase; letter-spacing: 0.05em; }
.invoice-meta-item .meta-val { font-weight: 500; }

.invoice-items-table { width: 100%; border-collapse: collapse; margin-bottom: 1.5rem; }
.invoice-items-table th { font-size: 11px; font-weight: 500; text-transform: uppercase; letter-spacing: 0.06em; color: var(--text-muted); padding: 0.5rem 0.75rem; border-bottom: 2px solid var(--border); text-align: left; }
.invoice-items-table th:last-child, .invoice-items-table td:last-child { text-align: right; }
.invoice-items-table td { padding: 0.75rem 0.75rem; border-bottom: 1px solid var(--border); font-size: 14px; }
.invoice-items-table tbody tr:last-child td { border-bottom: none; }

.invoice-totals { max-width: 280px; margin-left: auto; }
.invoice-totals-row { display: flex; justify-content: space-between; font-size: 14px; padding: 0.3rem 0; color: var(--text-muted); }
.invoice-totals-row.grand { border-top: 2px solid var(--primary); margin-top: 0.5rem; padding-top: 0.75rem; font-size: 18px; font-weight: 700; color: var(--primary); }

.invoice-notes { margin-top: 2rem; padding-top: 1.5rem; border-top: 1px solid var(--border); }
.invoice-notes-label { font-size: 11px; font-weight: 500; text-transform: uppercase; letter-spacing: 0.06em; color: var(--text-muted); margin-bottom: 0.4rem; }

.paid-stamp {
  display: inline-block;
  border: 3px solid var(--success);
  color: var(--success);
  border-radius: var(--radius);
  padding: 0.2rem 0.8rem;
  font-size: 20px;
  font-weight: 700;
  letter-spacing: 0.1em;
  transform: rotate(-8deg);
  opacity: 0.85;
}

/* ── Page header ── */
.page-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 1.75rem; }
.page-header h1 { font-size: 22px; font-weight: 600; color: var(--text); }
.page-header p { font-size: 13px; color: var(--text-muted); margin-top: 0.2rem; }

/* ── Search / Filter bar ── */
.filter-bar { display: flex; gap: 0.75rem; margin-bottom: 1.25rem; align-items: center; flex-wrap: wrap; }
.filter-bar input, .filter-bar select { width: auto; flex: 1; min-width: 160px; }

/* ── Misc ── */
.divider { border: none; border-top: 1px solid var(--border); margin: 1.5rem 0; }
.text-muted { color: var(--text-muted); }
.text-sm { font-size: 13px; }
.mt-1 { margin-top: 0.5rem; }
.mt-2 { margin-top: 1rem; }
.mt-3 { margin-top: 1.5rem; }
.mb-1 { margin-bottom: 0.5rem; }
.mb-2 { margin-bottom: 1rem; }
.mb-3 { margin-bottom: 1.5rem; }
.text-right { text-align: right; }
.mono { font-family: 'DM Mono', monospace; }
.actions { display: flex; gap: 0.4rem; align-items: center; }
.empty-state { text-align: center; padding: 3rem 1rem; color: var(--text-muted); }
.empty-state .empty-icon { font-size: 40px; margin-bottom: 0.75rem; opacity: 0.4; }
.empty-state p { font-size: 14px; }

/* ── Logo upload preview ── */
.logo-preview { width: 120px; height: 60px; object-fit: contain; border: 1px solid var(--border); border-radius: var(--radius); padding: 4px; display: block; margin-bottom: 0.5rem; }

/* ── Print ── */
@media print {
  .sidebar, .topbar, .page-header .btn, .no-print, .topbar-actions { display: none !important; }
  .main-content { margin-left: 0 !important; }
  .page-body { padding: 0 !important; }
  .invoice-doc { border: none; box-shadow: none; padding: 0; max-width: 100%; }
  body { background: white; font-size: 12pt; }
  .card { box-shadow: none; border: none; }
  a { color: inherit; text-decoration: none; }
}

/* ── Responsive ── */
@media (max-width: 768px) {
  :root { --sidebar-w: 0px; }
  .sidebar { transform: translateX(-240px); transition: transform 0.25s; }
  .sidebar.open { transform: translateX(0); width: 240px; }
  .main-content { margin-left: 0; }
  .form-row, .form-row-3 { grid-template-columns: 1fr; }
  .invoice-header { flex-direction: column; gap: 1rem; }
  .invoice-header .invoice-number-block { text-align: left; }
  .invoice-parties { grid-template-columns: 1fr; gap: 1rem; }
  .stats-grid { grid-template-columns: 1fr 1fr; }
}
