/**
 * Born to Ride - Modern Alert System
 * Sistema unificato di notifiche con design moderno
 * 
 * @version 1.0.0
 */

/* ===========================
   Alert Base Styles
   =========================== */
.btr-alert {
    position: relative;
    padding: 1.25rem 1.5rem 1.25rem 4rem;
    border-radius: 0.75rem;
    margin: 1.25rem 0;
    font-size: 1rem;
    line-height: 1.6;
    display: flex;
    flex-direction: row;
    gap: 0;
    animation: btr-alert-slide-in 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08), 0 2px 4px rgba(0, 0, 0, 0.04);
    transition: all 0.3s ease;
    overflow: hidden;
    align-items: start;
}

/* Alert Icon Base */
.btr-alert::before {
    content: '';
    position: absolute;
    left: 1.25rem;
    top: 1.25rem;
    width: 2rem;
    height: 2rem;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    font-weight: 700;
    font-size: 1.125rem;
    flex-shrink: 0;
    z-index: 1;
}

/* Alert Border Accent */
.btr-alert::after {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 4px;
    border-radius: 0.75rem 0 0 0.75rem;
}

/* ===========================
   Alert Variants
   =========================== */

/* Success Alert */
.btr-alert.btr-success,
.btr-success {
    background: linear-gradient(135deg, #ecfdf5 0%, #d1fae5 100%);
    color: #065f46;
    border: 1px solid #6ee7b7;
}

.btr-alert.btr-success::before,
.btr-success::before {
    content: '✓';
    background: linear-gradient(135deg, #10b981 0%, #059669 100%);
    color: white;
    box-shadow: 0 2px 8px rgba(16, 185, 129, 0.3);
}
/*
.btr-alert.btr-success::after,
.btr-success::after {
    background: linear-gradient(180deg, #10b981 0%, #059669 100%);
}

/* Error Alert */
.btr-alert.btr-error,
.btr-error {
    background: linear-gradient(135deg, #fef2f2 0%, #fee2e2 100%);
    color: #991b1b;
    border: 1px solid #fca5a5;
}

.btr-alert.btr-error::before,
.btr-error::before {
    content: '✕';
    background: linear-gradient(135deg, #ef4444 0%, #dc2626 100%);
    color: white;
    box-shadow: 0 2px 8px rgba(239, 68, 68, 0.3);
}
/*
.btr-alert.btr-error::after,
.btr-error::after {
    background: linear-gradient(180deg, #ef4444 0%, #dc2626 100%);
}
*/
/* Warning Alert */
.btr-alert.btr-warning,
.btr-warning {
    background: linear-gradient(135deg, #fffbeb 0%, #fef3c7 100%);
    color: #78350f;
    border: 1px solid #fcd34d;
}

.btr-alert.btr-warning::before,
.btr-warning::before {
    content: '⚠';
    background: linear-gradient(135deg, #f59e0b 0%, #d97706 100%);
    color: white;
    box-shadow: 0 2px 8px rgba(245, 158, 11, 0.3);
}

/*
.btr-alert.btr-warning::after,
.btr-warning::after {
    background: linear-gradient(180deg, #f59e0b 0%, #d97706 100%);
}
*/

/* Info Alert */
.btr-alert.btr-info,
.btr-info {
    background: linear-gradient(135deg, #eff6ff 0%, #dbeafe 100%);
    color: #1e3a8a;
    border: 1px solid #93c5fd;
}

.btr-alert.btr-info::before,
.btr-info::before {
    content: 'ℹ';
    background: linear-gradient(135deg, #3b82f6 0%, #2563eb 100%);
    color: white;
    box-shadow: 0 2px 8px rgba(59, 130, 246, 0.3);
}

/*
.btr-alert.btr-info::after,
.btr-info::after {
    background: linear-gradient(180deg, #3b82f6 0%, #2563eb 100%);
}

/* ===========================
   Alert Content
   =========================== */
.btr-alert-title {
    font-weight: 600;
    font-size: 1.0625rem;
    margin: 0;
    display: flex;
    align-items: center;
    gap: 0.375rem;
}

.btr-alert-message {
    margin: 0;
    line-height: 1.6;
}

.btr-alert-list {
    margin: 0.75rem 0 0 0;
    padding-left: 1.25rem;
    list-style-type: disc;
}

.btr-alert-list li {
    margin: 0.375rem 0;
    line-height: 1.5;
}

.btr-alert-list li:last-child {
    margin-bottom: 0;
}

/* Alert Actions */
.btr-alert-actions {
    display: flex;
    gap: 0.75rem;
    margin-top: 0.75rem;
    flex-wrap: wrap;
}

.btr-alert-action {
    padding: 0.5rem 1rem;
    border-radius: 0.5rem;
    font-weight: 600;
    font-size: 0.9375rem;
    cursor: pointer;
    transition: all 0.2s ease;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: 0.375rem;
}

/* Success Actions */
.btr-success .btr-alert-action-primary {
    background: #10b981;
    color: white;
    border: none;
}

.btr-success .btr-alert-action-primary:hover {
    background: #059669;
    transform: translateY(-1px);
    box-shadow: 0 4px 8px rgba(16, 185, 129, 0.3);
}

/* Error Actions */
.btr-error .btr-alert-action-primary {
    background: #ef4444;
    color: white;
    border: none;
}

.btr-error .btr-alert-action-primary:hover {
    background: #dc2626;
    transform: translateY(-1px);
    box-shadow: 0 4px 8px rgba(239, 68, 68, 0.3);
}

/* Warning Actions */
.btr-warning .btr-alert-action-primary {
    background: #f59e0b;
    color: white;
    border: none;
}

.btr-warning .btr-alert-action-primary:hover {
    background: #d97706;
    transform: translateY(-1px);
    box-shadow: 0 4px 8px rgba(245, 158, 11, 0.3);
}

/* Info Actions */
.btr-info .btr-alert-action-primary {
    background: #3b82f6;
    color: white;
    border: none;
}

.btr-info .btr-alert-action-primary:hover {
    background: #2563eb;
    transform: translateY(-1px);
    box-shadow: 0 4px 8px rgba(59, 130, 246, 0.3);
}

/* Secondary Actions */
.btr-alert-action-secondary {
    background: transparent;
    border: 1px solid currentColor;
    color: inherit;
}

.btr-alert-action-secondary:hover {
    background: rgba(0, 0, 0, 0.05);
}

/* ===========================
   Dismiss Button
   =========================== */
.btr-alert-dismiss {
    position: absolute;
    top: 1rem;
    right: 1rem;
    width: 1.75rem;
    height: 1.75rem;
    border-radius: 0.375rem;
    background: transparent;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: currentColor;
    opacity: 0.6;
    transition: all 0.2s ease;
    padding: 0;
    font-size: 1.25rem;
    line-height: 1;
}

.btr-alert-dismiss:hover {
    opacity: 1;
    background: rgba(0, 0, 0, 0.1);
}

.btr-alert-dismiss:focus {
    outline: 2px solid currentColor;
    outline-offset: 2px;
}

/* ===========================
   Animations
   =========================== */
@keyframes btr-alert-slide-in {
    from {
        opacity: 0;
        transform: translateY(-10px) scale(0.98);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

@keyframes btr-alert-slide-out {
    from {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
    to {
        opacity: 0;
        transform: translateY(-10px) scale(0.98);
    }
}

.btr-alert-dismissing {
    animation: btr-alert-slide-out 0.3s cubic-bezier(0.4, 0, 1, 1) forwards;
}

/* Hover Effects */
.btr-alert:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.12), 0 3px 6px rgba(0, 0, 0, 0.08);
}

/* ===========================
   Alert Sizes
   =========================== */
.btr-alert.btr-alert-sm {
    padding: 0.875rem 1rem 0.875rem 3.5rem;
    font-size: 0.9375rem;
}

.btr-alert.btr-alert-sm::before {
    width: 1.5rem;
    height: 1.5rem;
    left: 1rem;
    top: 0.875rem;
    font-size: 0.875rem;
}

.btr-alert.btr-alert-lg {
    padding: 1.5rem 2rem 1.5rem 4.5rem;
    font-size: 1.0625rem;
}

.btr-alert.btr-alert-lg::before {
    width: 2.5rem;
    height: 2.5rem;
    left: 1.5rem;
    top: 1.5rem;
    font-size: 1.375rem;
}

/* ===========================
   Responsive Design
   =========================== */
@media (max-width: 768px) {
    .btr-alert {
        padding: 1rem 1.25rem 1rem 3.5rem;
        font-size: 0.9375rem;
        margin: 1rem 0;
    }

    .btr-alert::before {
        width: 1.75rem;
        height: 1.75rem;
        left: 1rem;
        top: 1rem;
        font-size: 1rem;
    }

    .btr-alert-title {
        font-size: 1rem;
    }

    .btr-alert-actions {
        flex-direction: column;
        gap: 0.5rem;
    }

    .btr-alert-action {
        width: 100%;
        justify-content: center;
    }

    .btr-alert-dismiss {
        top: 0.75rem;
        right: 0.75rem;
        width: 1.5rem;
        height: 1.5rem;
        font-size: 1rem;
    }
}

/* ===========================
   Container Specifics
   =========================== */
#btr-booking-response {
    position: relative;
    min-height: 0;
}

#btr-booking-response:empty {
    display: none;
}

#btr-booking-response .btr-alert:first-child {
    margin-top: 0;
}

#btr-booking-response .btr-alert:last-child {
    margin-bottom: 0;
}

/* ===========================
   Print Styles
   =========================== */
@media print {
    .btr-alert-dismiss {
        display: none !important;
    }

    .btr-alert {
        box-shadow: none !important;
        border: 2px solid currentColor;
        page-break-inside: avoid;
    }
}

/* ===========================
   Accessibility
   =========================== */
.btr-alert[role="alert"] {
    /* Screen readers will announce this automatically */
}

@media (prefers-reduced-motion: reduce) {
    .btr-alert,
    .btr-alert-dismissing {
        animation: none;
        transition: none;
    }

    .btr-alert:hover {
        transform: none;
    }
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    .btr-alert {
        border-width: 2px;
    }

    .btr-alert::after {
        width: 6px;
    }
}

/* ===========================
   Allocation Global Status
   Avviso sopra la selezione camere (#btr-alloc-global-status, frontend-scripts.js).
   Il markup indossa .btr-alert.btr-error: qui serve solo nasconderlo quando non ha
   messaggio — il codice lo svuota con .text(''), quindi :empty è il criterio esatto,
   e non richiede al JS di conoscere la presentazione.
   =========================== */
#btr-alloc-global-status:empty {
    /* L'elemento e' una live region (role="status" aria-live="polite") creata una volta
       sola e riempita dopo. Il tema Salient applica 'p:empty { display: none }'
       (style.css), che la toglie dall'albero di accessibilita' e rende inaffidabile
       l'annuncio successivo: qui la si tiene nel flusso e si azzera solo la
       presentazione, cosi' a box vuoto l'altezza resta 0 ma la regione continua a
       esistere per gli screen reader. La specificita' ID batte quella del tema. */
    display: block;
    margin: 0;
    padding: 0;
    border: 0;
    background: none;
    box-shadow: none;
}

/* Icona e barra d'accento sono in position:absolute: senza questo resterebbero visibili
   sopra la lista camere anche a box vuoto. */
#btr-alloc-global-status:empty::before,
#btr-alloc-global-status:empty::after {
    display: none;
}

/* ===========================
   Restore Notification
   Toast di ripristino selezione (btr-booking-state-saver.js).
   Prima era stilizzato inline con un gradiente viola #667eea→#764ba2 e font di
   sistema: fuori dal brand. Qui usa i token BTR (primario #0097c5, Archivo) e le
   stesse convenzioni degli alert: superficie chiara, icona in cerchio, radius
   0.75rem, entrata 0.4s cubic-bezier(0.4, 0, 0.2, 1).
   =========================== */
.btr-restore-notification {
    position: fixed;
    top: 100px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 99999;
    display: flex;
    /* Icona allineata al titolo come in .btr-alert (che usa align-items: start):
       col testo su due righe, centrarla la farebbe sembrare parte della riga
       secondaria. I controlli restano centrati via align-self. */
    align-items: flex-start;
    gap: 1rem;
    max-width: min(92vw, 720px);
    padding: 1rem 1.25rem;
    background: linear-gradient(135deg, var(--btr-primary-lightest, #f0f9fc) 0%, var(--btr-primary-light, #e6f7fc) 100%);
    border: 1px solid var(--btr-accent-border, rgba(0, 151, 197, 0.28));
    border-radius: 0.75rem;
    box-shadow: 0 10px 30px rgba(0, 151, 197, 0.18), 0 2px 6px rgba(0, 0, 0, 0.06);
    color: #00506a;
    font-family: var(--font-family, 'Archivo', sans-serif);
    animation: btr-restore-slide-in 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

.btr-restore-notification .btr-restore-icon {
    flex-shrink: 0;
    width: 2rem;
    height: 2rem;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--btr-primary, #0097c5) 0%, var(--btr-primary-dark, #006d8f) 100%);
    box-shadow: 0 2px 8px rgba(0, 151, 197, 0.3);
    color: #ffffff;
    font-size: 1.0625rem;
    line-height: 1;
}

.btr-restore-notification .btr-restore-body {
    flex: 1;
    min-width: 0;
}

.btr-restore-notification .btr-restore-title {
    margin: 0;
    font-size: 0.9375rem;
    font-weight: 600;
    line-height: 1.3;
    color: inherit;
}

.btr-restore-notification .btr-restore-text {
    margin: 0.125rem 0 0;
    font-size: 0.8125rem;
    line-height: 1.45;
    color: #0b6a86;
}

.btr-restore-notification .btr-restore-reset {
    flex-shrink: 0;
    align-self: center;
    padding: 0.5rem 1rem;
    border: 1px solid var(--btr-primary, #0097c5);
    border-radius: 0.5rem;
    background: #ffffff;
    /* #0097c5 su bianco a 13px/600 da' 3,37:1, sotto il minimo AA di 4,5:1 (a questa
       dimensione non vale la soglia "testo grande"). La variante scura arriva a 5,8:1
       restando nella palette. */
    color: var(--btr-primary-dark, #006d8f);
    font-family: inherit;
    font-size: 0.8125rem;
    font-weight: 600;
    line-height: 1.2;
    cursor: pointer;
    white-space: nowrap;
    transition: background-color 0.2s ease, color 0.2s ease;
}

.btr-restore-notification .btr-restore-reset:hover {
    background: var(--btr-primary, #0097c5);
    color: #ffffff;
}

.btr-restore-notification .btr-restore-close {
    flex-shrink: 0;
    align-self: center;
    padding: 0 0.25rem;
    border: none;
    background: none;
    color: #00506a;
    font-family: inherit;
    font-size: 1.25rem;
    line-height: 1;
    cursor: pointer;
    /* Niente opacity: al 55% il contrasto scendeva a 2,74:1, sotto sia la soglia testo
       (4,5:1) sia quella per elementi non testuali (3:1). A piena opacita' e' 7,8:1. */
    transition: color 0.2s ease;
}

.btr-restore-notification .btr-restore-close:hover {
    color: var(--btr-primary-dark, #006d8f);
}

.btr-restore-notification .btr-restore-reset:focus-visible,
.btr-restore-notification .btr-restore-close:focus-visible {
    /* Il ciano chiaro sull'azzurro del toast dava 2,95:1, sotto il 3:1 richiesto agli
       indicatori di focus: la variante scura lo porta oltre soglia su entrambi i fondi. */
    outline: 2px solid var(--btr-primary-dark, #006d8f);
    outline-offset: 2px;
}

@keyframes btr-restore-slide-in {
    from {
        opacity: 0;
        /* translateX(-50%) va ripetuto in ogni keyframe: senza, l'elemento perde
           il centraggio orizzontale per tutta la durata dell'animazione. */
        transform: translateX(-50%) translateY(-12px);
    }
    to {
        opacity: 1;
        transform: translateX(-50%) translateY(0);
    }
}

@media (max-width: 640px) {
    .btr-restore-notification {
        top: 76px;
        flex-wrap: wrap;
        gap: 0.75rem;
        /* width esplicita, non solo max-width: in shrink-to-fit il flex si
           restringerebbe al contenuto (misurato: 195px su viewport 390) invece di
           occupare lo spazio disponibile. */
        width: calc(100vw - 2rem);
        max-width: calc(100vw - 2rem);
        padding: 0.875rem 1rem;
    }

    .btr-restore-notification .btr-restore-reset {
        order: 3;
        width: 100%;
        text-align: center;
    }
}

@media (prefers-reduced-motion: reduce) {
    .btr-restore-notification {
        animation: none;
    }
}

