/* Base global de pagina y variables de color/fuente */
html { overflow-x: hidden; max-width: 100%; }
@font-face {
  font-family: 'CascadiaCode';
  src: url('https://cdn.jsdelivr.net/gh/microsoft/cascadia-code@v2111.01/ttf/CascadiaCode.ttf') format('truetype');
  font-weight: 400 700;
}
:root {
  --bg: #ede8f5;
  --surface: #f7f4fc;
  --border: #d8cff0;
  --accent: #7c4dcc;
  --warn: #e07b00;
  --danger: #d93025;
  --text: #2a1f3d;
  --muted: #7a6a99;
  --card: #ffffff;
  --icon-color: #6366f1;
}
* { box-sizing: border-box; margin: 0; padding: 0; }
body { background: var(--bg); color: var(--text); font-family: 'CascadiaCode', monospace; min-height: 100vh; overflow-x: hidden; max-width: 100vw; }
body::before {
  content: ''; position: fixed; inset: 0;
  background: radial-gradient(circle at 20% 20%, rgba(124,77,204,0.08) 0%, transparent 50%),
              radial-gradient(circle at 80% 80%, rgba(156,109,224,0.08) 0%, transparent 50%);
  pointer-events: none; z-index: 0;
}
.wrap { max-width: 680px; margin: 0 auto; padding: 16px 16px 60px; position: relative; z-index: 1; box-sizing: border-box; width: 100%; }

/* Encabezado principal (titulo y controles superiores) */
.header { margin-bottom: 24px; }
.header-top { display: flex; align-items: center; justify-content: space-between; margin-bottom: 4px; }
.label { font-size: 10px; letter-spacing: 4px; text-transform: uppercase; color: var(--accent); }
.live { font-size: 11px; color: var(--accent); }
h1 { font-size: clamp(32px, 8vw, 44px); font-weight: 700; color: var(--text); line-height: 1.1; margin-bottom: 6px; }
.subtitle { color: var(--muted); font-size: 13px; }

/* Menu de 3 puntos (copiar mensaje y cerrar sesion) */
.dots-wrap { position: relative; display: flex; align-items: center; gap: 8px; }
.dots-btn {
  background: var(--surface); border: 1px solid var(--border); border-radius: 10px;
  color: var(--accent); font-size: 20px; width: 42px; height: 42px;
  cursor: pointer; display: flex; align-items: center; justify-content: center;
  font-family: 'CascadiaCode', monospace;
}
.dots-menu {
  display: none; position: absolute; top: 48px; right: 0;
  background: var(--card); border: 1px solid var(--border); border-radius: 12px;
  box-shadow: 0 8px 24px rgba(124,77,204,0.15); z-index: 100; min-width: 220px; overflow: hidden;
}
.dots-menu.open { display: block; }
.dots-item { padding: 14px 18px; font-size: 13px; cursor: pointer; color: var(--text); border-bottom: 1px solid var(--border); font-family: 'CascadiaCode', monospace; }
.dots-item:last-child { border-bottom: none; }
.dots-item:hover { background: var(--bg); color: var(--accent); }
.dots-item.ok { color: green; }

/* Tarjetas de estadisticas (total, urgentes, vencidas) */
.stats { display: flex; gap: 12px; margin-bottom: 28px; flex-wrap: wrap; }
.stat { background: var(--card); border: 1px solid var(--border); border-radius: 10px; padding: 10px 16px; font-size: 12px; color: var(--muted); display: flex; align-items: center; gap: 8px; box-shadow: 0 1px 4px rgba(124,77,204,0.08); }
.stat strong { color: var(--text); font-size: 18px; margin-left: 2px; }

/* Tarjeta visual de cada tarea en la lista */
.task-card {
  background: var(--card); border: 1px solid var(--border); border-radius: 14px;
  padding: 18px; margin-bottom: 12px; position: relative;
  box-shadow: 0 2px 8px rgba(124,77,204,0.07); animation: fadeIn 0.3s ease;
  box-sizing: border-box; width: 100%; overflow: visible;
}
.task-card.is-recent { animation: fadeIn 0.3s ease, popRecent 0.25s ease; }
@keyframes popRecent {
  from { transform: scale(0.985); box-shadow: 0 0 0 rgba(124,77,204,0); }
  to { transform: scale(1); box-shadow: 0 2px 8px rgba(124,77,204,0.07); }
}
.recent-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.4px;
  background: #f6efff;
  color: #6b3fc2;
  border: 1px solid #d7c3fb;
}
.recent-hint {
  font-size: 10px;
  color: #5b3d94;
  background: rgba(255,255,255,0.5);
  border: 1px solid rgba(123,77,204,0.18);
  border-radius: 999px;
  padding: 2px 8px;
}
.recent-btn {
  border: 1px solid #b99bec;
  background: #fff;
  color: #6b3fc2;
  border-radius: 999px;
  padding: 3px 9px;
  font-size: 10px;
  cursor: pointer;
  font-family: 'CascadiaCode', monospace;
  font-weight: 700;
}
@keyframes fadeIn { from { opacity:0; transform:translateY(8px); } to { opacity:1; transform:none; } }
.card-actions { 
  position: absolute; 
  bottom: 101%; /* Positioned exactly above the card */
  margin-bottom: 0; /* No overlap with the card content */
  right: 24px; /* Moved away from the corner curve */
  display: flex; 
  gap: 12px; 
  background: #7a6a99; 
  border-radius: 10px 10px 0 0;
  padding: 0 16px; 
  height: 25px; /* Fixed height as requested */
  align-items: center; 
  z-index: 2;
}
.icon-btn { 
  background: none; 
  border: none; 
  color: rgba(255, 255, 255, 0.8); 
  cursor: pointer; 
  display: flex; 
  align-items: center; 
  justify-content: center;
  transition: all 0.2s ease;
  padding: 4px;
}
.icon-btn:hover {
  color: #fff;
}
.icon-btn:hover .lucide {
  transform: scale(1.1);
}
.icon-btn.edit:hover { color: #ffca28; } /* Yellow for edit hover */
.icon-btn.del:hover { color: #ff5252; } /* Red for delete hover */
.icon-btn.users:hover { color: #40c4ff; } /* Light blue for users hover */

.card-num { font-size: 13px; font-weight: 700; color: #7a6a99; margin-bottom: 8px; letter-spacing: 3px; display:flex; justify-content:space-between; align-items:center; flex-wrap:wrap; gap:4px; }


.badge { display: inline-flex; align-items: center; padding: 3px 10px; border-radius: 20px; font-size: 10px; font-weight: 700; letter-spacing: 0.5px; margin-bottom: 0; }
.card-title { font-size: 16px; font-weight: 700; color: var(--text); padding-right: 0px; margin-bottom: 6px; line-height: 1.3; clear:both; }
.card-desc { font-size: 13px; color: #8a7aaa; line-height: 1.6; margin-bottom: 12px; }
.card-meta { display: flex; gap: 16px; font-size: 12px; color: var(--muted); flex-wrap: wrap; align-items: center; }
.card-meta span { display: inline-flex; align-items: center; gap: 5px; }
.days-left { margin-left: auto; font-weight: 600; font-size: 12px; }

.empty { text-align: center; padding: 60px 20px; color: #c0b0d8; font-size: 13px; letter-spacing: 1px; }
.empty-icon { font-size: 32px; margin-bottom: 12px; opacity: 0.4; }

/* Botones y paneles de administracion */
.admin-toggle { background: var(--card); border: 1px solid var(--border); border-radius: 10px; padding: 10px 18px; color: var(--muted); font-size: 13px; cursor: pointer; width: 100%; margin-bottom: 8px; font-family: 'CascadiaCode', monospace; text-align: left; }
.admin-toggle:hover { border-color: var(--accent); color: var(--accent); }

.panel { background: var(--card); border: 1px solid var(--accent); border-radius: 14px; padding: 20px; margin-bottom: 12px; display: none; }
.panel.open { display: block; }
.panel-label { font-size: 10px; letter-spacing: 3px; color: var(--accent); margin-bottom: 16px; }

/* Estilos compartidos para formularios (agregar/editar/login) */
.form-grid { display: flex; flex-direction: column; gap: 10px; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.field label { display: block; font-size: 10px; letter-spacing: 2px; color: var(--muted); margin-bottom: 5px; text-transform: uppercase; }
.inp { background: var(--bg); border: 1px solid var(--border); border-radius: 9px; color: var(--text); padding: 10px 13px; font-size: 14px; width: 100%; outline: none; font-family: 'CascadiaCode', monospace; }
.inp:focus { border-color: var(--accent); }
textarea.inp { resize: vertical; }

/* Rich text toolbar */
.toolbar { display: flex; gap: 6px; margin-bottom: 6px; flex-wrap: wrap; align-items: center; }
.tb-btn { background: var(--bg); border: 1px solid var(--border); border-radius: 6px; padding: 4px 10px; font-size: 12px; cursor: pointer; font-family: 'CascadiaCode', monospace; color: var(--text); }
.tb-btn:hover { border-color: var(--accent); color: var(--accent); }
.tb-btn.active { background: var(--accent); color: #fff; border-color: var(--accent); }
.color-dot { width: 18px; height: 18px; border-radius: 50%; border: 2px solid transparent; cursor: pointer; display: inline-block; }
.color-dot.selected { border-color: var(--text); }
.rich-area { background: var(--bg); border: 1px solid var(--border); border-radius: 9px; color: var(--text); padding: 10px 13px; font-size: 14px; width: 100%; outline: none; font-family: 'CascadiaCode', monospace; min-height: 80px; }
.rich-area:focus { border-color: var(--accent); }

/* Card color picker */
.color-picker-row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.card-color-opt { width: 28px; height: 28px; border-radius: 50%; cursor: pointer; border: 3px solid transparent; transition: border-color 0.15s; }
.card-color-opt.selected { border-color: var(--text); }

/* Botones reutilizables (primario, secundario, advertencia) */
.btn { border: none; border-radius: 9px; padding: 11px 20px; font-size: 13px; font-family: 'CascadiaCode', monospace; font-weight: 700; cursor: pointer; letter-spacing: 0.5px; }
.btn-primary { background: var(--accent); color: #fff; }
.btn-secondary { background: #e8e0f0; color: var(--muted); }
.btn-warn { background: var(--warn); color: #fff; }
.btn-row { display: flex; gap: 10px; }

/* Icon sizes y Colores Originales */
.lucide {
  width: 18px;
  height: 18px;
  stroke-width: 2px;
  display: inline-block;
  vertical-align: middle;
}
.btn .lucide {
  width: 16px;
  height: 16px;
  margin-right: 6px;
  color: inherit;
}
.icon-btn .lucide {
  width: 14px;
  height: 14px;
  transition: all 0.2s ease;
}

/* Colores específicos solicitados: */
.card-meta span:nth-child(1) .lucide { color: var(--danger); } /* Calendario Rojo */
.card-meta span:nth-child(2) .lucide { color: var(--warn); }   /* Reloj Naranja */
.ranking-btn-icon { color: #f59e0b; }                         /* Ranking Oro */
.icon-btn.users .lucide { color: #ffffff; }                    /* Personas Blanco Puro para contraste total */
.stat .lucide { color: var(--accent); }                       /* Estadísticas Morado */

.icon-btn.users {
  color: #fff !important; /* Número siempre blanco para legibilidad */
}
.icon-btn.users:hover {
  color: #fff !important; /* Evita el cambio a azul en hover */
}

.card-meta .lucide {
  width: 14px;
  height: 14px;
  opacity: 1;
}
.empty-icon .lucide {
  width: 48px;
  height: 48px;
  stroke-width: 1.5px;
  opacity: 0.5;
  color: var(--accent);
}

.ai-preview { background: var(--bg); border: 1px solid var(--border); border-radius: 9px; padding: 12px; font-size: 13px; line-height: 1.8; color: var(--text); margin-bottom: 10px; }

.edit-card { background: var(--card); border: 1px dashed var(--warn); border-radius: 14px; padding: 18px; margin-bottom: 12px; animation: fadeIn 0.2s ease; }
.edit-label { font-size: 10px; letter-spacing: 3px; color: var(--warn); margin-bottom: 14px; }

.pin-wrap { display: flex; gap: 8px; margin-bottom: 12px; }
.pin-wrap .inp { flex: 1; }

/* Danger Zone for buttons like Clear History */
.danger-zone {
  margin-top: 20px;
  padding-top: 20px;
  border-top: 1px solid var(--border);
}
.danger-zone .admin-toggle {
  background: transparent;
  border-color: transparent;
  color: var(--danger);
  font-size: 12px;
  text-align: center;
}
.danger-zone .admin-toggle:hover {
  background: #fff0f0;
  border-color: var(--danger);
}

/* Pantalla de carga inicial */
.loading { display: flex; align-items: center; justify-content: center; min-height: 100vh; flex-direction: column; gap: 12px; color: var(--accent); font-family: 'CascadiaCode', monospace; font-size: 13px; letter-spacing: 2px; }
.spinner { width: 28px; height: 28px; border: 2px solid var(--border); border-top-color: var(--accent); border-radius: 50%; animation: spin 0.8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.btn-full { width: 100%; }
.reminder-toast {
  position: fixed;
  right: 18px;
  bottom: 18px;
  width: min(360px, calc(100vw - 36px));
  background: linear-gradient(135deg, #7c4dcc 0%, #9a6be0 100%);
  color: #fff;
  border-radius: 14px;
  box-shadow: 0 10px 28px rgba(124,77,204,0.35);
  border: 1px solid rgba(255,255,255,0.25);
  z-index: 10001;
  padding: 14px 14px 12px;
  transform: translateY(20px);
  opacity: 0;
  pointer-events: none;
  transition: all 0.25s ease;
}
.reminder-toast.info { background: linear-gradient(135deg, #7c4dcc 0%, #9a6be0 100%); }
.reminder-toast.success { background: linear-gradient(135deg, #2e7d32 0%, #43a047 100%); }
.reminder-toast.error { background: linear-gradient(135deg, #b3261e 0%, #d93025 100%); }
.reminder-toast.show {
  transform: translateY(0);
  opacity: 1;
  pointer-events: auto;
}
.reminder-toast-title {
  font-size: 12px;
  letter-spacing: 1px;
  text-transform: uppercase;
  opacity: 0.9;
  margin-bottom: 4px;
}
.reminder-toast-body {
  font-size: 14px;
  line-height: 1.45;
  margin-bottom: 8px;
}
.reminder-toast-meta {
  font-size: 11px;
  opacity: 0.88;
}
.reminder-toast-close {
  position: absolute;
  top: 8px;
  right: 10px;
  background: transparent;
  border: none;
  color: #fff;
  font-size: 16px;
  cursor: pointer;
  opacity: 0.9;
}
/* Modales y Overlays */
.modal-overlay {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.5);
  z-index: 10000;
  align-items: center;
  justify-content: center;
}
#infoModal, #actionModal {
  z-index: 10001;
}
.modal-content {
  background: white;
  border-radius: 16px;
  padding: 24px;
  width: 90%;
  max-width: 400px;
  max-height: 80vh;
  overflow-y: auto;
  font-family: 'CascadiaCode', monospace;
  position: relative;
}
.modal-content.small { max-width: 360px; text-align: center; }
.modal-content.large { max-width: 520px; }

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
}
.modal-title {
  font-weight: 700;
  font-size: 16px;
  color: var(--text);
}
.modal-close {
  background: none;
  border: none;
  font-size: 20px;
  cursor: pointer;
  color: var(--muted);
}
.modal-body-text {
  font-size: 12px;
  color: var(--muted);
  line-height: 1.5;
  margin-bottom: 12px;
}

@media (max-width: 480px) { .form-row { grid-template-columns: 1fr; }
.card-actions { bottom: 100% ;}
}