/* ===========================
   Potré Studio – Invoice App
   =========================== */

:root {
  --cream: #faf7f2;
  --warm-white: #fffef9;
  --dark: #1a1614;
  --brown: #6b4c3b;
  --brown-light: #c4916e;
  --gold: #c9a84c;
  --gold-light: #e8d49a;
  --sand: #e8ddd0;
  --sand-dark: #d4c4b0;
  --text-muted: #8c7b6e;
  --border: #e0d4c8;
  --shadow: 0 4px 24px rgba(107,76,59,0.10);
  --radius: 12px;
}

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

body {
  font-family: 'DM Sans', sans-serif;
  background: var(--cream);
  color: var(--dark);
  min-height: 100vh;
  overflow-x: hidden;
}

/* ===== LAYOUT ===== */
.app-container {
  display: flex;
  min-height: 100vh;
}

/* ===== SIDEBAR ===== */
.sidebar {
  width: 380px;
  min-width: 340px;
  background: var(--warm-white);
  border-right: 1.5px solid var(--border);
  overflow-y: auto;
  padding: 0 0 40px 0;
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  max-height: 100vh;
}

.sidebar-header {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 24px 24px 20px;
  border-bottom: 1.5px solid var(--border);
  background: var(--cream);
  position: sticky;
  top: 0;
  z-index: 10;
}

.sidebar-logo {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid var(--gold);
  box-shadow: 0 2px 8px rgba(201,168,76,0.2);
}

.brand-name {
  font-family: 'Playfair Display', serif;
  font-size: 1.3rem;
  font-weight: 700;
  color: var(--dark);
  letter-spacing: 0.5px;
}

.brand-sub {
  font-size: 0.72rem;
  color: var(--text-muted);
  font-weight: 500;
  letter-spacing: 1.5px;
  text-transform: uppercase;
}

/* ===== FORM SECTIONS ===== */
form {
  padding: 0 20px;
}

.form-section {
  margin: 20px 0 0;
  padding: 18px;
  background: var(--cream);
  border-radius: var(--radius);
  border: 1px solid var(--border);
}

.section-title {
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  color: var(--brown);
  margin-bottom: 14px;
}

.field-group {
  margin-bottom: 10px;
}

.field-group label {
  display: block;
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--text-muted);
  letter-spacing: 0.5px;
  margin-bottom: 4px;
  text-transform: uppercase;
}

.field-group input,
.field-group textarea,
.field-group select {
  width: 100%;
  padding: 8px 12px;
  border: 1.5px solid var(--border);
  border-radius: 8px;
  font-family: 'DM Sans', sans-serif;
  font-size: 0.875rem;
  color: var(--dark);
  background: var(--warm-white);
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.field-group input:focus,
.field-group textarea:focus,
.field-group select:focus {
  border-color: var(--brown-light);
  box-shadow: 0 0 0 3px rgba(196,145,110,0.12);
}

.field-group textarea { resize: vertical; }

/* ===== TOTAL PREVIEW ===== */
.total-preview {
  background: var(--warm-white);
  border: 1.5px solid var(--gold-light);
  border-radius: 8px;
  padding: 12px 14px;
  margin-top: 10px;
}
.total-row {
  display: flex;
  justify-content: space-between;
  font-size: 0.82rem;
  color: var(--text-muted);
  padding: 3px 0;
}
.total-sisa {
  font-weight: 700;
  color: var(--brown);
  font-size: 0.92rem;
  border-top: 1px solid var(--gold-light);
  margin-top: 6px;
  padding-top: 6px;
}

/* ===== TEMPLATE INPUTS ===== */
.template-row {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 6px;
}
.tmpl-num {
  font-size: 0.75rem;
  color: var(--text-muted);
  min-width: 18px;
}
.tmpl-input {
  flex: 1;
  padding: 7px 10px;
  border: 1.5px solid var(--border);
  border-radius: 7px;
  font-family: 'DM Sans', sans-serif;
  font-size: 0.85rem;
  background: var(--warm-white);
  outline: none;
  color: var(--dark);
}
.tmpl-input:focus { border-color: var(--brown-light); }
.btn-remove-tmpl {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 0.85rem;
  padding: 4px 6px;
  border-radius: 5px;
  transition: background 0.15s;
}
.btn-remove-tmpl:hover { background: #f3ddd3; color: #c0392b; }
.btn-add-tmpl {
  width: 100%;
  padding: 8px;
  border: 1.5px dashed var(--sand-dark);
  border-radius: 8px;
  background: transparent;
  color: var(--brown);
  font-size: 0.8rem;
  font-family: 'DM Sans', sans-serif;
  cursor: pointer;
  transition: background 0.2s;
}
.btn-add-tmpl:hover { background: var(--sand); }

/* ===== ACTION BUTTONS ===== */
.form-actions {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 24px;
  padding: 0 0 20px;
}
.btn-preview, .btn-download, .btn-reset {
  padding: 12px;
  border: none;
  border-radius: 10px;
  font-family: 'DM Sans', sans-serif;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.15s, opacity 0.15s;
  letter-spacing: 0.3px;
}
.btn-preview {
  background: var(--brown);
  color: #fff;
}
.btn-download {
  background: linear-gradient(135deg, var(--gold), #b8924a);
  color: #fff;
}
.btn-reset {
  background: var(--sand);
  color: var(--text-muted);
}
.btn-preview:hover, .btn-download:hover { opacity: 0.88; transform: translateY(-1px); }
.btn-reset:hover { background: var(--sand-dark); }

/* ===== PREVIEW PANEL ===== */
.preview-panel {
  flex: 1;
  background: #e8e0d8;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 32px 24px;
  min-height: 100vh;
  overflow-y: auto;
}

.preview-label {
  font-size: 0.7rem;
  letter-spacing: 2px;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 20px;
  font-weight: 600;
}

.preview-wrapper {
  width: 100%;
  max-width: 680px;
  box-shadow: var(--shadow), 0 12px 48px rgba(107,76,59,0.12);
  border-radius: 4px;
  overflow: hidden;
}

/* ===== EMPTY STATE ===== */
.empty-state {
  background: white;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 80px 40px;
  text-align: center;
  color: var(--text-muted);
}
.empty-icon { font-size: 3rem; margin-bottom: 16px; }
.empty-state p { font-size: 0.95rem; line-height: 1.6; }

/* ===========================
   INVOICE DOCUMENT STYLES
   =========================== */

.invoice-doc {
  background: #fff;
  font-family: 'DM Sans', sans-serif;
  color: #1a1614;
  position: relative;
}

/* --- INVOICE HEADER --- */
.inv-header {
  background: linear-gradient(135deg, #2c1f1a 0%, #4a2e22 60%, #6b4c3b 100%);
  padding: 36px 40px 28px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
}

.inv-header-left {
  display: flex;
  align-items: center;
  gap: 16px;
}

.inv-logo {
  width: 68px;
  height: 68px;
  border-radius: 50%;
  border: 3px solid rgba(201,168,76,0.6);
  object-fit: cover;
  background: #ffffff;
}

.inv-brand { color: #fff; }
.inv-brand-name {
  font-family: 'Playfair Display', serif;
  font-size: 1.6rem;
  font-weight: 700;
  letter-spacing: 1px;
  line-height: 1;
}
.inv-brand-tagline {
  font-size: 0.68rem;
  letter-spacing: 2.5px;
  text-transform: uppercase;
  color: var(--gold-light);
  margin-top: 4px;
}

.inv-header-right { text-align: right; color: #fff; }
.inv-label-invoice {
  font-family: 'Playfair Display', serif;
  font-size: 2rem;
  font-weight: 700;
  color: var(--gold-light);
  letter-spacing: 2px;
  text-transform: uppercase;
  line-height: 1;
}
.inv-number {
  font-size: 0.8rem;
  letter-spacing: 1px;
  color: rgba(255,255,255,0.7);
  margin-top: 4px;
}
.inv-date {
  font-size: 0.75rem;
  color: rgba(255,255,255,0.55);
  margin-top: 2px;
}

/* --- GOLD DIVIDER --- */
.inv-gold-bar {
  height: 3px;
  background: linear-gradient(90deg, var(--gold), var(--gold-light), var(--gold));
}

/* --- BODY --- */
.inv-body {
  padding: 28px 40px 36px;
}

/* --- SECTION HEADERS --- */
.inv-section-label {
  font-size: 0.62rem;
  font-weight: 700;
  letter-spacing: 2.5px;
  text-transform: uppercase;
  color: var(--brown);
  margin-bottom: 10px;
  padding-bottom: 5px;
  border-bottom: 1px solid var(--border);
}

/* --- CLIENT INFO --- */
.inv-client-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px 24px;
  margin-bottom: 24px;
}
.inv-client-row { display: flex; flex-direction: column; }
.inv-client-key {
  font-size: 0.65rem;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--text-muted);
  font-weight: 600;
}
.inv-client-val {
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--dark);
  margin-top: 1px;
}

/* --- EVENT BADGE --- */
.inv-event-badge {
  display: inline-block;
  background: linear-gradient(135deg, var(--gold), #b8924a);
  color: #fff;
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  padding: 3px 10px;
  border-radius: 20px;
}

/* --- PACKAGE TABLE --- */
.inv-table {
  width: 100%;
  border-collapse: collapse;
  margin-bottom: 0;
  font-size: 0.875rem;
}
.inv-table thead th {
  background: var(--cream);
  padding: 8px 12px;
  font-size: 0.65rem;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  color: var(--text-muted);
  font-weight: 600;
  text-align: left;
  border-bottom: 1.5px solid var(--border);
}
.inv-table thead th:last-child { text-align: right; }
.inv-table tbody td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
  color: var(--dark);
}
.inv-table tbody td:last-child { text-align: right; font-weight: 500; }

/* --- TOTALS BOX --- */
.inv-totals {
  margin-top: 0;
  border-left: 3px solid var(--gold);
  background: var(--cream);
  padding: 14px 16px;
  border-radius: 0 8px 8px 0;
}
.inv-total-row {
  display: flex;
  justify-content: space-between;
  font-size: 0.85rem;
  color: var(--text-muted);
  padding: 3px 0;
}
.inv-total-grand {
  display: flex;
  justify-content: space-between;
  font-size: 1rem;
  font-weight: 700;
  color: var(--dark);
  border-top: 1.5px solid var(--gold-light);
  margin-top: 6px;
  padding-top: 8px;
}
.inv-total-sisa {
  display: flex;
  justify-content: space-between;
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--brown);
  padding-top: 4px;
}
.sisa-badge {
  background: var(--brown);
  color: #fff;
  padding: 2px 10px;
  border-radius: 14px;
  font-size: 0.88rem;
}

/* --- TEMPLATE BOX --- */
.inv-template-box {
  background: var(--cream);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 14px 16px;
  margin-bottom: 20px;
}
.inv-template-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 16px;
  margin-bottom: 8px;
}
.inv-tmpl-item {
  font-size: 0.82rem;
  color: var(--brown);
  font-weight: 600;
  background: #fff;
  border: 1px solid var(--gold-light);
  padding: 3px 10px;
  border-radius: 4px;
}
.inv-caption {
  font-family: 'Playfair Display', serif;
  font-style: italic;
  font-size: 0.9rem;
  color: var(--dark);
  margin-top: 6px;
  padding-top: 8px;
  border-top: 1px dashed var(--border);
  line-height: 1.6;
  white-space: pre-line;
}

/* --- NOTES --- */
.inv-notes-box {
  background: var(--cream);
  border-left: 3px solid var(--brown-light);
  padding: 10px 14px;
  border-radius: 0 6px 6px 0;
  font-size: 0.82rem;
  color: var(--text-muted);
  margin-bottom: 20px;
  line-height: 1.6;
  white-space: pre-line;
}

/* --- FOOTER --- */
.inv-footer {
  background: var(--cream);
  border-top: 1.5px solid var(--border);
  padding: 20px 40px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.inv-footer-msg {
  font-family: 'Playfair Display', serif;
  font-style: italic;
  font-size: 0.9rem;
  color: var(--text-muted);
}
.inv-footer-stamp {
  text-align: right;
}
.inv-footer-stamp .stamp-label {
  font-size: 0.62rem;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  color: var(--text-muted);
}
.inv-footer-stamp .stamp-name {
  font-family: 'Playfair Display', serif;
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--brown);
  margin-top: 2px;
}

/* ===== RESPONSIVE ===== */
@media (max-width: 860px) {
  .app-container { flex-direction: column; }
  .sidebar { width: 100%; min-width: unset; max-height: unset; position: static; }
  .preview-panel { padding: 20px 12px; }
  .inv-header { padding: 24px 20px 18px; flex-direction: column; text-align: center; }
  .inv-header-right { text-align: center; }
  .inv-body { padding: 20px 18px 28px; }
  .inv-footer { flex-direction: column; gap: 12px; text-align: center; }
}
