/* ============================================
   AGENDAPRO v2.0 — SISTEMA DE DISEÑO
   Inspirado en Apple iOS, Meta y X (Twitter)
   Colores suaves, tipografía limpia, funcional
   ============================================ */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&display=swap');

/* ============================================
   VARIABLES — APPLE / META / X SYSTEM
   ============================================ */
:root {
  /* Sistema de color Apple */
  --blue:   #007AFF;
  --green:  #34C759;
  --red:    #FF3B30;
  --orange: #FF9500;
  --purple: #AF52DE;
  --teal:   #5AC8FA;
  --pink:   #FF2D55;
  --indigo: #5856D6;

  /* Colores principales */
  --primary:       #007AFF;
  --primary-dark:  #0062CC;
  --primary-light: #4DA3FF;
  --primary-bg:    rgba(0,122,255,0.08);
  --primary-glow:  rgba(0,122,255,0.2);

  /* Fondos — Apple style */
  --bg-primary:   #F2F2F7;
  --bg-secondary: #FFFFFF;
  --bg-card:      #FFFFFF;
  --bg-input:     #F2F2F7;
  --bg-sidebar:   #FFFFFF;
  --bg-navbar:    rgba(255,255,255,0.92);
  --bg-overlay:   rgba(0,0,0,0.4);

  /* Texto — Apple legibility */
  --text-primary:   #000000;
  --text-secondary: #3A3A3C;
  --text-tertiary:  #636366;
  --text-muted:     #8E8E93;
  --text-label:     #6D6D72;

  /* Bordes — super sutiles */
  --border:        rgba(0,0,0,0.08);
  --border-strong: rgba(0,0,0,0.15);
  --separator:     rgba(60,60,67,0.12);

  /* Estados */
  --success:    #34C759;
  --danger:     #FF3B30;
  --warning:    #FF9500;
  --info:       #007AFF;

  /* Success/danger backgrounds */
  --success-bg: rgba(52,199,89,0.1);
  --danger-bg:  rgba(255,59,48,0.1);
  --warning-bg: rgba(255,149,0,0.1);
  --info-bg:    rgba(0,122,255,0.08);

  /* Sombras — Apple elevation */
  --shadow-xs: 0 1px 3px rgba(0,0,0,0.06), 0 1px 2px rgba(0,0,0,0.04);
  --shadow-sm: 0 2px 8px rgba(0,0,0,0.08), 0 1px 3px rgba(0,0,0,0.05);
  --shadow-md: 0 4px 16px rgba(0,0,0,0.10), 0 2px 6px rgba(0,0,0,0.06);
  --shadow-lg: 0 8px 30px rgba(0,0,0,0.12), 0 4px 10px rgba(0,0,0,0.07);

  /* Tipografía — Apple SF equivalente */
  --font: 'Inter', -apple-system, BlinkMacSystemFont, 'SF Pro Display', system-ui, sans-serif;

  /* Radios — Apple rounded */
  --r-xs:  6px;
  --r-sm:  10px;
  --r-md:  12px;
  --r-lg:  16px;
  --r-xl:  20px;
  --r-2xl: 28px;
  --r-pill:50px;

  /* Transiciones */
  --t-fast:   0.12s ease;
  --t-normal: 0.22s ease;
  --t-slow:   0.35s cubic-bezier(0.4,0,0.2,1);

  /* Layout */
  --sidebar-w:  260px;
  --navbar-h:   52px;
}

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

html { font-size: 16px; -webkit-text-size-adjust: 100%; }

body {
  font-family: var(--font);
  background: var(--bg-primary);
  color: var(--text-primary);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow-x: hidden;
}

/* Scrollbar mínima */
::-webkit-scrollbar { width: 4px; height: 4px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--separator); border-radius: 2px; }

/* ============================================
   LOADING
   ============================================ */
#loading-screen {
  position: fixed; inset: 0;
  background: linear-gradient(145deg, #f0f4ff 0%, #e8f0fe 50%, #f5f0ff 100%);
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  z-index: 9999;
  transition: opacity 0.5s ease;
}

/* Ícono animado — calendario con hojas desprendiéndose */
.loading-logo {
  width: 88px; height: 88px;
  margin-bottom: 24px;
  position: relative;
  perspective: 300px;
}
.loading-logo svg {
  width: 88px; height: 88px;
  filter: drop-shadow(0 8px 24px rgba(0,122,255,0.35));
  animation: cal-flip 2.2s ease-in-out infinite;
  transform-origin: center bottom;
}
@keyframes cal-flip {
  0%   { transform: rotateX(0deg) scale(1); }
  18%  { transform: rotateX(-22deg) scale(0.97); }
  36%  { transform: rotateX(0deg) scale(1); }
  54%  { transform: rotateX(-14deg) scale(0.98); }
  72%  { transform: rotateX(0deg) scale(1); }
  100% { transform: rotateX(0deg) scale(1); }
}

/* Hoja que se desprende */
.loading-leaf {
  position: absolute;
  top: -4px; left: 50%;
  width: 44px; height: 44px;
  transform: translateX(-50%);
  opacity: 0;
  animation: leaf-fly 2.2s ease-in-out infinite;
}
@keyframes leaf-fly {
  0%   { opacity: 0; transform: translateX(-50%) translateY(0) rotate(0deg) scale(1); }
  10%  { opacity: 0.9; }
  40%  { opacity: 0.6; transform: translateX(calc(-50% + 30px)) translateY(-40px) rotate(25deg) scale(0.7); }
  70%  { opacity: 0; transform: translateX(calc(-50% + 50px)) translateY(-70px) rotate(45deg) scale(0.4); }
  100% { opacity: 0; transform: translateX(-50%) translateY(0) rotate(0deg) scale(1); }
}
.loading-leaf:nth-child(2) { animation-delay: 0.6s; left: 45%; }
.loading-leaf:nth-child(3) { animation-delay: 1.2s; left: 55%; }

/* Barra de progreso animada */
.loading-progress {
  width: 160px; height: 3px;
  background: rgba(0,122,255,0.15);
  border-radius: 3px;
  margin-bottom: 22px;
  overflow: hidden;
}
.loading-progress-bar {
  height: 100%;
  background: linear-gradient(90deg, var(--primary), var(--purple));
  border-radius: 3px;
  animation: progress-run 2s ease-in-out infinite;
}
@keyframes progress-run {
  0%   { width: 0%; margin-left: 0; }
  50%  { width: 70%; margin-left: 0; }
  80%  { width: 20%; margin-left: 78%; }
  100% { width: 0%; margin-left: 100%; }
}

.loading-title {
  font-size: 26px; font-weight: 800;
  color: var(--text-primary); margin-bottom: 4px; letter-spacing: -0.5px;
  background: linear-gradient(135deg, var(--primary) 0%, var(--purple) 100%);
  -webkit-background-clip: text; 
  background-clip: text; 
  -webkit-text-fill-color: transparent;
}

.loading-subtitle { font-size: 13px; color: var(--text-muted); margin-bottom: 18px; }

.loading-dots { display: flex; gap: 6px; }
.loading-dot {
  width: 7px; height: 7px;
  background: var(--primary); border-radius: 50%;
  animation: dot-bounce 1.2s ease-in-out infinite;
}
.loading-dot:nth-child(2) { animation-delay: 0.2s; background: var(--indigo); }
.loading-dot:nth-child(3) { animation-delay: 0.4s; background: var(--purple); }

@keyframes dot-bounce {
  0%,80%,100% { transform: scale(0.6); opacity: 0.35; }
  40% { transform: scale(1); opacity: 1; }
}

/* ============================================
   LOGIN PAGE
   ============================================ */
#login-page {
  display: none;
  position: fixed; inset: 0;
  background: linear-gradient(145deg, #f0f4ff 0%, #e8f0fe 50%, #f5f0ff 100%);
  padding: 20px;
  overflow-y: auto;
  z-index: 500;
}
#login-page.active { display: flex; align-items: center; justify-content: center; }

.login-container {
  width: 100%; max-width: 400px;
  margin: auto;
  animation: fade-up 0.4s ease;
}

.login-header { text-align: center; margin-bottom: 28px; }

.login-logo {
  width: 64px; height: 64px;
  background: var(--primary);
  border-radius: 16px;
  display: flex; align-items: center; justify-content: center;
  font-size: 28px; margin: 0 auto 14px;
  box-shadow: 0 6px 20px rgba(0,122,255,0.3);
}

.login-title {
  font-size: 24px; font-weight: 700;
  color: var(--text-primary); letter-spacing: -0.3px; margin-bottom: 4px;
}
.login-subtitle { font-size: 14px; color: var(--text-muted); }

/* Card login estilo Apple */
.login-card {
  background: var(--bg-card);
  border-radius: var(--r-2xl);
  padding: 28px 24px;
  box-shadow: var(--shadow-md);
}

.login-tabs {
  display: flex;
  background: var(--bg-input);
  border-radius: var(--r-md);
  padding: 3px; margin-bottom: 22px;
  gap: 2px;
}
.login-tab {
  flex: 1; padding: 7px;
  border: none; border-radius: var(--r-sm);
  font-family: var(--font); font-size: 14px; font-weight: 500;
  color: var(--text-muted); cursor: pointer;
  background: none; transition: all var(--t-fast);
}
.login-tab.active {
  background: var(--bg-card);
  color: var(--text-primary); font-weight: 600;
  box-shadow: var(--shadow-xs);
}

.login-tab-content { display: none; }
.login-tab-content.active { display: block; animation: fade-up 0.25s ease; }

/* Botones federados estilo clean */
.federated-btns { display: flex; flex-direction: column; gap: 8px; margin-bottom: 18px; }

.federated-btn {
  display: flex; align-items: center; justify-content: center;
  gap: 10px; padding: 11px 16px;
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  background: var(--bg-card);
  font-family: var(--font); font-size: 14px; font-weight: 500;
  color: var(--text-secondary); cursor: pointer;
  transition: all var(--t-fast);
}
.federated-btn:hover {
  background: var(--bg-primary);
  border-color: var(--border-strong);
}
.federated-btn:active { transform: scale(0.98); }

.login-divider {
  display: flex; align-items: center;
  gap: 10px; margin: 14px 0;
  font-size: 12px; color: var(--text-muted);
  font-weight: 500;
}
.login-divider::before, .login-divider::after {
  content: ''; flex: 1; height: 1px;
  background: var(--separator);
}

.demo-hint {
  margin-top: 14px; padding: 10px 12px;
  background: var(--info-bg); border-radius: var(--r-sm);
  font-size: 12px; color: var(--text-tertiary); text-align: center;
  line-height: 1.5;
}
.demo-hint strong { color: var(--primary); }

/* ============================================
   TUTORIAL
   ============================================ */
#tutorial-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.45);
  backdrop-filter: blur(8px);
  z-index: 8000;
  display: none; align-items: center; justify-content: center; padding: 20px;
}
#tutorial-overlay.active { display: flex; }

.tutorial-card {
  background: var(--bg-card);
  border-radius: var(--r-2xl);
  max-width: 400px; width: 100%;
  overflow: hidden;
  box-shadow: var(--shadow-lg);
  animation: scale-in 0.3s cubic-bezier(0.34,1.56,0.64,1);
}

@keyframes scale-in {
  from { transform: scale(0.88); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}

.tutorial-progress {
  height: 3px; background: var(--bg-input);
}
.tutorial-progress-bar {
  height: 100%; background: var(--primary);
  transition: width 0.35s ease;
}

.tutorial-body { padding: 28px 24px; }

.tutorial-icon {
  width: 56px; height: 56px;
  border-radius: 14px;
  display: flex; align-items: center; justify-content: center;
  font-size: 26px; margin-bottom: 18px;
}

.tutorial-step-num {
  font-size: 12px; font-weight: 600;
  color: var(--primary); text-transform: uppercase;
  letter-spacing: 0.8px; margin-bottom: 6px;
}
.tutorial-title {
  font-size: 20px; font-weight: 700;
  color: var(--text-primary); margin-bottom: 10px; letter-spacing: -0.2px;
}
.tutorial-desc {
  font-size: 15px; color: var(--text-secondary);
  line-height: 1.6;
}

.tutorial-footer {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 24px;
  border-top: 1px solid var(--separator);
  background: var(--bg-primary);
}
.tutorial-dots { display: flex; gap: 5px; }
.tutorial-dot {
  width: 6px; height: 6px; border-radius: 3px;
  background: var(--separator); transition: all var(--t-fast);
}
.tutorial-dot.active { width: 18px; background: var(--primary); }
.tutorial-btns { display: flex; gap: 8px; }

/* ============================================
   APP LAYOUT
   ============================================ */
#app { display: flex; min-height: 100vh; }

/* ============================================
   SIDEBAR — Apple Tabs + Meta Clean + X Dark
   ============================================ */
.sidebar {
  width: var(--sidebar-w);
  background: var(--bg-sidebar);
  border-right: 1px solid var(--separator);
  display: flex; flex-direction: column;
  position: fixed; top: 0; left: 0; height: 100vh;
  z-index: 1000;
  transition: transform var(--t-slow);
  overflow: hidden;
}

.sidebar-logo {
  display: flex; align-items: center; gap: 10px;
  padding: 16px 16px 12px;
  border-bottom: 1px solid var(--separator);
  text-decoration: none; min-height: var(--navbar-h);
}
.sidebar-logo-icon {
  width: 36px; height: 36px;
  background: var(--primary);
  border-radius: 9px;
  display: flex; align-items: center; justify-content: center;
  font-size: 16px; color: white; flex-shrink: 0;
}
.sidebar-logo-title {
  font-size: 16px; font-weight: 700;
  color: var(--text-primary); letter-spacing: -0.2px;
}
.sidebar-logo-subtitle { font-size: 11px; color: var(--text-muted); margin-top: 1px; }

.sidebar-nav { flex: 1; padding: 8px; overflow-y: auto; overflow-x: hidden; }

.sidebar-section-title {
  font-size: 11px; font-weight: 600;
  text-transform: uppercase; letter-spacing: 0.6px;
  color: var(--text-muted); padding: 12px 8px 4px;
}

/* Nav item estilo Apple Sidebar */
.nav-item {
  display: flex; align-items: center;
  gap: 10px; padding: 8px 10px;
  border-radius: var(--r-md);
  color: var(--text-secondary); font-size: 14px; font-weight: 500;
  cursor: pointer; border: none; background: none;
  width: 100%; text-align: left; margin: 1px 0;
  transition: all var(--t-fast);
  position: relative;
}
.nav-item:hover {
  background: var(--bg-primary);
  color: var(--text-primary);
}
.nav-item.active {
  background: var(--primary-bg);
  color: var(--primary); font-weight: 600;
}
.nav-item-icon {
  width: 30px; height: 30px;
  display: flex; align-items: center; justify-content: center;
  border-radius: 7px; font-size: 15px; flex-shrink: 0;
  color: inherit;
}
.nav-item.active .nav-item-icon { color: var(--primary); }

.nav-item-badge {
  margin-left: auto;
  background: var(--danger);
  color: white; font-size: 10px; font-weight: 700;
  min-width: 18px; height: 18px;
  border-radius: 9px; padding: 0 5px;
  display: flex; align-items: center; justify-content: center;
}

.sidebar-footer {
  padding: 8px; border-top: 1px solid var(--separator);
}
.sidebar-user {
  display: flex; align-items: center; gap: 10px;
  padding: 10px; border-radius: var(--r-md);
  cursor: pointer; transition: background var(--t-fast);
}
.sidebar-user:hover { background: var(--bg-primary); }
.sidebar-user-name { font-size: 13px; font-weight: 600; color: var(--text-primary); }
.sidebar-user-role { font-size: 11px; color: var(--text-muted); margin-top: 1px; }

.sidebar-overlay {
  display: none; position: fixed; inset: 0;
  background: var(--bg-overlay);
  z-index: 999;
}

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

/* ============================================
   NAVBAR — Translúcido Apple style
   ============================================ */
.navbar {
  position: sticky; top: 0; z-index: 900;
  background: var(--bg-navbar);
  backdrop-filter: saturate(180%) blur(20px);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  border-bottom: 1px solid var(--separator);
  height: var(--navbar-h);
  display: flex; align-items: center;
  padding: 0 20px; gap: 12px;
}

.navbar-hamburger {
  display: none; background: none; border: none;
  color: var(--text-muted); cursor: pointer;
  padding: 6px; border-radius: var(--r-xs);
  font-size: 18px; transition: color var(--t-fast);
}
.navbar-hamburger:hover { color: var(--text-primary); }

.navbar-title {
  font-size: 16px; font-weight: 700;
  color: var(--text-primary); letter-spacing: -0.2px;
}
.navbar-subtitle { font-size: 11px; color: var(--text-muted); }

.navbar-actions { display: flex; align-items: center; gap: 6px; margin-left: auto; }

.navbar-icon-btn {
  width: 34px; height: 34px;
  display: flex; align-items: center; justify-content: center;
  border-radius: var(--r-sm);
  background: none; border: none;
  color: var(--primary); cursor: pointer;
  font-size: 16px; position: relative;
  transition: background var(--t-fast);
}
.navbar-icon-btn:hover { background: var(--primary-bg); }

.notification-dot {
  position: absolute; top: 7px; right: 7px;
  width: 7px; height: 7px;
  background: var(--danger); border-radius: 50%;
  border: 1.5px solid var(--bg-navbar);
}

.user-avatar {
  width: 30px; height: 30px; border-radius: 15px;
  display: flex; align-items: center; justify-content: center;
  font-size: 13px; font-weight: 700; color: white;
  cursor: pointer; transition: opacity var(--t-fast); flex-shrink: 0;
}
.user-avatar:hover { opacity: 0.85; }

/* ============================================
   CONTENIDO
   ============================================ */
.main-content { flex: 1; padding: 20px; overflow-y: auto; }

.page { display: none; animation: fade-up 0.25s ease; }
.page.active { display: block; }

@keyframes fade-up {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ============================================
   PAGE HEADER
   ============================================ */
.page-header {
  display: flex; align-items: flex-start;
  justify-content: space-between;
  flex-wrap: wrap; gap: 10px;
  margin-bottom: 20px;
}

.page-title {
  font-size: 26px; font-weight: 800;
  color: var(--text-primary); letter-spacing: -0.5px;
  display: flex; align-items: center; gap: 8px;
}
.page-subtitle { font-size: 13px; color: var(--text-muted); margin-top: 3px; }

/* ============================================
   CARDS — Estilo Apple grouped
   ============================================ */
.card {
  background: var(--bg-card);
  border-radius: var(--r-xl);
  padding: 18px;
  box-shadow: var(--shadow-sm);
}

/* ============================================
   STATS
   ============================================ */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 12px; margin-bottom: 20px;
}

/* Stat card — diseño horizontal compacto */
.stat-card {
  background: var(--bg-card);
  border-radius: var(--r-xl);
  padding: 14px 16px;
  display: flex;
  align-items: center;
  gap: 14px;
  box-shadow: var(--shadow-xs);
  transition: transform var(--t-fast), box-shadow var(--t-fast);
  min-height: 76px;
}
.stat-card:hover { transform: translateY(-1px); box-shadow: var(--shadow-sm); }

.stat-icon {
  width: 44px; height: 44px;
  border-radius: 12px;
  background: var(--stat-bg, var(--primary-bg));
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  color: var(--stat-color, var(--primary));
}

.stat-body { flex: 1; min-width: 0; }

.stat-top {
  display: flex; align-items: center; justify-content: space-between; flex-direction: row-reverse;
  margin-bottom: 2px;
}

.stat-value {
  font-size: 24px; font-weight: 800;
  color: var(--stat-color, var(--primary)); letter-spacing: -0.5px;
  line-height: 1;
}
.stat-label { font-size: 12px; color: var(--text-secondary); font-weight: 600; }
.stat-detail { font-size: 11px; color: var(--text-muted); margin-bottom: 5px; }

/* Barra de progreso en stat card */
.stat-progress {
  height: 4px;
  background: var(--stat-bg, rgba(0,122,255,0.1));
  border-radius: 99px;
  overflow: hidden;
}
.stat-progress-bar {
  height: 100%;
  background: var(--stat-color, var(--primary));
  border-radius: 99px;
  transition: width 1s cubic-bezier(0.4,0,0.2,1);
  width: 0;
}

/* ============================================
   DASHBOARD GRID
   ============================================ */
.dashboard-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.dashboard-grid .card-full { grid-column: 1/-1; }
@media (max-width: 900px) { .dashboard-grid { grid-template-columns: 1fr; } }

/* ============================================
   BOTONES — Apple / X style
   ============================================ */
.btn {
  display: inline-flex; align-items: center;
  justify-content: center; gap: 6px;
  padding: 9px 18px;
  border-radius: var(--r-pill);
  font-family: var(--font); font-size: 14px; font-weight: 600;
  border: none; cursor: pointer;
  transition: all var(--t-fast);
  text-decoration: none; white-space: nowrap;
  -webkit-user-select: none; user-select: none;
}
.btn:active { transform: scale(0.97); }

/* Primario — Apple Blue */
.btn-primary {
  background: var(--primary);
  color: white;
}
.btn-primary:hover { background: var(--primary-dark); }

/* Secundario — neutral */
.btn-secondary {
  background: var(--bg-primary);
  color: var(--text-secondary);
}
.btn-secondary:hover { background: var(--separator); color: var(--text-primary); }

/* Danger */
.btn-danger {
  background: var(--danger-bg);
  color: var(--danger);
}
.btn-danger:hover { background: rgba(255,59,48,0.18); }

/* Success */
.btn-success {
  background: var(--success-bg);
  color: var(--success);
}
.btn-success:hover { background: rgba(52,199,89,0.18); }

/* Tamaños */
.btn-sm { padding: 6px 14px; font-size: 13px; border-radius: 20px; }
.btn-lg { padding: 12px 28px; font-size: 16px; }
.btn-icon { padding: 7px; border-radius: var(--r-sm); font-size: 15px; min-width: 32px; height: 32px; }

/* FAB */
.btn-fab {
  position: fixed; bottom: 24px; right: 24px;
  width: 52px; height: 52px; border-radius: 26px;
  background: var(--primary);
  color: white; font-size: 24px; font-weight: 300;
  box-shadow: 0 4px 16px rgba(0,122,255,0.4);
  z-index: 800; border: none; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: all var(--t-normal);
}
.btn-fab:hover { transform: scale(1.08); box-shadow: 0 6px 24px rgba(0,122,255,0.5); }
.btn-fab:active { transform: scale(0.96); }

/* ============================================
   FORMULARIOS — Apple input style
   ============================================ */
.form-group { margin-bottom: 14px; }

.form-label {
  display: flex; align-items: center; gap: 5px;
  font-size: 12px; font-weight: 600;
  color: var(--text-muted); margin-bottom: 5px;
  text-transform: uppercase; letter-spacing: 0.4px;
}

.help-icon { cursor: help; font-size: 12px; color: var(--primary); }

.form-control {
  width: 100%; background: var(--bg-input);
  border: none; border-radius: var(--r-md);
  padding: 11px 13px;
  font-family: var(--font); font-size: 15px;
  color: var(--text-primary);
  transition: all var(--t-fast); outline: none;
  -webkit-appearance: none;
  appearance: none;
}
.form-control:focus {
  background: var(--bg-card);
  box-shadow: 0 0 0 3px var(--primary-glow), 0 0 0 1.5px var(--primary);
}
.form-control::placeholder { color: var(--text-muted); }
textarea.form-control { resize: vertical; min-height: 80px; line-height: 1.5; }

select.form-control {
  cursor: pointer;
  -webkit-appearance: none;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' fill='%238E8E93' viewBox='0 0 16 16'%3E%3Cpath d='M7.247 11.14L2.451 5.658C1.885 5.013 2.345 4 3.204 4h9.592a1 1 0 0 1 .753 1.659l-4.796 5.48a1 1 0 0 1-1.506 0z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 32px;
}
.form-control option { background: var(--bg-card); color: var(--text-primary); }

/* Input con ícono */
.input-icon-wrap { position: relative; }
.input-icon-wrap .input-icon {
  position: absolute; left: 11px; top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted); font-size: 14px; pointer-events: none;
}
.input-icon-wrap .form-control { padding-left: 34px; }

/* Toggle — Apple iOS style */
.toggle-switch { position: relative; display: inline-block; width: 44px; height: 26px; flex-shrink: 0; }
.toggle-switch input { opacity: 0; width: 0; height: 0; }
.toggle-slider {
  position: absolute; cursor: pointer; inset: 0;
  background: #E5E5EA; border-radius: 13px;
  transition: background var(--t-fast);
}
.toggle-slider::before {
  content: ''; position: absolute;
  width: 22px; height: 22px;
  left: 2px; top: 2px;
  background: white; border-radius: 11px;
  transition: transform var(--t-fast);
  box-shadow: 0 2px 5px rgba(0,0,0,0.2);
}
input:checked + .toggle-slider { background: var(--green); }
input:checked + .toggle-slider::before { transform: translateX(18px); }

/* ============================================
   BADGES — Sistema
   ============================================ */
.badge {
  display: inline-flex; align-items: center;
  padding: 2px 8px; border-radius: 10px;
  font-size: 11px; font-weight: 600;
  text-transform: uppercase; letter-spacing: 0.3px;
}
.badge-pending   { background: var(--warning-bg); color: var(--warning); }
.badge-active    { background: var(--info-bg);    color: var(--info);    }
.badge-completed { background: var(--success-bg); color: var(--success); }
.badge-cancelled { background: var(--danger-bg);  color: var(--danger);  }
.badge-admin     { background: var(--primary-bg); color: var(--primary); }
.badge-editor    { background: rgba(175,82,222,0.1); color: var(--purple); }
.badge-viewer    { background: var(--warning-bg); color: var(--orange);  }

/* ============================================
   MODALES — Apple Sheet style
   ============================================ */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.4);
  backdrop-filter: blur(6px);
  z-index: 2000;
  display: flex; align-items: center; justify-content: center;
  padding: 16px; opacity: 0; pointer-events: none;
  transition: opacity var(--t-normal);
}
.modal-overlay.active { opacity: 1; pointer-events: all; }

.modal {
  background: var(--bg-card);
  border-radius: var(--r-2xl);
  width: 100%; max-width: 520px;
  max-height: 90vh; overflow-y: auto;
  transform: translateY(30px) scale(0.95);
  transition: transform var(--t-slow);
  box-shadow: var(--shadow-lg);
}
.modal-overlay.active .modal { transform: translateY(0) scale(1); }

.modal-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 18px 20px;
  border-bottom: 1px solid var(--separator);
  position: sticky; top: 0; background: var(--bg-card); z-index: 1;
}
.modal-title {
  font-size: 17px; font-weight: 700;
  color: var(--text-primary); letter-spacing: -0.2px;
  display: flex; align-items: center; gap: 8px;
}
.modal-close {
  width: 30px; height: 30px;
  display: flex; align-items: center; justify-content: center;
  border-radius: 15px; background: var(--bg-primary);
  border: none; color: var(--text-muted); cursor: pointer; font-size: 14px;
  transition: all var(--t-fast);
}
.modal-close:hover { background: var(--danger-bg); color: var(--danger); }

.modal-body { padding: 20px; }
.modal-footer {
  display: flex; justify-content: flex-end; gap: 8px;
  padding: 14px 20px;
  border-top: 1px solid var(--separator);
  background: var(--bg-primary);
  border-radius: 0 0 var(--r-2xl) var(--r-2xl);
}

/* ============================================
   FILTROS / CHIPS — Instagram / Meta
   ============================================ */
.filters-bar {
  display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 16px;
}

.search-input {
  display: flex; align-items: center; gap: 8px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--r-pill);
  padding: 7px 14px; flex: 1; min-width: 180px;
}
.search-input:focus-within { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-glow); }
.search-input input {
  flex: 1; background: none; border: none; outline: none;
  font-size: 14px; color: var(--text-primary); font-family: var(--font);
}
.search-icon { color: var(--text-muted); font-size: 14px; }

.filter-chip {
  padding: 6px 14px;
  border-radius: var(--r-pill);
  background: var(--bg-card);
  border: 1px solid var(--border);
  color: var(--text-secondary);
  font-size: 13px; font-weight: 500;
  cursor: pointer; transition: all var(--t-fast);
  display: flex; align-items: center; gap: 5px;
  white-space: nowrap;
}
.filter-chip:hover { border-color: var(--primary); color: var(--primary); }
.filter-chip.active {
  background: var(--primary); border-color: var(--primary);
  color: white; font-weight: 600;
}
.filter-chip.active .filter-count { background: rgba(255,255,255,0.25); color: white; }

.filter-count {
  background: var(--bg-primary); border-radius: 8px;
  font-size: 11px; font-weight: 700; padding: 1px 5px;
  transition: all var(--t-fast);
}

/* ============================================
   TAREAS — Lista
   ============================================ */
.task-list { display: flex; flex-direction: column; gap: 8px; }

.task-item {
  background: var(--bg-card);
  border-radius: var(--r-lg);
  padding: 13px 14px;
  display: flex; align-items: flex-start; gap: 12px;
  cursor: pointer; transition: all var(--t-fast);
  border-left: 3px solid var(--task-color, var(--primary));
  box-shadow: var(--shadow-xs);
}
.task-item:hover { box-shadow: var(--shadow-sm); transform: translateX(1px); }
.task-item.overdue { border-left-color: var(--danger); }

.task-checkbox {
  width: 20px; height: 20px; flex-shrink: 0;
  border: 1.5px solid var(--separator);
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  transition: all var(--t-fast); cursor: pointer; margin-top: 1px;
  font-size: 11px; font-weight: 700;
}
.task-checkbox:hover { border-color: var(--green); }
.task-checkbox.checked { background: var(--green); border-color: var(--green); color: white; }

.task-content { flex: 1; min-width: 0; }
.task-title {
  font-size: 14px; font-weight: 600; color: var(--text-primary);
  margin-bottom: 4px; line-height: 1.3;
}
.task-item.completed .task-title { text-decoration: line-through; color: var(--text-muted); }

.task-meta {
  display: flex; flex-wrap: wrap; gap: 6px;
  align-items: center; margin-top: 5px;
}
.task-meta-item { font-size: 11px; color: var(--text-muted); display: flex; align-items: center; gap: 3px; }

.task-actions { display: flex; gap: 4px; flex-shrink: 0; align-items: flex-start; }

/* Prioridad selector */
.priority-selector {
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px;
}
.priority-btn {
  padding: 8px 4px; border: 1.5px solid var(--border);
  border-radius: var(--r-sm); background: var(--bg-input);
  cursor: pointer; font-size: 12px; font-weight: 500;
  color: var(--text-secondary); transition: all var(--t-fast); text-align: center;
  font-family: var(--font);
}
.priority-btn:hover { border-color: var(--primary); color: var(--primary); }
.priority-btn[class*="selected"] { background: var(--primary-bg); border-color: var(--primary); color: var(--primary); font-weight: 700; }

/* Upload */
.upload-zone {
  border: 1.5px dashed var(--separator);
  border-radius: var(--r-lg);
  padding: 22px; text-align: center;
  cursor: pointer; transition: all var(--t-fast);
  background: var(--bg-input);
}
.upload-zone:hover, .upload-zone.dragover {
  border-color: var(--primary); background: var(--primary-bg);
}
.upload-icon { font-size: 24px; margin-bottom: 6px; color: var(--text-muted); }
.upload-title { font-size: 14px; font-weight: 500; color: var(--text-secondary); }
.upload-subtitle { font-size: 12px; color: var(--text-muted); margin-top: 3px; }

/* Files preview */
.files-grid { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.file-item {
  position: relative; border-radius: var(--r-sm);
  overflow: hidden; background: var(--bg-input);
  width: 80px; border: 1px solid var(--border);
}
.file-item img { width: 80px; height: 60px; object-fit: cover; display: block; }
.file-icon { width: 80px; height: 60px; display: flex; align-items: center; justify-content: center; font-size: 28px; }
.file-name { font-size: 9px; color: var(--text-muted); padding: 3px 4px; text-align: center; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ============================================
   RECORDATORIOS
   ============================================ */
.reminder-item, .reminder-card {
  background: var(--bg-card);
  border-radius: var(--r-lg);
  padding: 0;
  display: flex; align-items: stretch; gap: 0;
  box-shadow: var(--shadow-xs);
  transition: all var(--t-fast);
  overflow: hidden;
  border: 1px solid var(--border);
}
.reminder-card-body {
  display: flex; align-items: center; gap: 12px;
  flex: 1; padding: 13px 14px;
}
.reminder-card-actions {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: space-evenly;
  gap: 4px;
  padding: 8px 10px;
  border-left: 1px solid var(--border);
  background: var(--bg-primary);
  flex-shrink: 0;
  min-width: 48px;
}
.reminder-item:hover { box-shadow: var(--shadow-sm); }
.reminder-icon { font-size: 22px; flex-shrink: 0; }
.reminder-title { font-size: 14px; font-weight: 600; color: var(--text-primary); }
.reminder-time { font-size: 12px; color: var(--text-muted); margin-top: 3px; }
.reminder-repeat { font-size: 11px; color: var(--primary); margin-top: 2px; }

/* ============================================
   PROGRESO
   ============================================ */
.progress {
  height: 6px; background: var(--bg-primary);
  border-radius: 3px; overflow: hidden;
}
.progress-bar {
  height: 100%; background: var(--primary);
  border-radius: 3px; transition: width 0.5s ease;
}

/* ============================================
   USUARIOS / ADMIN
   ============================================ */
.user-card {
  background: var(--bg-card);
  border-radius: var(--r-lg);
  padding: 14px 16px;
  display: flex; align-items: center; gap: 12px;
  box-shadow: var(--shadow-xs); transition: all var(--t-fast);
}
.user-card:hover { box-shadow: var(--shadow-sm); }

/* ============================================
   SETTINGS
   ============================================ */
.settings-section { margin-bottom: 20px; }
.settings-section-title {
  font-size: 15px; font-weight: 700; color: var(--text-primary);
  margin-bottom: 12px; padding-bottom: 8px;
  border-bottom: 1px solid var(--separator);
  display: flex; align-items: center; gap: 8px;
}
.settings-row {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 0; border-bottom: 1px solid var(--separator); gap: 12px;
}
.settings-row:last-child { border-bottom: none; }
.settings-row-info { flex: 1; }
.settings-row-label {
  font-size: 15px; font-weight: 500; color: var(--text-primary);
  display: flex; align-items: center; gap: 6px;
}
.settings-row-desc { font-size: 13px; color: var(--text-muted); margin-top: 2px; }

/* ============================================
   ACTIVIDAD RECIENTE
   ============================================ */
.activity-item {
  display: flex; gap: 10px; align-items: flex-start;
  padding: 8px; border-radius: var(--r-md); cursor: pointer;
  transition: background var(--t-fast);
}
.activity-item:hover { background: var(--bg-primary); }
.activity-icon { font-size: 18px; flex-shrink: 0; }
.activity-title { font-size: 13px; font-weight: 600; color: var(--text-primary); }
.activity-time { font-size: 11px; color: var(--text-muted); margin-top: 2px; }

/* ============================================
   SKELETON LOADING
   ============================================ */
.skeleton {
  background: linear-gradient(90deg, #F2F2F7 25%, #E5E5EA 50%, #F2F2F7 75%);
  background-size: 200% 100%; border-radius: var(--r-lg);
  animation: shimmer 1.4s infinite;
}
@keyframes shimmer {
  0% { background-position: -200% 0; }
  100% { background-position: 200% 0; }
}

/* ============================================
   EMPTY STATE
   ============================================ */
.empty-state {
  text-align: center; padding: 40px 20px; color: var(--text-muted);
}
.empty-icon { font-size: 40px; margin-bottom: 12px; opacity: 0.5; display: block; }
.empty-title { font-size: 16px; font-weight: 700; color: var(--text-secondary); margin-bottom: 6px; }
.empty-desc { font-size: 14px; color: var(--text-muted); max-width: 240px; margin: 0 auto 16px; line-height: 1.5; }

/* ============================================
   TOAST — X (Twitter) badge style
   ============================================ */
#toast-container {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%);
  z-index: 9998; display: flex; flex-direction: column;
  gap: 8px; align-items: center; pointer-events: none;
}
.toast {
  display: flex; align-items: center; gap: 8px;
  background: var(--text-primary);
  color: var(--bg-card);
  padding: 10px 16px;
  border-radius: var(--r-pill);
  box-shadow: var(--shadow-lg);
  font-size: 14px; font-weight: 500; pointer-events: all;
  animation: toast-in 0.3s cubic-bezier(0.34,1.56,0.64,1);
  max-width: 360px;
}
.toast-icon { font-size: 15px; }
@keyframes toast-in {
  from { opacity: 0; transform: translateY(16px) scale(0.9); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}
@keyframes toast-out {
  to { opacity: 0; transform: translateY(12px) scale(0.95); }
}

/* ============================================
   TOOLTIP
   ============================================ */
[data-tooltip] { position: relative; }
[data-tooltip]::after {
  content: attr(data-tooltip);
  position: absolute; bottom: calc(100% + 6px); left: 50%; transform: translateX(-50%);
  background: rgba(0,0,0,0.75); color: white;
  padding: 5px 10px; border-radius: var(--r-sm);
  font-size: 12px; white-space: nowrap;
  pointer-events: none; opacity: 0;
  transition: opacity var(--t-fast); z-index: 9999;
}
[data-tooltip]:hover::after { opacity: 1; }
[data-tooltip].tooltip-bottom::after {
  bottom: auto;
  top: calc(100% + 6px);
}

/* ============================================
   NOTIFICACIONES DROPDOWN
   ============================================ */
.notif-dropdown {
  position: absolute; top: calc(100% + 10px); right: 0;
  width: 300px; background: var(--bg-card);
  border-radius: var(--r-xl);
  box-shadow: var(--shadow-lg); border: 1px solid var(--border);
  max-height: 380px; overflow-y: auto;
  z-index: 1000;
  /* Animación suave con opacity + transform */
  opacity: 0;
  transform: translateY(-8px) scale(0.97);
  pointer-events: none;
  transition: opacity 0.18s ease, transform 0.18s cubic-bezier(0.34,1.56,0.64,1);
}
.notif-dropdown.active {
  opacity: 1;
  transform: translateY(0) scale(1);
  pointer-events: all;
}
.notif-item {
  display: flex; gap: 10px; padding: 12px 14px;
  border-bottom: 1px solid var(--separator);
  cursor: pointer; transition: background var(--t-fast);
  align-items: flex-start;
}
.notif-item:hover { background: var(--bg-primary); }
.notif-item:last-child { border-bottom: none; }
.notif-item.unread { background: var(--primary-bg); }

/* ============================================
   CALENDARIO — Heredado mejorado
   ============================================ */
.calendar-view { display: grid; grid-template-columns: 1fr 260px; gap: 16px; }
@media (max-width: 1100px) { .calendar-view { grid-template-columns: 1fr; } .calendar-sidebar { display: none; } }

.calendar-header {
  display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px;
}
.calendar-nav-btn {
  width: 32px; height: 32px; border-radius: 50%;
  background: var(--bg-input); border: none;
  cursor: pointer; font-size: 18px; color: var(--text-primary);
  display: flex; align-items: center; justify-content: center;
  transition: background var(--t-fast);
}
.calendar-nav-btn:hover { background: var(--primary-bg); color: var(--primary); }
.calendar-month-title { font-size: 18px; font-weight: 700; color: var(--text-primary); letter-spacing: -0.2px; }
.calendar-today-btn {
  font-size: 12px; padding: 3px 10px;
  border-radius: var(--r-pill);
  background: var(--primary-bg); border: 1px solid var(--primary);
  color: var(--primary); cursor: pointer; font-weight: 500;
  font-family: var(--font); margin-top: 2px; display: block;
}

.calendar-weekdays { display: grid; grid-template-columns: repeat(7,1fr); gap: 4px; margin-bottom: 6px; }
.calendar-weekday { text-align: center; font-size: 11px; font-weight: 600; color: var(--text-muted); padding: 6px 0; text-transform: uppercase; }
.calendar-days { display: grid; grid-template-columns: repeat(7,1fr); gap: 4px; }

.calendar-day {
  border-radius: var(--r-md); border: none;
  display: flex; flex-direction: column; align-items: center;
  padding: 6px 2px; cursor: pointer; min-height: 52px;
  font-size: 13px; font-weight: 500; color: var(--text-secondary);
  background: var(--bg-card);
  transition: all var(--t-fast);
}
.calendar-day:hover { background: var(--primary-bg); color: var(--primary); }
.calendar-day.today { background: var(--primary); color: white; font-weight: 700; }
.calendar-day.today:hover { background: var(--primary-dark); }
.calendar-day.selected { background: var(--primary-bg); color: var(--primary); border: 1.5px solid var(--primary); }
.calendar-day.other-month { opacity: 0.3; }
.calendar-day.has-events::after { content: ''; width: 4px; height: 4px; border-radius: 2px; background: var(--primary); }
.calendar-day.today.has-events::after { background: white; }

.calendar-sidebar { display: flex; flex-direction: column; gap: 12px; }
.cal-mini { background: var(--bg-card); border-radius: var(--r-xl); padding: 14px; }
.day-agenda { background: var(--bg-card); border-radius: var(--r-xl); padding: 14px; flex: 1; }
.day-agenda-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; }
.day-agenda-title { font-weight: 700; font-size: 14px; color: var(--text-primary); }
.day-agenda-date { font-size: 12px; color: var(--text-muted); }
.day-agenda-list { display: flex; flex-direction: column; gap: 6px; }

.view-toggle {
  display: flex; background: var(--bg-input); border-radius: var(--r-md); padding: 3px; gap: 2px;
}
.view-toggle-btn {
  padding: 5px 12px; border: none; border-radius: var(--r-sm);
  background: none; font-size: 13px; font-weight: 500;
  color: var(--text-muted); cursor: pointer; font-family: var(--font);
  transition: all var(--t-fast);
}
.view-toggle-btn.active {
  background: var(--bg-card); color: var(--text-primary); font-weight: 600;
  box-shadow: var(--shadow-xs);
}

.cal-mini-header { margin-bottom: 8px; }
.cal-mini-title { font-weight: 600; font-size: 13px; color: var(--text-secondary); }
.cal-mini-grid { display: grid; grid-template-columns: repeat(7,1fr); gap: 2px; }

/* ============================================
   FLOATING LABEL — .field
   ============================================ */

.field {
  position: relative;
  margin-bottom: 14px;
}

/* Input base */
.field-input {
  width: 100%;
  background: var(--bg-input);
  border: 1.5px solid transparent;
  border-radius: var(--r-md);
  padding: 24px 42px 8px 14px;    /* top grande para que el label flote */
  font-family: var(--font);
  font-size: 15px;
  color: var(--text-primary);
  outline: none;
  transition: border-color .15s, box-shadow .15s, background .15s;
  -webkit-appearance: none;
  appearance: none;
}
/* Sin icono a la derecha */
.field--no-action .field-input { padding-right: 14px; }

.field-input:focus {
  background: var(--bg-card);
  border-color: var(--primary);
  box-shadow: 0 0 0 3.5px var(--primary-glow);
}
.field-input.error {
  border-color: var(--danger);
  box-shadow: 0 0 0 3px rgba(255,59,48,.15);
}
.field-input::placeholder { color: transparent; }   /* oculta placeholder nativo */

/* Label flotante */
.field-label {
  position: absolute;
  left: 14px;
  top: 50%;
  transform: translateY(-50%);
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 14.5px;
  font-weight: 400;
  color: var(--text-muted);
  pointer-events: none;
  white-space: nowrap;
  transition:
    top .18s cubic-bezier(.4,0,.2,1),
    transform .18s cubic-bezier(.4,0,.2,1),
    font-size .18s cubic-bezier(.4,0,.2,1),
    color .18s cubic-bezier(.4,0,.2,1),
    font-weight .18s;
}

/* State: enfocado O con contenido → label sube */
.field-input:focus          ~ .field-label,
.field-input:not(:placeholder-shown) ~ .field-label {
  top: 9px;
  transform: none;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: .5px;
  text-transform: uppercase;
  color: var(--primary);
}
/* Con contenido pero sin foco → color neutro */
.field-input:not(:focus):not(:placeholder-shown) ~ .field-label {
  color: var(--text-muted);
}

/* Icono dentro del label: se oculta al subir */
.field-label .f-icon {
  flex-shrink: 0;
  transition: opacity .15s, width .18s, margin .18s;
}
.field-input:focus          ~ .field-label .f-icon,
.field-input:not(:placeholder-shown) ~ .field-label .f-icon {
  opacity: 0;
  width: 0;
  margin-right: -6px;  /* colapsa el gap */
  overflow: hidden;
}

/* Botón acción derecha (ver/ocultar contraseña) */
.field-action {
  position: absolute;
  right: 10px;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text-muted);
  padding: 5px;
  border-radius: 7px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: color .15s, background .15s;
}
.field-action:hover { color: var(--primary); background: var(--primary-bg); }

/* --- Textarea --- */
.field--textarea .field-input {
  padding-top: 28px;
  padding-bottom: 10px;
  min-height: 86px;
  resize: vertical;
  line-height: 1.5;
}
.field--textarea .field-label {
  /* arranca en la parte superior, no centrado */
  top: 18px;
  transform: none;
}
.field--textarea .field-input:focus ~ .field-label,
.field--textarea .field-input:not(:placeholder-shown) ~ .field-label {
  top: 7px;
}

/* --- Select --- */
.field--select .field-input {
  cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' fill='none' stroke='%238E8E93' stroke-width='2' stroke-linecap='round' stroke-linejoin='round' viewBox='0 0 24 24'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 34px;
}
/* Select siempre tiene valor → label siempre arriba */
.field--select .field-label {
  top: 9px;
  transform: none;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: .5px;
  text-transform: uppercase;
  color: var(--text-muted);
}
.field--select .field-label .f-icon { opacity: 0; width: 0; margin-right: -6px; }
.field--select .field-input { padding-left: 14px; }

/* Icono SVG genérico */
.icon {
  display: inline-block;
  vertical-align: middle;
  flex-shrink: 0;
}

/* LOGIN — MEJORAS v2.1
   ============================================ */

/* Botones de acceso rápido demo */
.demo-cred-btn {
  display: flex; align-items: center; gap: 6px;
  width: 100%; padding: 7px 10px;
  background: transparent; border: 1px solid var(--separator);
  border-radius: var(--r-sm); cursor: pointer;
  font-family: var(--font); font-size: 12px;
  color: var(--text-secondary); text-align: left;
  transition: all var(--t-fast);
}
.demo-cred-btn:hover {
  background: var(--bg-primary);
  border-color: var(--primary);
  color: var(--text-primary);
}
.demo-cred-btn code {
  font-family: 'SF Mono', 'Fira Code', monospace;
  font-size: 11px;
  color: var(--primary);
  background: var(--primary-bg);
  padding: 1px 5px; border-radius: 4px;
}

/* Botón federated disabled */
.federated-btn:disabled {
  opacity: 0.65; cursor: not-allowed;
}
.federated-btn:disabled:active { transform: none; }

/* Animación shake para errores */
@keyframes shake {
  0%,100% { transform: translateX(0); }
  15%      { transform: translateX(-6px); }
  30%      { transform: translateX(6px); }
  45%      { transform: translateX(-4px); }
  60%      { transform: translateX(4px); }
  75%      { transform: translateX(-2px); }
}

/* Error box animado */
#login-error-box {
  animation: shake .4s ease;
}

/* ============================================
   RESPONSIVE
   ============================================ */
@media (max-width: 768px) {
  /* Sidebar: oculto por defecto, desliza desde la izquierda */
  .sidebar {
    transform: translateX(-100%);
    width: 260px;
    box-shadow: none;
    z-index: 1000;
    transition: transform var(--t-slow);
  }
  .sidebar.mobile-open {
    transform: translateX(0);
    box-shadow: var(--shadow-lg);
  }

  /* Overlay: siempre oculto, visible con clase .shown */
  .sidebar-overlay {
    display: none !important;
    opacity: 0;
    pointer-events: none;
    transition: opacity var(--t-normal);
    z-index: 999;
    cursor: pointer;
  }
  .sidebar-overlay.shown {
    display: block !important;
    opacity: 1;
    pointer-events: all;
  }

  .main-wrapper { margin-left: 0; }
  .navbar-hamburger { display: flex; }
  .main-content { padding: 14px; }
  .stats-grid { grid-template-columns: 1fr 1fr; gap: 10px; }
  .page-title { font-size: 22px; }
  .btn-fab { bottom: 16px; right: 16px; }
  .priority-selector { grid-template-columns: 1fr 1fr; }
  .dashboard-grid { grid-template-columns: 1fr; }
}

@media (max-width: 400px) {
  .stats-grid { grid-template-columns: 1fr 1fr; }
  .filter-chip { padding: 5px 10px; font-size: 12px; }
}

/* ============================================
   SVG ICONS — Estilos globales
   ============================================ */
svg[aria-hidden="true"] {
  display: inline-block;
  vertical-align: middle;
  flex-shrink: 0;
}
.search-input svg.search-icon {
  position: absolute;
  left: 14px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  pointer-events: none;
}
@keyframes spin {
  from { transform: rotate(0deg); }
  to   { transform: rotate(360deg); }
}
.btn svg { vertical-align: middle; margin-right: 2px; }
.nav-item-icon svg { width: 20px; height: 20px; }
.settings-section-title svg,
.modal-title svg,
.page-title svg { vertical-align: middle; }

/* ============================================
   SOUNDS — Panel de sonidos
   ============================================ */
.sound-panel {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.sound-btn {
  display: inline-flex;
  flex-direction: row;
  align-items: center;
  gap: 7px;
  padding: 7px 14px 7px 10px;
  background: var(--bg-primary);
  border: 1.5px solid var(--border);
  border-radius: 999px;
  cursor: pointer;
  transition: all var(--t-fast);
  color: var(--text-secondary);
  font-size: 13px;
  font-weight: 500;
  font-family: var(--font);
  white-space: nowrap;
}

.sound-btn:hover {
  background: var(--primary-bg);
  border-color: var(--primary);
  color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-glow);
}

.sound-btn:active {
  transform: scale(0.97);
}

.sound-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: var(--primary-bg);
  color: var(--primary);
  flex-shrink: 0;
  transition: all var(--t-fast);
}

.sound-btn:hover .sound-icon {
  background: var(--primary);
  color: white;
}

/* Estado: reproduciendo */
.sound-btn.playing {
  border-color: var(--success);
  color: var(--success);
  background: var(--success-bg);
  animation: sound-pulse 1.5s ease-in-out infinite;
}

.sound-btn.playing .sound-icon {
  background: var(--success);
  color: white;
}

@keyframes sound-pulse {
  0%, 100% { box-shadow: 0 0 0 3px rgba(52,199,89,0.15); }
  50%       { box-shadow: 0 0 0 6px rgba(52,199,89,0.06); }
}

/* Upload zone */
.upload-zone {
  border: 2px dashed var(--border-strong);
  border-radius: var(--r-lg);
  padding: 28px 20px;
  text-align: center;
  cursor: pointer;
  transition: all var(--t-normal);
  background: var(--bg-primary);
}

.upload-zone:hover {
  border-color: var(--primary);
  background: var(--primary-bg);
}

.upload-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 10px;
  width: 52px;
  height: 52px;
  border-radius: var(--r-xl);
  background: var(--primary-bg);
  border: 1px solid rgba(0,122,255,0.2);
  color: var(--primary);
  transition: all var(--t-normal);
}

.upload-zone:hover .upload-icon {
  background: var(--primary);
  color: white;
  box-shadow: 0 4px 16px var(--primary-glow);
  transform: scale(1.06);
}

.upload-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 4px;
}

.upload-subtitle {
  font-size: 12px;
  color: var(--text-muted);
}

/* ============================================
   TEMPLATE EDITOR — Split Panel
   ============================================ */

/* Bloque de contenido en el editor */
.tpl-block {
  background: var(--bg-card);
  border: 1.5px solid var(--border);
  border-radius: var(--r-lg);
  margin-bottom: 8px;
  transition: box-shadow var(--t-fast), border-color var(--t-fast), transform var(--t-fast);
  cursor: grab;
  position: relative;
}
.tpl-block:hover { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-glow); }
.tpl-block.drag-over { border-color: var(--primary); background: var(--primary-bg); transform: scale(1.01); }
.tpl-block.dragging  { opacity: 0.4; cursor: grabbing; }

.tpl-block-inner {
  display: flex;
  gap: 0;
}

.tpl-block-controls {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 8px 6px;
  border-right: 1px solid var(--separator);
  flex-shrink: 0;
  background: var(--bg-primary);
  border-radius: var(--r-lg) 0 0 var(--r-lg);
}

.tpl-btn-icon {
  width: 26px; height: 26px;
  border-radius: var(--r-sm);
  border: none;
  background: none;
  cursor: pointer;
  font-size: 13px;
  color: var(--text-muted);
  display: flex; align-items: center; justify-content: center;
  transition: all var(--t-fast);
  font-family: var(--font);
  padding: 0;
}
.tpl-btn-icon:hover { background: var(--bg-input); color: var(--text-primary); }
.tpl-btn-danger:hover { background: var(--danger-bg); color: var(--danger); }

/* Drag handle */
.tpl-drag-handle {
  width: 26px; height: 26px;
  display: flex; align-items: center; justify-content: center;
  color: var(--text-muted); font-size: 12px;
  cursor: grab; opacity: 0.5;
  transition: opacity var(--t-fast);
}
.tpl-block:hover .tpl-drag-handle { opacity: 1; }

.tpl-block-body {
  flex: 1;
  padding: 10px 12px;
  min-width: 0;
}

.tpl-block-label {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .5px;
  color: var(--text-muted);
  margin-bottom: 4px;
}

/* Toolbar para añadir bloques */
.tpl-add-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  padding: 10px 12px;
  background: var(--bg-primary);
  border-radius: var(--r-lg);
  border: 1.5px dashed var(--separator);
  margin-top: 8px;
}

/* SMTP colapsable */
.smtp-body {
  max-height: 600px;
  overflow: hidden;
  transition: max-height 0.35s ease;
}
.smtp-body.smtp-collapsed {
  max-height: 0;
}

/* Preview iframe container */
#tpl-preview-iframe {
  background: #f5f5f7;
}

/* Responsive: split → stack en móvil */
@media (max-width: 900px) {
  .tpl-split-grid {
    grid-template-columns: 1fr !important;
  }
  #tpl-preview-iframe {
    min-height: 350px !important;
    border-top: 1px solid var(--separator);
  }
}
