/* --- Variables CSS --- */
:root {
    --primary-color: #007bff; /* Azul vibrante */
    --success-color: #28a745; /* Verde para confirmación/éxito */
    --warning-color: #ffc107; /* Amarillo para online/atención */
    --danger-color: #dc3545; /* Rojo para cancelación/error */
    --info-color: #17a2b8; /* Azul claro para información */
    --light-color: #f8f9fa; /* Fondo claro */
    --dark-color: #343a40; /* Texto oscuro/fondo de barra */
    --border-color: #dee2e6;
    --hover-bg: #f2f2f2;
    --zebra-pink: #ffeef2; /* Rosa muy claro para el efecto cebreado */
}

/* --- Estilos Generales y Contenedor Principal --- */
body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background-color: var(--light-color);
    margin: 0;
    padding: 0;
    color: var(--dark-color);
}

.admin-main-content {
    max-width: 98%; 
    margin: 30px auto;
    padding: 20px;
    background: #ffffff;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

/* --- Encabezado y Controles --- */
.header-controls {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    padding-bottom: 10px;
    border-bottom: 2px solid var(--border-color);
}

.admin-title {
    font-size: 2.2rem;
    color: var(--dark-color);
    font-weight: 600;
    margin: 0;
}

.admin-subtitle {
    margin-top: -10px;
    margin-bottom: 20px;
    color: #6c757d;
    font-style: italic;
}

.btn-logout {
    padding: 8px 15px;
    background-color: var(--danger-color);
    color: white;
    text-decoration: none;
    border-radius: 5px;
    font-weight: 500;
    transition: background-color 0.2s;
}

.btn-logout:hover {
    background-color: #c82333;
}

/* --- Alertas y Mensajes --- */
.alert {
    padding: 15px;
    margin-bottom: 20px;
    border: 1px solid transparent;
    border-radius: 4px;
    font-weight: 500;
}
.alert-success {
    color: #155724;
    background-color: #d4edda;
    border-color: #c3e6cb;
}
.alert-danger {
    color: #721c24;
    background-color: #f8d7da;
    border-color: #f5c6cb;
}
.alert-info {
    color: #0c5460;
    background-color: #d1ecf1;
    border-color: #bee5eb;
}

/* --- Barra de Filtros y Búsqueda --- */
.filter-bar {
    display: flex;
    flex-wrap: wrap; 
    gap: 15px;
    background: var(--light-color);
    padding: 15px;
    border-radius: 8px;
    margin-bottom: 20px;
    border: 1px solid var(--border-color);
}

.filter-group label {
    font-weight: 600;
    color: var(--dark-color);
    margin-right: 5px;
}

.filter-group select, .filter-group input[type="date"] {
    padding: 8px 10px;
    border-radius: 5px;
    border: 1px solid #ced4da;
    background-color: #fff;
    font-size: 0.95rem;
    cursor: pointer;
}

.search-container {
    position: relative;
    margin-bottom: 20px;
    width: 100%;
    max-width: 400px;
}

.search-input {
    width: 100%;
    padding: 10px 15px 10px 40px; 
    border-radius: 20px;
    border: 2px solid var(--primary-color);
    font-size: 1rem;
    transition: border-color 0.3s, box-shadow 0.3s;
}

.search-input:focus {
    outline: none;
    border-color: #0056b3;
    box-shadow: 0 0 0 0.2rem rgba(0, 123, 255, 0.25);
}

.search-icon {
    position: absolute;
    left: 15px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--primary-color);
    font-size: 1rem;
}

.btn-download-report, .btn-reset, #applyFiltersBtn {
    padding: 10px 15px;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    font-weight: 600;
    transition: background-color 0.2s;
    white-space: nowrap;
}

#applyFiltersBtn {
    background-color: var(--primary-color);
    color: white;
}
#applyFiltersBtn:hover {
    background-color: #0056b3;
}

.btn-download-report {
    background-color: var(--success-color);
    color: white;
}
.btn-download-report:hover:not([disabled]) {
    background-color: #1e7e34;
}
.btn-download-report[disabled] {
    background-color: #6c757d;
    cursor: not-allowed;
    opacity: 0.7;
}

.btn-reset {
    background-color: var(--info-color);
    color: white;
}
.btn-reset:hover {
    background-color: #117a8b;
}

/* --- Estilos de la Tabla y Cebreado (Zebra) --- */
.data-table-container {
    overflow-x: hidden; 
    width: 100%;
}

.appointments-table {
    width: 100%;
    border-collapse: separate; 
    border-spacing: 0;
    table-layout: fixed; 
}

.appointments-table th, .appointments-table td {
    padding: 10px 5px; 
    text-align: left;
    border: none;
    vertical-align: middle;
    word-wrap: break-word; 
    font-size: 0.9rem; 
}

.appointments-table thead tr {
    background-color: var(--dark-color);
    color: white;
}

.appointments-table thead th {
    font-weight: 700;
    font-size: 0.85rem; 
    text-transform: uppercase;
    letter-spacing: 0.5px;
}
.appointments-table thead tr th:first-child { border-top-left-radius: 8px; }
.appointments-table thead tr th:last-child { border-top-right-radius: 8px; }

.appointments-table tbody tr {
    border-bottom: 1px solid var(--border-color);
    transition: background-color 0.2s;
}

/* EFECTO CEBREADO (ROSA CLARO) */
.appointments-table tbody tr:nth-child(odd) {
    background-color: var(--zebra-pink); 
}
.appointments-table tbody tr:nth-child(even) {
    background-color: #ffffff; 
}

.appointments-table tbody tr:hover {
    background-color: var(--hover-bg) !important; 
}

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

/* ANCHOS DE COLUMNAS REBALANCEADOS */
.folio-col { width: 6%; } 
.appointments-table td[data-label="Cliente"] { 
    width: 20%; 
    font-weight: 600; 
}
.type-col { width: 7%; } 
.datetime-col { width: 10%; } 
.appointments-table td[data-label="Localidad"] { width: 9%; } 
.monto-col { width: 8%; }
.payment-status-col { width: 9%; } 
.status-col { width: 9%; }
.whatsapp-col { width: 10%; } 
.actions-col { width: 12%; text-align: center; } 


/* --- Tipos y Estados (Badges) --- */
.type-badge {
    display: inline-block;
    padding: 3px 5px; 
    border-radius: 4px;
    font-size: 0.7rem; 
    font-weight: 700;
    text-transform: uppercase;
    white-space: nowrap; 
}

.type-online {
    background-color: var(--warning-color);
    color: var(--dark-color);
}

.type-presencial {
    background-color: var(--info-color);
    color: white;
}

.status-badge {
    display: inline-block;
    padding: 4px 6px; 
    border-radius: 20px; 
    font-size: 0.7rem; 
    font-weight: 600;
    text-align: center;
    min-width: 65px; 
    white-space: nowrap;
}
.status-pago-pagado {
    background-color: var(--dark-color);
    color: white;
}
.status-confirmada {
    background-color: var(--success-color);
    color: white;
}

.status-atendida {
    background-color: #4CAF50; 
    color: white;
}

.status-cancelada {
    background-color: var(--danger-color);
    color: white;
}

/* --- Detalles de Celda --- */
.text-secondary-email {
    color: #6c757d;
    font-size: 0.7rem; 
    display: block;
    margin-top: 2px;
}

.datetime-col small {
    display: block;
    color: #6c757d;
    font-weight: normal;
    font-size: 0.75rem; 
}

/* --- Botones de Acción (HORIZONTALES) --- */

.actions-col {
    white-space: nowrap; 
    display: flex; 
    justify-content: center; 
    align-items: center; 
    gap: 3px; 
    flex-wrap: nowrap; /* Evita que los botones se envuelvan */
    min-width: 90px; 
}

.actions-col button, .actions-col form button { 
    border: none;
    padding: 5px; 
    border-radius: 4px; 
    cursor: pointer;
    font-size: 0.8rem; 
    transition: background-color 0.2s, opacity 0.2s;
    width: 28px; 
    height: 28px; 
    display: inline-flex;
    justify-content: center;
    align-items: center;
    flex-shrink: 0; 
}

.btn-whatsapp {
    background-color: #25d366; 
    color: white;
    padding: 4px 6px; 
    border-radius: 4px; 
    font-size: 0.75rem; 
    width: auto;
    height: auto;
    font-weight: 500;
    text-decoration: none;
    flex-shrink: 0; 
}
.btn-whatsapp:hover {
    background-color: #128c7e;
}

.btn-view-narrativa { background-color: var(--info-color); color: white; }
.btn-view-narrativa:hover { background-color: #117a8b; }

.btn-atendida { background-color: var(--success-color); color: white; }
.btn-atendida:hover { background-color: #1e7e34; }

.btn-cancelar { background-color: var(--danger-color); color: white; }
.btn-cancelar:hover { background-color: #c82333; }

.btn-info-cancel { background-color: #ffc107; color: var(--dark-color); }
.btn-info-cancel:hover { background-color: #e0a800; }

.actions-col .text-muted {
    font-size: 0.75rem; 
    white-space: normal;
    display: block;
    margin-top: 5px;
    line-height: 1.2;
}

/* --- Paginación --- */
.pagination {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 20px;
    padding-top: 10px;
    border-top: 1px solid var(--border-color);
}

.data-count {
    color: #6c757d;
}

.pagination-controls {
    display: flex;
    gap: 5px;
}

.btn-page {
    padding: 8px 12px;
    border: 1px solid var(--primary-color);
    border-radius: 5px;
    text-decoration: none;
    color: var(--primary-color);
    background-color: white;
    transition: background-color 0.2s, color 0.2s;
    font-size: 0.9rem;
    font-weight: 500;
}

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

.btn-page.active {
    background-color: var(--primary-color);
    color: white;
    font-weight: 700;
    cursor: default;
}

/* --- Modales --- */
.modal {
    display: none; 
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    overflow: auto;
    background-color: rgba(0,0,0,0.6); 
}

.modal-content {
    background-color: #fefefe;
    margin: 10% auto; 
    padding: 30px;
    border: 1px solid #888;
    width: 90%; 
    max-width: 500px;
    border-radius: 10px;
    box-shadow: 0 5px 15px rgba(0,0,0,0.3);
    position: relative;
}

.modal-content h2 {
    color: var(--primary-color);
    border-bottom: 2px solid var(--border-color);
    padding-bottom: 10px;
    margin-top: 0;
}

.close-btn {
    color: #aaa;
    float: right;
    font-size: 28px;
    font-weight: bold;
    transition: color 0.2s;
}

.close-btn:hover,
.close-btn:focus {
    color: var(--danger-color);
    text-decoration: none;
    cursor: pointer;
}

.form-group label {
    display: block;
    margin-bottom: 5px;
    font-weight: 600;
}

.form-group textarea {
    width: 100%;
    padding: 10px;
    border: 1px solid #ced4da;
    border-radius: 5px;
    resize: vertical;
    box-sizing: border-box;
}

.btn-submit-cancel {
    background-color: var(--danger-color);
    color: white;
    padding: 10px 15px;
    border: none;
    border-radius: 5px;
    margin-top: 15px;
    width: 100%;
    font-weight: 600;
    cursor: pointer;
    transition: background-color 0.2s;
}

.btn-submit-cancel:hover {
    background-color: #c82333;
}

.info-modal {
    max-width: 600px; 
}
.info-section {
    padding: 10px;
    background: var(--light-color);
    border-radius: 5px;
    border: 1px solid var(--border-color);
}
.folio-highlight {
    font-weight: bold;
    color: var(--primary-color);
}
.cancellation-reason, .narrative-text {
    white-space: pre-wrap; 
    font-style: italic;
    color: var(--dark-color);
    background-color: #fff;
    padding: 10px;
    border-radius: 5px;
    border: 1px solid #dee2e6;
}
.btn-detail-close {
    background-color: var(--info-color);
    color: white;
    padding: 8px 15px;
    border: none;
    border-radius: 5px;
    margin-top: 15px;
    font-weight: 600;
    cursor: pointer;
    float: right;
}
.btn-detail-close:hover {
    background-color: #117a8b;
}

/* --- Media Queries (Responsividad) --- */
@media screen and (max-width: 768px) {
    .filter-bar {
        flex-direction: column;
        align-items: stretch;
    }
    
    .filter-group {
        width: 100%;
    }
    .filter-group select, .filter-group input[type="date"] {
        width: 100%;
    }

    .header-controls {
        flex-direction: column;
        align-items: flex-start;
    }
    
    .btn-logout {
        margin-top: 10px;
        width: 100%;
        text-align: center;
    }

    .data-table-container {
        overflow-x: auto; 
    }
    .appointments-table {
        min-width: 750px; 
    }

    .actions-col {
        /* Permite que los botones se apilen verticalmente en pantallas muy pequeñas */
        flex-direction: column; 
        gap: 5px;
        align-items: center;
        flex-wrap: wrap; 
    }
}