/* Reset suave y baseline */
*,
*::before,
*::after {
    box-sizing: border-box;
}

/* Layout principal */
body {
    margin: 0;
    font-family: Arial, sans-serif;
    background: #f9f9f9;
    padding: 20px;
    max-width: 800px;
    margin: auto;
    color: #333;
}

h2 {
    text-align: center;
}

/* Estados de carga para botones */
.is-loading {
    pointer-events: none;
    opacity: 0.7;
    cursor: not-allowed;
}

.is-loading::after {
    content: "...";
    animation: dots 1.5s steps(5, end) infinite;
}

@keyframes dots {
    0%, 20% {
        color: rgba(0,0,0,0);
        text-shadow:
            .25em 0 0 rgba(0,0,0,0),
            .5em 0 0 rgba(0,0,0,0);
    }
    40% {
        color: inherit;
        text-shadow:
            .25em 0 0 rgba(0,0,0,0),
            .5em 0 0 rgba(0,0,0,0);
    }
    60% {
        text-shadow:
            .25em 0 0 inherit,
            .5em 0 0 rgba(0,0,0,0);
    }
    80%, 100% {
        text-shadow:
            .25em 0 0 inherit,
            .5em 0 0 inherit;
    }
}

/* Clases para selección activa - especificidad mayor sin !important */
#horariosHoy button.is-active,
#diasDisponibles button.is-active,
#horariosDisponibles button.is-active {
    background-color: #007bff;
    color: white;
}

/* Contenedor de notificaciones aria-live */
[aria-live] {
    position: fixed;
    bottom: 20px;
    right: 20px;
    max-width: 300px;
    padding: 12px 16px;
    background: #fff;
    border: 1px solid #ddd;
    border-radius: 6px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    z-index: 1000;
    font-size: 14px;
    line-height: 1.4;
}

[aria-live].success {
    border-color: #28a745;
    background-color: #d4edda;
    color: #155724;
}

[aria-live].error {
    border-color: #dc3545;
    background-color: #f8d7da;
    color: #721c24;
}

[aria-live].info {
    border-color: #17a2b8;
    background-color: #d1ecf1;
    color: #0c5460;
}

/* Focus visible accesible */
:focus-visible {
    outline: 2px solid #007bff;
    outline-offset: 2px;
}

/* Mejoras para botones existentes */
button:focus-visible {
    outline: 2px solid #007bff;
    outline-offset: 2px;
}

/* Estados hover mejorados */
button:hover:not(.is-loading) {
    transform: translateY(-1px);
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    transition: all 0.2s ease;
}

/* Formulario y controles */
label {
    display: block;
    margin-top: 15px;
    font-weight: bold;
}

/* Fieldsets para grupos de selección */
fieldset {
    border: 1px solid #ddd;
    border-radius: 6px;
    padding: 15px;
    margin: 15px 0;
    background: #fafafa;
}

legend {
    font-weight: bold;
    padding: 0 10px;
    color: #333;
    font-size: 15px;
}

input,
textarea,
button,
select {
    width: 100%;
    padding: 12px;
    margin-top: 5px;
    border: 1px solid #ccc;
    border-radius: 6px;
    font-size: 15px;
    box-sizing: border-box;
}

textarea {
    resize: vertical;
    min-height: 80px;
}

/* Botones principales */
button {
    background-color: #007bff;
    color: white;
    font-size: 16px;
    margin-top: 20px;
    border: none;
    cursor: pointer;
    transition: all 0.2s ease;
}

button:hover {
    background-color: #0056b3;
}

/* Botones de selección de horarios y días */
#horariosHoy button,
#diasDisponibles button,
#horariosDisponibles button {
    display: inline-block;
    margin: 5px;
    padding: 10px 15px;
    border: none;
    border-radius: 4px;
    background-color: #e7f0ff;
    color: #000;
    cursor: pointer;
    transition: all 0.2s ease;
    width: auto;
    font-size: 15px;
    margin-top: 5px;
}

#horariosHoy button:hover,
#diasDisponibles button:hover,
#horariosDisponibles button:hover {
    background-color: #cde1ff;
}

/* Mapa */
#mapContainer {
    display: none;
    position: relative;
    margin-top: 10px;
    border-radius: 6px;
    border: 1px solid #ccc;
    overflow: hidden;
}

#map-hint {
    position: absolute;
    background: rgba(0, 0, 0, 0.7);
    color: white;
    padding: 6px 12px;
    border-radius: 4px;
    font-size: 13px;
    top: 10px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 10;
    box-shadow: 0 2px 4px rgba(0,0,0,0.3);
}

#map {
    height: 300px;
}

/* Mensaje de feedback */
#mensaje {
    text-align: center;
    margin-top: 20px;
    font-weight: bold;
    padding: 12px;
    border-radius: 6px;
    min-height: 20px;
    transition: all 0.3s ease;
}

#mensaje:not(:empty) {
    border: 1px solid #ddd;
    background: #f8f9fa;
}

/* Estados específicos de mensaje */
#mensaje[data-type="error"] {
    color: #721c24;
    background-color: #f8d7da;
    border-color: #dc3545;
}

#mensaje[data-type="success"] {
    color: #155724;
    background-color: #d4edda;
    border-color: #28a745;
}

/* Clases utilitarias */
.oculto {
    display: none !important;
}

.is-active {
    background-color: #007bff !important;
    color: white !important;
}

.msg-error {
    color: #dc3545;
    font-weight: bold;
}

.msg-ok {
    color: #28a745;
    font-weight: bold;
}

/* Checkbox IESS inline */
#bloqueIESS { 
    display: flex; 
    align-items: center; 
    gap: 8px; 
    margin: 12px 0;
}

#bloqueIESS .iess-inline { 
    display: inline-flex; 
    align-items: center; 
    gap: 6px; 
    cursor: pointer;
}

/* Clases utilitarias para estados */
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* Mensaje final centrado */
#finalMessage {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    min-height: 100vh;
    align-items: center;
    justify-content: center;
    text-align: center;
    font-size: 1.15rem;
    padding: 16px;
    background-color: #f9f9f9;
    z-index: 1000;
}

#finalMessage.show {
    display: flex;
}

.center-message {
    display: none;
    min-height: 40vh;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 16px;
    font-size: 1.1rem;
}

.center-message.show {
    display: flex;
}

/* Imagen ilustrativa de cirugía */
.cirugia-media {
    position: static !important;
    float: none !important;
    display: block;
    width: 100%;
    max-width: 100%;
    margin: 12px 0;
    text-align: center;
}

.cirugia-media img {
    display: block;
    width: 100%;
    height: auto;
    border-radius: 12px;
}

.cirugia-media figcaption {
    margin-top: 8px;
    font-size: .95rem;
    color: #555;
}

.oculto { 
    display: none !important; 
}

/* Anula cualquier toast flotante existente */
.toast, .toast-success, .msg-success, .msg-ok, .floating-message {
    display: none !important;
    visibility: hidden !important;
    pointer-events: none !important;
}