/* ── Google Fonts ─────────────────────────────────────────────────────────── */
@import url('https://fonts.googleapis.com/css2?family=Cormorant+Garamond:ital,wght@0,300;0,400;0,600;1,300&family=Montserrat:wght@300;400;500;600&display=swap');

/* ── Variables ────────────────────────────────────────────────────────────── */
:root {
  --bg:          #FAFAF8;
  --bg-alt:      #F2F0EB;
  --dark:        #1C1C1A;
  --gold:        #B8975A;
  --gold-light:  #D4B88A;
  --text-muted:  #6B6B68;
  --border:      #E5E0D8;
  --wa:          #25D366;
  --sidebar-w:   260px;
  --header-h:    64px;
  --radius:      12px;
  --shadow:      0 2px 8px rgba(28,28,26,.07);
}

/* ── Reset ────────────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
body { font-family: 'Montserrat', sans-serif; background: var(--bg); color: var(--dark); line-height: 1.55; -webkit-font-smoothing: antialiased; }
a { color: inherit; }
img { display: block; max-width: 100%; }

/* ── Layout ───────────────────────────────────────────────────────────────── */
.app { display: flex; min-height: 100vh; }

/* ── Sidebar ──────────────────────────────────────────────────────────────── */
.sidebar {
  width: var(--sidebar-w);
  background: var(--dark);
  display: flex;
  flex-direction: column;
  position: fixed;
  inset-block: 0;
  left: 0;
  z-index: 100;
}

.sidebar-logo {
  padding: 28px 24px 20px;
  border-bottom: 1px solid rgba(255,255,255,.08);
}

.sidebar-logo .logo-name {
  font-family: 'Cormorant Garamond', serif;
  font-size: 1.2rem;
  font-weight: 400;
  color: #fff;
  letter-spacing: .03em;
}

.sidebar-logo .logo-sub {
  font-size: .62rem;
  letter-spacing: .18em;
  text-transform: uppercase;
  color: var(--gold-light);
  margin-top: 3px;
}

.sidebar-nav {
  flex: 1;
  padding: 12px 0;
  overflow-y: auto;
}

.sidebar-nav a {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 11px 24px;
  color: rgba(255,255,255,.55);
  text-decoration: none;
  font-size: .82rem;
  font-weight: 500;
  letter-spacing: .02em;
  transition: color .18s, background .18s;
  border-right: 2px solid transparent;
}

.sidebar-nav a:hover { color: #fff; background: rgba(255,255,255,.05); }

.sidebar-nav a.active {
  color: var(--gold-light);
  background: rgba(184,151,90,.12);
  border-right-color: var(--gold);
}

.sidebar-nav a svg { width: 17px; height: 17px; flex-shrink: 0; }

.sidebar-user {
  padding: 14px 20px;
  border-top: 1px solid rgba(255,255,255,.08);
  display: flex;
  align-items: center;
  gap: 11px;
}

.sidebar-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--gold);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: .88rem;
  font-weight: 600;
  color: #fff;
  flex-shrink: 0;
  overflow: hidden;
}

.sidebar-avatar img { width: 100%; height: 100%; object-fit: cover; }

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

.sidebar-user-name {
  font-size: .8rem;
  font-weight: 600;
  color: #fff;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sidebar-user-role { font-size: .68rem; color: rgba(255,255,255,.4); margin-top: 1px; }

.btn-logout {
  background: none;
  border: none;
  color: rgba(255,255,255,.35);
  cursor: pointer;
  padding: 4px;
  display: flex;
  transition: color .18s;
}

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

/* ── Main ─────────────────────────────────────────────────────────────────── */
.main { flex: 1; margin-left: var(--sidebar-w); display: flex; flex-direction: column; min-height: 100vh; }

.main-header {
  height: var(--header-h);
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 32px;
  position: sticky;
  top: 0;
  z-index: 50;
  gap: 16px;
}

.main-header h1 {
  font-family: 'Cormorant Garamond', serif;
  font-size: 1.35rem;
  font-weight: 400;
  flex: 1;
}

.main-content { flex: 1; padding: 28px 32px; }

/* ── Buttons ──────────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 10px 20px;
  border-radius: 6px;
  font-family: 'Montserrat', sans-serif;
  font-size: .78rem;
  font-weight: 600;
  letter-spacing: .07em;
  text-transform: uppercase;
  cursor: pointer;
  border: none;
  transition: all .18s;
  text-decoration: none;
  white-space: nowrap;
}

.btn svg { flex-shrink: 0; }

.btn-primary { background: var(--gold); color: #fff; }
.btn-primary:hover { background: #a5864e; transform: translateY(-1px); }

.btn-outline { background: transparent; border: 1px solid var(--border); color: var(--dark); }
.btn-outline:hover { border-color: var(--gold); color: var(--gold); }

.btn-ghost { background: transparent; color: var(--text-muted); }
.btn-ghost:hover { color: var(--dark); }

.btn-danger { background: #ef4444; color: #fff; }
.btn-danger:hover { background: #dc2626; }

.btn-wa { background: var(--wa); color: #fff; }
.btn-wa:hover { background: #1aad55; }

.btn-sm { padding: 7px 14px; font-size: .72rem; }
.btn-full { width: 100%; justify-content: center; }

/* ── Cards ────────────────────────────────────────────────────────────────── */
.card {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  box-shadow: var(--shadow);
}

.card-title {
  font-family: 'Cormorant Garamond', serif;
  font-size: 1.1rem;
  font-weight: 400;
  margin-bottom: 16px;
}

/* ── Stats ────────────────────────────────────────────────────────────────── */
.stat-card {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px 24px;
  box-shadow: var(--shadow);
}

.stat-value {
  font-family: 'Cormorant Garamond', serif;
  font-size: 2.2rem;
  font-weight: 300;
  line-height: 1;
}

.stat-label {
  font-size: .7rem;
  font-weight: 600;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-top: 6px;
}

/* ── Grids ────────────────────────────────────────────────────────────────── */
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 20px; }
.grid-4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 20px; }

/* ── Welcome banner ───────────────────────────────────────────────────────── */
.welcome-banner {
  background: linear-gradient(135deg, var(--dark) 0%, #2a2a27 100%);
  border-radius: var(--radius);
  padding: 28px 32px;
  color: #fff;
  margin-bottom: 24px;
  position: relative;
  overflow: hidden;
}

.welcome-banner::before {
  content: '';
  position: absolute;
  top: -50px; right: -50px;
  width: 220px; height: 220px;
  border-radius: 50%;
  background: rgba(184,151,90,.1);
  pointer-events: none;
}

.welcome-banner h2 {
  font-family: 'Cormorant Garamond', serif;
  font-size: 1.65rem;
  font-weight: 300;
  margin-bottom: 5px;
}

.welcome-banner p { font-size: .85rem; color: rgba(255,255,255,.6); }

.welcome-banner .btn-wa { margin-top: 18px; }

/* ── Section header ───────────────────────────────────────────────────────── */
.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}

.section-title {
  font-family: 'Cormorant Garamond', serif;
  font-size: 1.1rem;
  font-weight: 400;
}

.section-link {
  font-size: .75rem;
  font-weight: 600;
  letter-spacing: .04em;
  color: var(--gold);
  text-decoration: none;
}

/* ── Appointments ─────────────────────────────────────────────────────────── */
.appt-item {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 14px 0;
  border-bottom: 1px solid var(--border);
}

.appt-item:last-child { border-bottom: none; }

.appt-date {
  text-align: center;
  min-width: 48px;
}

.appt-day {
  font-family: 'Cormorant Garamond', serif;
  font-size: 1.75rem;
  font-weight: 300;
  line-height: 1;
  color: var(--gold);
}

.appt-month {
  font-size: .62rem;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-top: 2px;
}

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

.appt-type { font-size: .88rem; font-weight: 600; }
.appt-meta { font-size: .78rem; color: var(--text-muted); margin-top: 3px; }

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

/* ── Documents ────────────────────────────────────────────────────────────── */
.doc-item {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
}

.doc-item:last-child { border-bottom: none; }

.doc-icon {
  width: 40px; height: 40px;
  border-radius: 8px;
  background: var(--bg-alt);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--gold);
  flex-shrink: 0;
}

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

.doc-name {
  font-size: .86rem;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.doc-meta { font-size: .74rem; color: var(--text-muted); margin-top: 2px; }

/* ── Badges ───────────────────────────────────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: .7rem;
  font-weight: 600;
  letter-spacing: .04em;
  white-space: nowrap;
}

.badge-confirmed   { background: #dcfce7; color: #16a34a; }
.badge-unconfirmed { background: #fef9c3; color: #ca8a04; }
.badge-new         { background: #fef9c3; color: #ca8a04; }
.badge-cancelled   { background: #fee2e2; color: #dc2626; }
.badge-completed   { background: #f3f4f6; color: #6b7280; }

/* ── Form elements ────────────────────────────────────────────────────────── */
.form-group { margin-bottom: 16px; }

.form-group label {
  display: block;
  font-size: .72rem;
  font-weight: 600;
  letter-spacing: .07em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 6px;
}

.form-group input,
.form-group select,
.form-group textarea {
  width: 100%;
  padding: 10px 13px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-family: 'Montserrat', sans-serif;
  font-size: .88rem;
  color: var(--dark);
  background: var(--bg);
  outline: none;
  transition: border-color .18s;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus { border-color: var(--gold); }

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

/* ── Upload area ──────────────────────────────────────────────────────────── */
.upload-area {
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  padding: 40px 24px;
  text-align: center;
  cursor: pointer;
  transition: all .2s;
}

.upload-area:hover,
.upload-area.drag-over { border-color: var(--gold); background: rgba(184,151,90,.04); }

.upload-area svg { color: var(--gold); margin: 0 auto 12px; }

.upload-area p { font-size: .86rem; color: var(--text-muted); }

/* ── Modal ────────────────────────────────────────────────────────────────── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(28,28,26,.55);
  backdrop-filter: blur(4px);
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s;
}

.modal-overlay.open { opacity: 1; pointer-events: all; }

.modal {
  background: #fff;
  border-radius: var(--radius);
  padding: 28px;
  width: 100%;
  max-width: 480px;
  box-shadow: 0 24px 60px rgba(28,28,26,.22);
  transform: translateY(10px);
  transition: transform .2s;
  max-height: 90vh;
  overflow-y: auto;
}

.modal-overlay.open .modal { transform: translateY(0); }

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

.modal-title {
  font-family: 'Cormorant Garamond', serif;
  font-size: 1.25rem;
  font-weight: 400;
}

.modal-close {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text-muted);
  padding: 4px;
  display: flex;
  transition: color .18s;
}

.modal-close:hover { color: var(--dark); }

.modal-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 20px; }

/* ── Alerts ───────────────────────────────────────────────────────────────── */
.alert { padding: 11px 14px; border-radius: 6px; font-size: .83rem; margin-bottom: 16px; }
.alert-error   { background: #fee2e2; color: #991b1b; }
.alert-success { background: #dcfce7; color: #166534; }
.alert-info    { background: #eff6ff; color: #1e40af; }

/* ── Empty state ──────────────────────────────────────────────────────────── */
.empty-state { text-align: center; padding: 48px 16px; }

.empty-state svg { color: var(--border); margin: 0 auto 14px; }

.empty-state h3 {
  font-family: 'Cormorant Garamond', serif;
  font-size: 1.15rem;
  font-weight: 400;
  margin-bottom: 6px;
}

.empty-state p { font-size: .84rem; color: var(--text-muted); margin-bottom: 18px; }

/* ── Tabs ─────────────────────────────────────────────────────────────────── */
.tabs {
  display: flex;
  gap: 2px;
  background: var(--bg-alt);
  padding: 4px;
  border-radius: 8px;
  margin-bottom: 20px;
}

.tab {
  flex: 1;
  padding: 9px;
  text-align: center;
  font-size: .78rem;
  font-weight: 600;
  letter-spacing: .04em;
  color: var(--text-muted);
  cursor: pointer;
  border-radius: 5px;
  border: none;
  background: none;
  font-family: 'Montserrat', sans-serif;
  transition: all .18s;
}

.tab.active { background: #fff; color: var(--dark); box-shadow: 0 1px 3px rgba(0,0,0,.08); }

/* ── Toggle ───────────────────────────────────────────────────────────────── */
.toggle-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 13px 0;
  border-bottom: 1px solid var(--border);
}

.toggle-row:last-child { border-bottom: none; }

.toggle-label h4 { font-size: .88rem; font-weight: 600; }
.toggle-label p { font-size: .77rem; color: var(--text-muted); margin-top: 2px; }

.toggle { position: relative; width: 44px; height: 24px; flex-shrink: 0; }

.toggle input { opacity: 0; width: 0; height: 0; position: absolute; }

.toggle-slider {
  position: absolute;
  inset: 0;
  background: var(--border);
  border-radius: 24px;
  cursor: pointer;
  transition: background .2s;
}

.toggle-slider::before {
  content: '';
  position: absolute;
  width: 18px; height: 18px;
  border-radius: 50%;
  background: #fff;
  left: 3px; top: 3px;
  transition: transform .2s;
  box-shadow: 0 1px 3px rgba(0,0,0,.2);
}

.toggle input:checked + .toggle-slider { background: var(--gold); }
.toggle input:checked + .toggle-slider::before { transform: translateX(20px); }

/* ── Skeleton ─────────────────────────────────────────────────────────────── */
.skeleton {
  background: linear-gradient(90deg, var(--bg-alt) 25%, var(--border) 50%, var(--bg-alt) 75%);
  background-size: 200% 100%;
  animation: skeleton-loading 1.4s infinite;
  border-radius: 4px;
}

@keyframes skeleton-loading {
  0%   { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* ── Mobile nav ───────────────────────────────────────────────────────────── */
.mobile-nav {
  display: none;
  position: fixed;
  bottom: 0; left: 0; right: 0;
  background: var(--dark);
  z-index: 100;
  padding-bottom: env(safe-area-inset-bottom);
}

.mobile-nav-items { display: flex; justify-content: space-around; }

.mobile-nav a {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  color: rgba(255,255,255,.45);
  text-decoration: none;
  font-size: .58rem;
  font-weight: 600;
  letter-spacing: .06em;
  text-transform: uppercase;
  padding: 10px 14px;
  transition: color .18s;
}

.mobile-nav a svg { width: 22px; height: 22px; }
.mobile-nav a.active { color: var(--gold-light); }

/* ── Divider ──────────────────────────────────────────────────────────────── */
.divider { height: 1px; background: var(--border); margin: 22px 0; }

/* ── Avatar upload ────────────────────────────────────────────────────────── */
.avatar-wrap { position: relative; width: 84px; height: 84px; }

.avatar-circle {
  width: 84px; height: 84px;
  border-radius: 50%;
  background: var(--gold);
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: 'Cormorant Garamond', serif;
  font-size: 2rem;
  color: #fff;
  overflow: hidden;
}

.avatar-circle img { width: 100%; height: 100%; object-fit: cover; }

.avatar-overlay {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  background: rgba(28,28,26,.55);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: opacity .18s;
}

.avatar-wrap:hover .avatar-overlay { opacity: 1; }

.avatar-badge {
  position: absolute;
  bottom: 2px; right: 2px;
  background: var(--gold);
  border: 2px solid #fff;
  border-radius: 50%;
  width: 24px; height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  box-shadow: 0 1px 4px rgba(0,0,0,.18);
}

/* ── Responsive ───────────────────────────────────────────────────────────── */
@media (max-width: 768px) {
  .sidebar { display: none; }
  .main { margin-left: 0; }
  .main-content { padding: 20px 16px 90px; }
  .main-header { padding: 0 16px; }
  .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; }
  .mobile-nav { display: block; }
  .appt-actions { flex-direction: column; }
}
