* {
    box-sizing: border-box;
}

body.admin-mode {
    margin: 0;
    padding: 0;
    font-family: 'Lato', sans-serif;
    color: #444;
    background-color: #f4f6f9;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

/* LAYOUT GENERAL */
.admin-layout {
    display: flex;
    flex: 1;
    overflow: hidden;
}

/* MAIN CONTENT */
.admin-main-content {
    position: relative;
    /* Ancla el spinner de carga del módulo (module_loading_overlay.css). */
    flex: 1;
    min-width: 0;
    /* CRÍTICO: Permite que el contenido se encoja en flexbox */
    padding: 30px;
    overflow-y: auto;
    background-color: #fdf6d6;
    transition: all 0.3s ease;
}

@media (max-width: 900px) {
    .admin-main-content {
        padding: 15px 10px;
        width: 100%;
        overflow-x: hidden;
    }
}

.no-transition {
    transition: none !important;
}

/* CARDS / CONTENIDO */
.admin-card {
    background: white;
    border-radius: 8px;
    padding: 25px;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.05);
    max-width: 100%;
}

@media (max-width: 600px) {
    .admin-card {
        padding: 15px;
    }
}

.admin-card-title {
    color: #3185cb;
    font-family: 'Lobster Two', cursive;
    font-size: 32px;
    font-weight: 700;
    margin-top: 0;
}

.admin-card-header {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    border-bottom: 2px solid #fee6b4;
    padding-bottom: 10px;
    margin-bottom: 25px;
    gap: 15px;
}

.admin-summary-inline {
    font-size: 14px;
    color: #666;
    font-family: 'Lato', sans-serif;
    white-space: nowrap;
}

@media (max-width: 768px) {
    .admin-card-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 10px;
    }
}

/* Modulo En Construcción */
.admin-construction-card {
    padding: 60px 20px;
    text-align: center;
    border: 3px dashed #fee6b4;
    border-radius: 12px;
    background: #fdfdfd;
    color: #a2825c;
    margin-top: 20px;
}

.admin-construction-card i {
    color: #ffdb5e;
    margin-bottom: 15px;
    display: block;
}

.admin-construction-card h2 {
    font-size: 32px;
    color: #3185cb;
    margin-bottom: 15px;
}

/* DASHBOARD STATS */
.admin-card-title + p[style] {
    margin-top: 0 !important;
    margin-bottom: 18px !important;
}

.dashboard-stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 20px;
    margin-bottom: 20px;
}

.stat-card {
    background: white;
    border-radius: 12px;
    padding: 20px;
    display: flex;
    align-items: center;
    gap: 15px;
    border: 1px solid #eee;
    transition: all 0.3s ease;
    text-decoration: none;
    /* Quitar subrayado */
    color: inherit;
    /* Heredar color de texto */
}

/* Fondos claros y bordes con contraste propio para cada módulo. */
.stat-card.blue {
    background: #f4f9fe;
    border-color: #9fc9e8;
}

.stat-card.green {
    background: #f4fbf5;
    border-color: #a8d7ad;
}

.stat-card.yellow {
    background: #fffdf1;
    border-color: #e8cf67;
}

.stat-card.purple {
    background: #fbf5fc;
    border-color: #d4a8dc;
}

.stat-card.orange {
    background: #fff8ef;
    border-color: #edbd7c;
}

.stat-card.red {
    background: #fff5f5;
    border-color: #e2a3a3;
}

.stat-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 10px 20px rgba(0, 0, 0, 0.05);
    border-color: #3185cb;
}

.stat-icon {
    width: 60px;
    height: 60px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
}

.stat-info h3 {
    margin: 0;
    font-size: 28px;
    color: #333;
    display: flex;
    align-items: baseline;
    gap: 5px;
}

.stat-info h3 small {
    font-size: 14px;
    color: #888;
    font-weight: normal;
}

.stat-info p {
    margin: 3px 0 8px 0;
    font-size: 13px;
    color: #666;
    font-weight: bold;
}

/* BARRAS DE PROGRESO */
.stat-progress-bar {
    width: 100%;
    height: 6px;
    background: #eee;
    border-radius: 10px;
    overflow: hidden;
    margin-top: 5px;
}

.stat-progress-fill {
    height: 100%;
    background: #3185cb;
    /* Color por defecto */
    border-radius: 10px;
    transition: width 0.5s ease-out;
}

/* Sincronización de colores con las cartas */
.stat-card.blue .stat-progress-fill {
    background: #2196f3;
}

.stat-card.green .stat-progress-fill {
    background: #4caf50;
}

.stat-card.yellow .stat-progress-fill {
    background: #fbc02d;
}

.stat-card.purple .stat-progress-fill {
    background: #9c27b0;
}

.stat-card.orange .stat-progress-fill {
    background: #ff9800;
}

.stat-card.red .stat-progress-fill {
    background: #f44336;
}

/* Colores de cartas */
.stat-card.blue .stat-icon {
    background: #e3f2fd;
    color: #2196f3;
}

.stat-card.green .stat-icon {
    background: #e8f5e9;
    color: #4caf50;
}

.stat-card.yellow .stat-icon {
    background: #fff9c4;
    color: #fbc02d;
}

.stat-card.purple .stat-icon {
    background: #f3e5f5;
    color: #9c27b0;
}

.stat-card.orange .stat-icon {
    background: #fff3e0;
    color: #ff9800;
}

.stat-card.red .stat-icon {
    background: #ffebee;
    color: #f44336;
}

/* TIMELINE */
.section-subtitle {
    font-family: 'Lato', sans-serif;
    font-size: 18px;
    color: #3185cb;
    border-bottom: 1px solid #fee6b4;
    padding-bottom: 10px;
    margin-bottom: 20px;
}

.activity-timeline {
    position: relative;
    padding-left: 30px;
}

.activity-timeline::before {
    content: '';
    position: absolute;
    left: 10px;
    top: 5px;
    bottom: 5px;
    width: 2px;
    background: #fee6b4;
}

.timeline-item {
    position: relative;
    margin-bottom: 25px;
}

.timeline-point {
    position: absolute;
    left: -25px;
    top: 5px;
    width: 12px;
    height: 12px;
    background: #3185cb;
    border-radius: 50%;
    border: 3px solid white;
    box-shadow: 0 0 0 2px #fee6b4;
}

.timeline-content {
    background: #fdfdfd;
    padding: 15px;
    border-radius: 8px;
    border: 1px solid #eee;
}

.timeline-header {
    display: flex;
    justify-content: space-between;
    margin-bottom: 5px;
    font-size: 14px;
}

.timeline-time {
    font-size: 12px;
    color: #999;
}

.timeline-content p {
    margin: 0;
    font-size: 13px;
    color: #666;
}

.timeline-content span {
    color: #3185cb;
    font-weight: bold;
}

.empty-logs {
    text-align: center;
    padding: 30px;
    color: #999;
}

.empty-logs i {
    font-size: 40px;
    margin-bottom: 10px;
}

/* QUICK ACTIONS GRID */
.quick-actions-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 15px;
}

.quick-btn {
    background: #fdfdfd;
    border: 1px solid #eee;
    padding: 20px;
    border-radius: 12px;
    text-decoration: none;
    color: #3185cb;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    transition: all 0.3s ease;
    text-align: center;
}

.quick-btn i {
    font-size: 28px;
}

.quick-btn span {
    font-size: 14px;
    font-weight: bold;
    font-family: 'Lato', sans-serif;
}

.quick-btn:hover {
    background: #3185cb;
    color: white;
    transform: translateY(-3px);
    box-shadow: 0 5px 15px rgba(49, 133, 203, 0.2);
    border-color: #3185cb;
}

.quick-btn.site-preview {
    background: #FFDB5E;
    color: #A2825C;
    border-color: #fee6b4;
}

.quick-btn.site-preview:hover {
    background: #fee6b4;
    color: #A2825C;
    box-shadow: 0 5px 15px rgba(255, 219, 94, 0.2);
}
/* =========================================================
   TARJETA AMPLIA DEL DASHBOARD (Próximas Actividades)
   Ocupa el doble de ancho para mostrar total vs. visibles.
   Móvil primero: en pantallas chicas ocupa una sola celda.
   ========================================================= */
.stat-card-wide {
    grid-column: auto;
}

@media (min-width: 701px) {
    .stat-card-wide {
        grid-column: span 2;
    }
}

.stat-card-wide .stat-info {
    flex: 1;
    min-width: 0;
}

/* Cifra principal: visibles vs total */
.stat-info h3 .stat-sep {
    color: #ccc;
    font-weight: normal;
    margin: 0 2px;
}

.stat-info h3 .stat-total {
    font-size: 20px;
    color: #888;
}

/* Fila de datos adicionales de la tarjeta amplia */
.stat-detail-row {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 10px;
}

.stat-chip {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    background: #f5f7fa;
    border: 1px solid #e9e9e9;
    border-radius: 20px;
    padding: 3px 10px;
    font-family: 'Lato', sans-serif;
    font-size: 11.5px;
    color: #666;
    white-space: nowrap;
}

.stat-chip i {
    font-size: 11px;
}

.stat-chip.chip-visible {
    background: #e8f5e9;
    border-color: #c8e6c9;
    color: #2e7d32;
}

.stat-chip.chip-oculto {
    background: #fff3e0;
    border-color: #ffe0b2;
    color: #b26a00;
}

.stat-chip.chip-limite {
    background: #e3f2fd;
    border-color: #bbdefb;
    color: #2b75b2;
}

/* Aviso cuando el módulo tiene contenido pero no se ve en el sitio */
.stat-alert {
    display: flex;
    align-items: center;
    gap: 7px;
    margin: 10px 0 0 0 !important;
    background: #ffebee;
    border-left: 3px solid #e05735;
    border-radius: 6px;
    padding: 7px 10px;
    font-size: 12px !important;
    color: #c0392b !important;
    font-weight: bold;
    line-height: 1.4;
}

.stat-alert i {
    font-size: 14px;
    flex-shrink: 0;
}

.stat-alert.stat-alert-ok {
    background: #e8f5e9;
    border-left-color: #4caf50;
    color: #2e7d32 !important;
}

.stat-alert.stat-alert-warn {
    background: #fff3e0;
    border-left-color: #ff9800;
    color: #b26a00 !important;
}

@media (max-width: 480px) {
    .stat-card-wide {
        flex-direction: column;
        align-items: flex-start;
    }

    .stat-detail-row {
        gap: 5px;
    }

    .stat-chip {
        font-size: 11px;
        padding: 3px 8px;
    }
}

/* Renglón 1: cifra a la izquierda, chip de fecha pasada pegado a la derecha */
/* Dashboard en celular: tarjetas compactas en dos columnas.
   Cada tarjeta conserva la lectura visual: icono, contador, nombre y barra. */
@media (max-width: 700px) {
    .dashboard-stats-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 12px;
    }

    .stat-card,
    .stat-card-wide {
        min-width: 0;
        grid-column: auto;
        display: grid;
        grid-template-columns: 52px minmax(0, 1fr);
        grid-template-rows: auto auto auto;
        align-items: stretch;
        row-gap: 3px;
        column-gap: 10px;
        padding: 14px 12px;
        border-radius: 10px;
    }

    .stat-icon {
        grid-column: 1;
        grid-row: 1;
        align-self: center;
        width: 52px;
        height: 52px;
        border-radius: 11px;
        font-size: 21px;
    }

    .stat-info,
    .stat-card-wide .stat-info {
        display: contents;
        width: 100%;
        min-width: 0;
        text-align: center;
    }

    .stat-info h3 {
        grid-column: 2;
        grid-row: 1;
        align-self: center;
        justify-content: flex-start;
        flex-wrap: wrap;
        gap: 3px;
        min-width: 0;
        margin: 0;
        font-size: 24px;
        line-height: 1.05;
        text-align: left;
    }

    .stat-info h3 small {
        font-size: 12px;
    }

    .stat-info p {
        grid-column: 1 / -1;
        grid-row: 2;
        margin: 3px 0 1px;
        font-size: 12px;
        line-height: 1.25;
        text-align: left;
    }

    .stat-progress-bar {
        grid-column: 1 / -1;
        grid-row: 3;
        height: 6px;
        margin-top: 0;
    }

    .stat-title-row {
        grid-column: 1 / -1;
        grid-row: 2;
        justify-content: center;
    }

    .stat-title-row p,
    .stat-title-row .stat-chip {
        margin-left: 0;
    }

    .stat-chip {
        max-width: 100%;
        white-space: normal;
        justify-content: center;
        line-height: 1.25;
    }

    .stat-alert {
        grid-column: 1 / -1;
        grid-row: 4;
        text-align: left;
    }

    /* En celular, la tarjeta de Próximas conserva solo el resumen esencial. */
    .stat-card-wide .stat-alert,
    .stat-card-wide .stat-chip.chip-inline,
    .stat-card-wide .stat-chip.chip-limite {
        display: none;
    }
}

@media (max-width: 360px) {
    .dashboard-stats-grid {
        gap: 9px;
    }

    .stat-card,
    .stat-card-wide {
        grid-template-columns: 46px minmax(0, 1fr);
        padding: 12px 9px;
    }

    .stat-icon {
        width: 46px;
        height: 46px;
        font-size: 19px;
    }

    .stat-info h3 {
        font-size: 21px;
    }

    .stat-info h3 small {
        font-size: 11px;
    }

    .stat-info p {
        font-size: 11px;
    }
}

/* En dispositivos móviles, todos los select del admin usan el control nativo
   del sistema operativo (Android/iOS), sin flechas dibujadas por CSS. */
@media (max-width: 768px) {
    body.admin-mode select {
        appearance: auto !important;
        -webkit-appearance: menulist-button !important;
        background-image: none !important;
    }
}

.stat-info h3 {
    flex-wrap: wrap;
}

.stat-chip.chip-inline {
    align-self: center;
    margin-left: auto;
    font-weight: normal;
}

/* Renglón 2: nombre del módulo a la izquierda, límite alineado a la derecha
   (queda justo debajo del chip de fecha pasada). */
.stat-title-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 8px 12px;
    margin-top: 4px;
}

.stat-title-row p {
    margin: 0 !important;
}

.stat-title-row .stat-chip {
    margin-left: auto;
}

@media (max-width: 480px) {
    .stat-chip.chip-inline,
    .stat-title-row .stat-chip {
        margin-left: 0;
    }
}
