/* ========================================================================== */
/* CALENDARIO ENTREGAS PAGE - Administración De Calendario                    */
/* ========================================================================== */

/* Eliminar padding del main-content para esta página */
.main-content:has(.calentregas-page) {
    padding: 0 !important;
}

.calentregas-page {
    display: flex;
    flex-direction: column;
    height: calc(100vh - 95px);
    width: 100%;
    padding: 0;
    overflow: hidden;
    background: var(--bg-primary);
}

/* Ajuste del camara-panel para que ocupe todo el espacio */
.calentregas-page .camara-panel {
    margin: 0;
    padding: 0.75rem;
    box-sizing: border-box;
    display: flex;
    flex-direction: column;
    flex: 1;
    min-height: 0;
    overflow: hidden;
}

/* Ajuste del camara-header */
.calentregas-page .camara-header {
    margin: 0 0 0.5rem 0;
    padding: 0.25rem 0.5rem;
    flex-shrink: 0;
}

/* Override de camara-body para ocupar todo el espacio */
.calentregas-page .camara-body {
    display: flex;
    align-items: stretch;
    justify-content: stretch;
    gap: 0;
    overflow: hidden;
    padding: 0.5rem;
    flex: 1;
    min-height: 0;
}

/* ========================================================================== */
/* CONTENEDOR DE CARDS - Horizontal centrado                                   */
/* ========================================================================== */

.calentregas-cards-container {
    display: flex;
    flex-direction: row;
    gap: 0.75rem;
    width: 100%;
    height: 100%;
    align-items: stretch;
}

/* ========================================================================== */
/* CARD GENERAL                                                                */
/* ========================================================================== */

.calentregas-card {
    display: flex;
    flex-direction: column;
    background: var(--bg-secondary);
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
    border: 1px solid var(--border-color);
    min-height: 0;
    transition: box-shadow 0.3s ease, border-color 0.3s ease;
}

/* Modo claro - fondo gris para el card */
:root.light-mode .calentregas-card,
.light-mode .calentregas-card {
    background: #e8e8e8;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
}

/* Card Principal (Datos) - 60% del ancho */
.calentregas-card.datos-card {
    flex: 0 0 60%;
    min-width: 0;
}

/* Card Detalle (Explicación) - 40% del ancho, siempre visible */
.calentregas-card.detalle-card {
    flex: 0 0 calc(40% - 0.75rem);
    min-width: 0;
    display: flex;
}

.calentregas-card.detalle-card.visible {
    display: flex;
}

/* Card Header con gradiente */
.calentregas-card-header {
    background: linear-gradient(135deg, #F07400, #00b4ff);
    padding: 0.65rem 1rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    flex-shrink: 0;
    min-height: 44px;
    box-sizing: border-box;
}

.calentregas-card-header h3 {
    color: white;
    margin: 0;
    font-size: 0.95rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.calentregas-card-header h3 svg {
    width: 18px;
    height: 18px;
}

.calentregas-card-header .anio-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    padding: 0.25rem 0.6rem;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 12px;
    font-size: 0.8rem;
    font-weight: 700;
    color: white;
}

/* Botones en header */
.calentregas-header-actions {
    display: flex;
    gap: 0.5rem;
}

.btn-calendario {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.45rem 0.85rem;
    border-radius: 8px;
    border: 1px solid rgba(255, 255, 255, 0.3);
    background: rgba(255, 255, 255, 0.15);
    color: white;
    font-size: 0.78rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    backdrop-filter: blur(4px);
}

.btn-calendario:hover:not(:disabled) {
    background: rgba(255, 255, 255, 0.3);
    border-color: rgba(255, 255, 255, 0.5);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

.btn-calendario:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.btn-calendario svg {
    width: 14px;
    height: 14px;
}

.btn-calendario.primary {
    background: linear-gradient(135deg, #F07400, #00b4ff);
    color: white;
    border-color: transparent;
    font-weight: 600;
}

.btn-calendario.primary:hover:not(:disabled) {
    background: linear-gradient(135deg, #ff8c1a, #1ac3ff);
    box-shadow: 0 4px 16px rgba(240, 116, 0, 0.4);
}

/* Card Body */
.calentregas-card-body {
    display: flex;
    flex-direction: column;
    flex: 1;
    padding: 0.75rem;
    gap: 0.5rem;
    overflow: hidden;
    min-height: 0;
}

/* ========================================================================== */
/* TABLA DE CALENDARIO                                                         */
/* ========================================================================== */

.calendario-table-container {
    flex: 1;
    overflow: auto;
    border-radius: 10px;
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
}

:root.light-mode .calendario-table-container,
.light-mode .calendario-table-container {
    background: #ffffff;
}

.calendario-table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    font-size: 0.78rem;
}

.calendario-table thead {
    position: sticky;
    top: 0;
    z-index: 10;
}

.calendario-table thead tr {
    background: linear-gradient(135deg, #1a1a2e 0%, #16213e 50%, #0f3460 100%);
}

:root.light-mode .calendario-table thead tr,
.light-mode .calendario-table thead tr {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}

.calendario-table th {
    padding: 0.6rem 0.5rem;
    text-align: center;
    font-weight: 600;
    color: #ffffff;
    text-transform: uppercase;
    font-size: 0.68rem;
    letter-spacing: 0.5px;
    border-bottom: 2px solid rgba(240, 116, 0, 0.5);
    white-space: nowrap;
}

.calendario-table th:first-child {
    border-radius: 8px 0 0 0;
}

.calendario-table th:last-child {
    border-radius: 0 8px 0 0;
}

.calendario-table tbody tr {
    transition: all 0.15s ease;
}

.calendario-table tbody tr:nth-child(even) {
    background: var(--bg-primary);
}

.calendario-table tbody tr:nth-child(odd) {
    background: rgba(240, 116, 0, 0.03);
}

:root.light-mode .calendario-table tbody tr:nth-child(even),
.light-mode .calendario-table tbody tr:nth-child(even) {
    background: #ffffff;
}

:root.light-mode .calendario-table tbody tr:nth-child(odd),
.light-mode .calendario-table tbody tr:nth-child(odd) {
    background: rgba(102, 126, 234, 0.05);
}

.calendario-table tbody tr:hover {
    background: linear-gradient(90deg, rgba(240, 116, 0, 0.08), rgba(0, 180, 255, 0.08));
}

.calendario-table td {
    padding: 0.45rem 0.5rem;
    border-bottom: 1px solid var(--border-color);
    color: var(--text-primary);
    text-align: center;
    white-space: nowrap;
}

.calendario-table tbody tr:last-child td {
    border-bottom: none;
}

/* Celdas específicas */
.calendario-table td.mes-cell {
    text-align: left;
    font-weight: 500;
}

.calendario-table td.fecha-cell {
    font-family: 'Consolas', 'Monaco', monospace;
    font-size: 0.75rem;
}

/* ========================================================================== */
/* BADGES DE ESTATUS                                                           */
/* ========================================================================== */

.estatus-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    padding: 0.2rem 0.55rem;
    border-radius: 12px;
    font-size: 0.68rem;
    font-weight: 600;
    white-space: nowrap;
}

.estatus-badge .dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
}

/* Populado - Verde brillante */
.estatus-badge.populado {
    background: linear-gradient(135deg, rgba(34, 197, 94, 0.2), rgba(22, 163, 74, 0.1));
    color: #22c55e;
    border: 1px solid rgba(34, 197, 94, 0.4);
}

.estatus-badge.populado .dot {
    background: #22c55e;
    box-shadow: 0 0 6px rgba(34, 197, 94, 0.6);
}

/* Pendiente - Naranja */
.estatus-badge.pendiente {
    background: linear-gradient(135deg, rgba(240, 116, 0, 0.2), rgba(249, 115, 22, 0.1));
    color: #f97316;
    border: 1px solid rgba(249, 115, 22, 0.4);
}

.estatus-badge.pendiente .dot {
    background: #f97316;
}

/* ========================================================================== */
/* CARD DE DETALLE (Explicación)                                               */
/* ========================================================================== */

.detalle-list {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    overflow-y: auto;
    flex: 1;
    padding-right: 0.25rem;
}

.detalle-item {
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 0.6rem 0.75rem;
    transition: all 0.2s ease;
}

:root.light-mode .detalle-item,
.light-mode .detalle-item {
    background: #ffffff;
}

.detalle-item:hover {
    border-color: var(--primary-color);
    box-shadow: 0 2px 8px rgba(240, 116, 0, 0.1);
}

.detalle-item.tiene-festivo {
    border-left: 3px solid #eab308;
}

.detalle-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 0.35rem;
}

.detalle-quincena {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    font-weight: 600;
    font-size: 0.8rem;
    color: var(--text-primary);
}

.detalle-quincena svg {
    width: 14px;
    height: 14px;
    stroke: var(--primary-color);
}

.detalle-fecha-entrega {
    font-size: 0.75rem;
    font-weight: 600;
    color: #22c55e;
    display: flex;
    align-items: center;
    gap: 0.3rem;
}

.detalle-fecha-entrega svg {
    width: 12px;
    height: 12px;
}

.detalle-calculo {
    font-size: 0.72rem;
    color: var(--text-secondary);
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
}

.detalle-calculo .calculo-row {
    display: flex;
    align-items: center;
    gap: 0.35rem;
}

.detalle-calculo .calculo-row svg {
    width: 10px;
    height: 10px;
    flex-shrink: 0;
}

.detalle-calculo .calculo-row.festivo {
    color: #eab308;
}

.detalle-calculo .calculo-row.festivo svg {
    stroke: #eab308;
}

.detalle-dias {
    display: inline-flex;
    flex-wrap: wrap;
    gap: 0.2rem;
    margin-top: 0.25rem;
}

.detalle-dias .dia-chip {
    display: inline-block;
    padding: 0.1rem 0.35rem;
    background: linear-gradient(135deg, rgba(240, 116, 0, 0.1), rgba(0, 180, 255, 0.1));
    border-radius: 4px;
    font-size: 0.68rem;
    color: var(--text-primary);
}

/* ========================================================================== */
/* ESTADO VACÍO Y LOADING                                                      */
/* ========================================================================== */

.calendario-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    flex: 1;
    color: var(--text-secondary);
    gap: 0.75rem;
    padding: 2rem;
}

.calendario-empty svg {
    width: 48px;
    height: 48px;
    opacity: 0.4;
}

.calendario-loading {
    display: flex;
    align-items: center;
    justify-content: center;
    flex: 1;
}

.calendario-spinner {
    width: 40px;
    height: 40px;
    border: 3px solid var(--border-color);
    border-top: 3px solid var(--primary-color);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* ========================================================================== */
/* RESUMEN EN HEADER DEL DETALLE                                               */
/* ========================================================================== */

.detalle-resumen {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.5rem 0.75rem;
    background: var(--bg-primary);
    border-radius: 8px;
    margin-bottom: 0.5rem;
    flex-shrink: 0;
}

:root.light-mode .detalle-resumen,
.light-mode .detalle-resumen {
    background: #f0f0f0;
}

.detalle-resumen-item {
    display: flex;
    align-items: center;
    gap: 0.3rem;
    font-size: 0.75rem;
    color: var(--text-secondary);
}

.detalle-resumen-item strong {
    color: var(--primary-color);
    font-weight: 700;
}

.detalle-resumen-item svg {
    width: 14px;
    height: 14px;
    stroke: var(--primary-color);
}

/* ========================================================================== */
/* MENSAJE DE ÉXITO                                                            */
/* ========================================================================== */

.mensaje-exito {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.65rem 1rem;
    background: linear-gradient(135deg, rgba(34, 197, 94, 0.15), rgba(22, 163, 74, 0.1));
    border: 1px solid rgba(34, 197, 94, 0.4);
    border-radius: 8px;
    color: #22c55e;
    font-size: 0.85rem;
    font-weight: 500;
    margin-bottom: 0.5rem;
    flex-shrink: 0;
    animation: slideDown 0.3s ease-out;
}

.mensaje-exito svg {
    width: 18px;
    height: 18px;
    flex-shrink: 0;
}

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

/* ========================================================================== */
/* RESPONSIVE                                                                  */
/* ========================================================================== */

@media (max-width: 1400px) {
    .calentregas-cards-container {
        gap: 0.65rem;
    }
}

@media (max-width: 1200px) {
    .calentregas-cards-container {
        gap: 0.5rem;
    }

    .calentregas-card.datos-card {
        flex: 0 0 58%;
    }

    .calentregas-card.detalle-card {
        flex: 0 0 calc(42% - 0.5rem);
    }

    .calendario-table {
        font-size: 0.75rem;
    }

    .calendario-table th,
    .calendario-table td {
        padding: 0.4rem 0.35rem;
    }
}

@media (max-width: 1024px) {
    .calentregas-page .camara-body {
        align-items: stretch;
        justify-content: stretch;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
    }

    .calentregas-cards-container {
        flex-direction: column;
        height: auto;
        width: 100%;
        padding-bottom: 1rem;
    }

    .calentregas-card.datos-card {
        flex: 0 0 auto;
        width: 100%;
        min-height: auto;
        max-height: 500px;
    }

    .calentregas-card.detalle-card {
        flex: 0 0 auto;
        width: 100%;
        max-height: 400px;
    }

    .calendario-table-container {
        max-height: 380px;
        overflow-y: auto;
    }
}

@media (max-width: 768px) {
    .calentregas-page {
        height: calc(100vh - 95px);
        min-height: calc(100vh - 95px);
        max-height: calc(100vh - 95px);
        overflow: hidden;
    }

    .calentregas-page .camara-panel {
        padding: 0.5rem;
        display: flex;
        flex-direction: column;
        height: 100%;
        overflow: hidden;
    }

    .calentregas-page .camara-header {
        flex-shrink: 0;
    }

    .calentregas-page .camara-body {
        flex: 1;
        overflow-y: auto !important;
        overflow-x: hidden;
        -webkit-overflow-scrolling: touch;
        min-height: 0;
        padding: 0.5rem;
        align-items: flex-start;
        justify-content: flex-start;
    }

    .calentregas-cards-container {
        width: 100%;
        gap: 0.75rem;
        flex-direction: column;
        height: auto;
    }

    .calentregas-card.datos-card {
        max-height: none;
        min-height: auto;
        flex: 0 0 auto;
    }

    .calentregas-card.detalle-card {
        max-height: none;
        min-height: auto;
        flex: 0 0 auto;
    }

    .calendario-table-container {
        max-height: none;
        overflow: visible;
    }

    .calentregas-card-header {
        flex-direction: column;
        gap: 0.5rem;
        padding: 0.5rem 0.75rem;
    }

    .calentregas-card-header h3 {
        font-size: 0.85rem;
        flex-wrap: wrap;
        justify-content: center;
    }

    .calentregas-header-actions {
        width: 100%;
        justify-content: center;
    }

    .btn-calendario {
        flex: 1;
        justify-content: center;
        padding: 0.45rem 0.6rem;
        font-size: 0.75rem;
    }

    .calendario-table {
        font-size: 0.72rem;
    }

    .calendario-table th {
        font-size: 0.62rem;
        padding: 0.4rem 0.3rem;
    }

    .calendario-table td {
        padding: 0.38rem 0.3rem;
    }

    .estatus-badge {
        font-size: 0.62rem;
        padding: 0.15rem 0.4rem;
    }

    .detalle-list {
        max-height: 350px;
    }

    .detalle-resumen {
        flex-wrap: wrap;
        gap: 0.5rem;
    }
}

@media (max-width: 480px) {
    .calentregas-page .camara-panel {
        padding: 0.35rem;
    }

    .calentregas-card-header h3 {
        font-size: 0.8rem;
    }

    .calentregas-card-header h3 span:first-of-type {
        display: none;
    }

    .calentregas-card-body {
        padding: 0.5rem;
    }

    .calendario-table {
        font-size: 0.65rem;
    }

    .calendario-table th {
        font-size: 0.58rem;
        padding: 0.35rem 0.2rem;
    }

    .calendario-table td {
        padding: 0.32rem 0.2rem;
    }

    .calendario-table td.fecha-cell {
        font-size: 0.62rem;
    }

    /* Ocultar columna Ciclo en móvil pequeño */
    .calendario-table .hide-mobile {
        display: none;
    }

    .estatus-badge {
        font-size: 0.58rem;
        padding: 0.12rem 0.35rem;
        gap: 0.2rem;
    }

    .estatus-badge .dot {
        width: 5px;
        height: 5px;
    }

    .btn-calendario {
        padding: 0.4rem 0.5rem;
        font-size: 0.7rem;
    }

    .btn-calendario svg {
        width: 12px;
        height: 12px;
    }

    .detalle-item {
        padding: 0.5rem 0.6rem;
    }

    .detalle-quincena {
        font-size: 0.72rem;
    }

    .detalle-fecha-entrega {
        font-size: 0.68rem;
    }

    .detalle-calculo {
        font-size: 0.65rem;
    }

    .detalle-dias .dia-chip {
        font-size: 0.6rem;
        padding: 0.08rem 0.25rem;
    }

    .mensaje-exito {
        font-size: 0.75rem;
        padding: 0.5rem 0.75rem;
    }

    .mensaje-exito svg {
        width: 16px;
        height: 16px;
    }
}
