/* ============================================================
   BillGun.app — Master Stylesheet
   Title: BillGun - Create & Manage Invoice at Gun Speed
   ============================================================ */

:root {
  --bg-main: #f8fafc;
  --bg-card: #ffffff;
  --bg-sidebar: #0f172a;
  --text-dark: #0f172a;
  --text-muted: #64748b;
  --text-light: #f8fafc;
  --primary: #2563eb;
  --primary-hover: #1d4ed8;
  --accent-gold: #f59e0b;
  --accent-green: #10b981;
  --accent-red: #ef4444;
  --accent-purple: #8b5cf6;
  --border-color: #e2e8f0;
  --radius-sm: 6px;
  --radius-md: 12px;
  --radius-lg: 18px;
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.05);
  --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 25px -5px rgba(0,0,0,0.1), 0 8px 10px -6px rgba(0,0,0,0.05);
  --font-family: 'Plus Jakarta Sans', system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

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

body {
  font-family: var(--font-family);
  background-color: var(--bg-main);
  color: var(--text-dark);
  line-height: 1.5;
  min-height: 100vh;
}

/* Header & Navigation */
.gun-navbar {
  background: var(--bg-sidebar);
  color: var(--text-light);
  padding: 0.85rem 1.5rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  box-shadow: 0 4px 12px rgba(0,0,0,0.15);
  position: sticky;
  top: 0;
  z-index: 100;
}

.gun-brand {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  text-decoration: none;
  color: #fff;
}

.gun-brand img {
  height: 38px;
  width: auto;
  object-fit: contain;
  border-radius: var(--radius-sm);
}

.gun-title-group h1 {
  font-size: 1.15rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  background: linear-gradient(90deg, #ffffff, #93c5fd);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.gun-title-group p {
  font-size: 0.72rem;
  color: #94a3b8;
  font-weight: 500;
}

.gun-nav-tabs {
  display: flex;
  gap: 0.5rem;
  background: rgba(255, 255, 255, 0.08);
  padding: 0.25rem;
  border-radius: 30px;
}

.gun-tab-btn {
  background: transparent;
  border: none;
  color: #cbd5e1;
  padding: 0.45rem 1.1rem;
  border-radius: 20px;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.gun-tab-btn:hover {
  color: #fff;
  background: rgba(255, 255, 255, 0.12);
}

.gun-tab-btn.active {
  background: var(--primary);
  color: #fff;
  box-shadow: 0 2px 8px rgba(37, 99, 235, 0.4);
}

/* Quick Gun Speed Bar */
.gun-speed-bar-container {
  background: linear-gradient(135deg, #1e293b 0%, #0f172a 100%);
  color: #fff;
  padding: 1.25rem 2rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.gun-speed-wrapper {
  max-width: 1300px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  gap: 1rem;
}

.gun-speed-badge {
  background: linear-gradient(135deg, #f59e0b, #d97706);
  color: #fff;
  font-weight: 800;
  font-size: 0.75rem;
  text-transform: uppercase;
  padding: 0.35rem 0.75rem;
  border-radius: 6px;
  white-space: nowrap;
  letter-spacing: 0.05em;
  box-shadow: 0 0 10px rgba(245, 158, 11, 0.4);
}

.gun-speed-input-group {
  flex: 1;
  position: relative;
}

.gun-speed-input {
  width: 100%;
  padding: 0.7rem 1.2rem;
  padding-right: 6.5rem;
  background: rgba(255, 255, 255, 0.07);
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 8px;
  color: #fff;
  font-size: 0.92rem;
  transition: all 0.2s ease;
}

.gun-speed-input:focus {
  outline: none;
  border-color: var(--primary);
  background: rgba(255, 255, 255, 0.12);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.3);
}

.gun-speed-btn {
  position: absolute;
  right: 4px;
  top: 4px;
  bottom: 4px;
  background: var(--primary);
  color: #fff;
  border: none;
  padding: 0 1.1rem;
  border-radius: 6px;
  font-weight: 700;
  font-size: 0.85rem;
  cursor: pointer;
  transition: background 0.2s ease;
}

.gun-speed-btn:hover {
  background: var(--primary-hover);
}

/* Main Container */
.gun-main-container {
  max-width: 1400px;
  margin: 1.5rem auto;
  padding: 0 1.5rem;
}

/* Stats Row */
.gun-stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 1.25rem;
  margin-bottom: 1.5rem;
}

.gun-stat-card {
  background: var(--bg-card);
  padding: 1.25rem;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-color);
  box-shadow: var(--shadow-sm);
  display: flex;
  align-items: center;
  gap: 1rem;
}

.gun-stat-icon {
  width: 48px;
  height: 48px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.3rem;
  color: #fff;
}

.gun-stat-icon.revenue { background: linear-gradient(135deg, #10b981, #059669); }
.gun-stat-icon.pending { background: linear-gradient(135deg, #f59e0b, #d97706); }
.gun-stat-icon.overdue { background: linear-gradient(135deg, #ef4444, #dc2626); }
.gun-stat-icon.count { background: linear-gradient(135deg, #3b82f6, #2563eb); }

.gun-stat-info label {
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.gun-stat-info h3 {
  font-size: 1.4rem;
  font-weight: 800;
  color: var(--text-dark);
}

/* Tab Views */
.tab-content {
  display: none;
}

.tab-content.active {
  display: block;
}

/* Builder Split Layout */
.builder-split-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.5rem;
  align-items: start;
}

@media (max-width: 1024px) {
  .builder-split-grid {
    grid-template-columns: 1fr;
  }
}

.gun-card {
  background: var(--bg-card);
  border-radius: var(--radius-md);
  border: 1px solid var(--border-color);
  box-shadow: var(--shadow-sm);
  padding: 1.5rem;
  margin-bottom: 1.5rem;
}

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

.gun-card-title {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text-dark);
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

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

.form-group {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.form-group label {
  font-size: 0.82rem;
  font-weight: 700;
  color: #334155;
}

.form-control {
  padding: 0.6rem 0.85rem;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  font-family: inherit;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
  width: 100%;
}

.form-control:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
}

textarea.form-control {
  resize: vertical;
  min-height: 70px;
}

/* Items Table Builder */
.items-table {
  width: 100%;
  border-collapse: collapse;
  margin-bottom: 1rem;
}

.items-table th {
  background: #f1f5f9;
  text-align: left;
  padding: 0.6rem 0.8rem;
  font-size: 0.78rem;
  font-weight: 700;
  color: #475569;
  text-transform: uppercase;
}

.items-table td {
  padding: 0.5rem 0.4rem;
  border-bottom: 1px solid #f1f5f9;
  vertical-align: middle;
}

.btn-icon-danger {
  background: #fee2e2;
  color: #ef4444;
  border: none;
  width: 32px;
  height: 32px;
  border-radius: 6px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
}

.btn-icon-danger:hover {
  background: #ef4444;
  color: #fff;
}

.btn-add-item {
  background: #eff6ff;
  color: var(--primary);
  border: 1px dashed var(--primary);
  padding: 0.6rem 1rem;
  border-radius: var(--radius-sm);
  font-weight: 700;
  font-size: 0.85rem;
  cursor: pointer;
  width: 100%;
  transition: all 0.2s ease;
}

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

/* Primary Action Buttons */
.btn-primary {
  background: var(--primary);
  color: #fff;
  border: none;
  padding: 0.65rem 1.4rem;
  border-radius: var(--radius-sm);
  font-weight: 700;
  font-size: 0.9rem;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  transition: background 0.2s ease;
}

.btn-primary:hover {
  background: var(--primary-hover);
}

.btn-secondary {
  background: #f1f5f9;
  color: #334155;
  border: 1px solid var(--border-color);
  padding: 0.65rem 1.2rem;
  border-radius: var(--radius-sm);
  font-weight: 700;
  font-size: 0.9rem;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
}

.btn-secondary:hover {
  background: #e2e8f0;
}

.btn-success {
  background: var(--accent-green);
  color: #fff;
  border: none;
  padding: 0.65rem 1.2rem;
  border-radius: var(--radius-sm);
  font-weight: 700;
  font-size: 0.9rem;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
}

.btn-success:hover {
  background: #059669;
}

/* Invoice Preview Document Frame */
.invoice-preview-card {
  background: #ffffff;
  border-radius: var(--radius-md);
  border: 1px solid #cbd5e1;
  box-shadow: var(--shadow-lg);
  padding: 2.5rem;
  color: #1e293b;
  position: sticky;
  top: 80px;
}

.inv-header-row {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 2rem;
  border-bottom: 2px solid #f1f5f9;
  padding-bottom: 1.5rem;
}

.inv-logo-box img {
  max-height: 55px;
  width: auto;
  object-fit: contain;
}

.inv-company-name {
  font-size: 1.4rem;
  font-weight: 800;
  color: var(--text-dark);
}

.inv-company-meta {
  font-size: 0.85rem;
  color: var(--text-muted);
  white-space: pre-line;
}

.inv-doc-title {
  text-align: right;
}

.inv-doc-title h2 {
  font-size: 1.8rem;
  font-weight: 900;
  letter-spacing: 0.05em;
  color: var(--primary);
  text-transform: uppercase;
}

.inv-doc-title .inv-num {
  font-weight: 700;
  font-size: 1.1rem;
  color: #475569;
}

.inv-status-badge {
  display: inline-block;
  padding: 0.25rem 0.75rem;
  border-radius: 20px;
  font-size: 0.78rem;
  font-weight: 800;
  text-transform: uppercase;
  margin-top: 0.3rem;
}

.badge-draft { background: #e2e8f0; color: #475569; }
.badge-sent { background: #dbeafe; color: #1e40af; }
.badge-paid { background: #d1fae5; color: #065f46; }
.badge-overdue { background: #fee2e2; color: #991b1b; }
.badge-cancelled { background: #f3f4f6; color: #6b7280; }

.inv-details-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.5rem;
  margin-bottom: 2rem;
}

.inv-bill-to h4, .inv-dates h4 {
  font-size: 0.75rem;
  font-weight: 800;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 0.4rem;
  letter-spacing: 0.05em;
}

.inv-bill-to p {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--text-dark);
}

.inv-bill-to span {
  display: block;
  font-size: 0.85rem;
  color: var(--text-muted);
  white-space: pre-line;
}

.inv-display-table {
  width: 100%;
  border-collapse: collapse;
  margin-bottom: 1.5rem;
}

.inv-display-table th {
  background: #f8fafc;
  padding: 0.75rem 1rem;
  font-size: 0.78rem;
  font-weight: 800;
  text-transform: uppercase;
  color: #475569;
  border-bottom: 2px solid #e2e8f0;
}

.inv-display-table td {
  padding: 0.75rem 1rem;
  font-size: 0.9rem;
  border-bottom: 1px solid #f1f5f9;
}

.inv-summary-box {
  display: flex;
  justify-content: flex-end;
  margin-bottom: 2rem;
}

.inv-summary-table {
  width: 260px;
  border-collapse: collapse;
}

.inv-summary-table td {
  padding: 0.45rem 0.5rem;
  font-size: 0.9rem;
}

.inv-summary-table tr.grand-total-row td {
  font-size: 1.25rem;
  font-weight: 800;
  color: var(--primary);
  border-top: 2px solid var(--primary);
  border-bottom: 2px solid var(--primary);
}

.inv-notes-box {
  background: #f8fafc;
  border-left: 4px solid var(--primary);
  padding: 1rem;
  border-radius: 0 8px 8px 0;
  font-size: 0.85rem;
  color: #475569;
}

/* Invoices List Table */
.table-responsive {
  overflow-x: auto;
}

.gun-data-table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
}

.gun-data-table th {
  background: #f8fafc;
  padding: 0.85rem 1rem;
  font-size: 0.8rem;
  font-weight: 800;
  text-transform: uppercase;
  color: var(--text-muted);
  border-bottom: 2px solid var(--border-color);
}

.gun-data-table td {
  padding: 0.9rem 1rem;
  font-size: 0.9rem;
  border-bottom: 1px solid var(--border-color);
  vertical-align: middle;
}

.gun-data-table tr:hover {
  background: #f1f5f9;
}

.action-btns-group {
  display: flex;
  gap: 0.4rem;
}

/* Modal Dialog */
.gun-modal-backdrop {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(15, 23, 42, 0.7);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
}

.gun-modal-backdrop.active {
  opacity: 1;
  pointer-events: auto;
}

.gun-modal {
  background: #fff;
  border-radius: var(--radius-md);
  width: 90%;
  max-width: 600px;
  padding: 1.5rem;
  box-shadow: var(--shadow-lg);
}

/* PRINT STYLES FOR CLEAN PDF EXPORT */
@media print {
  body {
    background: #fff !important;
    color: #000 !important;
  }

  .gun-navbar,
  .gun-speed-bar-container,
  .builder-split-grid > div:first-child,
  .no-print,
  .gun-stats-grid {
    display: none !important;
  }

  .builder-split-grid {
    grid-template-columns: 1fr !important;
  }

  .invoice-preview-card {
    border: none !important;
    box-shadow: none !important;
    padding: 0 !important;
    position: static !important;
  }
}
