/* ============================================================
   BASE — Tema Marrom Escuro / Dourado
   ============================================================ */
@import url('https://fonts.googleapis.com/css2?family=Cinzel:wght@600;700&family=Outfit:wght@400;500;600;700;800&display=swap');

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

:root {
  --bg:            #140800;
  --surface:       #231100;
  --surface2:      #2d1800;
  --surface3:      #3a1f00;
  --border:        #5a2e00;
  --border-light:  #7a4010;
  --gold:          #c8921a;
  --gold-light:    #e8b84b;
  --gold-dim:      #8a6010;
  --paid:          #2d8f55;
  --paid-bg:       rgba(45,143,85,.15);
  --paid-border:   #2d8f55;
  --pending:       #c07820;
  --pending-bg:    rgba(192,120,32,.15);
  --pending-border:#c07820;
  --danger:        #c02020;
  --inactive:      #5a4a30;
  --text:          #f5e8d0;
  --text-mid:      #c8a870;
  --text-muted:    #806040;
  --radius-sm:     10px;
  --radius:        14px;
  --radius-lg:     22px;
  --shadow:        0 2px 12px rgba(0,0,0,.5);
  --shadow-lg:     0 8px 32px rgba(0,0,0,.7);
}

html { height: 100%; }

body {
  font-family: 'Outfit', -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100%;
  padding-bottom: 40px;
  -webkit-tap-highlight-color: transparent;
  background-image:
    radial-gradient(ellipse at 20% 0%, rgba(120,60,0,.35) 0%, transparent 60%),
    radial-gradient(ellipse at 80% 100%, rgba(80,30,0,.25) 0%, transparent 60%);
}

/* ============================================================
   HEADER
   ============================================================ */
.header {
  background: linear-gradient(180deg, #2a1200 0%, #1a0900 100%);
  color: var(--text);
  padding: 48px 20px 20px;
  position: sticky;
  top: 0;
  z-index: 100;
  border-bottom: 1px solid var(--border);
  box-shadow: 0 4px 24px rgba(0,0,0,.6);
}

.header-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 18px;
}

.app-brand {
  display: flex;
  align-items: center;
  gap: 10px;
}

.brand-icon {
  width: 38px;
  height: 38px;
  background: linear-gradient(135deg, var(--gold) 0%, #8a5c10 100%);
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  font-weight: 800;
  color: #fff;
  box-shadow: 0 2px 8px rgba(200,146,26,.4);
}

.brand-name {
  font-family: 'Cinzel', serif;
  font-size: 19px;
  font-weight: 700;
  color: var(--gold-light);
  letter-spacing: .5px;
}

.admin-badge {
  font-size: 10px;
  font-weight: 700;
  background: var(--gold);
  color: #1a0800;
  padding: 2px 8px;
  border-radius: 20px;
  letter-spacing: .08em;
  text-transform: uppercase;
}

.add-btn {
  width: 40px;
  height: 40px;
  border-radius: 12px;
  background: var(--surface2);
  border: 1px solid var(--border-light);
  color: var(--gold-light);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background .2s, transform .1s;
}
.add-btn:active { background: var(--surface3); transform: scale(.94); }

/* Month navigation */
.month-nav {
  display: flex;
  align-items: center;
  gap: 12px;
}

.month-label {
  flex: 1;
  text-align: center;
  font-size: 17px;
  font-weight: 600;
  color: var(--gold-light);
  letter-spacing: -.1px;
}

.nav-btn {
  width: 34px;
  height: 34px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 9px;
  color: var(--gold-light);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background .2s;
}
.nav-btn:active { background: var(--surface3); }

/* ============================================================
   SUMMARY CARDS
   ============================================================ */
.summary-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  padding: 16px 16px 0;
}

.summary-card {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 14px 16px;
  box-shadow: var(--shadow);
  display: flex;
  align-items: center;
  gap: 12px;
  border: 1px solid var(--border);
  position: relative;
  overflow: hidden;
}

.paid-card    { border-top: 3px solid var(--paid);    }
.pending-card { border-top: 3px solid var(--pending); }

.summary-icon {
  width: 34px;
  height: 34px;
  border-radius: 9px;
  font-size: 16px;
  font-weight: 800;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.paid-card    .summary-icon { background: var(--paid-bg);    color: var(--paid);    border: 1px solid var(--paid-border); }
.pending-card .summary-icon { background: var(--pending-bg); color: var(--pending); border: 1px solid var(--pending-border); }

.summary-body {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-width: 0;
}

.summary-label {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--text-muted);
}

.summary-count {
  font-size: 24px;
  font-weight: 800;
  line-height: 1.1;
}

.paid-card    .summary-count { color: var(--paid);    }
.pending-card .summary-count { color: var(--pending); }

.summary-value {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  text-align: right;
  white-space: nowrap;
  flex-shrink: 0;
}

/* ============================================================
   SEARCH BAR
   ============================================================ */
.search-bar {
  margin: 14px 16px 10px;
  background: var(--surface);
  border-radius: var(--radius-sm);
  border: 1.5px solid var(--border);
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 14px;
  transition: border-color .2s;
}
.search-bar:focus-within { border-color: var(--gold); }

.search-bar svg { flex-shrink: 0; }

.search-bar input {
  flex: 1;
  border: none;
  outline: none;
  font-family: 'Outfit', sans-serif;
  font-size: 15px;
  color: var(--text);
  background: transparent;
  padding: 11px 0;
}
.search-bar input::placeholder { color: var(--text-muted); }

/* ============================================================
   CLIENT LIST
   ============================================================ */
.client-list {
  padding: 6px 16px 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.section-title {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .1em;
  color: var(--gold-dim);
  padding: 10px 2px 4px;
}

/* ============================================================
   CLIENT CARD
   ============================================================ */
.client-card {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 13px 14px;
  border: 1px solid var(--border);
  border-left: 4px solid transparent;
  transition: transform .12s, box-shadow .12s;
  position: relative;
  overflow: hidden;
}

.client-card:active { transform: scale(.99); }
.client-card.paid    { border-left-color: var(--paid);    }
.client-card.pending { border-left-color: var(--pending); }
.client-card.inactive { border-left-color: var(--inactive); opacity: .55; }

.status-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
  margin-right: 2px;
}
.paid    .status-dot { background: var(--paid);    box-shadow: 0 0 8px rgba(45,143,85,.6); }
.pending .status-dot { background: var(--pending); box-shadow: 0 0 8px rgba(192,120,32,.6); }
.inactive .status-dot{ background: var(--inactive); }

.client-info { flex: 1; min-width: 0; }

.client-name {
  font-size: 15px;
  font-weight: 700;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-bottom: 3px;
}

.client-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  font-size: 12px;
  color: var(--text-muted);
  font-weight: 500;
}

.meta-chip { display: flex; align-items: center; gap: 3px; }

.client-price {
  font-size: 14px;
  font-weight: 700;
  color: var(--gold-light);
  margin-top: 4px;
}

.next-due {
  font-size: 11px;
  color: var(--paid);
  margin-top: 2px;
  font-weight: 600;
}

.client-actions {
  display: flex;
  gap: 6px;
  flex-shrink: 0;
}

.action-btn {
  width: 36px;
  height: 36px;
  border: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 15px;
  transition: transform .1s, opacity .15s;
  background: var(--surface2);
  color: var(--text);
  border: 1px solid var(--border);
}
.action-btn:active { transform: scale(.88); opacity: .7; }

.btn-toggle-paid    { border-color: var(--paid);    color: var(--paid);    }
.btn-toggle-pending { border-color: var(--pending); color: var(--pending); }
.btn-edit           { color: var(--gold-light); border-color: var(--gold-dim); }
.btn-deactivate     { color: var(--text-muted); }
.btn-activate       { color: var(--paid); border-color: var(--paid); }
.btn-delete         { color: var(--danger); border-color: var(--danger); }
.btn-next-due       { color: var(--gold-light); border-color: var(--gold); font-size: 13px; }

/* ============================================================
   STATES
   ============================================================ */
.loading-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  padding: 60px 20px;
  color: var(--text-muted);
  font-size: 15px;
}

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

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

.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-muted);
}
.empty-state .empty-icon { font-size: 48px; margin-bottom: 12px; opacity: .4; }
.empty-state p { font-size: 15px; line-height: 1.6; }

.error-state {
  text-align: center;
  padding: 40px 20px;
  color: var(--danger);
  font-size: 14px;
  line-height: 1.6;
  background: rgba(192,32,32,.1);
  border-radius: var(--radius);
  border: 1px solid rgba(192,32,32,.3);
}

/* ============================================================
   MODAL
   ============================================================ */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.75);
  backdrop-filter: blur(4px);
  z-index: 300;
  align-items: flex-end;
  justify-content: center;
}
.modal-overlay.active { display: flex; }

.modal {
  background: var(--surface);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  padding: 16px 24px 36px;
  width: 100%;
  max-width: 520px;
  animation: slideUp .28s cubic-bezier(.25,.8,.25,1);
  max-height: 92vh;
  overflow-y: auto;
}
.modal-sm { padding-bottom: 28px; }

@keyframes slideUp {
  from { transform: translateY(100%); opacity: 0; }
  to   { transform: translateY(0);    opacity: 1; }
}

.modal-handle {
  width: 40px;
  height: 4px;
  background: var(--border-light);
  border-radius: 2px;
  margin: 0 auto 22px;
}

.modal-title {
  font-family: 'Cinzel', serif;
  font-size: 18px;
  font-weight: 700;
  color: var(--gold-light);
  margin-bottom: 20px;
  letter-spacing: .3px;
}

.confirm-message {
  font-size: 15px;
  color: var(--text-mid);
  line-height: 1.5;
  margin-bottom: 24px;
}

/* Form */
.form-group { margin-bottom: 14px; }

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.form-group label {
  display: block;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--gold-dim);
  margin-bottom: 6px;
}

.form-group input, .form-group select {
  width: 100%;
  padding: 12px 14px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  font-family: 'Outfit', sans-serif;
  font-size: 16px;
  color: var(--text);
  background: var(--surface2);
  transition: border-color .2s, box-shadow .2s;
  -webkit-appearance: none;
}

.form-group input:focus, .form-group select:focus {
  outline: none;
  border-color: var(--gold);
  box-shadow: 0 0 0 3px rgba(200,146,26,.18);
  background: var(--surface3);
}

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

/* Modal buttons */
.modal-actions {
  display: flex;
  gap: 10px;
  margin-top: 22px;
}

.btn-cancel, .btn-save, .btn-danger, .btn-gold {
  flex: 1;
  padding: 14px;
  border: none;
  border-radius: var(--radius-sm);
  font-family: 'Outfit', sans-serif;
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
  transition: opacity .15s, transform .1s;
}

.btn-cancel {
  background: var(--surface2);
  color: var(--text-muted);
  border: 1.5px solid var(--border);
}

.btn-save {
  background: linear-gradient(135deg, var(--gold-light), var(--gold));
  color: #1a0800;
  box-shadow: 0 2px 10px rgba(200,146,26,.4);
}

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

.btn-gold {
  background: linear-gradient(135deg, var(--gold-light), var(--gold));
  color: #1a0800;
}

.btn-cancel:active, .btn-save:active, .btn-danger:active, .btn-gold:active {
  opacity: .8;
  transform: scale(.98);
}

/* ============================================================
   TOAST
   ============================================================ */
.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(80px);
  background: var(--surface3);
  border: 1px solid var(--border-light);
  color: var(--text);
  padding: 12px 22px;
  border-radius: 100px;
  font-size: 14px;
  font-weight: 600;
  z-index: 400;
  transition: transform .3s cubic-bezier(.34,1.56,.64,1), opacity .3s;
  opacity: 0;
  white-space: nowrap;
  pointer-events: none;
  box-shadow: var(--shadow-lg);
}
.toast.show {
  transform: translateX(-50%) translateY(0);
  opacity: 1;
}

/* ============================================================
   LOCK SCREEN (Admin)
   ============================================================ */
.lock-screen {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 40px 24px;
  text-align: center;
}

.lock-icon {
  font-size: 64px;
  margin-bottom: 20px;
  filter: drop-shadow(0 4px 12px rgba(200,146,26,.4));
}

.lock-title {
  font-family: 'Cinzel', serif;
  font-size: 24px;
  font-weight: 700;
  color: var(--gold-light);
  margin-bottom: 8px;
}

.lock-subtitle {
  font-size: 14px;
  color: var(--text-muted);
  margin-bottom: 32px;
}

.lock-form {
  width: 100%;
  max-width: 320px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.lock-form input {
  width: 100%;
  padding: 14px 18px;
  border: 1.5px solid var(--border-light);
  border-radius: var(--radius-sm);
  font-family: 'Outfit', sans-serif;
  font-size: 20px;
  text-align: center;
  letter-spacing: .3em;
  color: var(--text);
  background: var(--surface2);
  outline: none;
}
.lock-form input:focus { border-color: var(--gold); box-shadow: 0 0 0 3px rgba(200,146,26,.2); }

.lock-error {
  font-size: 13px;
  color: var(--danger);
  min-height: 18px;
}

.btn-unlock {
  padding: 14px;
  background: linear-gradient(135deg, var(--gold-light), var(--gold));
  color: #1a0800;
  border: none;
  border-radius: var(--radius-sm);
  font-family: 'Outfit', sans-serif;
  font-size: 16px;
  font-weight: 700;
  cursor: pointer;
  transition: opacity .15s;
}
.btn-unlock:active { opacity: .85; }

/* Admin-specific extras */
.admin-header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.logout-btn {
  padding: 8px 14px;
  background: transparent;
  border: 1px solid var(--border-light);
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  font-family: 'Outfit', sans-serif;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}
.logout-btn:active { background: var(--surface2); }

/* ============================================================
   RESPONSIVE
   ============================================================ */
@media (min-width: 480px) {
  .header       { padding: 52px 24px 20px; }
  .summary-grid { padding: 16px 24px 0; }
  .search-bar   { margin: 14px 24px 10px; }
  .client-list  { padding: 6px 24px 24px; }
}
