/* ============================================================
   NIKKI OPENS DOORS — Lease Agreement Generator
   Aesthetic: Soft rose / blush — feminine, warm, elegant
   Fonts: Cormorant Garamond (display), Nunito (body)
   ============================================================ */

:root {
  --bg: #FFF8FA;
  --surface: #FFFFFF;
  --sidebar-bg: #1A1118;
  --sidebar-hover: #2A1D26;
  --sidebar-active: #3D1F30;
  --primary: #C75B7A;
  --primary-hover: #D76E8C;
  --primary-light: #FDF0F4;
  --accent: #D4A07A;
  --text: #2D2028;
  --text-secondary: #7A6670;
  --text-muted: #B0A0A8;
  --text-sidebar: #9A8A92;
  --text-sidebar-active: #F8E8EE;
  --border: #F0DDE4;
  --border-focus: #C75B7A;
  --radius: 12px;
  --radius-lg: 16px;
  --shadow: 0 1px 4px rgba(80,20,40,0.04), 0 4px 14px rgba(80,20,40,0.03);
  --shadow-lg: 0 8px 36px rgba(80,20,40,0.1);
  --font-display: 'Nunito', -apple-system, sans-serif;
  --font-body: 'Nunito', -apple-system, sans-serif;
  --transition: 0.18s cubic-bezier(0.4, 0, 0.2, 1);
}

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

html, body { height: 100%; overflow: hidden; }

body {
  font-family: var(--font-body);
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

/* ============================================================
   AUTH SCREEN
   ============================================================ */
.auth-screen {
  height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  overflow: hidden;
}

.auth-bg {
  position: absolute;
  inset: 0;
  background:
    radial-gradient(ellipse 80% 60% at 20% 80%, rgba(199, 91, 122, 0.1), transparent),
    radial-gradient(ellipse 60% 50% at 80% 20%, rgba(212, 160, 122, 0.08), transparent),
    radial-gradient(ellipse 40% 40% at 50% 50%, rgba(199, 91, 122, 0.04), transparent),
    var(--bg);
  z-index: 0;
}

.auth-card {
  position: relative;
  z-index: 1;
  background: var(--surface);
  border-radius: 20px;
  padding: 48px 44px;
  width: 100%;
  max-width: 400px;
  box-shadow: var(--shadow-lg);
  text-align: center;
  animation: authIn 0.5s ease-out;
}

@keyframes authIn {
  from { opacity: 0; transform: translateY(16px); }
  to { opacity: 1; transform: translateY(0); }
}

.auth-logo {
  height: 56px;
  margin-bottom: 28px;
}

.auth-title {
  font-family: var(--font-display);
  font-size: 2.2rem;
  font-weight: 800;
  color: var(--text);
  margin-bottom: 6px;
}

.auth-subtitle {
  font-size: 0.95rem;
  color: var(--text-secondary);
  margin-bottom: 32px;
}

.auth-step { animation: fadeIn 0.3s ease; }

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

.auth-otp-msg {
  font-size: 0.88rem;
  color: var(--text-secondary);
  margin-bottom: 20px;
}

.auth-error {
  margin-top: 16px;
  padding: 10px 14px;
  background: #FEF2F2;
  border: 1px solid #FECACA;
  color: #B91C1C;
  border-radius: 8px;
  font-size: 0.85rem;
}

.auth-loading {
  display: flex;
  justify-content: center;
  padding: 20px;
}

.spinner {
  width: 28px;
  height: 28px;
  border: 3px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* ============================================================
   INPUTS (shared auth + form)
   ============================================================ */
.input-group {
  text-align: left;
  margin-bottom: 16px;
}

.input-group label {
  display: block;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 6px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.input-group input {
  width: 100%;
}

input, select {
  padding: 12px 15px;
  border: 1.5px solid var(--border);
  border-radius: 10px;
  font-family: var(--font-body);
  font-size: 0.95rem;
  color: var(--text);
  background: var(--surface);
  transition: border var(--transition), box-shadow var(--transition);
  width: 100%;
}

input::placeholder { color: var(--text-muted); }

input:focus, select:focus {
  outline: none;
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px rgba(155, 77, 58, 0.08);
}

input[readonly] {
  background: var(--bg);
  color: var(--text-secondary);
  cursor: default;
}

/* ============================================================
   BUTTONS
   ============================================================ */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 11px 22px;
  border: none;
  border-radius: 8px;
  font-family: var(--font-body);
  font-size: 0.88rem;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition);
  white-space: nowrap;
}

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

.btn--primary:hover {
  background: var(--primary-hover);
  box-shadow: 0 4px 16px rgba(155, 77, 58, 0.25);
  transform: translateY(-1px);
}

.btn--outline {
  background: transparent;
  color: var(--text);
  border: 1.5px solid var(--border);
}

.btn--outline:hover {
  border-color: var(--primary);
  color: var(--primary);
  background: var(--primary-light);
}

.btn--ghost {
  background: transparent;
  color: var(--text-secondary);
}

.btn--ghost:hover {
  color: var(--text);
}

.btn--block { width: 100%; }

.btn--save {
  background: var(--primary);
  color: #fff;
}

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

.btn-icon {
  background: none;
  border: 1px solid transparent;
  color: var(--text-sidebar);
  width: 30px;
  height: 30px;
  border-radius: 7px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--transition);
}

.btn-icon:hover {
  background: var(--sidebar-hover);
  color: #fff;
  border-color: rgba(255,255,255,0.06);
}

/* ============================================================
   LAYOUT
   ============================================================ */
.layout {
  display: flex;
  height: 100vh;
}

/* ============================================================
   SIDEBAR
   ============================================================ */
.sidebar {
  width: 270px;
  min-width: 270px;
  background: var(--sidebar-bg);
  display: flex;
  flex-direction: column;
  animation: sidebarIn 0.4s ease;
}

@keyframes sidebarIn {
  from { opacity: 0; transform: translateX(-20px); }
  to { opacity: 1; transform: translateX(0); }
}

.sidebar-header {
  padding: 24px 22px 16px;
}

.sidebar-logo {
  height: 40px;
  opacity: 0.9;
  filter: brightness(1.2);
}

.sidebar-nav {
  padding: 0 10px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.nav-tab {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 11px 14px;
  background: none;
  border: none;
  color: var(--text-sidebar);
  font-family: var(--font-body);
  font-size: 0.92rem;
  font-weight: 600;
  border-radius: 8px;
  cursor: pointer;
  transition: all var(--transition);
  text-align: left;
}

.nav-tab:hover { background: var(--sidebar-hover); color: #ccc; }

.nav-tab.active {
  background: var(--sidebar-active);
  color: var(--text-sidebar-active);
  font-weight: 600;
}

.nav-tab svg { opacity: 0.6; flex-shrink: 0; }
.nav-tab.active svg { opacity: 1; }

.sidebar-divider {
  height: 1px;
  background: rgba(255,255,255,0.06);
  margin: 12px 16px;
}

/* Sessions */
.sidebar-sessions {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  padding: 0 10px;
}

.sessions-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 4px 6px 10px;
}

.sessions-label {
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1.2px;
  color: #555;
}

.session-list {
  list-style: none;
  overflow-y: auto;
  flex: 1;
}

.session-list::-webkit-scrollbar { width: 3px; }
.session-list::-webkit-scrollbar-thumb { background: #333; border-radius: 3px; }

.session-item {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 9px 12px;
  border-radius: 7px;
  cursor: pointer;
  transition: all 0.12s;
  font-size: 0.84rem;
  color: #888;
}

.session-item:hover { background: var(--sidebar-hover); color: #ccc; }

.session-item.active {
  background: var(--sidebar-active);
  color: var(--text-sidebar-active);
}

.session-item-name {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.session-item-delete {
  background: none;
  border: none;
  color: transparent;
  cursor: pointer;
  font-size: 1rem;
  padding: 0 4px;
  border-radius: 4px;
  transition: all 0.12s;
  flex-shrink: 0;
  line-height: 1;
}

.session-item:hover .session-item-delete { color: #666; }
.session-item-delete:hover { color: #e74c3c !important; }

.session-empty {
  color: #444;
  font-size: 0.82rem;
  text-align: center;
  padding: 28px 12px;
  font-style: italic;
}

/* Sidebar footer */
.sidebar-footer {
  padding: 14px 12px;
  border-top: 1px solid rgba(255,255,255,0.06);
}

.sidebar-user {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 10px;
  padding: 0 2px;
}

.user-email {
  font-size: 0.75rem;
  color: #555;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.btn-logout {
  background: none;
  border: none;
  color: #555;
  cursor: pointer;
  padding: 4px;
  border-radius: 4px;
  transition: color var(--transition);
  display: flex;
}

.btn-logout:hover { color: #e74c3c; }

/* ============================================================
   MAIN CONTENT
   ============================================================ */
.main {
  flex: 1;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.tab-pane {
  display: none;
  flex-direction: column;
  height: 100%;
  overflow: hidden;
}

.tab-pane.active {
  display: flex;
}

.pane-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 24px 36px 20px;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.pane-title {
  font-family: var(--font-display);
  font-size: 2rem;
  font-weight: 800;
  color: var(--text);
}

.pane-subtitle {
  font-size: 0.82rem;
  color: var(--text-muted);
  margin-top: 2px;
}

.pane-actions {
  display: flex;
  gap: 10px;
}

.pane-body {
  flex: 1;
  overflow-y: auto;
  padding: 24px 36px 48px;
}

.pane-body::-webkit-scrollbar { width: 6px; }
.pane-body::-webkit-scrollbar-thumb { background: #ddd; border-radius: 6px; }

/* ============================================================
   CARDS
   ============================================================ */
.card {
  background: var(--surface);
  border-radius: var(--radius-lg);
  padding: 24px 28px;
  margin-bottom: 20px;
  box-shadow: var(--shadow);
  animation: cardIn 0.35s ease both;
}

@keyframes cardIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

.card:nth-child(2) { animation-delay: 0.04s; }
.card:nth-child(3) { animation-delay: 0.08s; }
.card:nth-child(4) { animation-delay: 0.12s; }
.card:nth-child(5) { animation-delay: 0.16s; }

.card-title {
  font-family: var(--font-display);
  font-size: 1.35rem;
  font-weight: 800;
  color: var(--primary);
  margin-bottom: 20px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border);
}

.card-desc {
  font-size: 0.88rem;
  color: var(--text-secondary);
  margin-bottom: 20px;
}

.card-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
  margin-bottom: 20px;
}

.card-row .card { margin-bottom: 0; }

/* ============================================================
   FIELD GRID
   ============================================================ */
.field-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}

.field {
  display: flex;
  flex-direction: column;
}

.field label {
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--text-secondary);
  margin-bottom: 6px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.field--full { grid-column: 1 / -1; }
.field--quarter { grid-column: span 1; max-width: 140px; }
.field--three-quarter { grid-column: span 1; }

/* Computed values row */
.computed-row {
  display: flex;
  gap: 16px;
}

.computed {
  flex: 1;
  background: var(--primary-light);
  border-radius: 8px;
  padding: 12px 16px;
  border: 1px solid rgba(155, 77, 58, 0.1);
}

.computed-label {
  display: block;
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--primary);
  margin-bottom: 4px;
}

.computed-en {
  display: block;
  font-size: 0.84rem;
  font-weight: 500;
  color: var(--text);
}

.computed-th {
  display: block;
  font-size: 0.82rem;
  color: var(--text-secondary);
  margin-top: 2px;
}

/* Backup */
.backup-row {
  display: flex;
  gap: 12px;
}

/* ============================================================
   MODAL
   ============================================================ */
.modal {
  position: fixed;
  inset: 0;
  z-index: 1000;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,0.45);
  animation: fadeIn 0.2s ease;
}

.modal-dialog {
  position: relative;
  background: var(--surface);
  width: 90%;
  max-width: 850px;
  height: 90vh;
  margin: 5vh auto;
  border-radius: 16px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: 0 24px 80px rgba(0,0,0,0.2);
  animation: modalIn 0.3s ease;
}

@keyframes modalIn {
  from { opacity: 0; transform: scale(0.96) translateY(12px); }
  to { opacity: 1; transform: scale(1) translateY(0); }
}

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

.modal-top h2 {
  font-family: var(--font-display);
  font-size: 1.1rem;
  color: var(--text);
}

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

.modal-bottom {
  padding: 14px 24px;
  border-top: 1px solid var(--border);
  text-align: right;
}

/* ============================================================
   TOAST
   ============================================================ */
.toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  padding: 12px 20px;
  background: var(--sidebar-bg);
  color: #fff;
  border-radius: 10px;
  font-size: 0.88rem;
  font-weight: 500;
  box-shadow: 0 8px 24px rgba(0,0,0,0.2);
  opacity: 0;
  transform: translateY(12px);
  transition: all 0.3s ease;
  pointer-events: none;
  z-index: 2000;
}

.toast.show {
  opacity: 1;
  transform: translateY(0);
}

/* ============================================================
   SAVE DIALOG
   ============================================================ */
.save-dialog {
  position: relative;
  background: var(--surface);
  width: 100%;
  max-width: 440px;
  margin: 30vh auto 0;
  border-radius: 20px;
  padding: 36px 32px 28px;
  text-align: center;
  box-shadow: 0 24px 80px rgba(0,0,0,0.25);
  animation: modalIn 0.25s ease;
}

.save-dialog-icon {
  width: 56px;
  height: 56px;
  margin: 0 auto 18px;
  background: var(--primary-light);
  border-radius: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--primary);
}

.save-dialog-title {
  font-family: var(--font-display);
  font-size: 1.7rem;
  font-weight: 800;
  color: var(--text);
  margin-bottom: 6px;
}

.save-dialog-desc {
  font-size: 0.88rem;
  color: var(--text-secondary);
  margin-bottom: 22px;
}

.save-dialog-field {
  margin-bottom: 24px;
}

.save-dialog-field input {
  width: 100%;
  padding: 13px 16px;
  font-size: 0.95rem;
  border: 1.5px solid var(--border);
  border-radius: 10px;
  text-align: center;
  font-family: var(--font-body);
  transition: border var(--transition), box-shadow var(--transition);
}

.save-dialog-field input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 4px rgba(155, 77, 58, 0.1);
}

.save-dialog-actions {
  display: flex;
  gap: 10px;
}

.save-dialog-actions .btn {
  flex: 1;
  padding: 12px 0;
}

/* ============================================================
   RESPONSIVE
   ============================================================ */
@media (max-width: 900px) {
  .card-row { grid-template-columns: 1fr; }
}

@media (max-width: 768px) {
  .layout { flex-direction: column; }
  .sidebar { width: 100%; min-width: 100%; max-height: 56px; overflow: hidden; flex-direction: row; align-items: center; }
  .sidebar.open { max-height: 100vh; flex-direction: column; align-items: stretch; }
  .sidebar-header { padding: 8px 16px; }
  .sidebar-logo { height: 32px; }
  .pane-header { padding: 16px 20px; flex-wrap: wrap; gap: 10px; }
  .pane-body { padding: 16px 20px 40px; }
  .field-grid { grid-template-columns: 1fr; }
  .field--quarter { max-width: none; }
  .computed-row { flex-direction: column; }
}

/* ============================================================
   CONTRACT PDF STYLES (render target, never visible)
   ============================================================ */
.contract {
  font-family: 'Times New Roman', Times, serif;
  font-size: 13px;
  line-height: 1.55;
  color: #000;
  width: 210mm;
}

.contract-page {
  position: relative;
  padding: 18mm 20mm 28mm 20mm;
  min-height: 277mm;
  page-break-after: always;
}

.contract-page:last-child { page-break-after: auto; }

.page-ack { display: flex; justify-content: space-between; font-size: 11px; margin-bottom: 16px; }
.page-ack-col { text-align: center; width: 45%; }
.page-ack-col .dots { display: block; margin-top: 2px; }
.page-ack-col .ack-name { display: block; font-size: 10px; }
.contract-title { text-align: center; font-size: 18px; font-weight: bold; margin: 8px 0 2px; }
.contract-title-th { text-align: center; font-size: 15px; font-weight: bold; margin-bottom: 16px; }
.clause { margin-bottom: 10px; text-align: justify; }
.clause-th { margin-bottom: 12px; text-align: justify; }
.clause-number { font-weight: bold; margin-top: 14px; margin-bottom: 4px; }
.indent { margin-left: 20px; }
.bank-table { width: 100%; margin: 10px 0; border-collapse: collapse; }
.bank-table td { padding: 3px 8px; vertical-align: top; }
.bank-table td:first-child { width: 200px; }
.signature-block { margin-top: 40px; display: flex; justify-content: space-between; }
.sig-col { width: 45%; text-align: center; }
.sig-line { border-bottom: 1px solid #000; width: 200px; margin: 40px auto 4px; }
.sig-name { font-size: 12px; }
.witness-block { margin-top: 30px; display: flex; justify-content: space-between; }
.qr-container { text-align: center; margin: 20px 0; }
.qr-container img { width: 120px; height: 120px; }
