/* ============================================
   Certificazioni AIF — Design System v2
   Marzo 2026
   ============================================ */

:root {
    --navy: #1B3A5C;
    --navy-dark: #132942;
    --navy-light: #2B5EA7;
    --blue-accent: #3B82F6;
    --blue-soft: #EFF6FF;
    --green: #16A34A;
    --green-bg: #F0FDF4;
    --orange: #EA580C;
    --orange-bg: #FFF7ED;
    --red: #DC2626;
    --red-bg: #FEF2F2;
    --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;
    --gold: #D97706;
    --gold-bg: #FFFBEB;
    --radius: 12px;
    --radius-sm: 8px;
    --shadow-sm: 0 1px 3px rgba(0,0,0,0.08);
    --shadow: 0 4px 12px rgba(0,0,0,0.08);
    --shadow-lg: 0 8px 30px rgba(0,0,0,0.12);
    --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, var(--navy) 0%, var(--navy-dark) 100%);
    color: white;
    padding: 32px 24px 40px;
    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: 64px;
    height: 64px;
    margin: 0 auto 16px;
    background: rgba(255,255,255,0.15);
    border-radius: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.header-logo img {
    width: 48px;
    height: auto;
}

.header-logo svg {
    width: 36px;
    height: 36px;
    opacity: 0.95;
}

.page-header h1 {
    font-size: 1.5rem;
    font-weight: 700;
    margin-bottom: 6px;
    letter-spacing: -0.02em;
}

.page-header p {
    font-size: 0.9rem;
    opacity: 0.8;
    max-width: 500px;
    margin: 0 auto;
}

/* === CONTAINER === */
.container {
    max-width: 800px;
    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: 16px;
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--gray-200);
}

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

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

.cert-type-item {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    padding: 8px 10px;
    background: var(--gray-50);
    border-radius: var(--radius-sm);
    font-size: 0.78rem;
    color: var(--gray-600);
    line-height: 1.4;
}

.cert-type-item .icon {
    flex-shrink: 0;
    margin-top: 1px;
    font-size: 0.85rem;
}

.cert-type-item strong {
    color: var(--gray-800);
    font-weight: 600;
    display: block;
}

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

.search-card label {
    display: block;
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--gray-600);
    margin-bottom: 8px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

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

.search-row input {
    flex: 1;
    padding: 12px 16px;
    font-size: 1rem;
    border: 2px solid var(--gray-200);
    border-radius: var(--radius-sm);
    transition: var(--transition);
    text-transform: uppercase;
    font-family: 'SF Mono', 'Fira Code', monospace;
    letter-spacing: 0.05em;
    background: var(--gray-50);
}

.search-row input:focus {
    outline: none;
    border-color: var(--navy-light);
    box-shadow: 0 0 0 3px rgba(43, 94, 167, 0.12);
    background: white;
}

.search-row input::placeholder {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    letter-spacing: normal;
    text-transform: none;
    color: var(--gray-400);
    font-size: 0.85rem;
}

.btn-search {
    padding: 12px 24px;
    background: var(--navy);
    color: white;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    display: flex;
    align-items: center;
    gap: 8px;
    white-space: nowrap;
}

.btn-search:hover {
    background: var(--navy-light);
    transform: translateY(-1px);
    box-shadow: var(--shadow);
}

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

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

.error-message {
    margin-top: 12px;
    padding: 10px 14px;
    background: var(--red-bg);
    border: 1px solid #FCA5A5;
    border-radius: var(--radius-sm);
    color: var(--red);
    font-size: 0.85rem;
    display: none;
}

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

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

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

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

/* === RESULTS HEADER === */
.results-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 16px;
    flex-wrap: wrap;
    gap: 12px;
}

.results-header h2 {
    font-size: 1.15rem;
    font-weight: 700;
    color: var(--navy);
}

.results-header .badge-count {
    background: var(--navy);
    color: white;
    font-size: 0.7rem;
    font-weight: 700;
    padding: 3px 10px;
    border-radius: 20px;
    margin-left: 8px;
}

.btn-download-all {
    padding: 8px 16px;
    background: var(--green);
    color: white;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 0.8rem;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    display: flex;
    align-items: center;
    gap: 6px;
}

.btn-download-all:hover { background: #15803D; }
.btn-download-all svg { width: 16px; height: 16px; }

/* === CERTIFICATE CARDS === */
.cert-card {
    background: white;
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--gray-200);
    margin-bottom: 12px;
    overflow: hidden;
    transition: var(--transition);
}

.cert-card:hover {
    box-shadow: var(--shadow);
    border-color: var(--gray-300);
}

.cert-card.route-card {
    border-left: 4px solid var(--gold);
}

.cert-card.bls-card {
    border-left: 4px solid var(--red);
}

.cert-card.course-card {
    border-left: 4px solid var(--navy-light);
}

.cert-card-header {
    padding: 16px 20px 12px;
    display: flex;
    align-items: flex-start;
    gap: 12px;
}

.cert-card-icon {
    width: 40px;
    height: 40px;
    min-width: 40px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
    flex-shrink: 0;
}

.route-card .cert-card-icon { background: var(--gold-bg); }
.bls-card .cert-card-icon { background: var(--red-bg); }
.course-card .cert-card-icon { background: var(--blue-soft); }

.cert-card-title {
    flex: 1;
    min-width: 0;
}

.cert-card-title h3 {
    font-size: 0.95rem;
    font-weight: 700;
    color: var(--gray-800);
    line-height: 1.3;
    margin-bottom: 4px;
}

.cert-card-title .cert-tag {
    font-size: 0.68rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    padding: 2px 8px;
    border-radius: 4px;
    display: inline-block;
}

.tag-route { background: var(--gold-bg); color: var(--gold); }
.tag-bls { background: var(--red-bg); color: var(--red); }
.tag-course { background: var(--blue-soft); color: var(--navy-light); }

.cert-card-body {
    padding: 0 20px 16px;
}

/* Grades row */
.grades-row {
    display: flex;
    gap: 8px;
    margin-bottom: 12px;
}

.grade-chip {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 5px 10px;
    background: var(--gray-50);
    border: 1px solid var(--gray-200);
    border-radius: 6px;
    font-size: 0.78rem;
}

.grade-chip .label { color: var(--gray-500); }
.grade-chip .value { font-weight: 700; color: var(--navy); }

/* Module details (for routes) */
.module-list {
    margin-bottom: 12px;
}

.module-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 6px 0;
    border-bottom: 1px solid var(--gray-100);
    font-size: 0.78rem;
}

.module-item:last-child { border-bottom: none; }

.module-item .mod-name {
    color: var(--gray-700);
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    padding-right: 12px;
}

.module-item .mod-grade {
    font-weight: 600;
    color: var(--navy);
    white-space: nowrap;
}

/* Info chips */
.info-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 12px;
}

.info-chip {
    display: flex;
    align-items: center;
    gap: 5px;
    font-size: 0.78rem;
    color: var(--gray-600);
}

.info-chip svg {
    width: 14px;
    height: 14px;
    stroke: var(--gray-400);
    flex-shrink: 0;
}

/* Tesserino status */
.tesserino-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 12px;
    border-radius: var(--radius-sm);
    margin-bottom: 12px;
    font-size: 0.8rem;
}

.tesserino-row.valido { background: var(--green-bg); border: 1px solid #BBF7D0; }
.tesserino-row.in_scadenza { background: var(--orange-bg); border: 1px solid #FED7AA; }
.tesserino-row.scaduto { background: var(--red-bg); border: 1px solid #FECACA; }
.tesserino-row.mai_rinnovato { background: var(--gray-100); border: 1px solid var(--gray-200); }

.tesserino-label {
    display: flex;
    align-items: center;
    gap: 6px;
    font-weight: 600;
}

.tesserino-row.valido .tesserino-label { color: var(--green); }
.tesserino-row.in_scadenza .tesserino-label { color: var(--orange); }
.tesserino-row.scaduto .tesserino-label { color: var(--red); }
.tesserino-row.mai_rinnovato .tesserino-label { color: var(--gray-500); }

.btn-rinnova {
    padding: 4px 12px;
    font-size: 0.72rem;
    font-weight: 600;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    transition: var(--transition);
    text-decoration: none;
    display: inline-block;
}

.btn-rinnova.red { background: var(--red); color: white; }
.btn-rinnova.red:hover { background: #B91C1C; }
.btn-rinnova.orange { background: var(--orange); color: white; }
.btn-rinnova.orange:hover { background: #C2410C; }

/* BLS expiry */
.bls-expiry {
    padding: 8px 12px;
    border-radius: var(--radius-sm);
    margin-bottom: 12px;
    font-size: 0.8rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 6px;
}

.bls-expiry.valid { background: var(--green-bg); border: 1px solid #BBF7D0; color: var(--green); }
.bls-expiry.expired { background: var(--red-bg); border: 1px solid #FECACA; color: var(--red); }

/* Download row */
.cert-card-footer {
    padding: 12px 20px;
    background: var(--gray-50);
    border-top: 1px solid var(--gray-100);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.cert-card-footer .diplomi-note {
    font-size: 0.75rem;
    color: var(--gray-400);
    flex: 1;
}

.btn-download {
    padding: 8px 18px;
    background: var(--navy);
    color: white;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 0.8rem;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    display: flex;
    align-items: center;
    gap: 6px;
    white-space: nowrap;
}

.btn-download:hover { background: var(--navy-light); }
.btn-download svg { width: 16px; height: 16px; }

.btn-download.disabled {
    background: var(--gray-300);
    cursor: not-allowed;
    pointer-events: none;
}

/* === 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: 16px; }

.no-results h3 {
    font-size: 1.1rem;
    color: var(--gray-700);
    margin-bottom: 8px;
}

.no-results p {
    color: var(--gray-500);
    font-size: 0.9rem;
    margin-bottom: 6px;
}

.no-results .hint {
    color: var(--gray-400);
    font-size: 0.8rem;
    font-style: italic;
}

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

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

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

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

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

.contact-item .icon {
    width: 28px;
    height: 28px;
    min-width: 28px;
    border-radius: 6px;
    background: var(--navy);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.75rem;
}

.contact-item .icon.whatsapp { background: #25D366; }
.contact-item .icon.email { background: var(--navy-light); }
.contact-item .icon.calc { background: var(--gold); }

.contact-item span {
    flex: 1;
    min-width: 0;
}

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

/* === RENEWAL SECTION === */
.renewal-header {
    margin-top: 32px;
    padding-top: 24px;
    border-top: 2px solid var(--gray-200);
}

.renewal-header h2 {
    font-size: 1rem;
    color: var(--gray-700);
}

.renewal-card {
    background: white;
    border-radius: var(--radius-sm);
    border: 1px solid var(--gray-200);
    margin-bottom: 8px;
    overflow: hidden;
    transition: var(--transition);
}

.renewal-card:hover {
    border-color: var(--gray-300);
    box-shadow: var(--shadow-sm);
}

.renewal-card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    gap: 12px;
}

.renewal-name {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--gray-800);
    flex: 1;
    min-width: 0;
}

.renewal-badge {
    font-size: 0.72rem;
    font-weight: 600;
    padding: 3px 10px;
    border-radius: 4px;
    white-space: nowrap;
    display: flex;
    align-items: center;
    gap: 4px;
}

.renewal-badge.valid,
.renewal-badge.valido { background: var(--green-bg); color: var(--green); }
.renewal-badge.in_scadenza { background: var(--orange-bg); color: var(--orange); }
.renewal-badge.scaduto { background: var(--red-bg); color: var(--red); }
.renewal-badge.mai_rinnovato { background: var(--gray-100); color: var(--gray-500); }

.renewal-card-body {
    padding: 0 16px 12px;
}

.renewal-ok-msg {
    font-size: 0.82rem;
    color: var(--gray-600);
    line-height: 1.5;
}

.renewal-card.same-year {
    border-left: 3px solid var(--green);
}

.renewal-card.status-scaduto {
    border-left: 3px solid var(--red);
}

.renewal-card.status-in_scadenza {
    border-left: 3px solid var(--orange);
}

.renewal-card.status-valido {
    border-left: 3px solid var(--green);
}

.renewal-card.status-mai_rinnovato {
    border-left: 3px solid var(--gray-300);
}

.renewal-card-actions {
    padding: 0 16px 12px;
    display: flex;
    justify-content: flex-end;
}

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

/* === ANIMATIONS === */
@keyframes spin { to { transform: rotate(360deg); } }

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(12px); }
    to { opacity: 1; transform: translateY(0); }
}

.cert-card { animation: fadeIn 0.3s ease-out both; }
.cert-card:nth-child(1) { animation-delay: 0.05s; }
.cert-card:nth-child(2) { animation-delay: 0.1s; }
.cert-card:nth-child(3) { animation-delay: 0.15s; }
.cert-card:nth-child(4) { animation-delay: 0.2s; }
.cert-card:nth-child(5) { animation-delay: 0.25s; }
.cert-card:nth-child(6) { animation-delay: 0.3s; }

/* === RESPONSIVE === */
@media (max-width: 640px) {
    .page-header { padding: 24px 16px 32px; }
    .page-header h1 { font-size: 1.25rem; }

    .search-row { flex-direction: column; }
    .btn-search { width: 100%; justify-content: center; }

    .cert-types-grid,
    .contacts-grid { grid-template-columns: 1fr; }

    .results-header { flex-direction: column; align-items: flex-start; }

    .cert-card-footer { flex-direction: column; align-items: stretch; }
    .cert-card-footer .diplomi-note { text-align: center; }
    .btn-download { justify-content: center; }

    .grades-row { flex-wrap: wrap; }
}

@media (max-width: 380px) {
    .container { padding: 0 10px 32px; }
    .search-card { padding: 16px; }
    .cert-card-header { padding: 12px 14px 8px; }
    .cert-card-body { padding: 0 14px 12px; }
    .cert-card-footer { padding: 10px 14px; }
}

/* ============================================================
   ESWA — Diploma Europeo section
   ============================================================ */
.eswa-section { margin-bottom: 28px; }
.eswa-card {
    background: linear-gradient(180deg, #fffbf2 0%, #ffffff 100%);
    border: 1px solid #e9d9a8;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 6px 24px rgba(27, 54, 93, 0.08);
}
.eswa-header { padding: 28px 28px 20px; text-align: center; background: linear-gradient(180deg, #1B365D 0%, #122347 100%); color: #fff; }
.eswa-brand { display: flex; align-items: center; justify-content: center; gap: 10px; }
.eswa-logo { font-size: 22px; font-weight: 800; letter-spacing: 5px; color: #fff; }
.eswa-tag { font-size: 10px; font-weight: 600; letter-spacing: 3px; color: #C5A55A; text-transform: uppercase; }
.eswa-divider { width: 50px; height: 2px; background: #C5A55A; margin: 12px auto; }
.eswa-title { font-size: 22px; color: #fff; margin: 6px 0 4px; font-weight: 700; }
.eswa-subtitle { font-size: 13px; color: rgba(255,255,255,0.78); margin: 0; line-height: 1.5; max-width: 480px; margin: 0 auto; }

.eswa-status-block { padding: 26px 28px; }

/* Stato: pay_required */
.eswa-status-card { display: grid; grid-template-columns: 1fr; gap: 14px; }
.eswa-status-row { display: flex; gap: 14px; align-items: flex-start; }
.eswa-status-icon { width: 38px; height: 38px; flex-shrink: 0; display: flex; align-items: center; justify-content: center; border-radius: 50%; font-size: 18px; font-weight: bold; }
.eswa-status-icon.pending { background: #FFF5E6; color: #C5A55A; }
.eswa-status-icon.active  { background: #E6F4EA; color: #2d8659; }
.eswa-status-icon.expired { background: #FBE9E9; color: #b04222; }
.eswa-status-icon.processing { background: #E6F0FB; color: #1B365D; }
.eswa-status-content h3 { font-size: 16px; color: #1B365D; margin: 0 0 4px; font-weight: 700; }
.eswa-status-content p { font-size: 13.5px; color: #555; margin: 0; line-height: 1.55; }
.eswa-status-content p strong { color: #1B365D; }

.eswa-meta-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px 18px; padding: 16px 18px; background: #f5f6f9; border-radius: 8px; margin: 16px 0 0; }
.eswa-meta-row { }
.eswa-meta-label { font-size: 10px; color: #C5A55A; text-transform: uppercase; letter-spacing: 1.5px; font-weight: 700; margin-bottom: 3px; }
.eswa-meta-value { font-size: 14px; color: #1B365D; font-weight: 600; }
.eswa-meta-value.mono { font-family: 'SF Mono', 'Courier New', monospace; letter-spacing: 1.2px; font-size: 13px; }

.eswa-actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 18px; }
.eswa-btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; padding: 12px 20px; border-radius: 8px; font-size: 14px; font-weight: 600; text-decoration: none; transition: all 0.2s; cursor: pointer; border: none; }
.eswa-btn-primary { background: #1B365D; color: #fff; }
.eswa-btn-primary:hover { background: #0F2F8C; }
.eswa-btn-gold { background: #C5A55A; color: #1B365D; }
.eswa-btn-gold:hover { background: #b3934d; }
.eswa-btn-outline { background: #fff; color: #1B365D; border: 1px solid #1B365D; }
.eswa-btn-outline:hover { background: #f5f6f9; }
.eswa-btn-link { background: transparent; color: #1B365D; text-decoration: underline; padding: 12px 8px; }

.eswa-corridors { padding: 18px 28px 22px; background: #fafbfc; border-top: 1px solid #f0e9d4; }
.eswa-corridor-label { font-size: 10px; color: #C5A55A; text-transform: uppercase; letter-spacing: 2px; font-weight: 700; text-align: center; margin-bottom: 12px; }
.eswa-corridor-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.eswa-corridor { background: #fff; padding: 10px 12px; border-left: 3px solid #1B365D; border-radius: 0 4px 4px 0; font-size: 12px; line-height: 1.35; color: #555; }
.eswa-corridor strong { display: block; color: #1B365D; font-size: 10px; letter-spacing: 1px; text-transform: uppercase; margin-bottom: 2px; }

@media (max-width: 640px) {
    .eswa-corridor-grid { grid-template-columns: repeat(2, 1fr); }
    .eswa-meta-grid { grid-template-columns: 1fr; }
    .eswa-actions { flex-direction: column; }
    .eswa-btn { width: 100%; }
}
