/* ===== Un Giorno da Eroe - Tema ===== */
:root {
    --blu-navy: #1e3a8a;
    --blu-medio: #2563eb;
    --blu-chiaro: #3b82f6;
    --rosso: #dc2626;
    --rosso-scuro: #991b1b;
    --oro: #f59e0b;
    --oro-chiaro: #fbbf24;
    --verde: #16a34a;
    --viola: #7c3aed;
    --arancio: #ea580c;
    --grigio-50: #f9fafb;
    --grigio-100: #f3f4f6;
    --grigio-200: #e5e7eb;
    --grigio-300: #d1d5db;
    --grigio-500: #6b7280;
    --grigio-700: #374151;
    --grigio-900: #111827;
    --raggio: 8px;
    --ombra: 0 1px 3px rgba(0,0,0,.12), 0 1px 2px rgba(0,0,0,.08);
    --ombra-lg: 0 4px 12px rgba(0,0,0,.15);
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--grigio-100);
    color: var(--grigio-900);
    line-height: 1.6;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* ===== Navbar ===== */
.navbar {
    background: linear-gradient(135deg, var(--blu-navy), var(--rosso-scuro));
    color: #fff;
    padding: .75rem 1.5rem;
    display: flex;
    align-items: center;
    gap: 1rem;
    box-shadow: 0 2px 8px rgba(0,0,0,.3);
    position: sticky;
    top: 0;
    z-index: 100;
}
.nav-brand {
    display: flex;
    align-items: center;
    gap: .5rem;
    font-weight: 700;
    font-size: 1.1rem;
    white-space: nowrap;
}
.nav-icon { font-size: 1.5rem; }
.nav-links {
    display: flex;
    align-items: center;
    gap: .25rem;
    margin-left: auto;
}
.nav-link {
    color: rgba(255,255,255,.85);
    text-decoration: none;
    padding: .4rem .75rem;
    border-radius: var(--raggio);
    transition: background .2s, color .2s;
    font-size: .9rem;
}
.nav-link:hover { background: rgba(255,255,255,.15); color: #fff; }
.nav-link-logout { color: var(--oro-chiaro); }
.nav-link-logout:hover { background: rgba(245,158,11,.2); }
.nav-toggle {
    display: none;
    background: none;
    border: none;
    color: #fff;
    font-size: 1.5rem;
    cursor: pointer;
    margin-left: auto;
}

/* ===== Container ===== */
.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 1.5rem;
    flex: 1;
    width: 100%;
}

/* ===== Flash Messages ===== */
.flash-container { margin-bottom: 1rem; }
.flash {
    padding: .75rem 1rem;
    border-radius: var(--raggio);
    margin-bottom: .5rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    animation: slideDown .3s ease;
}
.flash-success { background: #dcfce7; color: #166534; border-left: 4px solid var(--verde); }
.flash-danger { background: #fef2f2; color: #991b1b; border-left: 4px solid var(--rosso); }
.flash-warning { background: #fefce8; color: #854d0e; border-left: 4px solid var(--oro); }
.flash-info { background: #dbeafe; color: #1e40af; border-left: 4px solid var(--blu-medio); }
.flash-close {
    background: none; border: none; font-size: 1.2rem;
    cursor: pointer; color: inherit; opacity: .6;
}
.flash-close:hover { opacity: 1; }

/* ===== Page Header ===== */
.page-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: .75rem;
    margin-bottom: 1.5rem;
}
.page-header h1 {
    font-size: 1.75rem;
    color: var(--blu-navy);
}
.subtitle { color: var(--grigio-500); margin-top: .25rem; }

/* ===== Cards ===== */
.card {
    background: #fff;
    border-radius: var(--raggio);
    box-shadow: var(--ombra);
    overflow: hidden;
}
.card-header {
    padding: 1rem 1.25rem;
    border-bottom: 1px solid var(--grigio-200);
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.card-header h2 { font-size: 1.1rem; color: var(--grigio-700); }
.card-body { padding: 1.25rem; }

/* ===== Stat Cards ===== */
.stat-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 1rem;
    margin-bottom: 1.5rem;
}
.stat-card {
    background: #fff;
    border-radius: var(--raggio);
    padding: 1.25rem;
    text-align: center;
    box-shadow: var(--ombra);
    border-top: 4px solid var(--grigio-300);
    transition: transform .2s, box-shadow .2s;
}
.stat-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--ombra-lg);
}
.stat-card-blue { border-top-color: var(--blu-medio); }
.stat-card-green { border-top-color: var(--verde); }
.stat-card-gold { border-top-color: var(--oro); }
.stat-card-red { border-top-color: var(--rosso); }
.stat-card-purple { border-top-color: var(--viola); }
.stat-card-orange { border-top-color: var(--arancio); }

.stat-icon { font-size: 2rem; margin-bottom: .5rem; }
.stat-value {
    font-size: 2.5rem;
    font-weight: 800;
    line-height: 1;
    margin-bottom: .25rem;
}
.stat-card-blue .stat-value { color: var(--blu-medio); }
.stat-card-green .stat-value { color: var(--verde); }
.stat-card-gold .stat-value { color: var(--oro); }
.stat-card-red .stat-value { color: var(--rosso); }
.stat-card-purple .stat-value { color: var(--viola); }
.stat-card-orange .stat-value { color: var(--arancio); }

.stat-label { color: var(--grigio-500); font-size: .85rem; }

/* Staggered animation */
.animate-in {
    opacity: 0;
    transform: translateY(20px);
    animation: slideUp .5s ease forwards;
    animation-delay: calc(var(--delay, 0) * 0.1s);
}
@keyframes slideUp {
    to { opacity: 1; transform: translateY(0); }
}
@keyframes slideDown {
    from { opacity: 0; transform: translateY(-10px); }
    to { opacity: 1; transform: translateY(0); }
}
@keyframes bounceIn {
    0% { transform: scale(0.3); opacity: 0; }
    50% { transform: scale(1.05); }
    70% { transform: scale(0.95); }
    100% { transform: scale(1); opacity: 1; }
}

/* ===== Progress Bar ===== */
.progress-bar-container {
    background: var(--grigio-200);
    border-radius: 20px;
    overflow: hidden;
    height: 28px;
}
.progress-bar {
    background: linear-gradient(90deg, var(--blu-medio), var(--verde));
    height: 100%;
    border-radius: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 60px;
    transition: width .6s ease;
    animation: pulseWave 2s ease-in-out infinite;
}
.progress-bar span {
    color: #fff;
    font-size: .8rem;
    font-weight: 600;
    white-space: nowrap;
    padding: 0 .5rem;
}
@keyframes pulseWave {
    0%, 100% { opacity: 1; }
    50% { opacity: .85; }
}

/* ===== Tables ===== */
.table-responsive { overflow-x: auto; }
.table {
    width: 100%;
    border-collapse: collapse;
}
.table th, .table td {
    padding: .65rem .75rem;
    text-align: left;
    border-bottom: 1px solid var(--grigio-200);
}
.table thead th {
    background: var(--grigio-50);
    font-weight: 600;
    color: var(--grigio-700);
    font-size: .85rem;
    text-transform: uppercase;
    letter-spacing: .03em;
}
.table tbody tr:hover { background: var(--grigio-50); }
.table tfoot td {
    background: var(--grigio-100);
    font-weight: 600;
}
.table-logo {
    width: 28px;
    height: 28px;
    object-fit: contain;
    vertical-align: middle;
    margin-right: .4rem;
    border-radius: 4px;
}

/* ===== Badges ===== */
.badge {
    display: inline-block;
    padding: .2rem .6rem;
    border-radius: 12px;
    font-size: .75rem;
    font-weight: 600;
}
.badge-success { background: #dcfce7; color: #166534; }
.badge-warning { background: #fefce8; color: #854d0e; }
.badge-danger { background: #fef2f2; color: #991b1b; }

/* ===== Forms ===== */
.form-group {
    margin-bottom: 1rem;
    flex: 1;
}
.form-group label {
    display: block;
    font-weight: 600;
    margin-bottom: .3rem;
    color: var(--grigio-700);
    font-size: .9rem;
}
.form-group input[type="text"],
.form-group input[type="email"],
.form-group input[type="password"],
.form-group input[type="tel"],
.form-group input[type="number"],
.form-group input[type="file"],
.form-group textarea,
.form-group select {
    width: 100%;
    padding: .55rem .75rem;
    border: 1px solid var(--grigio-300);
    border-radius: var(--raggio);
    font-size: .95rem;
    transition: border-color .2s, box-shadow .2s;
    background: #fff;
}
.form-group input:focus,
.form-group textarea:focus,
.form-group select:focus {
    outline: none;
    border-color: var(--blu-medio);
    box-shadow: 0 0 0 3px rgba(37,99,235,.15);
}
.form-row {
    display: flex;
    gap: 1rem;
}
.radio-group {
    display: flex;
    gap: 1.5rem;
}
.radio-label {
    display: flex;
    align-items: center;
    gap: .3rem;
    cursor: pointer;
    font-weight: normal;
}

/* ===== Form Section Title ===== */
.form-section-title {
    font-size: 1.05rem;
    color: var(--blu-navy);
    margin: 1.25rem 0 .75rem;
    padding-bottom: .4rem;
    border-bottom: 2px solid var(--grigio-200);
}

/* ===== Buttons ===== */
.btn {
    display: inline-block;
    padding: .5rem 1rem;
    border: none;
    border-radius: var(--raggio);
    font-size: .9rem;
    font-weight: 600;
    cursor: pointer;
    text-decoration: none;
    transition: background .2s, transform .1s;
    line-height: 1.4;
}
.btn:active { transform: scale(.97); }
.btn-primary { background: var(--blu-medio); color: #fff; }
.btn-primary:hover { background: var(--blu-navy); }
.btn-secondary { background: var(--grigio-500); color: #fff; }
.btn-secondary:hover { background: var(--grigio-700); }
.btn-warning { background: var(--oro); color: #fff; }
.btn-warning:hover { background: #d97706; }
.btn-danger { background: var(--rosso); color: #fff; }
.btn-danger:hover { background: var(--rosso-scuro); }
.btn-info { background: var(--blu-chiaro); color: #fff; }
.btn-info:hover { background: var(--blu-medio); }
.btn-block { width: 100%; text-align: center; }
.btn-sm { padding: .3rem .6rem; font-size: .8rem; }

.actions { white-space: nowrap; }
.actions form, .inline { display: inline; }

/* ===== Auth Pages ===== */
.auth-container {
    min-height: 80vh;
    display: flex;
    align-items: center;
    justify-content: center;
}
.auth-card {
    background: #fff;
    border-radius: 12px;
    box-shadow: var(--ombra-lg);
    width: 100%;
    max-width: 440px;
    overflow: hidden;
}
.auth-header {
    background: linear-gradient(135deg, var(--blu-navy), var(--rosso-scuro));
    color: #fff;
    text-align: center;
    padding: 2rem 1.5rem 1.5rem;
}
.auth-icon { font-size: 3rem; display: block; margin-bottom: .5rem; }
.auth-header h1 { font-size: 1.4rem; margin-bottom: .25rem; }
.auth-header p { opacity: .8; font-size: .9rem; }
.auth-form { padding: 1.5rem; }
.auth-footer {
    text-align: center;
    padding: 0 1.5rem 1.5rem;
    color: var(--grigio-500);
    font-size: .9rem;
}
.auth-footer a { color: var(--blu-medio); }

/* ===== Detail Pages ===== */
.detail-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(350px, 1fr));
    gap: 1rem;
}
.detail-list { margin: 0; }
.detail-list dt {
    font-weight: 600;
    color: var(--grigio-500);
    font-size: .85rem;
    margin-top: .75rem;
}
.detail-list dd {
    margin-left: 0;
    font-size: .95rem;
}
.detail-logo {
    text-align: center;
    margin-bottom: 1rem;
}
.detail-logo img {
    max-width: 150px;
    max-height: 150px;
    object-fit: contain;
    border-radius: var(--raggio);
    border: 1px solid var(--grigio-200);
    padding: .5rem;
}

/* ===== Logo Preview ===== */
.logo-preview img {
    max-width: 120px;
    max-height: 120px;
    object-fit: contain;
    border: 1px solid var(--grigio-200);
    border-radius: var(--raggio);
    padding: .25rem;
}

/* ===== Report ===== */
.report-summary {
    background: linear-gradient(135deg, var(--blu-navy), var(--blu-medio));
    color: #fff;
    padding: 1rem 1.25rem;
    border-radius: var(--raggio);
    margin-bottom: 1rem;
    font-size: 1.05rem;
}
.report-nav { display: flex; gap: .5rem; flex-wrap: wrap; }
.allergia-item {
    padding: .75rem;
    border-bottom: 1px solid var(--grigio-200);
}
.allergia-item:last-child { border-bottom: none; }

/* ===== Checklist ===== */
.checklist-form {
    display: flex;
    gap: .5rem;
}
.checklist-form input[type="text"] {
    flex: 1;
    padding: .55rem .75rem;
    border: 1px solid var(--grigio-300);
    border-radius: var(--raggio);
    font-size: .95rem;
}
.checklist-form input:focus {
    outline: none;
    border-color: var(--blu-medio);
    box-shadow: 0 0 0 3px rgba(37,99,235,.15);
}
.checklist-toggle {
    background: none;
    border: none;
    font-size: 1.3rem;
    cursor: pointer;
    padding: 0;
    line-height: 1;
}

/* ===== Trello Board ===== */
.trello-board {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 1rem;
    align-items: start;
}
.trello-card {
    background: var(--grigio-100);
    border-radius: var(--raggio);
    box-shadow: var(--ombra);
    overflow: hidden;
}
.trello-card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: .75rem 1rem;
    background: linear-gradient(135deg, var(--blu-navy), var(--blu-medio));
    color: #fff;
}
.trello-card-title {
    font-size: 1rem;
    font-weight: 700;
    margin: 0;
}
.trello-card-actions {
    display: flex;
    align-items: center;
    gap: .35rem;
}
.trello-card-count {
    font-size: .8rem;
    opacity: .85;
    font-weight: 600;
}
.btn-icon {
    background: none;
    border: none;
    color: rgba(255,255,255,.8);
    cursor: pointer;
    font-size: 1rem;
    padding: .15rem .3rem;
    border-radius: 4px;
    transition: background .2s;
    line-height: 1;
}
.btn-icon:hover { background: rgba(255,255,255,.2); color: #fff; }
.btn-icon-danger:hover { background: rgba(220,38,38,.3); }
.btn-icon-sm { font-size: .85rem; color: var(--grigio-500); }
.btn-icon-sm:hover { color: var(--rosso); background: rgba(220,38,38,.1); }

.trello-rename {
    padding: .5rem .75rem;
    background: var(--grigio-50);
    border-bottom: 1px solid var(--grigio-200);
}

.trello-progress {
    height: 4px;
    background: var(--grigio-200);
}
.trello-progress-bar {
    height: 100%;
    background: linear-gradient(90deg, var(--verde), #22c55e);
    transition: width .4s ease;
}

.trello-items {
    padding: .25rem .5rem;
    max-height: 400px;
    overflow-y: auto;
}
.trello-item {
    display: flex;
    align-items: center;
    gap: .4rem;
    padding: .5rem .5rem;
    margin: .25rem 0;
    background: #fff;
    border-radius: 6px;
    box-shadow: 0 1px 2px rgba(0,0,0,.06);
    transition: background .2s, opacity .2s;
}
.trello-item:hover { box-shadow: 0 2px 4px rgba(0,0,0,.1); }
.trello-item.done { opacity: .55; }
.trello-item.done .trello-item-text { text-decoration: line-through; color: var(--grigio-500); }
.trello-item-text { flex: 1; font-size: .9rem; }
.trello-item-who {
    font-size: .7rem;
    color: var(--grigio-500);
    font-style: italic;
    white-space: nowrap;
}

.trello-add {
    padding: .5rem .75rem;
    border-top: 1px solid var(--grigio-200);
}
.trello-add .checklist-form input[type="text"] {
    padding: .4rem .6rem;
    font-size: .85rem;
}

/* ===== Quick Links ===== */
.quick-links { display: flex; gap: .5rem; flex-wrap: wrap; }

/* ===== Footer ===== */
.footer {
    text-align: center;
    padding: 1rem;
    color: var(--grigio-500);
    font-size: .8rem;
    border-top: 1px solid var(--grigio-200);
    margin-top: 2rem;
}

/* ===== Utilities ===== */
.mt-1 { margin-top: 1rem; }
.text-center { text-align: center; }
.text-muted { color: var(--grigio-500); }

/* ===== Responsive ===== */
@media (max-width: 768px) {
    .nav-links { display: none; flex-direction: column; position: absolute; top: 100%; left: 0; right: 0; background: var(--blu-navy); padding: .5rem; }
    .nav-links.open { display: flex; }
    .nav-toggle { display: block; }
    .form-row { flex-direction: column; gap: 0; }
    .stat-grid { grid-template-columns: repeat(2, 1fr); }
    .detail-grid { grid-template-columns: 1fr; }
    .page-header { flex-direction: column; align-items: flex-start; }
    .container { padding: 1rem; }
}

/* ===== Print ===== */
@media print {
    .navbar, .footer, .no-print, .btn, .flash-container, .nav-toggle { display: none !important; }
    body { background: #fff; }
    .container { max-width: 100%; padding: 0; }
    .card { box-shadow: none; border: 1px solid #ddd; }
    .stat-card { break-inside: avoid; border: 1px solid #ddd; box-shadow: none; }
    .table th, .table td { padding: .4rem .5rem; font-size: .85rem; }
    .report-summary { background: #eee !important; color: #000 !important; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
    .page-header h1 { font-size: 1.4rem; }
}
