/* ==========================================================================
   Car Emporium Billing - Responsive Desktop & Mobile Design System
   Red, White & Black PDF Invoice Theme with Logo & Cache Control
   ========================================================================== */

@import url('https://fonts.googleapis.com/css2?family=Plus+Jakarta+Sans:wght@400;500;600;700;800&family=Outfit:wght@500;600;700;800&display=swap');

:root {
  /* Colors */
  --bg-app: #f4f6fb;
  --bg-card: #ffffff;
  --text-dark: #0f172a;
  --text-muted: #64748b;
  --text-light: #94a3b8;
  --border-light: #e2e8f0;

  /* Quick Access Tile Colors */
  --qa-blue-bg: #e0f2fe;
  --qa-blue-icon: #0284c7;
  --qa-green-bg: #dcfce7;
  --qa-green-icon: #16a34a;
  --qa-purple-bg: #f3e8ff;
  --qa-purple-icon: #9333ea;
  --qa-pink-bg: #fce7f3;
  --qa-pink-icon: #db2777;

  /* Status Colors */
  --status-paid: #10b981;
  --status-paid-bg: #ecfdf5;
  --status-unpaid: #f59e0b;
  --status-unpaid-bg: #fffbe6;
  --status-overdue: #ef4444;
  --status-overdue-bg: #fef2f2;

  /* Red, White & Black PDF Theme */
  --brand-red: #dc2626;
  --brand-black: #111827;
  --brand-gray: #4b5563;
  --brand-white: #ffffff;

  /* Geometry & Typography */
  --font-main: 'Plus Jakarta Sans', sans-serif;
  --font-heading: 'Outfit', sans-serif;
  --radius-xl: 20px;
  --radius-lg: 14px;
  --radius-md: 10px;
  --radius-sm: 6px;
  --shadow-sm: 0 2px 10px rgba(0, 0, 0, 0.04);
  --shadow-md: 0 8px 24px rgba(0, 0, 0, 0.06);
  --shadow-lg: 0 16px 40px rgba(0, 0, 0, 0.12);
  --transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

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

body {
  font-family: var(--font-main);
  background-color: var(--bg-app);
  color: var(--text-dark);
  min-height: 100vh;
  -webkit-tap-highlight-color: transparent;
}

/* Desktop Full Width Layout Shell */
.app-viewport {
  width: 100%;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* Top Navbar Header */
.app-header {
  background: #ffffff;
  border-bottom: 1px solid var(--border-light);
  padding: 16px 40px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 0 2px 10px rgba(0,0,0,0.03);
}

.brand-title {
  display: flex;
  align-items: center;
  gap: 12px;
  font-family: var(--font-heading);
  font-size: 1.4rem;
  font-weight: 800;
  color: #0f172a;
}

.sparkle-icon {
  color: #f59e0b;
  font-size: 1.2rem;
}

.brand-badge {
  background: rgba(220, 38, 38, 0.1);
  color: var(--brand-red);
  font-size: 0.72rem;
  font-weight: 800;
  padding: 4px 10px;
  border-radius: 50px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 14px;
}

.pro-badge {
  background: linear-gradient(135deg, #f59e0b, #d97706);
  color: #fff;
  font-size: 0.8rem;
  font-weight: 800;
  padding: 8px 18px;
  border-radius: 50px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  box-shadow: 0 4px 14px rgba(245, 158, 11, 0.3);
  cursor: pointer;
  border: none;
}

.btn-create-desktop {
  background: linear-gradient(135deg, #2563eb, #1d4ed8);
  color: #fff;
  border: none;
  padding: 9px 20px;
  border-radius: 50px;
  font-weight: 700;
  font-size: 0.88rem;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  box-shadow: 0 4px 14px rgba(37, 99, 235, 0.35);
  transition: var(--transition);
}

.btn-create-desktop:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(37, 99, 235, 0.5);
}

/* Main Container (Full Width Desktop Grid) */
.app-body {
  flex: 1;
  max-width: 1400px;
  width: 100%;
  margin: 0 auto;
  padding: 30px 40px;
  display: flex;
  flex-direction: column;
  gap: 24px;
}

/* Dashboard Summary Metrics Cards (Desktop Row) */
.metrics-row {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 18px;
}

.metric-card {
  background: #ffffff;
  border-radius: var(--radius-xl);
  padding: 20px;
  display: flex;
  align-items: center;
  gap: 16px;
  border: 1px solid var(--border-light);
  box-shadow: var(--shadow-sm);
}

.metric-icon {
  width: 52px;
  height: 52px;
  border-radius: var(--radius-lg);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.4rem;
}

.metric-icon.blue { background: #e0f2fe; color: #0284c7; }
.metric-icon.green { background: #dcfce7; color: #16a34a; }
.metric-icon.amber { background: #fffbe6; color: #d97706; }
.metric-icon.red { background: #fef2f2; color: #dc2626; }

.metric-info h4 {
  font-size: 0.78rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  font-weight: 700;
}

.metric-info .value {
  font-family: var(--font-heading);
  font-size: 1.4rem;
  font-weight: 800;
  color: #0f172a;
  margin-top: 2px;
}

/* Section Card */
.section-card {
  background: var(--bg-card);
  border-radius: var(--radius-xl);
  padding: 24px;
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border-light);
  max-width: 100%;
  box-sizing: border-box;
  overflow: hidden;
}

.section-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
}

.section-title {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 1.15rem;
  font-weight: 800;
  color: #0f172a;
}

.section-title i {
  color: #2563eb;
}

.view-all-link {
  font-size: 0.85rem;
  font-weight: 700;
  color: #2563eb;
  text-decoration: none;
  cursor: pointer;
}

/* Quick Access 4 Tile Grid */
.quick-access-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 18px;
}

.qa-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding: 20px 14px;
  border-radius: var(--radius-lg);
  cursor: pointer;
  transition: var(--transition);
  border: 1px solid transparent;
}

.qa-item:hover {
  transform: translateY(-3px);
}

.qa-icon-box {
  width: 60px;
  height: 60px;
  border-radius: var(--radius-lg);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
  margin-bottom: 10px;
}

.qa-item.blue { background: #f0f9ff; }
.qa-item.blue .qa-icon-box { background: var(--qa-blue-bg); color: var(--qa-blue-icon); }
.qa-item.green { background: #f0fdf4; }
.qa-item.green .qa-icon-box { background: var(--qa-green-bg); color: var(--qa-green-icon); }
.qa-item.purple { background: #faf5ff; }
.qa-item.purple .qa-icon-box { background: var(--qa-purple-bg); color: var(--qa-purple-icon); }
.qa-item.pink { background: #fdf2f8; }
.qa-item.pink .qa-icon-box { background: var(--qa-pink-bg); color: var(--qa-pink-icon); }

.qa-label {
  font-size: 0.88rem;
  font-weight: 700;
  color: #334155;
}

/* Search Bar & Filter Bar */
.controls-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 20px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}

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

.search-input-box input {
  width: 100%;
  padding: 12px 18px 12px 46px;
  border-radius: 50px;
  border: 1px solid var(--border-light);
  background: #f8fafc;
  font-size: 0.9rem;
  font-family: var(--font-main);
  outline: none;
  transition: var(--transition);
}

.search-input-box input:focus {
  border-color: #2563eb;
  background: #ffffff;
  box-shadow: 0 0 12px rgba(37, 99, 235, 0.15);
}

.search-input-box i {
  position: absolute;
  left: 18px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-light);
}

.filter-pills-row {
  display: flex;
  gap: 8px;
  width: 100%;
  max-width: 100%;
  overflow-x: auto;
  white-space: nowrap;
  -webkit-overflow-scrolling: touch;
  padding-bottom: 6px;
  scroll-behavior: smooth;
  -ms-overflow-style: none;
  scrollbar-width: none;
}

.filter-pills-row::-webkit-scrollbar {
  display: none;
}

.filter-pill {
  padding: 9px 20px;
  border-radius: 50px;
  font-size: 0.85rem;
  font-weight: 600;
  border: 1px solid var(--border-light);
  background: #ffffff;
  color: var(--text-muted);
  cursor: pointer;
  white-space: nowrap;
  flex-shrink: 0;
  transition: var(--transition);
}

.filter-pill.active {
  background: #10b981;
  color: #ffffff;
  border-color: #10b981;
  box-shadow: 0 4px 12px rgba(16, 185, 129, 0.3);
}

/* Transactions Data Grid List (Desktop & Mobile) */
.transaction-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.trans-card {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 24px;
  border-radius: var(--radius-md);
  background: #ffffff;
  border: 1px solid #f1f5f9;
  transition: var(--transition);
}

.trans-card:hover {
  background: #f8fafc;
  border-color: rgba(37, 99, 235, 0.2);
  box-shadow: 0 4px 16px rgba(0,0,0,0.04);
}

.trans-info {
  flex: 1;
  cursor: pointer;
}

.trans-info .client-name {
  font-size: 1.05rem;
  font-weight: 700;
  color: #0f172a;
}

.trans-info .sub-meta {
  font-size: 0.82rem;
  color: var(--text-muted);
  margin-top: 4px;
}

.trans-right {
  display: flex;
  align-items: center;
  gap: 28px;
}

.trans-amount {
  font-size: 1.15rem;
  font-weight: 800;
  color: #0f172a;
  text-align: right;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.78rem;
  font-weight: 700;
  padding: 5px 14px;
  border-radius: 50px;
}

.status-pill.paid { background: var(--status-paid-bg); color: var(--status-paid); }
.status-pill.pending { background: var(--status-unpaid-bg); color: var(--status-unpaid); }
.status-pill.overdue { background: var(--status-overdue-bg); color: var(--status-overdue); }

.trans-actions {
  display: flex;
  gap: 8px;
}

.icon-btn-sm {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 1px solid var(--border-light);
  background: #ffffff;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.85rem;
  cursor: pointer;
  transition: var(--transition);
}

.icon-btn-sm:hover {
  background: #2563eb;
  color: #ffffff;
  border-color: #2563eb;
}

.icon-btn-sm.delete:hover {
  background: #ef4444;
  color: #ffffff;
  border-color: #ef4444;
}

/* Bottom Nav (Hidden on Desktop, Visible on Mobile Screen width <= 768px) */
.bottom-nav {
  display: none;
}

/* Mobile Screen Breakpoint Rules (<= 768px) */
@media (max-width: 768px) {
  .app-header {
    padding: 12px 18px;
  }
  .brand-badge, .btn-create-desktop {
    display: none;
  }
  .app-body {
    padding: 14px 14px 80px 14px;
    gap: 14px;
  }
  .metrics-row {
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
  }
  .metric-card {
    padding: 14px;
  }
  .metric-icon {
    width: 42px;
    height: 42px;
    font-size: 1.1rem;
  }
  .metric-info .value {
    font-size: 1.1rem;
  }
  .quick-access-grid {
    grid-template-columns: repeat(4, 1fr);
    gap: 8px;
  }
  .qa-item {
    padding: 12px 6px;
  }
  .qa-icon-box {
    width: 48px;
    height: 48px;
    font-size: 1.2rem;
  }
  .qa-label {
    font-size: 0.7rem;
  }
  .search-input-box {
    min-width: 100%;
  }
  .trans-card {
    padding: 12px 14px;
  }
  .trans-right {
    gap: 10px;
    flex-direction: column;
    align-items: flex-end;
  }
  .trans-amount {
    font-size: 0.98rem;
  }
  
  .bottom-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: 66px;
    background: #ffffff;
    border-top: 1px solid var(--border-light);
    display: flex;
    justify-content: space-around;
    align-items: center;
    padding: 0 10px;
    z-index: 200;
    box-shadow: 0 -4px 16px rgba(0,0,0,0.06);
  }

  .nav-tab {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    color: var(--text-light);
    font-size: 0.7rem;
    font-weight: 600;
    text-decoration: none;
    cursor: pointer;
  }

  .nav-tab.active {
    color: #2563eb;
  }

  .nav-tab-center {
    width: 46px;
    height: 46px;
    background: linear-gradient(135deg, #2563eb, #1d4ed8);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #ffffff;
    font-size: 1.2rem;
    box-shadow: 0 6px 16px rgba(37, 99, 235, 0.4);
    transform: translateY(-12px);
    cursor: pointer;
  }
}

/* Modals Overlay & Sheet */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(15, 23, 42, 0.65);
  backdrop-filter: blur(4px);
  z-index: 500;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  visibility: hidden;
  transition: var(--transition);
  padding: 16px;
}

.modal-overlay.active {
  opacity: 1;
  visibility: visible;
}

.modal-sheet {
  background: #ffffff;
  width: 100%;
  max-width: 800px;
  max-height: 90vh;
  border-radius: var(--radius-xl);
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow-lg);
  overflow: hidden;
  transform: translateY(20px);
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.modal-overlay.active .modal-sheet {
  transform: translateY(0);
}

.modal-sheet-header {
  padding: 18px 24px;
  border-bottom: 1px solid var(--border-light);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.modal-sheet-header h3 {
  font-size: 1.2rem;
  font-weight: 800;
  color: #0f172a;
}

.sheet-close-btn {
  background: #f1f5f9;
  border: none;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.2rem;
  cursor: pointer;
}

.modal-sheet-body {
  padding: 24px;
  overflow-y: auto;
  flex: 1;
}

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

.form-group {
  margin-bottom: 12px;
}

.form-group label {
  display: block;
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--text-muted);
  margin-bottom: 4px;
}

.form-control {
  width: 100%;
  padding: 10px 14px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-light);
  font-size: 0.88rem;
  font-family: var(--font-main);
  outline: none;
}

.form-control:focus {
  border-color: #2563eb;
}

.items-table {
  width: 100%;
  border-collapse: collapse;
  margin-bottom: 14px;
}

.items-table th {
  font-size: 0.78rem;
  color: var(--text-muted);
  text-align: left;
  padding: 8px;
  border-bottom: 1px solid var(--border-light);
}

.items-table td {
  padding: 8px;
}

.btn-primary-block {
  width: 100%;
  padding: 12px;
  background: linear-gradient(135deg, #2563eb, #1d4ed8);
  color: #ffffff;
  border: none;
  border-radius: var(--radius-md);
  font-size: 0.95rem;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 4px 14px rgba(37, 99, 235, 0.3);
}

/* RED, WHITE & BLACK PDF INVOICE THEME */
.red-white-invoice {
  background: #ffffff;
  color: var(--brand-black);
  padding: 28px;
  border-radius: var(--radius-md);
  font-family: var(--font-main);
  border: 3px solid var(--brand-red);
  width: 100%;
  box-sizing: border-box;
}

.pdf-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  border-bottom: 3px solid var(--brand-red);
  padding-bottom: 20px;
  margin-bottom: 24px;
}

.pdf-brand-logo {
  display: flex;
  align-items: center;
  gap: 16px;
}

.pdf-brand-logo img {
  height: 65px;
  width: auto;
  object-fit: contain;
}

.pdf-brand-info h2 {
  font-family: var(--font-heading);
  font-size: 1.7rem;
  font-weight: 800;
  color: var(--brand-red);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.pdf-brand-info p {
  font-size: 0.85rem;
  color: var(--brand-black);
  font-weight: 700;
}

.pdf-meta-box {
  text-align: right;
}

.pdf-meta-box .inv-tag {
  background: var(--brand-red);
  color: var(--brand-white);
  padding: 6px 16px;
  font-size: 0.95rem;
  font-weight: 800;
  border-radius: 4px;
  display: inline-block;
  margin-bottom: 8px;
}

.pdf-meta-box p {
  font-size: 0.85rem;
  color: var(--brand-black);
}

.pdf-billing-row {
  display: flex;
  justify-content: space-between;
  background: #f8fafc;
  border-left: 5px solid var(--brand-black);
  padding: 16px 20px;
  border-radius: 6px;
  margin-bottom: 24px;
}

.pdf-billing-col h4 {
  font-size: 0.8rem;
  text-transform: uppercase;
  color: var(--brand-red);
  font-weight: 800;
  margin-bottom: 6px;
}

.pdf-billing-col p {
  font-size: 0.88rem;
  color: var(--brand-black);
}

.pdf-table {
  width: 100%;
  border-collapse: collapse;
  margin-bottom: 24px;
}

.pdf-table th {
  background: var(--brand-black);
  color: var(--brand-white);
  font-size: 0.82rem;
  text-transform: uppercase;
  padding: 10px 14px;
  text-align: left;
}

.pdf-table td {
  padding: 12px 14px;
  border-bottom: 1px solid #e2e8f0;
  font-size: 0.9rem;
  color: var(--brand-black);
}

.pdf-table tbody tr:nth-child(even) {
  background: #f9fafb;
}

.pdf-totals-box {
  width: 280px;
  margin-left: auto;
  border-top: 2px solid var(--brand-red);
  padding-top: 12px;
}

.pdf-total-row {
  display: flex;
  justify-content: space-between;
  font-size: 0.9rem;
  padding: 4px 0;
  color: var(--brand-black);
}

.pdf-total-row.grand {
  background: var(--brand-red);
  color: var(--brand-white);
  font-weight: 800;
  font-size: 1.15rem;
  padding: 10px 14px;
  border-radius: 4px;
  margin-top: 8px;
}

.pdf-footer-note {
  margin-top: 28px;
  padding-top: 16px;
  border-top: 1px solid #e2e8f0;
  text-align: center;
  font-size: 0.8rem;
  color: var(--brand-gray);
}

/* Print CSS */
@media print {
  body * {
    visibility: hidden;
  }
  #printableModal, #printableModal * {
    visibility: visible;
  }
  #printableModal {
    position: fixed;
    left: 0;
    top: 0;
    width: 100vw;
    height: 100vh;
    background: #ffffff;
    padding: 0;
  }
  .modal-sheet {
    max-width: 100%;
    max-height: 100vh;
    border-radius: 0;
  }
  .modal-sheet-header, .btn-primary-block {
    display: none !important;
  }
}
