/* ============================================
   Tesserino Tecnico AIF — Design System
   Marzo 2026
   ============================================ */

:root {
    --navy: #1B3A5C;
    --navy-dark: #0F2640;
    --navy-light: #2B5EA7;
    --amber: #D97706;
    --amber-bg: #FFFBEB;
    --amber-border: #FDE68A;
    --green: #059669;
    --green-bg: #F0FDF4;
    --green-border: #BBF7D0;
    --red: #DC2626;
    --red-bg: #FEF2F2;
    --red-border: #FECACA;
    --blue-soft: #EFF6FF;
    --gray-50: #F9FAFB;
    --gray-100: #F3F4F6;
    --gray-200: #E5E7EB;
    --gray-300: #D1D5DB;
    --gray-400: #9CA3AF;
    --gray-500: #6B7280;
    --gray-600: #4B5563;
    --gray-700: #374151;
    --gray-800: #1F2937;
    --radius: 12px;
    --radius-sm: 8px;
    --shadow: 0 4px 12px rgba(0,0,0,0.08);
    --shadow-sm: 0 1px 3px rgba(0,0,0,0.08);
    --transition: all 0.2s ease;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--gray-50);
    color: var(--gray-800);
    line-height: 1.6;
    min-height: 100vh;
}

/* === HEADER === */
.page-header {
    background: linear-gradient(135deg, #78350f 0%, #92400e 50%, var(--amber) 100%);
    color: white;
    padding: 40px 24px 48px;
    text-align: center;
    position: relative;
}

.page-header::after {
    content: '';
    position: absolute;
    bottom: -20px;
    left: 0; right: 0;
    height: 40px;
    background: var(--gray-50);
    border-radius: 24px 24px 0 0;
}

.header-logo {
    width: 56px; height: 56px;
    margin: 0 auto 12px;
    background: rgba(255,255,255,0.12);
    border: 2px solid rgba(255,255,255,0.25);
    border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
}

.header-logo svg { width: 28px; height: 28px; }

.page-header h1 {
    font-size: 1.6rem;
    font-weight: 800;
    margin-bottom: 8px;
    letter-spacing: -0.02em;
}

.page-header > p {
    font-size: 0.85rem;
    opacity: 0.8;
    max-width: 540px;
    margin: 0 auto;
    line-height: 1.5;
}

/* === CONTAINER === */
.container {
    max-width: 720px;
    width: 100%;
    margin: 0 auto;
    padding: 0 16px 40px;
    position: relative;
    z-index: 1;
}

/* === INFO SECTION === */
.info-section {
    background: white;
    border-radius: var(--radius);
    padding: 20px;
    margin-bottom: 20px;
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--gray-200);
}

.info-section h3 {
    font-size: 0.85rem;
    font-weight: 700;
    color: var(--navy);
    margin-bottom: 12px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.info-section h3 svg { flex-shrink: 0; }

.info-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 8px;
}

.info-item {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 10px 14px;
    background: var(--gray-50);
    border-radius: var(--radius-sm);
    font-size: 0.82rem;
    line-height: 1.5;
    color: var(--gray-600);
}

.info-item .icon {
    flex-shrink: 0;
    font-size: 1rem;
    line-height: 1.4;
}

.info-item strong {
    color: var(--gray-800);
}

/* === SEARCH === */
.search-card {
    background: white;
    border-radius: var(--radius);
    padding: 16px;
    box-shadow: var(--shadow);
    margin-bottom: 20px;
    border: 1px solid var(--gray-200);
}

.search-card label {
    display: block;
    font-size: 0.82rem;
    color: var(--gray-600);
    margin-bottom: 8px;
    font-weight: 500;
}

.search-row {
    display: flex;
    gap: 8px;
}

.search-row input {
    flex: 1;
    padding: 10px 14px;
    font-size: 0.9rem;
    border: 2px solid var(--gray-200);
    border-radius: var(--radius-sm);
    background: var(--gray-50);
    transition: var(--transition);
    text-transform: uppercase;
}

.search-row input:focus {
    outline: none;
    border-color: var(--amber);
    box-shadow: 0 0 0 3px rgba(217,119,6,0.1);
    background: white;
}

.search-row input::placeholder {
    color: var(--gray-400);
    text-transform: none;
}

.btn-search {
    padding: 10px 20px;
    background: var(--amber);
    color: white;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    white-space: nowrap;
    display: flex;
    align-items: center;
    gap: 6px;
}

.btn-search:hover { background: #b45309; }

.btn-search svg { width: 16px; height: 16px; }

/* === LOADING === */
.loading-spinner {
    text-align: center;
    padding: 40px 20px;
}

.spinner {
    width: 32px; height: 32px;
    border: 3px solid var(--gray-200);
    border-top-color: var(--amber);
    border-radius: 50%;
    margin: 0 auto 12px;
    animation: spin 0.8s linear infinite;
}

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

.loading-spinner p { color: var(--gray-500); font-size: 0.85rem; }

/* === ERROR === */
.error-message {
    display: none;
    margin-top: 8px;
    padding: 8px 12px;
    background: var(--red-bg);
    border: 1px solid var(--red-border);
    border-radius: 6px;
    color: var(--red);
    font-size: 0.8rem;
    font-weight: 500;
}

.error-message.show { display: flex; align-items: center; gap: 6px; }

/* === RESULTS === */
.results-header {
    margin-bottom: 16px;
}

.results-header h2 {
    font-size: 1.2rem;
    font-weight: 700;
    color: var(--gray-800);
}

.results-header h2 .badge-count {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: var(--amber);
    color: white;
    font-size: 0.7rem;
    width: 22px; height: 22px;
    border-radius: 50%;
    vertical-align: middle;
    margin-left: 6px;
}

/* === SUMMARY STATS === */
.summary-stats {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
    margin-bottom: 16px;
}

.stat-card {
    background: white;
    border-radius: var(--radius-sm);
    padding: 14px;
    text-align: center;
    border: 1px solid var(--gray-200);
}

.stat-card .stat-value {
    font-size: 1.4rem;
    font-weight: 800;
    line-height: 1;
}

.stat-card .stat-label {
    font-size: 0.68rem;
    color: var(--gray-500);
    margin-top: 4px;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.stat-card.green { border-color: var(--green-border); }
.stat-card.green .stat-value { color: var(--green); }
.stat-card.red { border-color: var(--red-border); }
.stat-card.red .stat-value { color: var(--red); }
.stat-card.amber { border-color: var(--amber-border); }
.stat-card.amber .stat-value { color: var(--amber); }

/* === DISCIPLINE CARDS === */
.disc-card {
    background: white;
    border-radius: var(--radius);
    border: 1px solid var(--gray-200);
    margin-bottom: 10px;
    overflow: hidden;
    transition: var(--transition);
    animation: fadeIn 0.2s ease-out both;
}

.disc-card.status-valido { border-left: 4px solid var(--green); }
.disc-card.status-in_scadenza { border-left: 4px solid var(--amber); }
.disc-card.status-scaduto { border-left: 4px solid var(--red); }
.disc-card.status-mai_rinnovato { border-left: 4px solid var(--gray-400); }

.disc-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 16px;
    gap: 10px;
}

.disc-header-left {
    display: flex;
    align-items: center;
    gap: 10px;
    flex: 1;
    min-width: 0;
}

.disc-icon {
    flex-shrink: 0;
    font-size: 1.2rem;
}

.disc-name {
    font-size: 0.88rem;
    font-weight: 600;
    color: var(--gray-800);
}

.disc-type-badge {
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 0.65rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    flex-shrink: 0;
}

.badge-route { background: #DBEAFE; color: #1D4ED8; }
.badge-bls { background: #FEF3C7; color: #92400E; }
.badge-course { background: var(--gray-100); color: var(--gray-600); }

.disc-body {
    padding: 0 16px 14px;
}

.disc-detail-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
}

.disc-detail {
    padding: 8px 12px;
    background: var(--gray-50);
    border-radius: 6px;
}

.disc-detail-label {
    font-size: 0.68rem;
    font-weight: 600;
    color: var(--gray-500);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    margin-bottom: 2px;
}

.disc-detail-value {
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--gray-800);
}

.disc-detail-value.green { color: var(--green); }
.disc-detail-value.red { color: var(--red); }
.disc-detail-value.amber { color: var(--amber); }

/* Evasione badge */
.evasione-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 8px;
    border-radius: 4px;
    font-size: 0.72rem;
    font-weight: 600;
}

.evasione-badge.emesso { background: var(--green-bg); color: var(--green); border: 1px solid var(--green-border); }
.evasione-badge.pending { background: var(--amber-bg); color: var(--amber); border: 1px solid var(--amber-border); }

/* Renewal row */
.disc-renewal {
    margin-top: 8px;
    padding: 10px 12px;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
}

.disc-renewal.urgent { background: var(--red-bg); border: 1px solid var(--red-border); }
.disc-renewal.warning { background: var(--amber-bg); border: 1px solid var(--amber-border); }

.disc-renewal-text {
    font-size: 0.78rem;
    font-weight: 600;
}

.disc-renewal.urgent .disc-renewal-text { color: var(--red); }
.disc-renewal.warning .disc-renewal-text { color: var(--amber); }

.btn-renew {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 6px 14px;
    border-radius: 6px;
    font-size: 0.78rem;
    font-weight: 700;
    text-decoration: none;
    white-space: nowrap;
    border: none;
    cursor: pointer;
    color: white;
    transition: var(--transition);
}

.btn-renew.red { background: var(--red); }
.btn-renew.red:hover { background: #b91c1c; }
.btn-renew.amber { background: var(--amber); }
.btn-renew.amber:hover { background: #b45309; }

/* === STORICO SECTION === */
.storico-section {
    margin-top: 10px;
}

.storico-label {
    font-size: 0.68rem;
    font-weight: 600;
    color: var(--gray-500);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    margin-bottom: 4px;
}

.storico-badges {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
}

.storico-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 8px;
    border-radius: 4px;
    font-size: 0.7rem;
    font-weight: 600;
}

.storico-badge.emesso { background: var(--green-bg); border: 1px solid var(--green-border); color: var(--green); }
.storico-badge.pending { background: var(--amber-bg); border: 1px solid var(--amber-border); color: var(--amber); }

/* === DOWNLOAD SECTION === */
.download-section {
    margin-top: 10px;
    padding-top: 10px;
    border-top: 1px solid var(--gray-100);
}

.download-section-label {
    font-size: 0.68rem;
    font-weight: 600;
    color: var(--gray-500);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    margin-bottom: 6px;
}

.download-buttons {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.btn-download {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 5px 12px;
    background: var(--navy);
    color: white;
    border-radius: 6px;
    font-size: 0.75rem;
    font-weight: 700;
    text-decoration: none;
    transition: var(--transition);
}

.btn-download:hover { background: var(--navy-light); }
.btn-download:active { transform: scale(0.97); }

.btn-download svg { flex-shrink: 0; }

/* === NO RESULTS === */
.no-results {
    background: white;
    border-radius: var(--radius);
    padding: 48px 24px;
    text-align: center;
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--gray-200);
}

.no-results svg { stroke: var(--gray-300); margin-bottom: 12px; }
.no-results h3 { font-size: 1rem; color: var(--gray-700); margin-bottom: 6px; }
.no-results p { color: var(--gray-500); font-size: 0.85rem; }
.no-results .hint { font-size: 0.78rem; color: var(--gray-400); margin-top: 12px; font-style: italic; }

/* === CONTACTS === */
.contacts-section {
    background: white;
    border-radius: var(--radius);
    padding: 20px;
    margin-top: 20px;
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--gray-200);
}

.contacts-section h3 {
    font-size: 0.85rem;
    font-weight: 700;
    color: var(--navy);
    margin-bottom: 12px;
    display: flex; align-items: center; gap: 8px;
}

.contacts-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
}

.contact-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 14px;
    background: var(--gray-50);
    border-radius: var(--radius-sm);
    text-decoration: none;
    color: var(--gray-700);
    font-size: 0.8rem;
    transition: var(--transition);
}

.contact-item:hover { background: var(--blue-soft); }

.contact-item .icon {
    width: 32px; height: 32px;
    border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    font-size: 0.75rem; font-weight: 700;
    flex-shrink: 0;
}

.contact-item .icon.email { background: #DBEAFE; color: #2563EB; }
.contact-item .icon.calc { background: var(--green-bg); color: var(--green); }

.contact-item span strong { display: block; font-size: 0.78rem; color: var(--gray-800); }

/* === FOOTER === */
.page-footer {
    text-align: center;
    padding: 20px;
    color: var(--gray-400);
    font-size: 0.75rem;
}

/* === ANIMATIONS === */
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
}

/* === RESPONSIVE === */
@media (max-width: 640px) {
    .page-header h1 { font-size: 1.3rem; }
    .container { padding: 0 12px 32px; }
    .search-row { flex-direction: column; }
    .btn-search { width: 100%; justify-content: center; }
    .summary-stats { grid-template-columns: repeat(3, 1fr); gap: 6px; }
    .stat-card { padding: 10px 6px; }
    .stat-card .stat-value { font-size: 1.1rem; }
    .disc-detail-grid { grid-template-columns: 1fr; }
    .contacts-grid { grid-template-columns: 1fr; }
    .disc-renewal { flex-direction: column; align-items: stretch; text-align: center; }
}

@media (max-width: 380px) {
    .page-header { padding: 28px 16px 40px; }
    .page-header h1 { font-size: 1.15rem; }
    .search-card { padding: 12px; }
}
