/* ================= GLOBAL ================= */
* {
  box-sizing: border-box;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  margin: 0;
  background: linear-gradient(135deg, #ff7e00, #ffae42);
  color: #222;
  -webkit-font-smoothing: antialiased; 
  font-size: 14px;
}

/* Control de Versiones */
.version-tag {
    font-size: 0.85em;
    color: #666;
    margin-bottom: 20px;
    background: #f0f0f0;
    display: inline-block;
    padding: 2px 10px;
    border-radius: 12px;
    font-weight: 500;
}
#app-version {
    color: #ff7e00;
    font-weight: bold;
}

/* ================= LOGIN BOX ================= */
.centered-container {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100vh;
  padding: 20px;
}

.login-box {
  width: 100%;
  max-width: 400px;
  background: #fff;
  padding: 30px;
  border-radius: 14px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
  text-align: center;
}

.login-box h2 {
  color: #ff7e00;
  margin-bottom: 8px;
}

.login-box input {
  width: 100%;
  padding: 12px;
  margin: 8px 0;
  border-radius: 8px;
  border: 1px solid #eee;
  font-size: 16px;
}

.login-box button {
  width: 100%;
  margin-top: 15px;
}

.error-msg {
  color: #f44336;
  font-size: 14px;
  margin-top: 10px;
}

/* Contenedor para Input Password + Ojo */
.password-container {
    position: relative;
    width: 100%;
}
.password-container input {
    padding-right: 40px; /* Espacio para el ojo */
}
.toggle-eye {
    position: absolute;
    right: 15px;
    top: 50%;
    transform: translateY(-50%);
    cursor: pointer;
    font-size: 18px;
    color: #ff7e00;
    z-index: 2;
    font-style: normal;
}

/* ================= DASHBOARD LAYOUT ================= */
.dashboard { 
    max-width: 1200px; 
    margin: 20px auto; 
    background: #f4f7f6; 
    border-radius: 12px; 
    box-shadow: 0 5px 20px rgba(0,0,0,0.15); 
    overflow: hidden; 
    min-height: 90vh; 
    display: flex; 
    flex-direction: column; 
    padding: 20px;
}

.header {
  background: #fff; 
  padding: 15px 25px; 
  border-radius: 10px;
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1); 
  margin-bottom: 20px;
  display: flex; 
  justify-content: space-between; 
  align-items: center; 
  flex-wrap: wrap; 
  gap: 10px;
}

.header-controls { 
  display: flex; 
  align-items: center; 
  gap: 15px; 
  flex-wrap: wrap; 
}

/* PERFIL DE USUARIO */
.user-profile-display { 
  display: flex; 
  align-items: center; 
  gap: 10px; 
  font-weight: bold; 
  color: #555; 
}

.profile-avatar { 
  width: 40px; 
  height: 40px; 
  border-radius: 50%; 
  object-fit: cover; 
  border: 2px solid #ff7e00; 
  background-color: #eee; 
}

.profile-avatar-large { 
  width: 100px; 
  height: 100px; 
  border-radius: 50%; 
  object-fit: cover; 
  border: 3px solid #ff7e00; 
  margin: 0 auto 15px auto; 
  display: block; 
  background-color: #eee; 
}

.content { flex: 1; }

.content h2 { 
  color: #333; 
  border-bottom: 2px solid #eee; 
  padding-bottom: 5px; 
  margin-bottom: 20px; 
}

/* ================= BOTONES ================= */
button { 
  cursor: pointer; 
  transition: background 0.2s; 
  font-family: inherit; 
}

.primary-btn {
  background: #ff7e00; 
  color: white; 
  border: none; 
  padding: 12px 20px;
  border-radius: 8px; 
  font-weight: bold; 
  font-size: 14px;
}
.primary-btn:hover { background: #e06c00; }
.primary-btn:disabled { background: #ccc; cursor: not-allowed; }

.secondary-btn {
  background: #f5f5f5; 
  color: #333; 
  border: 1px solid #ddd;
  padding: 10px 15px; 
  border-radius: 8px; 
  font-weight: 600; 
  font-size: 13px;
}
.secondary-btn:hover { background: #e0e0e0; }

.small-btn { 
  padding: 6px 12px; 
  font-size: 12px; 
  margin-left: 5px; 
  display: inline-block; 
}

.delete-btn { 
  background: #ffebee; 
  color: #c62828; 
  border-color: #ffcdd2; 
}
.delete-btn:hover { background: #ffcdd2; }

.whatsapp-btn {
    background-color: #25D366; 
    color: white; 
    padding: 4px 8px;
    border: none; 
    border-radius: 4px; 
    cursor: pointer; 
    font-size: 12px; 
    text-decoration: none; 
    display: inline-block;
}
.whatsapp-btn:hover { background-color: #128C7E; }

/* ================= ESTADÍSTICAS ================= */
.stats-grid {
  display: grid; 
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); 
  gap: 20px; 
  margin-bottom: 30px;
}

.stat-card {
  background: #fff; 
  padding: 20px; 
  border-radius: 10px;
  box-shadow: 0 4px 6px rgba(0, 0, 0, 0.05); 
  font-size: 16px; 
  color: #666; 
  text-align: center;
  border-bottom: 4px solid #ff7e00;
}

.clickable-stat { 
  cursor: pointer; 
  transition: transform 0.2s, box-shadow 0.2s; 
}
.clickable-stat:hover { 
  transform: translateY(-3px); 
  box-shadow: 0 4px 10px rgba(255, 126, 0, 0.2); 
  background: #fff3e0; 
  color: #e65100; 
}

.stat-card span { 
  display: block; 
  font-size: 32px; 
  font-weight: bold; 
  color: #ff7e00; 
  margin-top: 5px; 
}

/* ================= ACCIONES ================= */
.action-grid { 
  display: flex; 
  gap: 15px; 
  flex-wrap: wrap; 
  margin-bottom: 30px; 
}

/* ================= MODALES ================= */
.modal {
  display: none; 
  position: fixed; 
  z-index: 2000; /* Alto z-index para estar sobre el mapa */
  left: 0; 
  top: 0;
  width: 100%; 
  height: 100%; 
  overflow: auto; 
  background-color: rgba(0, 0, 0, 0.6);
  justify-content: center; 
  align-items: center; 
  backdrop-filter: blur(2px);
}

.modal-content {
  background: #fff; 
  padding: 30px; 
  border-radius: 10px; 
  width: 90%; 
  max-width: 600px;
  max-height: 90vh; 
  overflow-y: auto; 
  position: relative; 
  box-shadow: 0 10px 25px rgba(0,0,0,0.3);
}

.modal-content-large { max-width: 1200px; }

.close { 
  position: absolute; 
  top: 15px; 
  right: 20px; 
  font-size: 28px; 
  cursor: pointer; 
  color: #aaa; 
  font-weight: bold;
}
.close:hover { color: #ff7e00; }

/* ================= FORMULARIOS ================= */
form label { 
  display: block; 
  margin-top: 10px; 
  font-weight: bold; 
  font-size: 14px; 
  color: #444; 
}

form input, form select, form textarea {
  width: 100%; 
  padding: 10px; 
  margin-top: 5px; 
  margin-bottom: 10px;
  border-radius: 6px; 
  border: 1px solid #ddd; 
  font-size: 16px;
}

form textarea { resize: vertical; }

.full-width-select { width: 100%; }

.small { font-size: 13px; color: #666; margin-top: 2px; }

/* Form Grid Layout */
.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 15px;
  margin-bottom: 10px;
}
.form-field {
  display: flex;
  flex-direction: column;
}
.form-field label {
  margin-bottom: 5px;
}

/* FIRMA & MAPA */
.signature-canvas { 
  border: 2px dashed #ccc; 
  border-radius: 8px; 
  touch-action: none; 
  background: #fafafa; 
  width: 100%; 
  cursor: crosshair;
}

#map, #mapContainer { 
  width: 100%; 
  height: 400px; 
  border-radius: 8px; 
  border: 1px solid #ccc; 
  margin-top: 10px; 
  z-index: 1; /* Bajo z-index */
}

/* ================= TABLAS ================= */
.report-table { 
  width: 100%; 
  border-collapse: collapse; 
  margin-top: 12px; 
  font-size: 13px; 
}

.report-table th, .report-table td { 
  border: 1px solid #eee; 
  padding: 10px; 
  text-align: left; 
}

.report-table th { 
  background: #ff7e00; 
  color: #fff; 
  font-weight: bold; 
  position: sticky; 
  top: 0; 
}

.report-table tr:hover { background: #fff8e1; }

/* =========================================
   ESTILO DE TARJETAS DE SELECCIÓN (NUEVO)
   ========================================= */

/* El contenedor (la rejilla) */
.options-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); 
    gap: 15px;
    margin-top: 15px;
    margin-bottom: 20px;
}

/* La tarjeta individual (Label) */
.option-card {
    position: relative;
    cursor: pointer;
    user-select: none;
}

/* Ocultar el cuadrito checkbox original */
.option-card input[type="checkbox"] {
    position: absolute;
    opacity: 0;
    cursor: pointer;
    height: 0;
    width: 0;
}

/* El diseño visual de la tarjeta (El Span) */
.option-card span {
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    height: 100%;
    min-height: 80px;
    padding: 10px;
    background-color: #fff;
    border: 2px solid #ddd;
    border-radius: 12px;
    color: #555;
    font-weight: 500;
    font-size: 13px;
    transition: all 0.2s cubic-bezier(0.25, 0.8, 0.25, 1);
    box-shadow: 0 2px 5px rgba(0,0,0,0.05);
}

/* Efecto al pasar el mouse (Hover) */
.option-card:hover span {
    border-color: #ffcc80;
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0,0,0,0.1);
}

/* ESTADO SELECCIONADO */
.option-card input[type="checkbox"]:checked + span {
    background-color: #ff7e00;
    color: white;
    border-color: #e65100;
    font-weight: bold;
    box-shadow: 0 4px 10px rgba(255, 126, 0, 0.4);
    transform: scale(1.02);
}

/* Invitaciones y filtros */
.invitation-options-grid,
.cause-filters-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 8px;
    background: #f9f9f9;
    padding: 10px;
    border-radius: 6px;
    margin-bottom: 15px;
}

/* ================= CALENDARIO ================= */
.calendar-grid { 
  display: grid; 
  grid-template-columns: repeat(7, 1fr); 
  gap: 1px; 
  background-color: #ddd; 
  border: 1px solid #ddd; 
  margin-top: 15px; 
}

.calendar-day { 
  min-height: 100px; 
  background-color: #fff; 
  padding: 8px; 
  font-size: 12px; 
  position: relative; 
  cursor: pointer; 
}

.calendar-day.other-month { background-color: #f9f9f9; color: #aaa; cursor: default; }

.calendar-day .day-number { font-weight: bold; color: #333; }

.calendar-event {
    background-color: #fff3e0; 
    border-left: 3px solid #ff7e00; 
    padding: 4px; 
    margin-top: 4px; 
    border-radius: 4px; 
    font-size: 11px; 
    cursor: pointer;
    overflow: hidden; 
    white-space: nowrap; 
    text-overflow: ellipsis;
}
.calendar-event:hover { background-color: #ffe0b2; }

.calendar-event img { width: 100%; height: 30px; object-fit: cover; border-radius: 3px; }

/* ================= WIDGET DE METAS 2027 (Gamification) ================= */
.goal-container {
    background: white; 
    padding: 20px; 
    border-radius: 12px;
    box-shadow: 0 4px 15px rgba(255, 126, 0, 0.15); 
    margin-bottom: 25px; 
    border-left: 5px solid #ff7e00;
}

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

.goal-title { font-size: 18px; font-weight: bold; color: #333; margin: 0; }

.goal-badge { 
    background-color: #ff7e00; 
    color: white; 
    padding: 4px 10px; 
    border-radius: 20px; 
    font-size: 12px; 
    font-weight: bold; 
}

.progress-track { 
    width: 100%; 
    height: 25px; 
    background-color: #e0e0e0; 
    border-radius: 15px; 
    overflow: hidden; 
    box-shadow: inset 0 2px 5px rgba(0,0,0,0.1); 
    position: relative; 
}

.progress-fill { 
    height: 100%; 
    width: 0%; 
    background: linear-gradient(90deg, #ffae42, #ff7e00); 
    border-radius: 15px 0 0 15px; 
    transition: width 1.5s cubic-bezier(0.4, 0, 0.2, 1); 
    display: flex; 
    align-items: center; 
    justify-content: flex-end; 
    padding-right: 10px; 
}

.progress-text-inside { 
    color: white; 
    font-size: 11px; 
    font-weight: bold; 
    text-shadow: 0 1px 2px rgba(0,0,0,0.3); 
    white-space: nowrap; 
}

.goal-stats { 
    display: flex; 
    justify-content: space-between; 
    margin-top: 8px; 
    font-size: 13px; 
    color: #666; 
}

.stat-highlight { color: #333; font-weight: bold; font-size: 15px; }

/* =========================================
   === ESTILOS DE LA CREDENCIAL PREMIUM ===
   ========================================= */
.credencial-box {
    width: 600px; height: 380px; 
    background: #fff;
    position: relative;
    overflow: hidden;
    font-family: 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
    border: 1px solid #ddd;
    display: flex; flex-direction: column;
}

/* Fondo decorativo */
.credencial-bg {
    position: absolute; top: 0; left: 0; width: 100%; height: 10px;
    background: linear-gradient(90deg, #ff7e00, #ffae42);
}
.credencial-watermark {
    position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%);
    width: 400px; height: 400px;
    background-image: url('img/mc.jpeg'); 
    background-size: contain; background-repeat: no-repeat; background-position: center;
    opacity: 0.05; z-index: 0;
}

/* Encabezado */
.credencial-header {
    display: flex; align-items: center; padding: 25px 30px 10px 30px; z-index: 1;
}
.logo-mc-cred { height: 50px; margin-right: 15px; }
.header-text h2 { margin: 0; color: #ff7e00; font-size: 24px; font-weight: 900; letter-spacing: 1px; }
.header-text h3 { margin: 0; color: #555; font-size: 14px; font-weight: 600; letter-spacing: 3px; text-transform: uppercase; }

/* Cuerpo */
.credencial-body {
    display: flex; padding: 10px 30px; z-index: 1; flex: 1; align-items: center;
}
.photo-area {
    width: 130px; height: 130px; margin-right: 25px;
    border-radius: 50%; border: 5px solid #ff7e00;
    overflow: hidden; box-shadow: 0 5px 15px rgba(255, 126, 0, 0.2);
    background: #eee; flex-shrink: 0;
}
.photo-area img { width: 100%; height: 100%; object-fit: cover; }

.info-area { flex: 1; }
.info-area h1 {
    margin: 0; color: #333; font-size: 22px; font-weight: 800; text-transform: uppercase;
    line-height: 1.1; margin-bottom: 5px;
}
.label { font-size: 9px; color: #999; font-weight: 700; text-transform: uppercase; margin: 0; letter-spacing: 0.5px;}
.info-area h4 {
    margin: 0; background: #ff7e00; color: white; display: inline-block;
    padding: 2px 10px; border-radius: 4px; font-size: 12px; text-transform: uppercase;
    margin-bottom: 10px;
}

.grid-info { display: flex; gap: 20px; margin-bottom: 8px; }
.grid-info span { font-weight: 600; font-size: 14px; color: #444; }

.circle-name-box { 
    margin-top: 5px; padding: 5px 10px; background: #f4f4f4; border-radius: 4px; border-left: 4px solid #666; 
}
.circle-name-box strong { color: #ff7e00; font-size: 15px; }

/* Footer */
.credencial-footer {
    background: #f9f9f9; padding: 10px 30px;
    display: flex; align-items: center; justify-content: space-between;
    border-top: 1px solid #eee; z-index: 1;
}
.qr-box { width: 60px; height: 60px; }
.qr-box img { width: 100%; height: 100%; }

.footer-text { text-align: left; margin-left: 15px; flex: 1; }
.footer-text p { margin: 0; font-weight: bold; color: #333; font-size: 14px; }
.footer-text .small-id { font-size: 10px; color: #999; font-family: monospace; }

.logo-circulos-cred { height: 35px; opacity: 0.8; }

/* =========================================
   === RESPONSIVE DESIGN (MÓVIL) ===
   ========================================= */
@media (max-width: 768px) {
    /* Ajuste general */
    .dashboard { margin: 0; border-radius: 0; box-shadow: none; min-height: 100vh; padding: 15px; }
    
    /* Header vertical */
    .header { flex-direction: column; align-items: flex-start; gap: 15px; padding: 15px; }
    .header h1 { font-size: 20px; }
    .header-controls { width: 100%; justify-content: space-between; }
    .user-profile-display { font-size: 12px; }
    
    /* Stats en columnas de 2 */
    .stats-grid { grid-template-columns: repeat(2, 1fr); gap: 10px; }
    .stat-card { padding: 15px; font-size: 14px; }
    .stat-card span { font-size: 24px; }
    
    /* Botones full width */
    .action-grid { flex-direction: column; }
    .action-grid button { width: 100%; padding: 15px; font-size: 16px; }

    /* Tablas con Scroll Horizontal */
    .modal-content-large { padding: 15px; width: 95%; }
    #circleListContainer, #userListContainer, #memberListTbody, #reporteEstadosContent, #reporteCircunscripcionesContent {
        overflow-x: auto; display: block; white-space: nowrap;
    }
    .report-table { min-width: 600px; } 
}

@media (max-width: 480px) {
    /* Stats una por una en celular */
    .stats-grid { grid-template-columns: 1fr; }
    
    .modal-content { width: 95%; padding: 20px; margin: 10px auto; }
    
    /* Ajuste firma */
    .signature-canvas { height: 150px; }
    
    /* Login */
    .login-box { width: 90%; padding: 20px; }
    
    /* Meta widget */
    .goal-header { flex-direction: column; align-items: flex-start; gap: 5px; }
    .goal-badge { align-self: flex-start; }
}