* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --primary: #2563eb;
    --secondary: #64748b;
    --success: #10b981;
    --danger: #ef4444;
    --warning: #f59e0b;
    --light: #f8fafc;
    --dark: #1e293b;
    --border: #e2e8f0;
    --guard-color-Normal: #3b82f6;
    --guard-color-Refuerzo_planta: #ef4444;
    --guard-color-Lab: #f59e0b;
    --guard-color-Festivo: #ec4899;
    --guard-color-Nocturna: #6366f1;
    --guard-color-Refuerzo: #10b981;
    --guard-font-size: 11px;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    background: var(--light);
    color: var(--dark);
    line-height: 1.6;
}

.container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 20px;
}

header {
    background: white;
    padding: 30px;
    border-radius: 10px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
    margin-bottom: 30px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

h1 {
    font-size: 28px;
    color: var(--dark);
}

.header-actions {
    display: flex;
    gap: 10px;
}

.btn {
    padding: 10px 20px;
    border: none;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s;
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 8px rgba(0,0,0,0.15);
}

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

.btn-primary:hover {
    background: #1d4ed8;
}

.btn-secondary {
    background: var(--secondary);
    color: white;
}

.btn-secondary:hover {
    background: #475569;
}

.btn-success {
    background: var(--success);
    color: white;
}

.btn-success:hover {
    background: #059669;
}

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

.btn-danger:hover {
    background: #dc2626;
}

.btn-sm {
    padding: 6px 12px;
    font-size: 12px;
}

.section {
    background: white;
    padding: 30px;
    border-radius: 10px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
    margin-bottom: 30px;
}

.hidden {
    display: none !important;
}

/* Import Section */
.upload-area {
    margin: 20px 0;
}

.drop-zone {
    border: 2px dashed var(--border);
    border-radius: 10px;
    padding: 60px;
    text-align: center;
    cursor: pointer;
    transition: all 0.3s;
}

.drop-zone:hover, .drop-zone.dragover {
    border-color: var(--primary);
    background: #eff6ff;
}

.drop-zone p {
    margin: 10px 0;
}

.text-small {
    font-size: 14px;
    color: var(--secondary);
}

/* Filters */
.filters {
    background: white;
    padding: 20px;
    border-radius: 10px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
    margin-bottom: 20px;
    display: flex;
    gap: 15px;
    align-items: end;
    flex-wrap: wrap;
}

.filter-group {
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.filter-group label {
    font-size: 14px;
    font-weight: 500;
    color: var(--dark);
}

.filter-group input, .filter-group select {
    padding: 8px 12px;
    border: 1px solid var(--border);
    border-radius: 6px;
    font-size: 14px;
}

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

.stat-card {
    background: white;
    padding: 25px;
    border-radius: 10px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
    text-align: center;
}

.stat-value {
    font-size: 36px;
    font-weight: 700;
    color: var(--primary);
    margin-bottom: 5px;
}

.stat-label {
    font-size: 14px;
    color: var(--secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* Table */
.table-container {
    background: white;
    border-radius: 10px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
    overflow: hidden;
}

table {
    width: 100%;
    border-collapse: collapse;
}

thead {
    background: var(--light);
}

th {
    padding: 15px;
    text-align: left;
    font-weight: 600;
    color: var(--dark);
    font-size: 14px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

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

tbody tr:hover {
    background: var(--light);
}

td {
    padding: 15px;
    font-size: 14px;
}

.text-center {
    text-align: center;
}

.loading {
    padding: 40px;
    text-align: center;
    color: var(--secondary);
}

.action-buttons {
    display: flex;
    gap: 8px;
}

/* Modal */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.modal-content {
    background: white;
    border-radius: 10px;
    width: 90%;
    max-width: 600px;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 20px 25px -5px rgba(0,0,0,0.1);
}

.modal-large {
    max-width: 900px;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 30px;
    border-bottom: 1px solid var(--border);
}

.modal-header h2 {
    font-size: 24px;
}

.close-btn {
    background: none;
    border: none;
    font-size: 28px;
    cursor: pointer;
    color: var(--secondary);
    transition: color 0.2s;
}

.close-btn:hover {
    color: var(--dark);
}

.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    margin-bottom: 8px;
    font-weight: 500;
    color: var(--dark);
}

.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: 6px;
    font-size: 14px;
    font-family: inherit;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(37,99,235,0.1);
}

form {
    padding: 30px;
}

.modal-actions {
    display: flex;
    gap: 10px;
    justify-content: flex-end;
    margin-top: 30px;
}

.actions {
    margin-top: 20px;
    display: flex;
    gap: 10px;
    justify-content: flex-end;
}

/* Historial */
#historialContent {
    padding: 30px;
}

.historial-item {
    padding: 20px;
    border-left: 4px solid var(--primary);
    background: var(--light);
    margin-bottom: 15px;
    border-radius: 6px;
}

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

.historial-accion {
    font-weight: 600;
    color: var(--dark);
}

.historial-fecha {
    font-size: 12px;
    color: var(--secondary);
}

.historial-detalles {
    font-size: 14px;
    color: var(--secondary);
    line-height: 1.8;
}

.badge {
    display: inline-block;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 12px;
    font-weight: 600;
}

.badge-crear {
    background: #dcfce7;
    color: #166534;
}

.badge-actualizar {
    background: #dbeafe;
    color: #1e40af;
}

.badge-eliminar {
    background: #fee2e2;
    color: #991b1b;
}

/* Badges de tipo de guardia */
.badge-normal {
    background: #dbeafe;
    color: #1e40af;
}

.badge-refuerzo-planta {
    background: #fee2e2;
    color: #991b1b;
}

.badge-lab {
    background: #fef3c7;
    color: #92400e;
}

.badge-festivo {
    background: #fce7f3;
    color: #831843;
}

.badge-nocturna {
    background: #e0e7ff;
    color: #3730a3;
}

.badge-refuerzo {
    background: #dcfce7;
    color: #166534;
}

/* Responsive */
@media (max-width: 768px) {
    header {
        flex-direction: column;
        gap: 20px;
    }

    .header-actions {
        width: 100%;
        flex-direction: column;
    }

    .filters {
        flex-direction: column;
        align-items: stretch;
    }

    .table-container {
        overflow-x: auto;
    }

    .modal-content {
        width: 95%;
        margin: 10px;
    }
}

/* Animaciones */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.fade-in {
    animation: fadeIn 0.3s ease-out;
}

/* View Toggle */
.view-toggle {
    display: flex;
    gap: 10px;
    margin-bottom: 20px;
    background: white;
    padding: 15px;
    border-radius: 10px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

.btn-toggle {
    flex: 1;
    padding: 12px 20px;
    border: 2px solid var(--border);
    background: white;
    color: var(--secondary);
    border-radius: 6px;
    cursor: pointer;
    font-weight: 600;
    transition: all 0.3s;
}

.btn-toggle:hover {
    border-color: var(--primary);
    color: var(--primary);
}

.btn-toggle.active {
    background: var(--primary);
    border-color: var(--primary);
    color: white;
}

/* Calendar Styles */
.calendar-section {
    background: white;
    padding: 30px;
    border-radius: 10px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
    margin-bottom: 30px;
}

.calendar-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 30px;
    padding-bottom: 20px;
    border-bottom: 2px solid var(--border);
}

.month-selector {
    font-size: 18px;
    color: var(--dark);
    margin: 0;
    flex: 1;
    text-align: center;
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 8px 12px;
    background: white;
    cursor: pointer;
}

.calendar-container {
    overflow-x: auto;
}

.calendar-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 0;
    border: 1px solid var(--border);
    border-radius: 8px;
    overflow: hidden;
}

.weekday-header {
    background: var(--primary);
    color: white;
    padding: 15px;
    font-weight: 600;
    text-align: center;
    font-size: 14px;
}

.calendar-days {
    display: contents;
}

.calendar-day {
    border: 1px solid var(--border);
    min-height: 140px;
    padding: 10px;
    background: white;
    overflow-y: auto;
    position: relative;
    cursor: pointer;
    transition: background 0.2s;
}

.calendar-day:hover {
    background: #f8fafc;
}

.calendar-day.other-month {
    background: #f8fafc;
    color: var(--secondary);
}

.calendar-day.today {
    background: #eff6ff;
    border-left: 4px solid var(--primary);
}

.calendar-day-number {
    font-weight: 600;
    font-size: 16px;
    margin-bottom: 8px;
    color: var(--dark);
}

.calendar-day.other-month .calendar-day-number {
    color: var(--secondary);
}

.calendar-day.today .calendar-day-number {
    color: var(--primary);
}

.calendar-guards {
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.calendar-guard-item {
    background: var(--guard-color-Normal);
    color: white;
    padding: 6px 8px;
    border-radius: 4px;
    font-size: var(--guard-font-size);
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    cursor: pointer;
    transition: all 0.2s;
}

.calendar-guard-item:hover {
    opacity: 0.8;
    transform: scale(1.02);
}

.calendar-guard-item.Normal {
    background: var(--guard-color-Normal);
}

.calendar-guard-item.Refuerzo_planta {
    background: var(--guard-color-Refuerzo_planta);
}

.calendar-guard-item.Lab {
    background: var(--guard-color-Lab);
}

.calendar-guard-item.Festivo {
    background: var(--guard-color-Festivo);
}

.calendar-guard-item.Nocturna {
    background: var(--guard-color-Nocturna);
}

.calendar-guard-item.Refuerzo {
    background: var(--guard-color-Refuerzo);
}

.calendar-day-empty {
    font-size: 12px;
    color: var(--secondary);
    font-style: italic;
    margin-top: 20px;
    text-align: center;
}

/* Responsive Calendar */
@media (max-width: 1200px) {
    .calendar-day {
        min-height: 120px;
        padding: 8px;
    }

    .calendar-day-number {
        font-size: 14px;
    }

    .calendar-guard-item {
        font-size: 10px;
        padding: 4px 6px;
    }
}

@media (max-width: 768px) {
    .calendar-grid {
        grid-template-columns: repeat(7, 1fr);
        gap: 1px;
    }

    .calendar-day {
        min-height: 80px;
        padding: 6px;
    }

    .weekday-header {
        padding: 10px 5px;
        font-size: 11px;
    }

    .calendar-day-number {
        font-size: 12px;
        margin-bottom: 4px;
    }

    .calendar-guard-item {
        font-size: 9px;
        padding: 3px 4px;
    }

    .view-toggle {
        gap: 5px;
        padding: 10px;
    }

    .btn-toggle {
        padding: 8px 10px;
        font-size: 12px;
    }
}

/* Estilos para vista de 3 meses */
.multi-month-container {
    display: flex;
    flex-direction: column;
    gap: 30px;
}

.month-section {
    border: 1px solid var(--border);
    border-radius: 8px;
    overflow: hidden;
    background: white;
}

.month-title {
    background: var(--primary);
    color: white;
    padding: 15px;
    margin: 0;
    font-size: 18px;
    font-weight: 600;
    text-align: center;
}

/* === Día Festivo === */
.calendar-day.festivo {
    background: #fff7ed;
    border-left: 4px solid #f97316;
}

.calendar-day.festivo .calendar-day-number {
    color: #ea580c;
}

.festivo-badge {
    background: linear-gradient(135deg, #fed7aa, #fdba74);
    color: #9a3412;
    font-size: 9px;
    font-weight: 700;
    padding: 2px 6px;
    border-radius: 3px;
    text-align: center;
    margin-bottom: 4px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* === Modal Opciones === */
.opciones-body {
    padding: 30px;
}

.opciones-seccion {
    margin-bottom: 30px;
    padding-bottom: 20px;
    border-bottom: 1px solid var(--border);
}

.opciones-seccion:last-of-type {
    border-bottom: none;
}

.opciones-seccion h3 {
    font-size: 16px;
    margin-bottom: 15px;
    color: var(--dark);
}

.opciones-colores {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 12px;
}

.color-row {
    display: flex;
    align-items: center;
    gap: 10px;
}

.color-row label {
    font-weight: 600;
    min-width: 75px;
    font-size: 14px;
}

.color-row input[type="color"] {
    width: 40px;
    height: 32px;
    border: 1px solid var(--border);
    border-radius: 6px;
    cursor: pointer;
    padding: 2px;
}

.color-preview {
    display: inline-block;
    padding: 4px 12px;
    border-radius: 4px;
    color: white;
    font-size: 12px;
    font-weight: 600;
}

.font-size-row {
    display: flex;
    align-items: center;
    gap: 15px;
    flex-wrap: wrap;
}

.font-size-row input[type="range"] {
    flex: 1;
    min-width: 150px;
}

#fontSizeLabel {
    font-weight: 700;
    font-size: 16px;
    min-width: 40px;
}

.font-preview {
    background: var(--primary);
    color: white;
    padding: 6px 12px;
    border-radius: 4px;
    font-weight: 600;
}

.festivos-form {
    display: flex;
    gap: 10px;
    margin-bottom: 15px;
    flex-wrap: wrap;
    align-items: center;
}

.festivos-form input[type="date"],
.festivos-form input[type="text"] {
    padding: 8px 12px;
    border: 1px solid var(--border);
    border-radius: 6px;
    font-size: 14px;
}

.festivos-form input[type="text"] {
    flex: 1;
    min-width: 180px;
}

.festivos-list {
    max-height: 250px;
    overflow-y: auto;
    border: 1px solid var(--border);
    border-radius: 8px;
}

.festivo-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 15px;
    border-bottom: 1px solid var(--border);
    background: #fffbeb;
}

.festivo-item:last-child {
    border-bottom: none;
}

.festivo-fecha {
    font-weight: 600;
    color: #ea580c;
    min-width: 90px;
}

.festivo-nombre {
    flex: 1;
    color: var(--dark);
}

.opciones-actions {
    display: flex;
    gap: 10px;
    justify-content: flex-end;
    margin-top: 20px;
}

@media (max-width: 768px) {
    .opciones-colores {
        grid-template-columns: 1fr;
    }
    .festivos-form {
        flex-direction: column;
        align-items: stretch;
    }
}

/* === Vista Estadísticas === */
.stats-section {
    background: white;
    padding: 30px;
    border-radius: 10px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
    margin-bottom: 30px;
}

.stats-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 25px;
    padding-bottom: 15px;
    border-bottom: 2px solid var(--border);
    flex-wrap: wrap;
    gap: 12px;
}

.stats-header h2 {
    font-size: 22px;
    color: var(--dark);
    margin: 0;
}

.stats-filter {
    display: flex;
    align-items: center;
    gap: 8px;
}

.stats-filter label {
    font-weight: 600;
    font-size: 14px;
    color: var(--dark);
}

.stats-filter select {
    padding: 8px 12px;
    border: 1px solid var(--border);
    border-radius: 6px;
    font-size: 14px;
    min-width: 180px;
    background: white;
}

.stats-medico-card {
    background: var(--light);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 20px;
    margin-bottom: 20px;
    transition: box-shadow 0.2s;
}

.stats-medico-card:hover {
    box-shadow: 0 4px 12px rgba(0,0,0,0.08);
}

.stats-medico-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
}

.stats-medico-header h3 {
    font-size: 18px;
    color: var(--dark);
    margin: 0;
}

.stats-total-badge {
    background: var(--primary);
    color: white;
    padding: 5px 14px;
    border-radius: 20px;
    font-size: 13px;
    font-weight: 700;
}

.stats-tabla-wrap {
    margin-bottom: 15px;
}

.stats-tabla-wrap:last-of-type {
    margin-bottom: 0;
}

.stats-tabla-wrap h4 {
    font-size: 14px;
    color: var(--secondary);
    margin: 0 0 8px 0;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.stats-tabla {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
    background: white;
    border-radius: 6px;
    overflow: hidden;
}

.stats-tabla th {
    background: var(--dark);
    color: white;
    padding: 10px 8px;
    text-align: center;
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

.stats-tabla th:first-child {
    text-align: left;
    padding-left: 12px;
}

.stats-tabla td {
    padding: 10px 8px;
    text-align: center;
    border-bottom: 1px solid var(--border);
}

.stats-tabla td:first-child {
    text-align: left;
    padding-left: 12px;
}

.stats-tabla tbody tr:last-child td {
    border-bottom: none;
}

.stats-tabla tbody tr:hover {
    background: #f1f5f9;
}

.stats-cell-filled {
    background: #eff6ff;
    font-weight: 600;
    color: var(--primary);
}

.stats-cell-total {
    background: #f0fdf4;
    color: #166534;
}

.stats-tipo-badge {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 4px;
    color: white;
    font-size: 11px;
    font-weight: 700;
}

@media (max-width: 768px) {
    .stats-medico-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 8px;
    }

    .stats-tabla-wrap {
        overflow-x: auto;
    }

    .stats-tabla {
        min-width: 500px;
    }
}
