/* ================================================================
   Dental Rewards – Premium Design System
   Palette: White · Light Blue · Soft Gray · Gold accents
   ================================================================ */

/* ── Custom Properties ── */
:root {
  --gold:          #C9A84C;
  --gold-light:    #E8D07A;
  --gold-dark:     #9A7A2E;
  --blue-light:    #4A9EBB;
  --blue-muted:    #EAF4F8;
  --gray-50:       #F8F9FA;
  --gray-100:      #F1F3F5;
  --gray-200:      #E9ECEF;
  --text-primary:  #1A1D23;
  --text-secondary:#6C757D;
  --white:         #FFFFFF;
  --radius-card:   16px;
  --radius-btn:    12px;
  --shadow-sm:     0 2px 8px rgba(0,0,0,.06);
  --shadow-md:     0 4px 20px rgba(0,0,0,.10);
  --shadow-lg:     0 8px 40px rgba(0,0,0,.15);
  --sidebar-w:     240px;
}

/* ── Reset & Base ── */
*, *::before, *::after { box-sizing: border-box; }

body {
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  background-color: var(--gray-50);
  color: var(--text-primary);
  -webkit-font-smoothing: antialiased;
}

/* ── Typography ── */
.letter-spacing-1 { letter-spacing: 0.06em; }
.text-gold { color: var(--gold) !important; }

/* ── Gold Button ── */
.btn-primary-gold {
  background: linear-gradient(135deg, var(--gold) 0%, var(--gold-dark) 100%);
  color: #fff;
  border: none;
  border-radius: var(--radius-btn);
  font-weight: 600;
  transition: all .25s ease;
  box-shadow: 0 4px 15px rgba(201,168,76,.35);
}
.btn-primary-gold:hover, .btn-primary-gold:focus {
  background: linear-gradient(135deg, var(--gold-light) 0%, var(--gold) 100%);
  color: #fff;
  transform: translateY(-1px);
  box-shadow: 0 6px 20px rgba(201,168,76,.45);
}
.btn-primary-gold:active { transform: translateY(0); }

.btn-outline-gold {
  color: var(--gold);
  border: 1.5px solid var(--gold);
  border-radius: var(--radius-btn);
  background: transparent;
  font-weight: 500;
  transition: all .2s ease;
}
.btn-outline-gold:hover {
  background: var(--gold);
  color: #fff;
  box-shadow: 0 4px 12px rgba(201,168,76,.3);
}

/* ── Cards ── */
.card-premium {
  background: var(--white);
  border-radius: var(--radius-card);
  border: 1px solid var(--gray-200);
  box-shadow: var(--shadow-sm);
  transition: box-shadow .2s ease;
}
.card-premium:hover { box-shadow: var(--shadow-md); }

.card-stat {
  background: var(--white);
  border-radius: var(--radius-card);
  border: 1px solid var(--gray-200);
  box-shadow: var(--shadow-sm);
}
.stat-icon { font-size: 2.2rem; }
.stat-label { font-size: .78rem; text-transform: uppercase; letter-spacing: .06em; color: var(--text-secondary); font-weight: 600; }
.stat-value { font-size: 2.2rem; font-weight: 700; color: var(--text-primary); line-height: 1; }
.stat-value-sm { font-size: 1.05rem; font-weight: 700; color: var(--text-primary); }

/* ── KPI Cards (admin) ── */
.kpi-card {
  background: var(--white);
  border-radius: var(--radius-card);
  border: 1px solid var(--gray-200);
  padding: 1.25rem;
  display: flex;
  align-items: center;
  gap: 1rem;
  box-shadow: var(--shadow-sm);
}
.kpi-icon {
  width: 52px; height: 52px;
  border-radius: 12px;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.5rem; flex-shrink: 0;
}
.kpi-primary  { background: #EEF3FF; color: #4A7BDE; }
.kpi-success  { background: #EEFAF3; color: #27AE60; }
.kpi-info     { background: #EAF4F8; color: var(--blue-light); }
.kpi-warning  { background: #FFF8EC; color: var(--gold); }
.kpi-value    { font-size: 1.6rem; font-weight: 700; line-height: 1.1; }
.kpi-label    { font-size: .75rem; color: var(--text-secondary); }

.kpi-card-sm {
  background: var(--white);
  border-radius: 12px;
  border: 1.5px solid var(--gray-200);
  padding: .85rem 1rem;
  box-shadow: var(--shadow-sm);
  transition: all .2s;
}
.kpi-card-sm:hover { border-color: var(--gold); }
.kpi-active { border-color: var(--gold) !important; }

/* ── Progress ── */
.progress-track {
  height: 10px;
  background: var(--gray-100);
  border-radius: 999px;
  overflow: hidden;
}
.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--gold) 0%, var(--gold-light) 100%);
  border-radius: 999px;
  transition: width 1s cubic-bezier(.4,0,.2,1);
}
.progress-fill-gold { background: linear-gradient(90deg, var(--gold) 0%, var(--gold-light) 100%); }
.progress-track-sm { height: 6px; background: var(--gray-100); border-radius: 999px; overflow: hidden; }

/* ── Level Orb ── */
.level-orb {
  width: 72px; height: 72px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.8rem; flex-shrink: 0;
}
.level-orb-bronce   { background: linear-gradient(135deg,#f5cba7,#CD7F32); color: #fff; box-shadow: 0 4px 16px rgba(205,127,50,.4); }
.level-orb-plata    { background: linear-gradient(135deg,#e8e8e8,#A8A8A8); color: #fff; box-shadow: 0 4px 16px rgba(168,168,168,.4); }
.level-orb-oro      { background: linear-gradient(135deg,#ffe082,#C9A84C); color: #fff; box-shadow: 0 4px 16px rgba(201,168,76,.45); }
.level-orb-diamante { background: linear-gradient(135deg,#b3e5fc,#6DAEDB); color: #fff; box-shadow: 0 4px 16px rgba(109,174,219,.4); }

/* ── Level Badge ── */
.level-badge {
  display: inline-flex; align-items: center;
  padding: .25rem .75rem;
  border-radius: 999px;
  font-size: .72rem; font-weight: 700; letter-spacing: .05em; text-transform: uppercase;
}
.level-bronce   { background: #fdf3ea; color: #8B5E3C; border: 1px solid #f0c49b; }
.level-plata    { background: #f4f4f4; color: #6B6B6B; border: 1px solid #d0d0d0; }
.level-oro      { background: #fdf6e3; color: #7A5C1E; border: 1px solid var(--gold); }
.level-diamante { background: #e8f4fd; color: #2980B9; border: 1px solid #93c9e9; }

/* ── Visit Counter ── */
.visitas-counter { font-size: 3rem; font-weight: 800; color: var(--gold); line-height: 1; }
.visitas-max { font-size: 1.2rem; font-weight: 400; color: var(--text-secondary); }
.level-display {
  background: linear-gradient(135deg, var(--gold) 0%, var(--gold-dark) 100%);
  color: #fff;
  padding: .6rem 1.2rem;
  border-radius: 999px;
  font-weight: 600; font-size: .9rem;
  display: inline-flex; align-items: center;
}

/* ── Badges ── */
.badge-gold { background: #fdf6e3; color: var(--gold-dark); border: 1px solid var(--gold); border-radius: 999px; font-weight: 600; font-size: .78rem; }
.badge-available { background: #EEFAF3; color: #1B7C46; border: 1px solid #a3e0be; border-radius: 999px; font-size: .75rem; font-weight: 600; padding: .2rem .65rem; display: inline-block; }

.badge-status-pendiente  { background: #fff8ec; color: #9A6B00; border: 1px solid #FFD27F; border-radius: 6px; padding: .2rem .6rem; font-size:.75rem; font-weight:600; }
.badge-status-entregada  { background: #EEFAF3; color: #1B7C46; border: 1px solid #a3e0be; border-radius: 6px; padding: .2rem .6rem; font-size:.75rem; font-weight:600; }
.badge-status-cancelada  { background: #fef0f0; color: #C0392B; border: 1px solid #f5b7b1; border-radius: 6px; padding: .2rem .6rem; font-size:.75rem; font-weight:600; }
.badge-status-disponible { background: #EEFAF3; color: #1B7C46; border: 1px solid #a3e0be; border-radius: 6px; padding: .2rem .6rem; font-size:.75rem; font-weight:600; }
.badge-status-utilizado  { background: #EEF3FF; color: #4A7BDE; border: 1px solid #b3c6f5; border-radius: 6px; padding: .2rem .6rem; font-size:.75rem; font-weight:600; }
.badge-status-expirado   { background: #f4f4f4; color: #6B6B6B; border: 1px solid #d0d0d0; border-radius: 6px; padding: .2rem .6rem; font-size:.75rem; font-weight:600; }

/* ── Divider ── */
.divider-text {
  display: flex; align-items: center; gap: .75rem; color: var(--text-secondary); font-size: .82rem;
}
.divider-text::before, .divider-text::after {
  content: ''; flex: 1; height: 1px; background: var(--gray-200);
}

/* ── Auth Layout ── */
.auth-wrapper { position: relative; }
.auth-bg-pattern {
  position: fixed; inset: 0; z-index: -1;
  background: radial-gradient(ellipse at 20% 50%, rgba(201,168,76,.06) 0%, transparent 60%),
              radial-gradient(ellipse at 80% 20%, rgba(74,158,187,.06) 0%, transparent 60%),
              var(--gray-50);
}
.auth-logo {
  width: 64px; height: 64px;
  border-radius: 18px;
  background: linear-gradient(135deg, var(--gold) 0%, var(--gold-dark) 100%);
  display: flex; align-items: center; justify-content: center;
  font-size: 1.8rem; color: #fff;
  box-shadow: 0 8px 24px rgba(201,168,76,.4);
}
.auth-brand { font-family: 'Playfair Display', Georgia, serif; font-size: 1.8rem; font-weight: 700; color: var(--text-primary); }
.auth-card {
  background: var(--white);
  border-radius: 20px;
  border: 1px solid var(--gray-200);
  box-shadow: var(--shadow-lg);
}

/* ── Form Controls ── */
.form-control, .form-select {
  border-radius: 10px;
  border-color: var(--gray-200);
  padding: .6rem .9rem;
  font-size: .92rem;
  transition: border-color .2s, box-shadow .2s;
}
.form-control:focus, .form-select:focus {
  border-color: var(--gold);
  box-shadow: 0 0 0 3px rgba(201,168,76,.15);
}
.input-group-text {
  border-radius: 10px;
  border-color: var(--gray-200);
  background: transparent;
}
.input-group .form-control:not(:first-child) { border-left: none; }
.input-group .form-control:not(:last-child)  { border-right: none; }
.input-group:focus-within .input-group-text  { border-color: var(--gold); }
.form-control-lg { font-size: 1rem; }
.code-input { border-radius: 12px !important; text-transform: uppercase; }

/* ── Password Strength ── */
.pass-strength-bar { height: 4px; background: var(--gray-200); border-radius: 999px; overflow: hidden; }
.pass-strength-fill { height: 100%; width: 0; border-radius: 999px; transition: width .3s, background .3s; }

/* ── Patient Navbar ── */
.navbar-patient {
  background: var(--white);
  border-bottom: 1px solid var(--gray-200);
  box-shadow: var(--shadow-sm);
}
.brand-icon {
  width: 36px; height: 36px;
  border-radius: 10px;
  background: linear-gradient(135deg, var(--gold) 0%, var(--gold-dark) 100%);
  display: flex; align-items: center; justify-content: center;
  color: #fff; font-size: 1rem;
}
.brand-name { font-family: 'Playfair Display', serif; font-weight: 700; font-size: 1.1rem; color: var(--text-primary); }
.nav-link {
  border-radius: 10px;
  padding: .45rem .85rem !important;
  color: var(--text-secondary);
  font-weight: 500; font-size: .88rem;
  transition: all .2s;
}
.nav-link:hover, .nav-link.active {
  background: var(--gray-100);
  color: var(--text-primary);
}
.nav-link.active { color: var(--gold) !important; }

/* ── Avatars ── */
.avatar-sm {
  width: 36px; height: 36px;
  border-radius: 50%; object-fit: cover;
}
.avatar-initials {
  display: inline-flex; align-items: center; justify-content: center;
  background: linear-gradient(135deg, var(--gold) 0%, var(--gold-dark) 100%);
  color: #fff; font-weight: 700; font-size: .85rem;
}
.avatar-btn { border-radius: 50%; }
.avatar-lg {
  width: 80px; height: 80px;
  border-radius: 50%; font-size: 1.6rem;
}

/* ── Admin Sidebar ── */
.admin-layout { background: var(--gray-50); }
.admin-sidebar {
  width: var(--sidebar-w);
  min-height: 100vh;
  background: var(--white);
  border-right: 1px solid var(--gray-200);
  position: sticky; top: 0;
  flex-shrink: 0;
  overflow-y: auto;
}
.sidebar-brand { border-bottom: 1px solid var(--gray-100); }
.brand-icon-sm {
  width: 30px; height: 30px;
  border-radius: 8px;
  background: linear-gradient(135deg, var(--gold) 0%, var(--gold-dark) 100%);
  display: flex; align-items: center; justify-content: center;
  color: #fff; font-size: .9rem; flex-shrink: 0;
}
.brand-name-sm { font-family: 'Playfair Display', serif; font-weight: 700; font-size: .95rem; }
.sidebar-link {
  display: flex; align-items: center; gap: .75rem;
  padding: .65rem 1rem;
  border-radius: 12px;
  color: var(--text-secondary);
  font-size: .88rem; font-weight: 500;
  text-decoration: none;
  transition: all .2s;
  margin-bottom: .15rem;
}
.sidebar-link i { font-size: 1.1rem; width: 20px; text-align: center; flex-shrink: 0; }
.sidebar-link:hover { background: var(--gray-100); color: var(--text-primary); }
.sidebar-link.active {
  background: linear-gradient(90deg, rgba(201,168,76,.12) 0%, rgba(201,168,76,.04) 100%);
  color: var(--gold);
  font-weight: 600;
}
.sidebar-user {
  border-top: 1px solid var(--gray-100);
  margin-top: auto;
}
.admin-topbar {
  display: none;
  background: var(--white);
  border-bottom: 1px solid var(--gray-200);
  padding: .6rem 1rem;
  align-items: center;
  position: sticky; top: 0; z-index: 100;
}
.admin-content { min-width: 0; }
.admin-content-header {
  background: var(--white);
  border-bottom: 1px solid var(--gray-200);
  position: sticky; top: 0; z-index: 50;
}

/* ── Reward Cards ── */
.reward-card {
  background: var(--white);
  border-radius: var(--radius-card);
  border: 1.5px solid var(--gray-200);
  overflow: hidden;
  transition: all .25s ease;
}
.reward-card:hover { box-shadow: var(--shadow-md); transform: translateY(-2px); }
.reward-unlocked { border-color: var(--gold); }
.reward-locked   { opacity: .75; }
.reward-card-icon {
  padding: 2rem;
  background: linear-gradient(135deg, #fdf6e3 0%, #fef9ef 100%);
  text-align: center;
  font-size: 3rem;
  color: var(--gold);
}
.reward-unlocked .reward-card-icon { background: linear-gradient(135deg, #fdf6e3 0%, #ffe082 100%); }
.reward-card-body { padding: 1.25rem; }

.reward-mini-card {
  background: var(--gray-50);
  border-radius: 12px;
  border: 1px solid var(--gray-200);
  transition: all .2s;
}
.reward-mini-card:hover { border-color: var(--gold); }
.reward-mini-icon {
  width: 38px; height: 38px;
  border-radius: 10px;
  background: linear-gradient(135deg, var(--gold) 0%, var(--gold-dark) 100%);
  display: flex; align-items: center; justify-content: center;
  color: #fff; font-size: 1rem; flex-shrink: 0;
}

.reward-admin-icon {
  width: 52px; height: 52px;
  border-radius: 14px;
  background: linear-gradient(135deg, #fdf6e3 0%, #ffe082 100%);
  display: flex; align-items: center; justify-content: center;
  font-size: 1.5rem; color: var(--gold);
}

/* ── VIP Card ── */
.vip-card {
  border-radius: 20px;
  padding: 1.75rem;
  box-shadow: 0 16px 48px rgba(0,0,0,.2);
  position: relative;
  overflow: hidden;
  min-height: 260px;
}
.vip-card::before {
  content: '';
  position: absolute;
  top: -60px; right: -60px;
  width: 200px; height: 200px;
  border-radius: 50%;
  background: rgba(255,255,255,.08);
}
.vip-card::after {
  content: '';
  position: absolute;
  bottom: -40px; left: -40px;
  width: 140px; height: 140px;
  border-radius: 50%;
  background: rgba(255,255,255,.05);
}
.vip-clinic-name { font-family: 'Playfair Display', serif; font-size: 1.1rem; font-weight: 700; opacity: .95; }
.vip-clinic-sub  { font-size: .72rem; opacity: .7; letter-spacing: .08em; text-transform: uppercase; }
.vip-level-badge {
  background: rgba(255,255,255,.25);
  padding: .3rem .85rem;
  border-radius: 999px;
  font-size: .72rem; font-weight: 700; letter-spacing: .05em; text-transform: uppercase;
  backdrop-filter: blur(4px);
}
.vip-avatar { width: 52px; height: 52px; border-radius: 50%; border: 2px solid rgba(255,255,255,.5); }
.vip-avatar-placeholder {
  width: 52px; height: 52px; border-radius: 50%;
  background: rgba(255,255,255,.25);
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 1.1rem; flex-shrink: 0;
}
.vip-name  { font-weight: 700; font-size: 1rem; }
.vip-email { font-size: .75rem; opacity: .75; }
.vip-stats { border-top: 1px solid rgba(255,255,255,.2); padding-top: .85rem; }
.vip-stat-value { font-weight: 700; font-size: 1.1rem; }
.vip-stat-label { font-size: .65rem; opacity: .7; text-transform: uppercase; letter-spacing: .06em; }
.vip-divider    { width: 1px; background: rgba(255,255,255,.3); align-self: stretch; }
.vip-member-since { font-size: .7rem; opacity: .6; }
.vip-qr-wrap canvas { border-radius: 8px; border: 3px solid rgba(255,255,255,.4); }

/* ── Stat Chip ── */
.stat-chip {
  display: inline-flex; align-items: center;
  background: var(--white); border: 1px solid var(--gray-200);
  border-radius: 999px; padding: .4rem 1rem;
  font-size: .85rem; font-weight: 500;
  box-shadow: var(--shadow-sm);
}

/* ── Empty State ── */
.empty-state { text-align: center; }

/* ── Tables ── */
.table { --bs-table-hover-bg: rgba(201,168,76,.04); }
.table thead th { font-size: .75rem; text-transform: uppercase; letter-spacing: .05em; border-bottom: 2px solid var(--gray-200); color: var(--text-secondary); font-weight: 600; }

/* ── Dropdown ── */
.dropdown-menu {
  border: 1px solid var(--gray-200);
  border-radius: 14px;
  box-shadow: var(--shadow-lg);
  padding: .5rem;
}
.dropdown-item { border-radius: 8px; font-size: .875rem; padding: .45rem .75rem; transition: all .15s; }
.dropdown-item:hover { background: var(--gray-50); }

/* ── App footer ── */
.app-footer { border-top: 1px solid var(--gray-200); background: var(--white); }

/* ── Patient layout ── */
.patient-layout { background: var(--gray-50); }

/* ── Responsive Sidebar ── */
@media (max-width: 991.98px) {
  .admin-sidebar {
    position: fixed;
    left: -100%;
    top: 0; bottom: 0;
    z-index: 1000;
    transition: left .3s ease;
    min-height: 100%;
    box-shadow: var(--shadow-lg);
  }
  .admin-sidebar.open { left: 0; }
  .admin-topbar { display: flex; }
  .admin-content { padding-top: 56px; }
  .sidebar-overlay {
    display: none;
    position: fixed; inset: 0;
    background: rgba(0,0,0,.4);
    z-index: 999;
  }
  .sidebar-overlay.show { display: block; }
}

/* ── QR Scanner ── */
.qr-scanner-viewport {
  width: 100%;
  max-width: 320px;
  border-radius: 16px;
  overflow: hidden;
  background: #000;
  min-height: 260px;
}
#qr-reader video {
  border-radius: 12px;
}
#qr-reader__scan_region {
  border-radius: 12px;
  overflow: hidden;
}
/* Remove default html5-qrcode UI clutter */
#qr-reader__dashboard_section_swaplink,
#qr-reader__status_span,
#qr-reader__camera_selection { display: none !important; }

/* ── QR Admin Grid ── */
.qr-admin-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  max-height: 380px;
  overflow-y: auto;
  padding: 4px 2px;
}
.qr-admin-card {
  background: var(--white);
  border: 1.5px solid var(--gray-200);
  border-radius: 12px;
  padding: 12px;
  text-align: center;
  width: 160px;
  flex-shrink: 0;
  transition: box-shadow .2s;
}
.qr-admin-card:hover { box-shadow: var(--shadow-md); }
.qr-admin-card canvas { border-radius: 8px; }
.qr-admin-code {
  font-family: monospace;
  font-size: .72rem;
  color: var(--text-secondary);
  margin-top: 6px;
  word-break: break-all;
  font-weight: 600;
}

/* ── Print (VIP Card) ── */
@media print {
  .navbar-patient, .app-footer, .btn, .breadcrumb { display: none !important; }
  .vip-card { box-shadow: none; }
}

/* ── Animations ── */
@keyframes fadeUp {
  from { opacity: 0; transform: translateY(16px); }
  to   { opacity: 1; transform: translateY(0); }
}
.card-premium, .card-stat, .kpi-card, .reward-card {
  animation: fadeUp .4s ease both;
}

@keyframes countUp {
  from { opacity: 0; }
  to   { opacity: 1; }
}
