/* Leonardo Portal — tema allineato alla sezione ticket di Leonardo (palette steel-blue) */

:root {
    --steel-azure: #054A91;
    --steel-blue: #3E7CB1;
    --wisteria-blue: #81A4CD;
    --alice-blue: #DBE4EE;
    --harvest-orange: #F17300;

    --brand: var(--steel-azure);
    --brand-strong: #043D7A;
    --brand-tint: var(--alice-blue);
    --header-bg: #05305B;

    --ink: #1B1F24;
    --muted: #6B7280;
    --line: #E5E7EB;
    --surface: #FFFFFF;
    --bg: #F6F7F8;

    --success: #16A34A; --success-tint: #ECFDF3;
    --info: #2563EB;    --info-tint: #EFF4FF;
    --warning: #D97706; --warning-tint: #FFFBEB;
    --danger: #DC2626;  --danger-tint: #FEF2F2;

    --radius: 10px;
    --radius-sm: 6px;
    --shadow-sm: 0 1px 2px rgba(16,24,40,.06);
    --shadow: 0 4px 12px rgba(16,24,40,.08);
}

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

body {
    margin: 0;
    font-family: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
    background: var(--bg);
    color: var(--ink);
}

/* Shell */
.portal-shell { display: flex; flex-direction: column; min-height: 100vh; }

.portal-header {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: .75rem 1.5rem;
    background: var(--header-bg);
    color: #fff;
    box-shadow: var(--shadow-sm);
}

.portal-brand { font-weight: 700; font-size: 1.1rem; flex: 1; }
.portal-nav { display: flex; gap: 1rem; }
.portal-nav a { color: var(--alice-blue); text-decoration: none; font-weight: 500; }
.portal-nav a:hover, .portal-nav a.active { color: #fff; }
.portal-user { font-size: .875rem; color: var(--wisteria-blue); }
.portal-content { flex: 1; padding: 2rem 1.5rem; max-width: 900px; margin: 0 auto; width: 100%; }

/* Auth */
.auth-shell { display: flex; align-items: center; justify-content: center; min-height: 100vh; }
.auth-card { background: var(--surface); border-radius: var(--radius); padding: 2rem; width: 100%; max-width: 400px; box-shadow: var(--shadow); }
.auth-brand { text-align: center; margin-bottom: 1.5rem; }
.auth-brand h1 { margin: 0; font-size: 1.6rem; color: var(--brand); }
.auth-brand p { color: var(--muted); margin: .25rem 0 0; }
.auth-hint { color: var(--muted); font-size: .875rem; }
.auth-links { text-align: center; margin-top: 1rem; }
.auth-links a { color: var(--brand-strong); font-size: .875rem; }

/* Forms */
.field { display: flex; flex-direction: column; gap: .3rem; margin-bottom: 1rem; font-size: .875rem; font-weight: 600; }
.field input, .field select, .field textarea {
    padding: .55rem .75rem; border: 1px solid var(--line); border-radius: var(--radius-sm);
    font-size: 1rem; width: 100%; font-family: inherit;
}
.field input:focus, .field select:focus, .field textarea:focus {
    outline: none; border-color: var(--steel-blue); box-shadow: 0 0 0 3px var(--alice-blue);
}
.hint { font-weight: 500; }

/* Buttons */
.btn-primary {
    background: var(--brand); color: #fff; border: none; padding: .6rem 1.2rem; border-radius: var(--radius-sm);
    cursor: pointer; font-size: .9rem; font-weight: 600; text-decoration: none; display: inline-block;
}
.btn-primary:hover { background: var(--brand-strong); }
.btn-primary:disabled { opacity: .6; cursor: not-allowed; }
.btn-secondary { background: var(--surface); color: var(--brand); border: 1px solid var(--brand); padding: .6rem 1.2rem; border-radius: var(--radius-sm); cursor: pointer; text-decoration: none; display: inline-block; font-weight: 600; }
.btn-link { background: none; border: none; color: var(--brand-strong); cursor: pointer; text-decoration: underline; padding: 0; font-size: inherit; }
.btn-block { width: 100%; text-align: center; }

/* Alerts */
.alert-danger { color: #991b1b; background: var(--danger-tint); border: 1px solid #f6d5d5; padding: .75rem; border-radius: var(--radius-sm); margin: .5rem 0; }
.alert-success { color: #166534; background: var(--success-tint); border: 1px solid #c5ecd2; padding: .75rem; border-radius: var(--radius-sm); margin: .5rem 0; }

/* Badges (stati ticket) */
.badge { display: inline-block; padding: .25em .7em; border-radius: 1em; font-size: .75rem; font-weight: 700; border: 1px solid transparent; }
.badge-info { background: var(--info-tint); color: var(--info); border-color: #c7d7ff; }
.badge-warning { background: var(--warning-tint); color: var(--warning); border-color: #fde68a; }
.badge-danger { background: var(--danger-tint); color: var(--danger); border-color: #f6d5d5; }
.badge-success { background: var(--success-tint); color: var(--success); border-color: #c5ecd2; }
.badge-secondary { background: var(--alice-blue); color: var(--steel-azure); border-color: var(--wisteria-blue); }

/* Table */
.data-table { width: 100%; border-collapse: collapse; background: var(--surface); border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow-sm); }
.data-table th, .data-table td { padding: .75rem 1rem; text-align: left; border-bottom: 1px solid var(--line); font-size: .875rem; }
.data-table th { background: #fafbfc; font-weight: 600; color: var(--muted); }
.data-table tbody tr:hover { background: var(--alice-blue); }

/* Page header */
.page-header { display: flex; align-items: center; gap: 1rem; margin-bottom: 1.5rem; }
.page-header h1 { margin: 0; font-size: 1.5rem; }
.page-header > a { margin-left: auto; }

/* Card generica (info ticket, thread, allegati, form) */
.ticket-info, .ticket-thread, .ticket-allegati, .form-card {
    background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
    padding: 1.25rem; margin-bottom: 1.5rem; box-shadow: var(--shadow-sm);
}
.ticket-info h1, .ticket-thread h2, .ticket-allegati h2 { margin-top: 0; }
.ticket-info blockquote { margin: .75rem 0 0; padding: .75rem; background: var(--bg); border-left: 3px solid var(--wisteria-blue); border-radius: var(--radius-sm); }

/* Chat: messaggi a bolle (il cliente "io" a destra/blu, l'assistenza a sinistra/chiaro) */
.chat { display: flex; flex-direction: column; gap: .7rem; margin-bottom: 1rem; }
.msg { max-width: 82%; padding: .55rem .8rem; border-radius: 14px; font-size: .9rem; }
.msg .meta { display: block; font-size: .72rem; font-weight: 700; margin-bottom: .2rem; opacity: .85; }
.msg .testo { white-space: pre-wrap; margin: 0; }
.msg.mio { align-self: flex-end; background: var(--steel-azure); color: #fff; border-bottom-right-radius: 3px; }
.msg.mio .meta { color: var(--alice-blue); }
.msg.staff { align-self: flex-start; background: var(--alice-blue); border: 1px solid var(--wisteria-blue); border-bottom-left-radius: 3px; }

.reply-form, .upload-form { margin-top: 1rem; border-top: 1px solid var(--line); padding-top: 1rem; }
.reply-form h3, .upload-form h3 { margin: 0 0 .5rem; font-size: 1rem; }
.textarea-full { width: 100%; padding: .5rem; border: 1px solid var(--line); border-radius: var(--radius-sm); resize: vertical; font-size: .9rem; font-family: inherit; }

.allegati-list { list-style: none; padding: 0; margin: 0; }
.allegati-list li { padding: .5rem 0; border-bottom: 1px solid var(--line); }
.allegati-list a { color: var(--brand-strong); font-weight: 500; }

.text-muted { color: var(--muted); font-size: .875rem; }
.portal-actions { display: flex; gap: 1rem; margin-top: 1.5rem; }
.empty-state { text-align: center; padding: 3rem; color: var(--muted); background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
.loading { color: var(--muted); }
.form-actions { display: flex; align-items: center; gap: 1rem; margin-top: 1rem; }
.pagination { display: flex; gap: .5rem; margin-top: 1rem; }
.btn-page { padding: .4rem .8rem; border: 1px solid var(--line); background: var(--surface); border-radius: var(--radius-sm); cursor: pointer; }
.btn-page.active { background: var(--brand); color: #fff; border-color: var(--brand); }
