/* ===== OPALINE VOGUE — STYLES.CSS ===== */

@import url('https://fonts.googleapis.com/css2?family=Playfair+Display:ital,wght@0,400;0,600;0,700;1,400&family=Inter:wght@300;400;500;600&display=swap');

:root {
  --primary:      #9B4F6A;
  --primary-dark: #7a3a53;
  --accent:       #C9A96E;
  --accent-light: #e8d4b0;
  --bg:           #FAF7F4;
  --card:         #FFFFFF;
  --text:         #2D2D2D;
  --text-muted:   #7a7068;
  --header-bg:    #3D1A2E;
  --paid:         #4CAF7D;
  --partial:      #F59E0B;
  --unpaid:       #E05C5C;
  --border:       #ede8e3;
  --shadow:       0 2px 16px rgba(61,26,46,0.09);
  --shadow-hover: 0 8px 32px rgba(61,26,46,0.15);
  --radius:       14px;
  --radius-sm:    8px;
  --sidebar-w:    260px;
  --transition:   0.22s cubic-bezier(.4,0,.2,1);
}

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

html { font-size: 16px; scroll-behavior: smooth; }

body {
  font-family: 'Inter', sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4 {
  font-family: 'Playfair Display', serif;
  font-weight: 600;
  line-height: 1.25;
}

a { color: inherit; text-decoration: none; }

/* ===== SCROLLBAR ===== */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--accent-light); border-radius: 99px; }

/* ===== BUTTONS ===== */
.btn {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 10px 22px;
  border-radius: 99px;
  font-family: 'Inter', sans-serif;
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
  border: none;
  transition: background var(--transition), box-shadow var(--transition), transform var(--transition), color var(--transition);
  outline: none;
  white-space: nowrap;
}
.btn:active { transform: scale(0.97); }

.btn-primary {
  background: var(--primary);
  color: #fff;
}
.btn-primary:hover { background: var(--primary-dark); box-shadow: 0 4px 18px rgba(155,79,106,0.32); }

.btn-accent {
  background: var(--accent);
  color: #fff;
}
.btn-accent:hover { background: #b8924f; box-shadow: 0 4px 18px rgba(201,169,110,0.32); }

.btn-ghost {
  background: transparent;
  color: var(--primary);
  border: 1.5px solid var(--primary);
}
.btn-ghost:hover { background: var(--primary); color: #fff; }

.btn-ghost-accent {
  background: transparent;
  color: var(--accent);
  border: 1.5px solid var(--accent);
}
.btn-ghost-accent:hover { background: var(--accent); color: #fff; }

.btn-danger {
  background: transparent;
  color: var(--unpaid);
  border: 1.5px solid var(--unpaid);
}
.btn-danger:hover { background: var(--unpaid); color: #fff; }

.btn-sm { padding: 7px 14px; font-size: 0.8rem; }
.btn-lg { padding: 13px 32px; font-size: 1rem; }
.btn-full { width: 100%; justify-content: center; }

/* ===== FORM ELEMENTS ===== */
.form-group { display: flex; flex-direction: column; gap: 6px; }

label {
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

input, select, textarea {
  padding: 11px 14px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  font-family: 'Inter', sans-serif;
  font-size: 0.9rem;
  color: var(--text);
  background: #fff;
  transition: border-color var(--transition), box-shadow var(--transition);
  outline: none;
}
input:focus, select:focus, textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(155,79,106,0.12);
}
input[readonly] { background: #f5f0ed; color: var(--text-muted); cursor: default; }
input::placeholder, textarea::placeholder { color: #c0b8b0; }

/* ===== CARDS ===== */
.card {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  transition: box-shadow var(--transition), transform var(--transition);
}
.card:hover { box-shadow: var(--shadow-hover); transform: translateY(-2px); }

/* ===== BADGE ===== */
.badge {
  display: inline-block;
  padding: 3px 11px;
  border-radius: 99px;
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}
.badge-paid    { background: #e8f7f1; color: var(--paid); }
.badge-partial { background: #fef3e2; color: var(--partial); }
.badge-unpaid  { background: #fdeaea; color: var(--unpaid); }

/* ===== SPINNER ===== */
.spinner-wrap {
  display: flex; justify-content: center; align-items: center;
  padding: 48px 0;
}
.spinner {
  width: 38px; height: 38px;
  border: 3px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.75s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ===== FADE IN ===== */
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(12px); }
  to   { opacity: 1; transform: translateY(0); }
}
.fade-in { animation: fadeIn 0.38s ease both; }

/* ===== TOAST ===== */
#toast-container {
  position: fixed; bottom: 24px; right: 24px;
  display: flex; flex-direction: column; gap: 10px;
  z-index: 9999;
}
.toast {
  background: var(--header-bg);
  color: #fff;
  padding: 13px 20px;
  border-radius: var(--radius-sm);
  font-size: 0.875rem;
  box-shadow: 0 6px 24px rgba(0,0,0,0.2);
  display: flex; align-items: center; gap: 10px;
  animation: fadeIn 0.28s ease both;
  min-width: 240px; max-width: 340px;
}
.toast.success { border-left: 4px solid var(--paid); }
.toast.error   { border-left: 4px solid var(--unpaid); }
.toast.info    { border-left: 4px solid var(--accent); }

/* ===== AUTH PAGES ===== */
.auth-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg);
  position: relative;
  overflow: hidden;
}
.auth-page::before {
  content: '';
  position: absolute; inset: 0;
  background:
    radial-gradient(ellipse 70% 60% at 80% 0%, rgba(155,79,106,0.13) 0%, transparent 60%),
    radial-gradient(ellipse 50% 40% at 0% 100%, rgba(201,169,110,0.12) 0%, transparent 60%);
  pointer-events: none;
}
.auth-card {
  background: var(--card);
  border-radius: 20px;
  box-shadow: 0 8px 48px rgba(61,26,46,0.13);
  padding: 48px 44px;
  width: 100%; max-width: 430px;
  position: relative; z-index: 1;
  animation: fadeIn 0.4s ease both;
}
@media (max-width: 480px) {
  .auth-card { padding: 36px 24px; margin: 16px; }
}
.auth-logo {
  text-align: center;
  margin-bottom: 32px;
}
.auth-logo-icon {
  width: 68px; height: 68px;
  background: linear-gradient(135deg, var(--header-bg), var(--primary));
  border-radius: 18px;
  display: inline-flex; align-items: center; justify-content: center;
  margin-bottom: 14px;
  box-shadow: 0 4px 18px rgba(155,79,106,0.28);
}
.auth-logo-icon i { font-size: 1.6rem; color: var(--accent); }
.auth-logo h1 {
  font-size: 1.7rem;
  color: var(--header-bg);
  margin-bottom: 4px;
}
.auth-logo p {
  font-size: 0.8rem;
  color: var(--text-muted);
  letter-spacing: 0.12em;
  text-transform: uppercase;
}
.auth-title {
  font-size: 1.2rem;
  color: var(--text);
  margin-bottom: 24px;
  text-align: center;
}
.auth-form { display: flex; flex-direction: column; gap: 18px; }
.auth-divider {
  text-align: center;
  margin-top: 20px;
  font-size: 0.85rem;
  color: var(--text-muted);
}
.auth-divider a { color: var(--primary); font-weight: 500; }
.auth-divider a:hover { text-decoration: underline; }
.auth-error {
  background: #fdeaea;
  color: var(--unpaid);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  font-size: 0.85rem;
  display: none;
}
.auth-error.show { display: block; }

/* ===== DASHBOARD LAYOUT ===== */
.dashboard-layout {
  display: flex; min-height: 100vh;
}

/* Sidebar */
.sidebar {
  width: var(--sidebar-w);
  background: var(--header-bg);
  position: fixed; top: 0; left: 0; bottom: 0;
  display: flex; flex-direction: column;
  z-index: 100;
  transition: transform var(--transition);
}
.sidebar-logo {
  padding: 28px 24px 20px;
  border-bottom: 1px solid rgba(255,255,255,0.07);
}
.sidebar-logo-icon {
  width: 44px; height: 44px;
  background: linear-gradient(135deg, var(--primary), var(--accent));
  border-radius: 11px;
  display: flex; align-items: center; justify-content: center;
  margin-bottom: 10px;
}
.sidebar-logo-icon i { color: #fff; font-size: 1.1rem; }
.sidebar-logo h2 {
  font-size: 1.25rem; color: #fff; font-family: 'Playfair Display', serif;
}
.sidebar-logo span {
  display: block; font-size: 0.68rem; color: var(--accent-light);
  letter-spacing: 0.14em; text-transform: uppercase; margin-top: 2px;
}
.sidebar-nav {
  flex: 1; padding: 16px 12px; overflow-y: auto;
}
.sidebar-nav ul { list-style: none; display: flex; flex-direction: column; gap: 4px; }
.sidebar-nav li a {
  display: flex; align-items: center; gap: 12px;
  padding: 11px 14px;
  border-radius: var(--radius-sm);
  color: rgba(255,255,255,0.7);
  font-size: 0.88rem;
  font-weight: 500;
  transition: background var(--transition), color var(--transition);
}
.sidebar-nav li a i {
  width: 18px; text-align: center;
  font-size: 0.9rem; opacity: 0.8;
}
.sidebar-nav li a:hover,
.sidebar-nav li a.active {
  background: rgba(255,255,255,0.1);
  color: #fff;
}
.sidebar-nav li a.active { background: rgba(201,169,110,0.18); color: var(--accent); }
.sidebar-nav li a.active i { opacity: 1; }
.sidebar-nav .nav-logout a { color: rgba(230,100,100,0.8); margin-top: 8px; }
.sidebar-nav .nav-logout a:hover { background: rgba(224,92,92,0.15); color: #f98e8e; }

/* Top bar (mobile) */
.topbar {
  display: none;
  position: fixed; top: 0; left: 0; right: 0;
  height: 58px;
  background: var(--header-bg);
  align-items: center;
  padding: 0 18px;
  z-index: 99;
  box-shadow: 0 2px 12px rgba(0,0,0,0.15);
}
.topbar-logo {
  font-family: 'Playfair Display', serif;
  font-size: 1.15rem;
  color: #fff;
  flex: 1;
}
.topbar-logo span { color: var(--accent); }
.hamburger {
  background: none; border: none; cursor: pointer;
  color: #fff; font-size: 1.3rem; padding: 4px 6px;
  display: flex; align-items: center;
}

/* Overlay */
.sidebar-overlay {
  display: none;
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 98;
}

/* Main content */
.main-content {
  margin-left: var(--sidebar-w);
  flex: 1;
  min-height: 100vh;
  display: flex; flex-direction: column;
}
.main-inner {
  flex: 1;
  padding: 36px 40px;
  max-width: 1100px;
}

/* ===== SECTION HEADER ===== */
.section-header {
  margin-bottom: 28px;
}
.section-header h2 {
  font-size: 1.75rem;
  color: var(--header-bg);
}
.section-header p {
  font-size: 0.875rem;
  color: var(--text-muted);
  margin-top: 4px;
}

/* ===== WELCOME BANNER ===== */
.welcome-banner {
  background: linear-gradient(135deg, var(--header-bg) 0%, #5a2845 100%);
  color: #fff;
  border-radius: var(--radius);
  padding: 28px 32px;
  margin-bottom: 32px;
  position: relative; overflow: hidden;
}
.welcome-banner::after {
  content: '';
  position: absolute; right: -30px; top: -30px;
  width: 160px; height: 160px;
  background: radial-gradient(circle, rgba(201,169,110,0.22) 0%, transparent 70%);
  pointer-events: none;
}
.welcome-banner h2 { font-size: 1.5rem; margin-bottom: 5px; }
.welcome-banner p { font-size: 0.875rem; opacity: 0.75; }
.welcome-banner .accent-dot { color: var(--accent); }

/* ===== CREATE RECEIPT FORM ===== */
.receipt-form-card {
  padding: 32px;
  margin-bottom: 24px;
}
.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 18px;
}
.form-grid .full-col { grid-column: 1 / -1; }
.form-section-title {
  font-family: 'Playfair Display', serif;
  font-size: 1rem;
  color: var(--primary);
  margin: 20px 0 14px;
  padding-bottom: 6px;
  border-bottom: 1.5px solid var(--border);
}

/* Items table */
.items-table-wrap { overflow-x: auto; }
.items-table {
  width: 100%; border-collapse: collapse; font-size: 0.875rem;
}
.items-table th {
  text-align: left; padding: 10px 12px;
  background: var(--bg);
  border-bottom: 1.5px solid var(--border);
  font-size: 0.75rem; font-weight: 600;
  color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.05em;
}
.items-table td { padding: 8px 8px; border-bottom: 1px solid var(--border); }
.items-table td input { padding: 8px 10px; font-size: 0.85rem; }
.items-table .remove-item-btn {
  background: none; border: none; cursor: pointer;
  color: var(--unpaid); font-size: 0.95rem; padding: 4px 8px;
  border-radius: 6px; transition: background var(--transition);
}
.items-table .remove-item-btn:hover { background: #fdeaea; }
.add-item-row { margin-top: 10px; }

/* Total row */
.totals-grid {
  display: grid; grid-template-columns: 1fr 1fr 1fr;
  gap: 14px; margin-top: 8px;
}
.total-box {
  background: var(--bg);
  border-radius: var(--radius-sm);
  padding: 14px 16px;
  border: 1.5px solid var(--border);
}
.total-box label {
  font-size: 0.72rem; text-transform: uppercase;
  letter-spacing: 0.06em; color: var(--text-muted);
  display: block; margin-bottom: 5px;
}
.total-box span {
  font-family: 'Playfair Display', serif;
  font-size: 1.25rem;
  font-weight: 600;
  color: var(--text);
}
.total-box.balance span { color: var(--unpaid); }
.total-box.paid-box span { color: var(--paid); }

/* ===== RECEIPT CARDS ===== */
.receipts-grid {
  display: flex; flex-direction: column; gap: 18px;
}
.receipt-card { padding: 24px 26px; }
.receipt-card-header {
  display: flex; align-items: flex-start; justify-content: space-between;
  margin-bottom: 14px; gap: 12px; flex-wrap: wrap;
}
.receipt-card-title h3 { font-size: 1rem; color: var(--header-bg); margin-bottom: 3px; }
.receipt-card-title span { font-size: 0.78rem; color: var(--text-muted); }
.receipt-card-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.receipt-meta {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 10px 18px; font-size: 0.825rem; color: var(--text-muted);
  margin-bottom: 14px;
}
.receipt-meta strong { color: var(--text); }
.receipt-items-list { margin-top: 10px; }
.receipt-items-list h4 {
  font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.07em;
  color: var(--text-muted); margin-bottom: 6px;
}
.items-mini-table { width: 100%; border-collapse: collapse; font-size: 0.8rem; }
.items-mini-table th {
  text-align: left; padding: 5px 10px;
  background: var(--bg); color: var(--text-muted);
  font-size: 0.72rem; text-transform: uppercase;
}
.items-mini-table td { padding: 5px 10px; border-bottom: 1px solid var(--border); }

/* Edit payment modal */
.edit-payment-panel {
  background: var(--bg);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 20px;
  margin-top: 14px;
  display: none;
  animation: fadeIn 0.25s ease both;
}
.edit-payment-panel.open { display: block; }
.edit-payment-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin-bottom: 14px; }

/* ===== SALES BOOK ===== */
.sales-grid { display: flex; flex-direction: column; gap: 14px; }
.sale-card {
  padding: 20px 24px;
  display: flex; align-items: center; justify-content: space-between;
  gap: 16px; flex-wrap: wrap;
}
.sale-card-left h3 { font-size: 0.95rem; color: var(--header-bg); margin-bottom: 3px; }
.sale-card-left span { font-size: 0.78rem; color: var(--text-muted); }
.sale-amounts {
  display: flex; gap: 20px; flex-wrap: wrap;
}
.sale-amount-item { text-align: right; }
.sale-amount-item label {
  font-size: 0.7rem; text-transform: uppercase;
  letter-spacing: 0.05em; color: var(--text-muted);
  display: block; margin-bottom: 2px;
}
.sale-amount-item span {
  font-family: 'Playfair Display', serif;
  font-size: 1.05rem; font-weight: 600; color: var(--text);
}

/* ===== EMPTY STATE ===== */
.empty-state {
  text-align: center; padding: 60px 20px;
  color: var(--text-muted);
}
.empty-state i { font-size: 3rem; color: var(--accent-light); margin-bottom: 16px; display: block; }
.empty-state p { font-size: 0.9rem; }

/* ===== RESPONSIVE ===== */
@media (max-width: 900px) {
  .sidebar {
    transform: translateX(-100%);
  }
  .sidebar.open {
    transform: translateX(0);
    box-shadow: 4px 0 32px rgba(0,0,0,0.3);
  }
  .sidebar-overlay.show { display: block; }
  .topbar { display: flex; }
  .main-content { margin-left: 0; padding-top: 58px; }
  .main-inner { padding: 24px 18px; }
  .form-grid { grid-template-columns: 1fr; }
  .totals-grid { grid-template-columns: 1fr 1fr; }
  .edit-payment-grid { grid-template-columns: 1fr; }
}
@media (max-width: 560px) {
  .totals-grid { grid-template-columns: 1fr; }
  .receipt-meta { grid-template-columns: 1fr 1fr; }
  .sale-amounts { gap: 12px; }
  .receipt-card { padding: 18px 16px; }
  .receipt-form-card { padding: 18px 16px; }
}