/**
 * CUSTOM STYLES - Control Horario
 * Fichero único que reemplaza style.css y todos los <style> inline de los EJS.
 * Complementa Bootstrap 5.
 */

/* ============================================================================
   VARIABLES CSS
   ============================================================================ */

:root {
    /* Colores (alineados con Bootstrap) */
    --primary-color: #0d6efd;
    --secondary-color: #6c757d;
    --success-color: #198754;
    --danger-color: #dc3545;
    --warning-color: #ffc107;
    --info-color: #0dcaf0;
    --light-color: #f8f9fa;
    --dark-color: #212529;

    /* Alias Bootstrap para custom-styles */
    --ch-primary: #0d6efd;
    --ch-secondary: #6c757d;
    --ch-success: #198754;
    --ch-danger: #dc3545;
    --ch-warning: #ffc107;
    --ch-info: #0dcaf0;

    /* Gradientes de estaciones */
    --ch-spring-gradient: linear-gradient(135deg, #a8edea 0%, #fed6e3 100%);
    --ch-summer-gradient: linear-gradient(135deg, #ffecd2 0%, #fcb69f 100%);
    --ch-autumn-gradient: linear-gradient(135deg, #ff9a56 0%, #ff6a88 100%);
    --ch-winter-gradient: linear-gradient(135deg, #a1c4fd 0%, #c2e9fb 100%);

    /* Sombras */
    --ch-shadow-sm: 0 0.125rem 0.25rem rgba(0, 0, 0, 0.075);
    --ch-shadow-md: 0 0.5rem 1rem rgba(0, 0, 0, 0.15);
    --ch-shadow-lg: 0 1rem 3rem rgba(0, 0, 0, 0.175);

    /* Misc */
    --border-radius: 0.5rem;
    --ch-border-radius: 0.5rem;
    --ch-border-radius-lg: 0.75rem;
    --box-shadow: 0 0.125rem 0.25rem rgba(0, 0, 0, 0.075);
    --transition: all 0.3s ease;
    --ch-transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    --ch-transition-fast: all 0.15s ease-in-out;
}

/* ============================================================================
   ESTILOS GLOBALES
   ============================================================================ */

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    min-height: 100vh;
    overscroll-behavior: none;
    /* PWA: evita pull-to-refresh */
}

/* ============================================================================
   ESTACIONES DEL AÑO
   ============================================================================ */

.d_parent_primavera {
    background: url("../images/Primavera horizontal.jpg") no-repeat fixed center;
    background-size: cover;
    min-height: 100vh;
}

.d_parent_verano {
    background: url("../images/Verano horizontal.jpg") no-repeat fixed center;
    background-size: cover;
    min-height: 100vh;
}

.d_parent_otono {
    background: url("../images/Otono horizontal.jpg") no-repeat fixed center;
    background-size: cover;
    min-height: 100vh;
}

.d_parent_invierno {
    background: url("../images/Invierno horizontal.jpg") no-repeat fixed center;
    background-size: cover;
    min-height: 100vh;
}

/* ============================================================================
   PWA - SAFE AREA (NOTCH)
   ============================================================================ */

@media all and (display-mode: standalone) {
    body::before {
        content: '';
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        height: env(safe-area-inset-top);
        background-color: var(--primary-color);
        z-index: 9999;
    }
}

/* ============================================================================
   PWA - BANNERS
   ============================================================================ */

#installBanner {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 1rem;
    text-align: center;
    transform: translateY(100%);
    transition: transform 0.3s ease;
    z-index: 1000;
    box-shadow: 0 -4px 12px rgba(0, 0, 0, 0.15);
}

#installBanner.show {
    transform: translateY(0);
}

#installBanner button {
    margin: 0.5rem;
}

#updateBanner {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    background: #ffc107;
    color: #000;
    padding: 0.75rem;
    text-align: center;
    transform: translateY(-100%);
    transition: transform 0.3s ease;
    z-index: 1000;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

#updateBanner.show {
    transform: translateY(0);
}

#offlineIndicator {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    background: #dc3545;
    color: white;
    padding: 0.5rem;
    text-align: center;
    transform: translateY(-100%);
    transition: transform 0.3s ease;
    z-index: 1000;
    font-size: 0.875rem;
}

#offlineIndicator.show {
    transform: translateY(0);
}

/* ============================================================================
   CARDS
   ============================================================================ */

.card {
    background: rgba(255, 255, 255, 0.0) !important;
    /* 0.15 */

    backdrop-filter: blur(20px) saturate(100%);
    /*180%*/

    -webkit-backdrop-filter: blur(20px) saturate(180%);
    /*border: 1px solid rgba(255, 255, 255, 0.4) !important;*/

    border-radius: 1.5rem !important;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.18) !important;


    transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1), box-shadow 0.3s ease;
    overflow: hidden;
    position: relative;
    /* Necesario para el pie absoluto */
}

.card-footer-unified {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    padding: 1rem 1.5rem;
    background: transparent;
}

.card-footer-unified a {
    transition: color 0.2s ease;
}

.card-footer-unified a:hover {
    color: var(--primary-color) !important;
}



.card:hover {
    transform: none;
    box-shadow: 0 40px 80px rgba(0, 0, 0, 0.25) !important;
}



/* ============================================================================
   BOTONES
   ============================================================================ */

.btn {
    border-radius: var(--ch-border-radius);
    font-weight: 500;
    transition: var(--ch-transition-fast);
    -webkit-tap-highlight-color: transparent;
}

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

.btn:active {
    transform: translateY(0);
}

/* Botones numéricos del teclado */
.btn-num {
    background: rgba(255, 255, 255, 0.6);
    backdrop-filter: blur(5px);
    border: 1px solid rgba(255, 255, 255, 0.4);
    color: #1a202c;
    font-weight: 700 !important;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.05);
}

.btn-num:hover {
    background: rgba(255, 255, 255, 0.9);
    transform: scale(1.02);
    box-shadow: 0 8px 15px rgba(0, 0, 0, 0.08);
}

.btn-num:active {
    background: #e2e8f0 !important;
    transform: scale(0.95);
    transition: none;
}

.btn-primary {
    background: linear-gradient(135deg, #0d6efd 0%, #0043a8 100%) !important;
    border: none !important;
}

.btn-success {
    background: linear-gradient(135deg, #28a745 0%, #1e7e34 100%) !important;
    border: none !important;
}

.btn-danger {
    background: linear-gradient(135deg, #dc3545 0%, #a71d2a 100%) !important;
    border: none !important;
}


/* ============================================================================
   INPUTS Y SELECTS
   ============================================================================ */

.form-control,
.form-select {
    border-radius: var(--ch-border-radius);
    border: 1px solid #dee2e6;
    transition: var(--ch-transition-fast);
    background-color: #ffffff !important;
    color: #000000 !important;
    /* Texto siempre negro al escribir */
    font-weight: 600;
}

.form-control::placeholder {
    color: #cbd5e0 !important;
    /* Placeholder en gris claro */
    font-weight: 400;
}

.form-control:focus,
.form-select:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 0.25rem rgba(13, 110, 253, 0.25);
    background-color: #ffffff !important;
    color: #000000 !important;
}


textarea.form-control {
    resize: vertical;
    min-height: 100px;
    background-color: #ffffff !important;
    color: #212529 !important;
}

/* PIN display */
#i_display_pin {
    letter-spacing: 0.5rem;
    background-color: transparent !important;
    color: #212529;
}

#i_display_pin::placeholder {
    letter-spacing: normal;
}

/* Campo de código de activación */
#activation-code {
    letter-spacing: 0.15rem;
    padding-left: 0.5rem;
    padding-right: 0.5rem;
    font-size: 1.75rem !important;
}

@media (max-width: 576px) {
    #activation-code {
        font-size: 1.25rem !important;
        letter-spacing: 0.05rem;
        padding-left: 0.25rem;
        padding-right: 0.25rem;
    }
}


.input-group {

    border: 1px solid rgba(0, 0, 0, 0.2) !important;
    border-radius: var(--ch-border-radius) !important;
    overflow: hidden;
}

.input-group>*,
.input-group-text,
.input-group .form-control,
.input-group .btn {
    background-color: transparent !important;
    border: none !important;
    box-shadow: none !important;
}

/* ============================================================================
   ANIMACIONES
   ============================================================================ */

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

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: scale(0.9) translateY(20px);
    }

    to {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

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

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes pulse {

    0%,
    100% {
        transform: scale(1);
    }

    50% {
        transform: scale(1.05);
    }
}

@keyframes spinner {
    to {
        transform: rotate(360deg);
    }
}

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

.slide-in {
    animation: slideIn 0.4s ease-out;
}

.slide-down {
    animation: slideDown 0.4s ease-out;
}

/* Animación de entrada de las cards según vista */
.card-controlhorario {
    animation: none;
}

.card-cambiafechahora {
    animation: slideDown 0.4s ease-out;
}

.card-muestraresultado {
    animation: slideIn 0.4s ease-out;
}

/* Iconos de resultado */
.bi-check-circle-fill,
.bi-exclamation-circle-fill {
    animation: pulse 0.6s ease-in-out;
}

/* ============================================================================
   UTILIDADES
   ============================================================================ */

.hide-scrollbar {
    -ms-overflow-style: none;  /* IE and Edge */
    scrollbar-width: none;  /* Firefox */
}
.hide-scrollbar::-webkit-scrollbar {
    display: none; /* Chrome, Safari and Opera */
}

.badge {
    padding: 0.5em 1em;
    border-radius: var(--ch-border-radius);
    font-weight: 500;
}

.alert {
    border: none;
    border-radius: var(--ch-border-radius);
    box-shadow: var(--ch-shadow-sm);
}

.icon-hover {
    transition: var(--ch-transition-fast);
}

.icon-hover:hover {
    transform: rotate(10deg) scale(1.1);
}

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

/* ============================================================================
   ESTADOS DE CARGA
   ============================================================================ */

.loading {
    position: relative;
    pointer-events: none;
    opacity: 0.6;
}

.loading::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 2rem;
    height: 2rem;
    margin-top: -1rem;
    margin-left: -1rem;
    border: 0.25rem solid currentColor;
    border-right-color: transparent;
    border-radius: 50%;
    animation: spinner 0.75s linear infinite;
}

/* ============================================================================
   ACCESIBILIDAD
   ============================================================================ */

*:focus,
.btn:focus,
button:focus,
input:focus,
.card[role="button"]:focus {
    outline: 2px solid var(--primary-color);
    outline-offset: 2px;
}

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

@media (max-width: 576px) {
    .card {
        margin: 1rem;
    }

    h1,
    h2,
    h3,
    h4 {
        font-size: calc(1rem + 0.5vw);
    }
}

/* ============================================================================
   MODO OSCURO - solo afecta a la card, los inputs siempre son blancos
   ============================================================================ */

@media (prefers-color-scheme: dark) {
    .card {
        color: #212529;
    }
}

/* ============================================================================
   PRINT
   ============================================================================ */

@media print {
    body {
        background: white !important;
    }

    .card {
        box-shadow: none !important;
        border: 1px solid #dee2e6 !important;
    }

    .btn,
    .btn-close {
        display: none !important;
    }
}