/* ============================================================
   gare24.it — Custom styles (sopra Bootstrap 5)
   ============================================================ */

:root {
    --g24-primary:      #2563EB;
    --g24-primary-dark: #1D4ED8;
    --g24-primary-light:#EFF6FF;
    --g24-text:         #1F2937;
    --g24-muted:        #6B7280;
    --g24-muted-light:  #9CA3AF;
    --g24-bg:           #F9FAFB;
    --g24-border:       #E5E7EB;
    --g24-border-dark:  #D1D5DB;
    --g24-white:        #FFFFFF;
    --g24-success:      #16A34A;
    --g24-warning:      #D97706;
    --g24-danger:       #DC2626;
    --g24-shadow-sm:    0 1px 3px rgba(0,0,0,.06);
    --g24-shadow-md:    0 4px 12px rgba(37,99,235,.10);
    --g24-radius:       8px;
    --g24-radius-lg:    12px;
}

/* ============================================================
   BASE
   ============================================================ */
html { font-size: 16px; scroll-behavior: smooth; }

body {
    font-family: 'Inter', system-ui, -apple-system, sans-serif;
    color: var(--g24-text);
    background-color: var(--g24-bg);
    margin-bottom: 0;
    -webkit-font-smoothing: antialiased;
}

a { color: var(--g24-primary); }
a:hover { color: var(--g24-primary-dark); }

/* ============================================================
   NAVBAR
   ============================================================ */
.navbar {
    min-height: 62px;
}

.navbar-brand {
    letter-spacing: -0.5px;
    font-size: 1.35rem !important;
}

.navbar .nav-link {
    color: var(--g24-muted) !important;
    font-size: 0.9rem;
    font-weight: 500;
    padding: 0.4rem 0.75rem !important;
    border-radius: 6px;
    transition: background 0.12s, color 0.12s;
}

.navbar .nav-link:hover,
.navbar .nav-link.active {
    color: var(--g24-primary) !important;
    background-color: var(--g24-primary-light);
}

/* ============================================================
   HERO
   ============================================================ */
.hero-section {
    background: linear-gradient(135deg, #EFF6FF 0%, #DBEAFE 100%);
    padding: 4rem 0 3rem;
    border-bottom: 1px solid var(--g24-border);
}

.hero-section h1 {
    font-size: 2.2rem;
    font-weight: 700;
    color: var(--g24-text);
    letter-spacing: -0.5px;
    line-height: 1.2;
}

.hero-section .lead {
    color: var(--g24-muted);
    font-size: 1.05rem;
}

.hero-search .form-control {
    border-radius: var(--g24-radius) 0 0 var(--g24-radius);
    border: 1.5px solid var(--g24-border-dark);
    font-size: 1rem;
    padding: 0.65rem 1rem;
    background: var(--g24-white);
    box-shadow: none;
    transition: border-color 0.15s;
}

.hero-search .form-control:focus {
    border-color: var(--g24-primary);
    box-shadow: 0 0 0 3px rgba(37,99,235,.12);
}

.hero-search .btn {
    border-radius: 0 var(--g24-radius) var(--g24-radius) 0;
    padding: 0.65rem 1.5rem;
    font-weight: 600;
}

/* ============================================================
   COUNTER CARDS
   ============================================================ */
.counter-card {
    background: var(--g24-white);
    border: 1px solid var(--g24-border);
    border-radius: var(--g24-radius-lg);
    padding: 1.25rem 1.5rem;
    text-align: center;
    box-shadow: var(--g24-shadow-sm);
}

.counter-card .counter-value {
    font-size: 1.8rem;
    font-weight: 700;
    color: var(--g24-primary);
    line-height: 1.1;
}

.counter-card .counter-label {
    font-size: 0.83rem;
    color: var(--g24-muted);
    margin-top: 0.25rem;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

/* ============================================================
   BANDO CARD
   ============================================================ */
.bando-card {
    background: var(--g24-white);
    border: 1px solid var(--g24-border);
    border-radius: var(--g24-radius);
    padding: 1.1rem 1.25rem;
    transition: box-shadow 0.15s ease, transform 0.15s ease, border-color 0.15s;
    text-decoration: none;
    color: inherit;
    display: block;
}

.bando-card:hover {
    box-shadow: var(--g24-shadow-md);
    transform: translateY(-1px);
    border-color: #BFDBFE;
    color: inherit;
    text-decoration: none;
}

.bando-card:active {
    transform: translateY(0);
}

.bando-titolo {
    font-weight: 600;
    font-size: 0.95rem;
    color: var(--g24-text);
    margin-bottom: 0.4rem;
    line-height: 1.45;
}

.bando-meta {
    font-size: 0.8rem;
    color: var(--g24-muted);
}

/* ============================================================
   BADGES
   ============================================================ */
.badge-tipo {
    display: inline-block;
    font-size: 0.7rem;
    font-weight: 500;
    background-color: var(--g24-primary-light);
    color: var(--g24-primary);
    border: 1px solid #BFDBFE;
    border-radius: 4px;
    padding: 2px 7px;
    white-space: nowrap;
}

.badge-scaduto {
    display: inline-block;
    background-color: #FEF2F2;
    color: var(--g24-danger);
    border: 1px solid #FECACA;
    border-radius: 4px;
    padding: 2px 7px;
    font-size: 0.7rem;
    font-weight: 500;
    white-space: nowrap;
}

.badge-in-scadenza {
    display: inline-block;
    background-color: #FFFBEB;
    color: var(--g24-warning);
    border: 1px solid #FDE68A;
    border-radius: 4px;
    padding: 2px 7px;
    font-size: 0.7rem;
    font-weight: 500;
    white-space: nowrap;
}

.badge-attivo {
    display: inline-block;
    background-color: #F0FDF4;
    color: var(--g24-success);
    border: 1px solid #BBF7D0;
    border-radius: 4px;
    padding: 2px 7px;
    font-size: 0.7rem;
    font-weight: 500;
    white-space: nowrap;
}

/* ============================================================
   SECTION TITLE
   ============================================================ */
.section-title {
    font-size: 1.05rem;
    font-weight: 600;
    color: var(--g24-text);
    margin-bottom: 1rem;
    padding-bottom: 0.5rem;
    border-bottom: 2px solid var(--g24-primary-light);
}

/* ============================================================
   CPV QUICK LINKS
   ============================================================ */
.cpv-link {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 0.45rem 0.9rem;
    background: var(--g24-white);
    border: 1px solid var(--g24-border);
    border-radius: var(--g24-radius);
    color: var(--g24-text);
    text-decoration: none;
    font-size: 0.875rem;
    font-weight: 500;
    transition: border-color 0.15s, box-shadow 0.15s, color 0.15s;
}

.cpv-link:hover {
    border-color: var(--g24-primary);
    color: var(--g24-primary);
    box-shadow: 0 2px 8px rgba(37, 99, 235, 0.1);
    text-decoration: none;
}

/* ============================================================
   FILTRI SIDEBAR
   ============================================================ */
.filtri-label {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--g24-text);
    margin-bottom: 0.3rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

#form-filtri .form-control,
#form-filtri .form-select {
    font-size: 0.875rem;
    border-color: var(--g24-border);
    border-radius: 6px;
    background-color: var(--g24-white);
}

#form-filtri .form-control:focus,
#form-filtri .form-select:focus {
    border-color: var(--g24-primary);
    box-shadow: 0 0 0 3px rgba(37,99,235,.1);
}

#form-filtri .form-text {
    font-size: 0.72rem;
    color: var(--g24-muted-light);
}

/* ============================================================
   PAGINAZIONE
   ============================================================ */
.pagination .page-link {
    color: var(--g24-primary);
    border-color: var(--g24-border);
    border-radius: 6px !important;
    font-size: 0.875rem;
    padding: 0.35rem 0.65rem;
    min-width: 36px;
    text-align: center;
    transition: background 0.12s, border-color 0.12s;
}

.pagination .page-link:hover {
    background-color: var(--g24-primary-light);
    border-color: #BFDBFE;
    color: var(--g24-primary-dark);
}

.pagination .page-item.active .page-link {
    background-color: var(--g24-primary);
    border-color: var(--g24-primary);
    color: white;
    font-weight: 600;
}

.pagination .page-item.disabled .page-link {
    color: var(--g24-muted-light);
    background-color: transparent;
    border-color: var(--g24-border);
}

/* ============================================================
   DETTAGLIO GARA
   ============================================================ */
.detail-date-box {
    background: var(--g24-bg);
    border: 1px solid var(--g24-border);
    border-radius: var(--g24-radius);
    padding: 0.75rem 1rem;
}

.detail-date-box .small {
    font-size: 0.75rem;
}

/* ============================================================
   ADS
   ============================================================ */
.ad-sidebar {
    position: sticky;
    top: 80px;
    min-height: 280px;
    background: #F3F4F6;
    border: 1px dashed var(--g24-border-dark);
    border-radius: var(--g24-radius);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--g24-muted-light);
    font-size: 0.78rem;
}

.ad-sidebar-live {
    position: sticky;
    top: 80px;
}

.ad-footer {
    min-height: 90px;
    background: #F3F4F6;
    border: 1px dashed var(--g24-border-dark);
    border-radius: var(--g24-radius);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--g24-muted-light);
    font-size: 0.78rem;
}

/* ============================================================
   BACK TO TOP
   ============================================================ */
#back-to-top {
    position: fixed;
    bottom: 1.5rem;
    right: 1.5rem;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--g24-primary);
    color: white;
    border: none;
    cursor: pointer;
    display: none;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 8px rgba(37,99,235,.35);
    transition: opacity 0.2s, transform 0.2s;
    z-index: 1000;
    font-size: 1rem;
}

#back-to-top:hover {
    background: var(--g24-primary-dark);
    transform: translateY(-2px);
}

#back-to-top.visible {
    display: flex;
}

/* ============================================================
   UTILITIES
   ============================================================ */
.text-truncate-2 {
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.font-monospace { font-size: 0.82em; }

/* ============================================================
   RESPONSIVE — TABLET (768–991px)
   ============================================================ */
@media (min-width: 768px) and (max-width: 991.98px) {
    .hero-section { padding: 2.5rem 0 2rem; }
    .hero-section h1 { font-size: 1.75rem; }
    .counter-card .counter-value { font-size: 1.5rem; }
}

/* ============================================================
   RESPONSIVE — MOBILE (<768px)
   ============================================================ */
@media (max-width: 767.98px) {
    .hero-section { padding: 2rem 0 1.5rem; }
    .hero-section h1 { font-size: 1.5rem; }
    .hero-section .lead { font-size: 0.95rem; }
    .counter-card { padding: 0.85rem 1rem; }
    .counter-card .counter-value { font-size: 1.4rem; }
    .bando-card { padding: 0.85rem 1rem; }
    .bando-titolo { font-size: 0.9rem; }
}

/* ============================================================
   RESPONSIVE — SIDEBAR
   ============================================================ */
@media (max-width: 991.98px) {
    .ad-sidebar { display: none; }
}

/* ============================================================
   PRINT
   ============================================================ */
@media print {
    .navbar, footer, .ad-sidebar, .ad-footer, .ad-footer-live,
    #back-to-top, .offcanvas, .btn { display: none !important; }
    body { background: white; color: black; }
    .bando-card { border: 1px solid #ccc; page-break-inside: avoid; }
    a[href]::after { content: " (" attr(href) ")"; font-size: 0.7em; color: #666; }
}
