/* ============================================
   PREMIUM UI – Invoice System
   Apple‑inspired with Gold Accents
   ============================================ */

:root {
  --primary-start: #007aff;
  --primary-end: #4a00e0;
  --gold: #d4af37;
  --gold-light: #f5e6b8;
  --gold-dark: #b8960f;
  --bg-light: #f5f7fa;
  --bg-white: #ffffff;
  --text-dark: #1d1d1f;
  --text-muted: #6e6e73;
  --border-light: #e8e8ed;
  --shadow-sm: 0 2px 12px rgba(0, 0, 0, 0.04);
  --shadow-md: 0 8px 30px rgba(0, 0, 0, 0.06);
  --shadow-lg: 0 20px 60px rgba(0, 0, 0, 0.10);
  --radius: 16px;
  --radius-sm: 10px;
  --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--bg-light);
  color: var(--text-dark);
  padding: 1.5rem;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* ----- Header (Glass‑morphism) ----- */
header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: rgba(255, 255, 255, 0.8);
  backdrop-filter: saturate(180%) blur(20px);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  padding: 0.8rem 2rem;
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  margin-bottom: 1.8rem;
  border: 1px solid rgba(255, 255, 255, 0.6);
}

.logo {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  font-weight: 700;
  font-size: 1.2rem;
  letter-spacing: -0.02em;
  color: var(--text-dark);
}

.logo img {
  height: 38px;
  opacity: 0.9;
  filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.05));
}

.header-actions {
  display: flex;
  gap: 0.75rem;
  align-items: center;
  flex-wrap: wrap;
}

/* ----- Dark Mode Toggle ----- */
.dark-toggle {
  background: none;
  border: none;
  font-size: 1.2rem;
  color: var(--text-muted);
  cursor: pointer;
  transition: var(--transition);
  padding: 0.2rem 0.4rem;
}

.dark-toggle:hover {
  color: var(--text-dark);
  transform: rotate(20deg);
}

/* ============================================
   ✨ PREMIUM BUTTONS – Border + Shadow
   ============================================ */
.btn {
  padding: 0.6rem 1.6rem;
  border: none;
  border-radius: var(--radius-sm);
  font-family: inherit;
  font-size: 0.9rem;
  font-weight: 500;
  cursor: pointer;
  transition: var(--transition);
  letter-spacing: -0.01em;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  position: relative;
  overflow: hidden;
  /* base border & shadow – will be overridden by variants */
  border: 1px solid transparent;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
}

.btn::after {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: inherit;
  pointer-events: none;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.15);
}

/* Primary – Gold gradient + refined shadow */
.btn.primary {
  background: linear-gradient(135deg, var(--gold), var(--gold-dark));
  color: #1d1d1f;
  border: 1px solid rgba(212, 175, 55, 0.5);
  box-shadow: 0 4px 14px rgba(212, 175, 55, 0.3);
}

.btn.primary:hover {
  transform: translateY(-2px) scale(1.02);
  box-shadow: 0 8px 28px rgba(212, 175, 55, 0.45);
}

.btn.primary:active {
  transform: scale(0.97);
  box-shadow: 0 2px 8px rgba(212, 175, 55, 0.2);
}

/* Secondary – subtle border + shadow */
.btn.secondary {
  background: var(--bg-white);
  color: var(--text-dark);
  border: 1px solid var(--border-light);
  box-shadow: var(--shadow-sm);
}

.btn.secondary:hover {
  background: var(--border-light);
  border-color: var(--text-muted);
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

.btn.secondary:active {
  transform: scale(0.97);
}

/* Danger – soft red with border */
.btn.danger {
  background: #ff3b30;
  color: #fff;
  border: 1px solid rgba(255, 59, 48, 0.4);
  box-shadow: 0 4px 12px rgba(255, 59, 48, 0.25);
}

.btn.danger:hover {
  background: #e0352b;
  transform: translateY(-2px);
  box-shadow: 0 8px 20px rgba(255, 59, 48, 0.35);
}

.btn.danger:active {
  transform: scale(0.97);
}

/* Success – green accent (for Ride button) */
.btn.success {
  background: linear-gradient(135deg, #34c759, #28a745);
  color: #fff;
  border: 1px solid rgba(52, 199, 89, 0.4);
  box-shadow: 0 4px 14px rgba(52, 199, 89, 0.3);
}

.btn.success:hover {
  transform: translateY(-2px) scale(1.02);
  box-shadow: 0 8px 28px rgba(52, 199, 89, 0.45);
}

.btn.success:active {
  transform: scale(0.97);
}

/* Small variant */
.btn.small {
  padding: 0.3rem 0.9rem;
  font-size: 0.8rem;
  border-radius: 8px;
}

/* ----- Filters ----- */
.filters {
  display: flex;
  gap: 1rem;
  flex-wrap: wrap;
  background: var(--bg-white);
  padding: 0.8rem 1.2rem;
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  margin-bottom: 1.8rem;
  border: 1px solid var(--border-light);
}

.filters input,
.filters select {
  padding: 0.6rem 1rem;
  font-size: 0.95rem;
  font-family: inherit;
  background: var(--bg-light);
  border: 1.5px solid transparent;
  border-radius: var(--radius-sm);
  flex: 1 1 200px;
  transition: var(--transition);
  color: var(--text-dark);
}

.filters input:focus,
.filters select:focus {
  outline: none;
  background: var(--bg-white);
  border-color: var(--primary-start);
  box-shadow: 0 0 0 4px rgba(0, 122, 255, 0.12);
}

/* ----- Invoice List Container ----- */
#invoiceListContainer {
  background: var(--bg-white);
  border-radius: var(--radius);
  padding: 1.2rem 1.2rem 0.5rem;
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border-light);
  overflow-x: auto;
}

/* ----- Table ----- */
table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.95rem;
}

th {
  text-align: left;
  padding: 0.9rem 0.6rem 0.9rem 0;
  font-weight: 600;
  color: var(--text-muted);
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  border-bottom: 2px solid var(--border-light);
}

td {
  padding: 0.8rem 0.6rem 0.8rem 0;
  border-bottom: 1px solid var(--border-light);
  vertical-align: middle;
}

tr:hover td {
  background: rgba(0, 122, 255, 0.02);
}

.actions {
  display: flex;
  gap: 0.4rem;
  flex-wrap: wrap;
}

/* ----- Status Badges (Gold accents) ----- */
.status-badge {
  padding: 0.2rem 0.9rem;
  border-radius: 30px;
  font-size: 0.75rem;
  font-weight: 600;
  display: inline-block;
  letter-spacing: 0.02em;
  text-transform: capitalize;
}

.status-draft {
  background: var(--border-light);
  color: var(--text-muted);
}
.status-sent {
  background: #d6eaff;
  color: #0055b3;
}
.status-paid {
  background: #d9f0e1;
  color: #1e7a44;
}
.status-overdue {
  background: #ffe5e5;
  color: #b31c1c;
}
.status-active {
  background: #d9f0e1;
  color: #1e7a44;
}
.status-inactive {
  background: #fff3cd;
  color: #856404;
}
.status-terminated {
  background: #ffe5e5;
  color: #b31c1c;
}
.status-completed {
  background: #d9f0e1;
  color: #1e7a44;
}
.status-pending {
  background: #fff3cd;
  color: #856404;
}
.status-confirmed {
  background: #d6eaff;
  color: #0055b3;
}
.status-enroute {
  background: #cce5ff;
  color: #004085;
}
.status-cancelled {
  background: #ffe5e5;
  color: #b31c1c;
}
.status-maintenance {
  background: #ffe0b2;
  color: #bf360c;
}
.status-retired {
  background: #e0e0e0;
  color: #424242;
}

#emptyState {
  padding: 3rem 1rem;
  text-align: center;
  color: var(--text-muted);
  font-size: 1.05rem;
}

/* ----- Modals (Glass‑morphism) ----- */
.modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.35);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 1000;
  padding: 1rem;
}

.modal-content {
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  padding: 2rem 2.2rem;
  border-radius: 24px;
  max-width: 720px;
  width: 100%;
  max-height: 92vh;
  overflow-y: auto;
  position: relative;
  box-shadow: var(--shadow-lg);
  border: 1px solid rgba(255, 255, 255, 0.2);
}

.modal-content::-webkit-scrollbar {
  width: 6px;
}
.modal-content::-webkit-scrollbar-thumb {
  background: var(--border-light);
  border-radius: 10px;
}
.modal-content::-webkit-scrollbar-track {
  background: transparent;
}

.close {
  position: absolute;
  top: 1.2rem;
  right: 1.6rem;
  font-size: 1.8rem;
  cursor: pointer;
  color: var(--text-muted);
  transition: var(--transition);
  line-height: 1;
}

.close:hover {
  color: var(--text-dark);
  transform: rotate(90deg);
}

.modal-content h2 {
  font-size: 1.6rem;
  font-weight: 600;
  letter-spacing: -0.02em;
  color: var(--text-dark);
  margin-bottom: 1.5rem;
}

.modal-content h3 {
  font-size: 1.1rem;
  font-weight: 600;
  margin: 1.2rem 0 0.6rem;
  color: var(--text-dark);
}

/* ----- Form Elements ----- */
.form-row {
  display: flex;
  gap: 1rem;
  flex-wrap: wrap;
}
.form-row .form-group {
  flex: 1 1 200px;
}

.form-group {
  margin-bottom: 1rem;
}
.form-group label {
  display: block;
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--text-dark);
  margin-bottom: 0.3rem;
}
.form-group input,
.form-group select {
  width: 100%;
  padding: 0.7rem 1rem;
  font-size: 0.95rem;
  font-family: inherit;
  background: var(--bg-light);
  border: 1.5px solid transparent;
  border-radius: var(--radius-sm);
  transition: var(--transition);
  color: var(--text-dark);
}
.form-group input:focus,
.form-group select:focus {
  outline: none;
  background: var(--bg-white);
  border-color: var(--primary-start);
  box-shadow: 0 0 0 4px rgba(0, 122, 255, 0.12);
}

/* ----- Item Rows (inline) ----- */
.item-row {
  display: flex;
  gap: 0.6rem;
  align-items: center;
  margin-bottom: 0.6rem;
  flex-wrap: wrap;
}
.item-row input {
  padding: 0.6rem 0.8rem;
  font-size: 0.9rem;
  font-family: inherit;
  background: var(--bg-light);
  border: 1.5px solid transparent;
  border-radius: var(--radius-sm);
  transition: var(--transition);
  color: var(--text-dark);
}
.item-row input:focus {
  outline: none;
  background: var(--bg-white);
  border-color: var(--primary-start);
  box-shadow: 0 0 0 4px rgba(0, 122, 255, 0.1);
}
.item-row .item-desc {
  flex: 3;
  min-width: 120px;
}
.item-row .item-qty {
  flex: 1;
  max-width: 80px;
}
.item-row .item-price {
  flex: 1;
  max-width: 110px;
}
.item-row .item-total {
  flex: 1;
  max-width: 100px;
  font-weight: 500;
  font-size: 0.95rem;
  color: var(--text-dark);
}
.item-row .remove-item {
  background: transparent;
  border: none;
  font-size: 1.2rem;
  color: var(--text-muted);
  cursor: pointer;
  padding: 0 0.2rem;
  transition: var(--transition);
  line-height: 1;
}
.item-row .remove-item:hover {
  color: #ff3b30;
  transform: scale(1.2);
}

/* ----- Totals ----- */
.totals {
  margin-top: 1.2rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border-light);
  text-align: right;
}
.totals div {
  margin: 0.25rem 0;
  font-size: 1rem;
  color: var(--text-dark);
}
.totals div:last-child {
  font-size: 1.3rem;
  font-weight: 600;
  color: var(--text-dark);
}

/* ----- Form Actions ----- */
.form-actions {
  display: flex;
  gap: 0.8rem;
  margin-top: 1.8rem;
  justify-content: flex-end;
}

#addItemBtn {
  background: transparent;
  border: 1.5px dashed var(--border-light);
  border-radius: var(--radius-sm);
  padding: 0.6rem 1.2rem;
  font-family: inherit;
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--primary-start);
  cursor: pointer;
  transition: var(--transition);
  width: 100%;
}

#addItemBtn:hover {
  background: rgba(0, 122, 255, 0.05);
  border-color: var(--primary-start);
}

/* ============================================
   DARK MODE (data-theme="dark")
   ============================================ */
[data-theme="dark"] {
  --bg-light: #1c1c1e;
  --bg-white: #2c2c2e;
  --text-dark: #f5f5f7;
  --text-muted: #aeaeb2;
  --border-light: #3a3a3c;
  --shadow-sm: 0 2px 12px rgba(0, 0, 0, 0.2);
  --shadow-md: 0 8px 30px rgba(0, 0, 0, 0.3);
  --shadow-lg: 0 20px 60px rgba(0, 0, 0, 0.4);
}

[data-theme="dark"] header {
  background: rgba(44, 44, 46, 0.85);
  border-color: rgba(255, 255, 255, 0.05);
}

[data-theme="dark"] .modal-content {
  background: rgba(44, 44, 46, 0.95);
  border-color: rgba(255, 255, 255, 0.05);
}

[data-theme="dark"] .filters,
[data-theme="dark"] #invoiceListContainer {
  background: var(--bg-white);
  border-color: var(--border-light);
}

[data-theme="dark"] .filters input,
[data-theme="dark"] .filters select {
  background: var(--bg-light);
  color: var(--text-dark);
}

[data-theme="dark"] .btn.secondary {
  background: var(--bg-light);
  color: var(--text-dark);
  border-color: var(--border-light);
}

[data-theme="dark"] .btn.secondary:hover {
  background: var(--border-light);
}

/* Dark mode – button shadows become more subtle */
[data-theme="dark"] .btn.primary {
  box-shadow: 0 4px 14px rgba(212, 175, 55, 0.2);
}
[data-theme="dark"] .btn.primary:hover {
  box-shadow: 0 8px 28px rgba(212, 175, 55, 0.35);
}
[data-theme="dark"] .btn.danger {
  box-shadow: 0 4px 12px rgba(255, 59, 48, 0.2);
}
[data-theme="dark"] .btn.danger:hover {
  box-shadow: 0 8px 20px rgba(255, 59, 48, 0.3);
}
[data-theme="dark"] .btn.success {
  box-shadow: 0 4px 14px rgba(52, 199, 89, 0.2);
}
[data-theme="dark"] .btn.success:hover {
  box-shadow: 0 8px 28px rgba(52, 199, 89, 0.35);
}

[data-theme="dark"] .form-group input,
[data-theme="dark"] .form-group select,
[data-theme="dark"] .item-row input {
  background: var(--bg-light);
  color: var(--text-dark);
}

[data-theme="dark"] .form-group input:focus,
[data-theme="dark"] .form-group select:focus,
[data-theme="dark"] .item-row input:focus {
  background: var(--bg-white);
}

[data-theme="dark"] .close {
  color: var(--text-muted);
}

[data-theme="dark"] .close:hover {
  color: #fff;
}