/* ═══════════════════════════════════════════════════════════
   CitasApp — Base Stylesheet
   Theme: "Fresh Clinic" — precision meets warmth
   ═══════════════════════════════════════════════════════════ */

/* ── Custom Properties ──────────────────────────────────────── */
:root {
  --color-primary:   #22C55E;
  --color-accent:    #16A34A;
  --color-bg:        #F0FDF4;
  --color-text:      #0F172A;

  /* Extended palette */
  --color-primary-light: #DCFCE7;
  --color-primary-dark:  #15803D;
  --color-surface:       #FFFFFF;
  --color-border:        #E2E8F0;
  --color-muted:         #64748B;
  --color-danger:        #EF4444;
  --color-danger-light:  #FEE2E2;
  --color-warning:       #F59E0B;
  --color-info:          #3B82F6;

  /* Structure */
  --radius:    10px;
  --radius-sm: 6px;
  --radius-lg: 16px;
  --shadow:    0 2px 12px rgba(0,0,0,.08);
  --shadow-md: 0 4px 24px rgba(0,0,0,.12);
  --shadow-lg: 0 8px 40px rgba(0,0,0,.16);

  /* Sidebar */
  --sidebar-width: 224px;
  --sidebar-bg:    #0F2318;
  --sidebar-hover: rgba(34,197,94,.12);
  --sidebar-active:rgba(34,197,94,.18);

  /* Transitions */
  --ease: cubic-bezier(.4,0,.2,1);
  --dur:  160ms;
}

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

html { scroll-behavior: smooth; -webkit-font-smoothing: antialiased; }

body {
  font-family: system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: var(--color-bg);
  color: var(--color-text);
  line-height: 1.6;
  font-size: 15px;
}

a { color: inherit; text-decoration: none; }
img { display: block; max-width: 100%; }
button { font-family: inherit; }

/* ── Typography ──────────────────────────────────────────────── */
h1 { font-size: clamp(1.5rem, 3vw, 2rem); font-weight: 800; line-height: 1.2; letter-spacing: -.02em; }
h2 { font-size: 1.3rem; font-weight: 700; letter-spacing: -.01em; }
h3 { font-size: 1.05rem; font-weight: 600; }
p  { color: var(--color-muted); }

/* ── Buttons ─────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 9px 20px;
  border-radius: var(--radius);
  font-size: .875rem;
  font-weight: 600;
  border: none;
  cursor: pointer;
  transition: opacity var(--dur) var(--ease),
              transform var(--dur) var(--ease),
              box-shadow var(--dur) var(--ease);
  text-decoration: none;
  white-space: nowrap;
  letter-spacing: -.01em;
}
.btn:active  { transform: scale(.97); }
.btn:disabled { opacity: .55; pointer-events: none; }

.btn-primary {
  background: var(--color-primary);
  color: #fff;
  box-shadow: 0 2px 8px rgba(34,197,94,.35);
}
.btn-primary:hover  { opacity: .88; box-shadow: 0 4px 16px rgba(34,197,94,.45); }

.btn-secondary {
  background: var(--color-surface);
  color: var(--color-text);
  border: 1.5px solid var(--color-border);
}
.btn-secondary:hover { background: var(--color-bg); border-color: #CBD5E1; }

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

.btn-ghost {
  background: transparent;
  color: var(--color-muted);
  padding: 8px 14px;
}
.btn-ghost:hover { background: var(--color-bg); color: var(--color-text); }

.btn-sm { padding: 6px 14px; font-size: .8rem; }
.btn-lg { padding: 12px 28px; font-size: .95rem; }

/* ── Cards ───────────────────────────────────────────────────── */
.card {
  background: var(--color-surface);
  border-radius: var(--radius);
  border: 1px solid var(--color-border);
  box-shadow: var(--shadow);
  padding: 20px;
}
.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--color-border);
}
.card-title { font-size: 1rem; font-weight: 700; color: var(--color-text); }

/* ── Stat cards ──────────────────────────────────────────────── */
.stat-card {
  background: var(--color-surface);
  border-radius: var(--radius);
  border: 1px solid var(--color-border);
  box-shadow: var(--shadow);
  padding: 20px 24px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.stat-label { font-size: .75rem; font-weight: 600; color: var(--color-muted); text-transform: uppercase; letter-spacing: .06em; }
.stat-value { font-size: 2rem; font-weight: 800; color: var(--color-text); letter-spacing: -.03em; line-height: 1; }
.stat-sub   { font-size: .78rem; color: var(--color-muted); }

/* ── Status Chips ────────────────────────────────────────────── */
.chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 10px;
  border-radius: 99px;
  font-size: .72rem;
  font-weight: 700;
  letter-spacing: .02em;
  text-transform: uppercase;
}
.chip::before {
  content: '';
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: currentColor;
  opacity: .7;
}
.chip-pending   { background: #FEF3C7; color: #92400E; }
.chip-confirmed { background: #DBEAFE; color: #1D4ED8; }
.chip-completed { background: #DCFCE7; color: #15803D; }
.chip-cancelled { background: #FEE2E2; color: #991B1B; }
.chip-no_show   { background: #F3F4F6; color: #374151; }

/* ── Forms ───────────────────────────────────────────────────── */
.form-group { margin-bottom: 18px; }

.form-label {
  display: block;
  font-size: .8rem;
  font-weight: 700;
  margin-bottom: 6px;
  color: #374151;
  letter-spacing: .01em;
}
.form-label .required { color: var(--color-danger); margin-left: 2px; }

.form-input,
.form-select,
.form-textarea {
  width: 100%;
  padding: 10px 13px;
  border: 1.5px solid var(--color-border);
  border-radius: var(--radius-sm);
  font-size: .9rem;
  font-family: inherit;
  background: var(--color-surface);
  color: var(--color-text);
  transition: border-color var(--dur) var(--ease),
              box-shadow var(--dur) var(--ease);
  appearance: none;
}
.form-input:focus,
.form-select:focus,
.form-textarea:focus {
  outline: none;
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px rgba(34,197,94,.15);
}
.form-input::placeholder,
.form-textarea::placeholder { color: #94A3B8; }
.form-textarea { resize: vertical; min-height: 90px; }
.form-select { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%2364748B' d='M6 8L1 3h10z'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 12px center; padding-right: 36px; }
.form-error { font-size: .78rem; color: var(--color-danger); margin-top: 5px; display: flex; align-items: center; gap: 4px; }
.form-error::before { content: '⚠'; font-size: .7rem; }
.form-hint  { font-size: .78rem; color: var(--color-muted); margin-top: 5px; }

/* ── Tables ──────────────────────────────────────────────────── */
.table-wrap { overflow-x: auto; border-radius: var(--radius); border: 1px solid var(--color-border); }
table { width: 100%; border-collapse: collapse; font-size: .875rem; }
thead th {
  background: #F8FAFC;
  padding: 11px 16px;
  text-align: left;
  font-size: .72rem;
  font-weight: 700;
  color: var(--color-muted);
  text-transform: uppercase;
  letter-spacing: .06em;
  border-bottom: 1px solid var(--color-border);
  white-space: nowrap;
}
tbody td {
  padding: 12px 16px;
  border-bottom: 1px solid #F1F5F9;
  color: var(--color-text);
  vertical-align: middle;
}
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover td { background: #FAFCFF; }

/* ── Alerts ──────────────────────────────────────────────────── */
.alert {
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  font-size: .875rem;
  display: flex;
  align-items: flex-start;
  gap: 10px;
  margin-bottom: 16px;
}
.alert-success { background: #DCFCE7; border: 1px solid #86EFAC; color: #15803D; }
.alert-error   { background: #FEE2E2; border: 1px solid #FCA5A5; color: #991B1B; }
.alert-warning { background: #FEF3C7; border: 1px solid #FDE68A; color: #92400E; }
.alert-info    { background: #DBEAFE; border: 1px solid #BFDBFE; color: #1D4ED8; }

/* ── Pagination ──────────────────────────────────────────────── */
.pagination { display: flex; gap: 6px; align-items: center; justify-content: center; padding: 16px 0; }
.page-btn {
  width: 34px; height: 34px;
  border-radius: var(--radius-sm);
  border: 1.5px solid var(--color-border);
  background: var(--color-surface);
  display: flex; align-items: center; justify-content: center;
  font-size: .82rem; font-weight: 600; cursor: pointer; color: var(--color-muted);
  transition: all var(--dur);
}
.page-btn:hover { border-color: var(--color-primary); color: var(--color-primary); }
.page-btn.active { background: var(--color-primary); border-color: var(--color-primary); color: #fff; }

/* ── Empty state ─────────────────────────────────────────────── */
.empty-state {
  text-align: center;
  padding: 48px 24px;
  color: var(--color-muted);
}
.empty-state .empty-icon { font-size: 2.5rem; margin-bottom: 12px; opacity: .6; }
.empty-state h3 { font-size: 1rem; font-weight: 600; color: var(--color-text); margin-bottom: 6px; }
.empty-state p  { font-size: .875rem; max-width: 320px; margin: 0 auto 16px; }

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

/* ── Grid helpers ────────────────────────────────────────────── */
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
.grid-4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; }
@media (max-width: 768px) {
  .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; }
}
@media (min-width: 769px) and (max-width: 1024px) {
  .grid-3, .grid-4 { grid-template-columns: 1fr 1fr; }
}

/* ── Utilities ───────────────────────────────────────────────── */
.text-muted   { color: var(--color-muted); }
.text-primary { color: var(--color-primary); }
.text-danger  { color: var(--color-danger); }
.text-sm      { font-size: .8rem; }
.text-xs      { font-size: .72rem; }
.font-bold    { font-weight: 700; }
.font-semibold{ font-weight: 600; }
.truncate     { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.flex         { display: flex; }
.flex-center  { display: flex; align-items: center; justify-content: center; }
.items-center { align-items: center; }
.gap-8        { gap: 8px; }
.gap-12       { gap: 12px; }
.mt-4         { margin-top: 4px; }
.mt-8         { margin-top: 8px; }
.mt-16        { margin-top: 16px; }
.mt-24        { margin-top: 24px; }
.mb-8         { margin-bottom: 8px; }
.mb-16        { margin-bottom: 16px; }
.w-full       { width: 100%; }
.hide-mobile  { display: none !important; }
@media (min-width: 769px) { .hide-mobile { display: unset !important; } }
.hide-desktop { display: unset !important; }
@media (min-width: 769px) { .hide-desktop { display: none !important; } }

/* ══════════════════════════════════════════════════════════
   LOADER — Branded full-screen overlay
   ══════════════════════════════════════════════════════════ */
.app-loader {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 9999;
  background: rgba(240,253,244,.96);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 0;
}
.app-loader.active { display: flex; }

/* Logo / brand ring */
.loader-brand {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 28px;
}
.loader-ring {
  position: absolute;
  width: 90px;
  height: 90px;
  border-radius: 50%;
  border: 3px solid transparent;
  border-top-color: var(--color-primary, #22C55E);
  border-right-color: rgba(34,197,94,.3);
  animation: loaderSpin 1s linear infinite;
}
.loader-ring-2 {
  position: absolute;
  width: 72px;
  height: 72px;
  border-radius: 50%;
  border: 2px solid transparent;
  border-bottom-color: var(--color-accent, #16A34A);
  border-left-color: rgba(22,163,74,.2);
  animation: loaderSpin .7s linear infinite reverse;
}
@keyframes loaderSpin {
  to { transform: rotate(360deg); }
}
.loader-logo-wrap {
  width: 60px;
  height: 60px;
  border-radius: 16px;
  background: var(--color-primary, #22C55E);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 20px rgba(34,197,94,.4);
  animation: loaderPulse 2s ease-in-out infinite;
  overflow: hidden;
  position: relative;
  z-index: 1;
}
@keyframes loaderPulse {
  0%, 100% { box-shadow: 0 4px 20px rgba(34,197,94,.4); transform: scale(1); }
  50%       { box-shadow: 0 6px 32px rgba(34,197,94,.6); transform: scale(1.04); }
}
.loader-logo-img { width: 40px; height: 40px; object-fit: contain; }
.loader-logo-icon { font-size: 1.6rem; }

/* Business name */
.loader-name {
  font-size: 1rem;
  font-weight: 800;
  color: var(--color-text, #0F172A);
  letter-spacing: -.02em;
  margin-bottom: 6px;
  animation: loaderFadeIn .4s ease both;
}
@keyframes loaderFadeIn {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* Message */
.loader-msg {
  font-size: .78rem;
  color: #64748B;
  font-weight: 500;
  letter-spacing: .02em;
  margin-bottom: 20px;
  min-height: 18px;
}

/* Dot track */
.loader-dots {
  display: flex;
  gap: 7px;
  align-items: center;
}
.loader-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--color-primary, #22C55E);
  animation: loaderDot 1.4s ease-in-out infinite;
  opacity: .3;
}
.loader-dot:nth-child(1) { animation-delay: 0s; }
.loader-dot:nth-child(2) { animation-delay: .2s; }
.loader-dot:nth-child(3) { animation-delay: .4s; }
.loader-dot:nth-child(4) { animation-delay: .6s; }
.loader-dot:nth-child(5) { animation-delay: .8s; }
@keyframes loaderDot {
  0%, 100% { opacity: .2; transform: scale(.8); }
  50%       { opacity: 1;  transform: scale(1.3); }
}

/* Progress bar */
.loader-bar-wrap {
  width: 140px;
  height: 3px;
  background: rgba(34,197,94,.15);
  border-radius: 99px;
  overflow: hidden;
  margin-top: 16px;
}
.loader-bar {
  height: 100%;
  background: linear-gradient(90deg, var(--color-primary, #22C55E), var(--color-accent, #16A34A));
  border-radius: 99px;
  animation: loaderBar 1.8s ease-in-out infinite;
  transform-origin: left;
}
@keyframes loaderBar {
  0%   { transform: scaleX(0) translateX(0); }
  50%  { transform: scaleX(1) translateX(0); }
  100% { transform: scaleX(0) translateX(100%); }
}
