﻿@import url('open-iconic/font/css/open-iconic-bootstrap.min.css');

/* BASE STILI GLOBALI */
html, body {
    font-family: 'Segoe UI', Roboto, 'Helvetica Neue', Helvetica, Arial, sans-serif;
    background: linear-gradient(135deg, #e0eafc 0%, #cfdef3 100%);
    min-height: 100vh;
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

.ddt-main-lines th,
.ddt-main-lines td {
    vertical-align: middle;
}

.ddt-main-lines .form-control-sm {
    margin-bottom: 0;
    padding: 0.25rem 0.5rem;
    height: calc(1.5em + 0.5rem + 2px);
}

.ddt-main-lines .btn {
    margin-bottom: 0;
}

/* Titoli */
h1, h2, h3, h4, h5, h6 {
    color: #29457c;
    font-weight: 600;
    letter-spacing: 0.06em;
}

    h1:focus, h2:focus, h3:focus {
        outline: none;
    }

/* LINK E BOTTONI */
a, .btn-link {
    color: #397cff;
    text-decoration: none;
    transition: color 0.2s;
}

    a:hover, .btn-link:hover {
        color: #295fc3;
    }

.btn-primary {
    color: #fff;
    background: linear-gradient(90deg, #397cff 0%, #64b5ff 100%);
    border: none;
    border-radius: 10px;
    font-weight: 600;
    box-shadow: 0 2px 12px #90caf926;
    transition: background 0.2s, box-shadow 0.2s;
}

    .btn-primary:hover {
        background: linear-gradient(90deg, #295fc3 0%, #56a1fa 100%);
        box-shadow: 0 4px 24px #a3bffa55;
    }

/* INPUT E VALIDAZIONE */
input, textarea, select {
    border-radius: 8px;
    border: 1px solid #cfdef3;
    background: #f4f8fd;
    font-size: 1rem;
    transition: box-shadow 0.2s;
    padding: 0.85rem 1.1rem;
    margin-bottom: 0.75rem;
}

    input:focus, textarea:focus, select:focus {
        outline: none;
        box-shadow: 0 0 0 2px #b1c3f7;
        background: #fdfcff;
    }

/* Validazione input */
.valid.modified:not([type=checkbox]) {
    box-shadow: 0 0 0 2px #26b050;
}

.invalid {
    box-shadow: 0 0 0 2px #d32f2f;
}

.validation-message {
    color: #d32f2f;
    font-size: 0.98em;
    padding-left: 3px;
}

/* COMPONENTI DI SISTEMA BLAZOR */
#blazor-error-ui {
    background: #ffe5e3;
    bottom: 0;
    box-shadow: 0 -1px 10px rgba(0,0,0,0.09);
    display: none;
    left: 0;
    padding: 0.6rem 1.25rem 0.7rem 1.25rem;
    position: fixed;
    width: 100%;
    z-index: 1000;
    border-top: 2px solid #d32f2f;
    color: #d32f2f;
    font-weight: 500;
}

    #blazor-error-ui .dismiss {
        cursor: pointer;
        position: absolute;
        right: 0.75rem;
        top: 0.5rem;
    }

.blazor-error-boundary {
    background: #ffe5e3;
    color: #d32f2f;
    padding: 1rem 1rem 1rem 3.7rem;
}

/* ELEMENTI DI LISTA E AUTOCOMPLETE */
.list-group-item {
    cursor: pointer;
    background: #fff;
    border-radius: 7px;
    transition: background-color 0.2s;
}

    .list-group-item:hover, .autocomplete-item:hover {
        background-color: #f4f8fd;
    }

.autocomplete-results {
    position: absolute;
    z-index: 1000;
    background: #fff;
    border: 1px solid #cfdef3;
    border-radius: 8px;
    box-shadow: 0 2px 16px #a3bffa26;
    max-height: 200px;
    overflow-y: auto;
    width: 100%;
}

.autocomplete-item {
    padding: 0.5rem;
    cursor: pointer;
    border-radius: 7px;
    transition: background-color 0.2s;
}

/* LOADER GENERICO */
.loader {
    border: 6px solid #f3f3f3;
    border-top: 6px solid #3498db;
    border-radius: 50%;
    width: 36px;
    height: 36px;
    animation: spin 1s linear infinite;
    margin: auto;
    display: block;
}

@keyframes spin {
    0% {
        transform: rotate(0deg);
    }

    100% {
        transform: rotate(360deg);
    }
}

/* SIDEBAR E LOGO */
.sidebar {
    background: linear-gradient(180deg, #0b1843 0%, #1a1040 100%);
    color: #fff;
}

.navbar-brand {
    color: white !important;
    font-weight: 600;
    font-size: 1rem;
    margin: 0;
    text-decoration: none;
    display: flex;
    align-items: center;
    gap: 0.6rem;
}

    .navbar-brand:hover {
        text-decoration: none;
        color: #cfd8ff !important;
    }

.logo-ara {
    height: 60px;
    width: auto;
    user-select: none;
    -webkit-user-drag: none;
    filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.3));
    display: inline-block;
    margin-right: 6px;
    margin-left: 20px;
    margin-top: 6px;
    vertical-align: middle;
}

/* STRUTTURA PAGINA */
.content {
    padding-top: 1.1rem;
    background: unset;
}

nav {
    height: 100%;
    padding-top: 1rem;
}

/* Rimuove outline su SVG al click */
button:focus svg {
    outline: none;
}

/* --- Sottotabella destinazioni --- */
.subtable-container {
    background: #f8fbff;
    border: 1px solid #d9e4f5;
    border-radius: 8px;
    margin: 6px 8px; /* align to left within the parent cell */
    overflow: hidden;
    box-shadow: inset 0 0 4px rgba(0, 0, 0, 0.03);
    display: inline-block;
    width: auto;
    overflow-x: auto;
}


.subtable thead {
    background: linear-gradient(90deg, #e6eefc 0%, #dde9ff 100%);
    font-size: 0.85rem;
    font-weight: 600;
    color: #29457c;
    border-bottom: 1px solid #cdddf7;
}

.subtable {
    width: auto; /* allow table to size to content */
    table-layout: auto;
    border-collapse: collapse;
}

.subtable tbody tr td {
    padding: 0.4rem 0.6rem;
    font-size: 0.9rem;
    color: #2b2b2b;
    vertical-align: middle;
    white-space: nowrap; /* prevent wrapping so table width matches content */
}

.subtable tbody tr:nth-child(even) {
    background-color: #f2f6fd;
}

.subtable tbody tr:hover {
    background-color: #e8f0fe;
}

.subtable-row > td {
    background-color: transparent; /* let the .subtable-container provide the background */
    border-top: none;
    padding-top: 0;
    text-align: left; /* align the inline-block subtable to the left */
}

.subtable th, .subtable td {
    text-align: left;
}

    .subtable th:last-child, .subtable td:last-child {
        text-align: center;
    }

/* POPUP MODALE DETTAGLIO DESTINAZIONE */
.modal-backdrop {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0, 0, 0, 0.55);
    z-index: 1040;
    backdrop-filter: blur(2px);
}

.modal-content-box {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: #fff;
    border-radius: 12px;
    width: 520px;
    max-width: 90%;
    box-shadow: 0 6px 24px rgba(0, 0, 0, 0.25);
    z-index: 1050;
    overflow: hidden;
    animation: fadeInPopup 0.25s ease-out;
}

/* Header del popup */
.modal-header {
    background: linear-gradient(90deg, #3e61a3 0%, #3e61a3 100%);
    color: white;
    padding: 0.85rem 1.2rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: relative;
}

/* Pulsante X */
.modal-close {
    border: none;
    background: transparent;
    color: white;
    font-size: 1.6rem;
    font-weight: 400;
    line-height: 1;
    cursor: pointer;
    opacity: 0.8;
    transition: opacity 0.2s;
}

    .modal-close:hover {
        opacity: 1;
        transform: scale(1.1);
    }

.modal-body {
    padding: 1.2rem;
    font-size: 0.95rem;
    color: #2c2c2c;
}

/* Nessun effetto scroll pagina al popup */
body.modal-open {
    overflow: hidden !important;
}

@keyframes fadeInPopup {
    from {
        opacity: 0;
        transform: translate(-50%, -46%);
    }

    to {
        opacity: 1;
        transform: translate(-50%, -50%);
    }
}

/* LINK DESTINAZIONE CLICCABILE */
.destinazione-link {
    cursor: pointer;
    color: #295fc3;
    font-weight: 500;
    text-decoration: none;
    transition: color 0.15s ease;
}

    .destinazione-link:hover {
        color: #163b91;
        text-decoration: underline;
    }

/* ========================================
   NUOVO STILE TIMER - PROGRESS BAR FIX
   ======================================== */
.timer-container {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border-radius: 12px;
    padding: 10px 18px;
    min-width: 280px;
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.3);
}

.timer-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1px;
}

.timer-info {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-right: 10px;
}

.timer-icon {
    font-size: 18px;
}

.timer-text {
    color: white;
    font-size: 13px;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.timer-display-linear {
    font-size: 25px;
    font-weight: 700;
    color: white;
    text-align: center;
    font-variant-numeric: tabular-nums;
    margin-bottom: 5px;
    margin-top: -5px;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.progress-bar-container {
    width: 100%;
    height: 8px;
    background: rgba(255, 255, 255, 0.25);
    border-radius: 10px;
    overflow: hidden;
    margin-bottom: 6px;
    position: relative;
}

/* UNICA DEFINIZIONE PER LA BARRA */
.progress-bar-fill {
    height: 100%;
    background: linear-gradient(90deg, #4ade80 0%, #22c55e 100%);
    border-radius: 10px;
    transition: width 1s linear; /* Transizione fluida sulla larghezza */
    box-shadow: 0 0 10px rgba(74, 222, 128, 0.5);
    width: 0%; /* Parte da 0 */
}

    /* Cambio colore quando rimane poco tempo (opzionale, gestito via classi aggiuntive se serve) */
    .progress-bar-fill.warning {
        background: linear-gradient(90deg, #fbbf24 0%, #f59e0b 100%);
        box-shadow: 0 0 10px rgba(251, 191, 36, 0.5);
    }

    .progress-bar-fill.danger {
        background: linear-gradient(90deg, #ef4444 0%, #dc2626 100%);
        box-shadow: 0 0 10px rgba(239, 68, 68, 0.5);
    }


.timer-labels {
    display: flex;
    justify-content: space-between;
    font-size: 11px;
    color: rgba(255, 255, 255, 0.8);
    font-weight: 500;
}

.btn-refresh-linear {
    background: rgba(255, 255, 255, 0.2);
    border: 1px solid rgba(255, 255, 255, 0.3);
    border-radius: 8px;
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s ease;
    color: white;
    backdrop-filter: blur(10px);
}

    .btn-refresh-linear:hover:not(:disabled) {
        background: rgba(255, 255, 255, 0.3);
        border-color: rgba(255, 255, 255, 0.5);
        transform: scale(1.05);
    }

    .btn-refresh-linear:active:not(:disabled) {
        transform: scale(0.95);
    }

    .btn-refresh-linear:disabled {
        opacity: 0.6;
        cursor: not-allowed;
    }

    .btn-refresh-linear svg {
        transition: transform 0.3s ease;
    }

    .btn-refresh-linear:hover:not(:disabled) svg {
        transform: rotate(180deg);
    }

/* Responsive */
@media (max-width: 768px) {
    .timer-container {
        min-width: 240px;
        padding: 12px 16px;
    }

    .timer-display-linear {
        font-size: 28px;
        margin-bottom: 10px;
    }

    .timer-text {
        font-size: 11px;
    }

    .progress-bar-container {
        height: 6px;
    }
}


.articolo-link {
    cursor: pointer;
    color: #295fc3;
    font-weight: 500;
    text-decoration: none;
    transition: color 0.15s ease;
}

    .articolo-link:hover {
        color: #163b91;
        text-decoration: underline;
    }

/* --- NUOVO STILE MIGLIORATO PER LE INTESTAZIONI --- */

.th-sortable {
    cursor: pointer;
    user-select: none;
    position: relative;
    transition: all 0.2s ease-in-out;
    border-bottom: 2px solid transparent; /* Bordo invisibile di default */
}

    /* Effetto Hover: sfondo leggero e bordo inferiore colorato */
    .th-sortable:hover {
        background-color: #f8f9fa;
        color: #0d6efd; /* Blu Bootstrap */
        border-bottom: 2px solid #0d6efd;
    }

/* Contenitore flex per allineare testo e icona */
.th-content {
    display: flex;
    align-items: center;
    gap: 5px; /* Spazio tra testo e icona */
}

/* Gestione allineamento basato sulla classe parent */
.th-sortable .th-content {
    justify-content: flex-start;
}
/* Default sinistra */
.text-center .th-content {
    justify-content: center;
}

.text-end .th-content {
    justify-content: flex-end;
}

/* Icona di ordinamento */
.sort-icon {
    font-size: 0.75rem;
    opacity: 0.3; /* Icona semi-trasparente quando inattiva */
    display: inline-block;
    width: 12px;
}

/* Quando la colonna è ordinata (icona attiva) */
.sort-active {
    opacity: 1 !important;
    color: #0d6efd;
    font-weight: bold;
}

/* Small checkbox styling for destinazioni dropdown */
.dest-checkbox {
    /* Use native checkbox appearance but slightly smaller */
    transform: scale(0.92);
    margin-top: 2px; /* better vertical alignment with label text */
    vertical-align: middle;
    accent-color: #0d6efd; /* modern browsers */
    -webkit-appearance: checkbox;
    appearance: auto;
    width: auto;
    height: auto;
    padding: 0;
}

/* Dropdown container for destinazioni - ensure visible background */
.dest-filter-dropdown {
    background: #ffffff; /* solid white background */
    border: 1px solid rgba(0,0,0,0.06);
    border-radius: 8px;
    box-shadow: 0 6px 20px rgba(20,40,80,0.08);
}

.dest-filter-item {
    padding: 6px 8px;
}

.dest-filter-item:hover {
    background: rgba(13,110,253,0.04);
}

/* Ensure checkbox aligns vertically with text inside flex label */
.dest-filter-item .form-check-input {
    align-self: center; /* center in flex row */
    margin-top: 0 !important; /* remove any top offset */
}

.dest-filter-dropdown small {
    color: #6b7280;
    font-weight: 600;
}

.dest-filter-dropdown .btn-link {
    color: #6b7280;
}

.dest-filter-item label {
    display: flex !important;
    align-items: center !important;
    line-height: 1 !important;
    margin: 0;
}

/* Checkbox completamente centrata + spazio dal testo */
.dest-filter-item input[type="checkbox"] {
    margin: 0 12px 0 0 !important;   
    transform: scale(0.95);
}

.main-line-index-cell {
    vertical-align: middle !important;
    padding: 0.25rem;
}

.main-line-index {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: calc(1.5em + 0.5rem);
    padding: 0 0.5rem;
    border: 1px solid #cfdef3;
    border-radius: 8px;
    background: #f4f8fd;
    font-weight: 600;
    color: #1f2937;
}

.success-toast {
    position: fixed;
    top: 1.5rem;
    right: 1.5rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.75rem 1rem;
    border-radius: 0.5rem;
    background-color: #d1e7dd;
    color: #0f5132;
    border: 1px solid #a3cfbb;
    z-index: 3000;
    box-shadow: 0 0.25rem 0.5rem rgba(0, 0, 0, 0.15);
    animation: toast-in 0.3s ease-out, toast-out 0.3s ease-in 1.7s forwards;
}

.success-toast .toast-icon {
    font-size: 1.2rem;
}

@keyframes toast-in {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes toast-out {
    from {
        opacity: 1;
        transform: translateY(0);
    }
    to {
        opacity: 0;
        transform: translateY(-10px);
    }
}
