/* InvoiceBeast — App Styles */
/* Navy (#1e293b) + Orange (#f97316) + White */

:root {
  --navy: #1e293b;
  --navy-light: #334155;
  --orange: #f97316;
  --orange-hover: #ea580c;
  --green: #22c55e;
  --red: #ef4444;
  --gray-50: #f8fafc;
  --gray-100: #f1f5f9;
  --gray-200: #e2e8f0;
  --gray-300: #cbd5e1;
  --gray-400: #94a3b8;
  --gray-500: #64748b;
  --gray-600: #475569;
  --gray-700: #334155;
  --radius: 8px;
  --shadow: 0 1px 3px rgba(0,0,0,0.08), 0 1px 2px rgba(0,0,0,0.06);
  --shadow-md: 0 4px 6px rgba(0,0,0,0.07), 0 2px 4px rgba(0,0,0,0.06);
}

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: var(--gray-50);
  color: var(--navy);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

/* === LAYOUT === */
.app-shell {
  display: flex;
  min-height: 100vh;
}

.sidebar-wrapper {
  width: 250px;
  flex-shrink: 0;
  background: var(--navy);
  color: white;
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  z-index: 100;
  transition: transform 0.3s ease;
}

.sidebar {
  display: flex;
  flex-direction: column;
  height: 100%;
  padding: 20px 0;
}

.sidebar-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 20px 24px;
  border-bottom: 1px solid rgba(255,255,255,0.1);
  margin-bottom: 12px;
}

.logo-icon { font-size: 28px; }
.logo-text { font-size: 20px; font-weight: 700; }

.sidebar-nav {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 0 8px;
}

.nav-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 6px;
  color: rgba(255,255,255,0.7);
  text-decoration: none;
  font-size: 14px;
  font-weight: 500;
  transition: all 0.15s;
}

.nav-link:hover { background: rgba(255,255,255,0.08); color: white; }
.nav-link.active { background: var(--orange); color: white; }
.nav-icon { font-size: 18px; width: 24px; text-align: center; }

.sidebar-footer {
  padding: 16px 20px;
  border-top: 1px solid rgba(255,255,255,0.1);
}

.user-email {
  font-size: 12px;
  color: rgba(255,255,255,0.5);
  margin-bottom: 8px;
  overflow: hidden;
  text-overflow: ellipsis;
}

.main-content {
  flex: 1;
  margin-left: 250px;
  min-height: 100vh;
}

.mobile-header {
  display: none;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  background: var(--navy);
  color: white;
  position: sticky;
  top: 0;
  z-index: 50;
}

.menu-btn {
  background: none;
  border: none;
  color: white;
  font-size: 24px;
  cursor: pointer;
  padding: 4px;
}

.mobile-logo { font-size: 16px; font-weight: 700; }

.overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 99;
}

.page-content {
  padding: 24px;
  max-width: 1100px;
  margin: 0 auto;
}

/* === RESPONSIVE === */
@media (max-width: 768px) {
  .sidebar-wrapper {
    transform: translateX(-100%);
  }
  .sidebar-wrapper.open {
    transform: translateX(0);
  }
  .main-content { margin-left: 0; }
  .mobile-header { display: flex; }
  .overlay { display: block; }
  .page-content { padding: 16px; }
  .form-row { flex-direction: column; }
  .stat-cards { flex-direction: column; }
  .invoice-detail-header { flex-direction: column; gap: 16px; }
  .invoice-actions { flex-wrap: wrap; }
  .line-item { flex-wrap: wrap; }
  .item-desc { width: 100%; }
}

/* === PAGE HEADER === */
.page-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 24px;
  flex-wrap: wrap;
  gap: 12px;
}

.page-header h1 { font-size: 24px; font-weight: 700; }

/* === BUTTONS === */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 10px 20px;
  border-radius: var(--radius);
  border: none;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
  text-decoration: none;
  white-space: nowrap;
}

.btn:disabled { opacity: 0.6; cursor: not-allowed; }
.btn-primary { background: var(--orange); color: white; }
.btn-primary:hover:not(:disabled) { background: var(--orange-hover); }
.btn-success { background: var(--green); color: white; }
.btn-success:hover:not(:disabled) { background: #16a34a; }
.btn-danger { background: var(--red); color: white; }
.btn-danger:hover:not(:disabled) { background: #dc2626; }
.btn-outline { background: white; color: var(--navy); border: 1px solid var(--gray-200); }
.btn-outline:hover { border-color: var(--gray-300); background: var(--gray-50); }
.btn-ghost { background: none; color: var(--gray-500); }
.btn-ghost:hover { color: var(--navy); }
.btn-sm { padding: 6px 12px; font-size: 13px; }
.btn-block { width: 100%; justify-content: center; }

/* === CARDS === */
.card {
  background: white;
  border-radius: var(--radius);
  border: 1px solid var(--gray-200);
  padding: 24px;
  box-shadow: var(--shadow);
}

.card-title {
  font-size: 16px;
  font-weight: 600;
  margin-bottom: 4px;
}

/* === STAT CARDS === */
.stat-cards {
  display: flex;
  gap: 16px;
  margin-bottom: 24px;
}

.stat-card {
  flex: 1;
  background: white;
  border-radius: var(--radius);
  border: 1px solid var(--gray-200);
  border-left: 4px solid;
  padding: 20px;
  display: flex;
  align-items: center;
  gap: 16px;
  box-shadow: var(--shadow);
}

.stat-icon { font-size: 28px; }
.stat-label { font-size: 13px; color: var(--gray-500); font-weight: 500; }
.stat-amount { font-size: 24px; font-weight: 700; font-variant-numeric: tabular-nums; }
.stat-count { font-size: 12px; color: var(--gray-400); }

/* === TABLES === */
.table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

.table th {
  text-align: left;
  padding: 10px 12px;
  border-bottom: 2px solid var(--gray-200);
  font-weight: 600;
  color: var(--gray-600);
  font-size: 13px;
}

.table td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--gray-100);
}

.clickable-row { cursor: pointer; transition: background 0.15s; }
.clickable-row:hover { background: var(--gray-50); }

/* === BADGES === */
.badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 600;
  text-transform: capitalize;
}

.badge-draft { background: var(--gray-100); color: var(--gray-600); }
.badge-sent { background: #dbeafe; color: #1d4ed8; }
.badge-paid { background: #dcfce7; color: #15803d; }
.badge-overdue { background: #fef2f2; color: #dc2626; }
.badge-trial { background: #fef3c7; color: #92400e; }
.badge-active { background: #dcfce7; color: #15803d; }

/* === FORMS === */
.form-row {
  display: flex;
  gap: 16px;
}

.form-row .form-group { flex: 1; }

.form-group {
  margin-bottom: 16px;
}

.form-group label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--gray-600);
  margin-bottom: 4px;
}

.input {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--gray-200);
  border-radius: 6px;
  font-size: 14px;
  font-family: inherit;
  transition: border-color 0.15s;
  background: white;
}

.input:focus {
  outline: none;
  border-color: var(--orange);
  box-shadow: 0 0 0 3px rgba(249,115,22,0.1);
}

select.input { cursor: pointer; }
textarea.input { resize: vertical; }

/* === LINE ITEMS === */
.line-items {
  margin-bottom: 12px;
}

.line-item {
  display: flex;
  gap: 8px;
  align-items: center;
  margin-bottom: 8px;
}

.item-desc { flex: 3; }
.item-qty { flex: 0.7; text-align: center; }
.item-rate { flex: 1; }
.item-total { flex: 1; text-align: right; font-weight: 600; font-variant-numeric: tabular-nums; color: var(--gray-600); min-width: 80px; }

.section-title {
  font-size: 15px;
  font-weight: 600;
  margin: 16px 0 12px;
  color: var(--gray-700);
}

/* === INVOICE TOTALS === */
.invoice-totals {
  text-align: right;
  margin-top: 16px;
  padding-top: 12px;
  border-top: 1px solid var(--gray-200);
  font-size: 14px;
  line-height: 2;
}

.total-line {
  font-size: 20px;
  color: var(--orange);
  padding-top: 4px;
  border-top: 2px solid var(--gray-200);
  margin-top: 4px;
}

/* === INVOICE DETAIL === */
.invoice-actions {
  display: flex;
  gap: 8px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}

.invoice-detail-header {
  display: flex;
  justify-content: space-between;
  margin-bottom: 24px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--gray-200);
}

.invoice-meta {
  text-align: right;
  font-size: 14px;
  line-height: 1.8;
}

.bill-to {
  margin-bottom: 20px;
  font-size: 14px;
  line-height: 1.8;
}

.invoice-notes {
  margin-top: 16px;
  padding-top: 12px;
  border-top: 1px solid var(--gray-200);
  font-size: 14px;
  color: var(--gray-600);
}

/* === FILTER BAR === */
.filter-bar {
  display: flex;
  gap: 6px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

.filter-btn {
  padding: 6px 14px;
  border-radius: 20px;
  border: 1px solid var(--gray-200);
  background: white;
  color: var(--gray-600);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s;
}

.filter-btn:hover { border-color: var(--gray-300); }
.filter-btn.active { background: var(--navy); color: white; border-color: var(--navy); }

/* === LOGIN === */
.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, var(--navy) 0%, #0f172a 100%);
  padding: 20px;
}

.login-card {
  background: white;
  border-radius: 12px;
  padding: 40px;
  width: 100%;
  max-width: 400px;
  text-align: center;
  box-shadow: 0 20px 40px rgba(0,0,0,0.2);
}

.login-logo { font-size: 48px; margin-bottom: 16px; }
.login-card h1 { font-size: 24px; margin-bottom: 4px; }
.login-subtitle { color: var(--gray-500); font-size: 14px; margin-bottom: 24px; }
.login-card form { text-align: left; }
.login-card .input { margin-bottom: 12px; }

.magic-link-box {
  background: var(--gray-50);
  border: 1px solid var(--gray-200);
  border-radius: var(--radius);
  padding: 16px;
  margin-top: 16px;
}

/* === EMPTY STATES === */
.empty-state { text-align: center; color: var(--gray-400); padding: 20px; }

.empty-state-box {
  text-align: center;
  padding: 60px 20px;
  background: white;
  border-radius: var(--radius);
  border: 2px dashed var(--gray-200);
}

.empty-icon { font-size: 48px; margin-bottom: 12px; opacity: 0.5; }
.empty-state-box p { color: var(--gray-500); margin-bottom: 16px; }

/* === LOADING === */
.loading {
  text-align: center;
  padding: 40px;
  color: var(--gray-400);
  font-size: 14px;
}

.loading-screen {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: var(--gray-50);
  color: var(--gray-400);
  gap: 16px;
}

/* === TOAST === */
.toast-container {
  position: fixed;
  top: 16px;
  right: 16px;
  z-index: 1000;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.toast {
  padding: 12px 20px;
  border-radius: var(--radius);
  font-size: 14px;
  font-weight: 500;
  box-shadow: var(--shadow-md);
  animation: slideIn 0.3s ease;
  max-width: 360px;
}

.toast-success { background: var(--green); color: white; }
.toast-error { background: var(--red); color: white; }

@keyframes slideIn {
  from { transform: translateX(100%); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}

/* === UTILITIES === */
.text-muted { color: var(--gray-500); font-size: 13px; }
.font-mono { font-family: 'JetBrains Mono', 'Fira Code', monospace; font-size: 13px; }
