/* ============================================================
   Area Clienti — Studio Legale Iodice
   Palette e tipografia coerenti col sito principale.
   ============================================================ */

:root {
    --bg: #ffffff;
    --bg-soft: #f7f5f0;
    --bg-alt: #f1ede4;
    --text: #1a1a1a;
    --text-muted: #5a5a5a;
    --navy: #0f1f3d;
    --navy-light: #1a2f56;
    --navy-dark: #0a1428;
    --gold: #b8924a;
    --gold-light: #d4ac6a;
    --danger: #b3261e;
    --success: #2e7d32;
    --line: #e6e1d6;
    --shadow: 0 6px 24px rgba(15, 31, 61, 0.08);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
    font-family: 'Lato', system-ui, -apple-system, sans-serif;
    background: var(--bg-soft);
    color: var(--text);
    line-height: 1.55;
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4 {
    font-family: 'Cormorant Garamond', Georgia, serif;
    color: var(--navy);
    font-weight: 600;
    margin: 0 0 .5em;
    letter-spacing: .01em;
}
h1 { font-size: clamp(1.8rem, 3.5vw, 2.6rem); }
h2 { font-size: 1.4rem; }
h3 { font-size: 1.1rem; }

a { color: var(--navy); text-decoration: none; border-bottom: 1px solid transparent; transition: border-color .15s; }
a:hover, a:focus { border-bottom-color: var(--gold); }

button { font-family: inherit; cursor: pointer; }

/* ---------- Layout principale ---------- */
.shell { display: flex; min-height: 100vh; }
.sidebar {
    width: 260px;
    background: var(--navy);
    color: #fff;
    padding: 1.5rem 1.25rem;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}
.sidebar a, .sidebar button.nav {
    display: flex; align-items: center; gap: .6rem;
    color: rgba(255,255,255,.78);
    padding: .6rem .75rem;
    border-radius: 6px;
    border: none; background: transparent; width: 100%; text-align: left;
    font-size: .98rem;
}
.sidebar a.active, .sidebar button.nav.active,
.sidebar a:hover, .sidebar button.nav:hover {
    background: rgba(255,255,255,.06); color: #fff; border-bottom: none;
}
.sidebar .brand {
    padding-bottom: 1.1rem;
    margin-bottom: .3rem;
    border-bottom: 1px solid rgba(255,255,255,.12);
}
.sidebar .brand::before {
    content: '';
    display: block;
    width: 28px; height: 2px;
    background: var(--gold);
    margin-bottom: .7rem;
}
.sidebar .brand-text {
    font-family: 'Cormorant Garamond', Georgia, serif;
    font-weight: 600;
    font-size: 1.25rem;
    line-height: 1.15;
    color: #fff;
    letter-spacing: .01em;
    white-space: nowrap;
}
.sidebar .brand-sub {
    font-size: .68rem;
    color: rgba(255,255,255,.55);
    text-transform: uppercase;
    letter-spacing: .14em;
    margin-top: .35rem;
}
.sidebar .badge {
    margin-left: auto; background: var(--gold); color: var(--navy);
    font-size: .72rem; font-weight: 700; padding: .15rem .45rem; border-radius: 10px;
    min-width: 22px; text-align: center;
}
.sidebar .footer-info {
    margin-top: auto; font-size: .82rem; color: rgba(255,255,255,.6);
    padding-top: 1rem; border-top: 1px solid rgba(255,255,255,.1);
    word-break: break-word;
}

.main { flex: 1; padding: 2rem 2.5rem; max-width: 1100px; }
.main header.page-head { margin-bottom: 1.5rem; }
.main header.page-head p { color: var(--text-muted); margin: 0; }

/* ---------- Sidebar più larga per evitare wrap di "Studio Legale Iodice" ---------- */
.sidebar { width: 280px; }

/* ============== Tablet & mobile ============== */
@media (max-width: 900px) {
    .shell { flex-direction: column; }
    .sidebar {
        width: auto;
        position: sticky; top: 0; z-index: 100;
        flex-direction: column;
        padding: .8rem 1rem .6rem;
        gap: .5rem;
    }
    .sidebar .brand {
        padding-bottom: .55rem; margin-bottom: 0;
        border-bottom: 1px solid rgba(255,255,255,.1);
    }
    .sidebar .brand::before { display: none; }
    .sidebar .brand-text { font-size: 1.05rem; }
    .sidebar .brand-sub { display: none; }
    .sidebar nav {
        display: flex; flex-wrap: nowrap; overflow-x: auto;
        gap: .25rem; -webkit-overflow-scrolling: touch;
        margin: 0 -1rem; padding: 0 1rem;
    }
    .sidebar nav::-webkit-scrollbar { display: none; }
    .sidebar a, .sidebar button.nav {
        width: auto; white-space: nowrap;
        padding: .55rem .85rem;
        min-height: 40px; font-size: .92rem;
    }
    .sidebar .footer-info { display: none; }
    .main { padding: 1.25rem 1rem; max-width: 100%; }
}

@media (max-width: 600px) {
    .main { padding: 1rem .85rem; }
    .card { padding: 1rem 1rem; }
    h1 { font-size: 1.4rem; }
    h2 { font-size: 1.2rem; }
    .main header.page-head p { font-size: .92rem; }
}

@media (max-width: 480px) {
    .auth-card { padding: 1.6rem 1.25rem; }
    .auth-card h1 { font-size: 1.4rem; }
    .kvs { grid-template-columns: 1fr; gap: 0 .5rem; }
    .kvs dt { margin-top: .55rem; font-size: .78rem; text-transform: uppercase; letter-spacing: .04em; }
    .kvs dd { margin-bottom: .15rem; }
}

/* ---------- Cards e tabelle ---------- */
.card {
    background: var(--bg); border: 1px solid var(--line); border-radius: 8px;
    padding: 1.25rem 1.5rem; box-shadow: var(--shadow);
    margin-bottom: 1.25rem;
}
.card h2 { margin-top: 0; }

.kvs { display: grid; grid-template-columns: max-content 1fr; gap: .35rem 1rem; }
.kvs dt { color: var(--text-muted); font-size: .9rem; }
.kvs dd { margin: 0; font-weight: 500; }

/* Wrapper scrollabile orizzontalmente su mobile */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table.list {
    width: 100%; border-collapse: collapse; font-size: .95rem;
    min-width: 600px; /* su schermi stretti scrolla orizzontale */
}
table.list th, table.list td {
    text-align: left; padding: .7rem .6rem; border-bottom: 1px solid var(--line);
    white-space: nowrap;
}
table.list td.wrap { white-space: normal; }
table.list th {
    background: var(--bg-alt); color: var(--navy); font-weight: 600; font-size: .85rem;
    text-transform: uppercase; letter-spacing: .05em;
}
table.list tr:hover td { background: var(--bg-soft); }
@media (max-width: 600px) {
    table.list { font-size: .88rem; min-width: 520px; }
    table.list th, table.list td { padding: .55rem .45rem; }
}

.empty {
    text-align: center; color: var(--text-muted); font-style: italic;
    padding: 2rem 1rem;
}

/* ---------- Pill / status ---------- */
.pill {
    display: inline-block; font-size: .78rem; font-weight: 600;
    padding: .2rem .6rem; border-radius: 12px;
    background: var(--bg-alt); color: var(--navy);
}
.pill-status-in-corso     { background: #dceaff; color: #0a3a8a; }
.pill-status-non-iniziata { background: #ece9e4; color: #555; }
.pill-status-definita     { background: #d9efd9; color: #1f6a1f; }
.pill-status-proposto     { background: #fff1cc; color: #7a5a00; }
.pill-status-confermato   { background: #d9efd9; color: #1f6a1f; }
.pill-status-annullato    { background: #f5d3d0; color: #8a1a14; }

/* ---------- Form ---------- */
.field { margin-bottom: 1rem; }
.field label { display: block; font-size: .9rem; color: var(--navy); margin-bottom: .25rem; font-weight: 600; }
.field input, .field textarea, .field select {
    width: 100%; padding: .65rem .8rem;
    border: 1px solid var(--line); border-radius: 6px;
    font: inherit; color: inherit; background: var(--bg);
}
.field input:focus, .field textarea:focus, .field select:focus {
    outline: 2px solid var(--gold); outline-offset: 1px; border-color: var(--gold);
}
.field .hint { font-size: .82rem; color: var(--text-muted); margin-top: .25rem; }
.field .err { color: var(--danger); font-size: .85rem; margin-top: .25rem; }

button.primary, button.secondary, button.ghost, button.danger {
    display: inline-flex; align-items: center; gap: .4rem;
    padding: .65rem 1.1rem; border-radius: 6px; font-weight: 600; font-size: .95rem;
    border: 1px solid transparent; cursor: pointer; transition: filter .15s, background .15s;
}
button.primary  { background: var(--navy); color: #fff; }
button.primary:hover, button.primary:focus  { filter: brightness(1.15); }
button.secondary{ background: var(--bg); color: var(--navy); border-color: var(--navy); }
button.secondary:hover { background: var(--bg-alt); }
button.ghost    { background: transparent; color: var(--navy); }
button.ghost:hover { background: var(--bg-alt); }
button.danger   { background: var(--danger); color: #fff; }
button[disabled] { opacity: .55; cursor: not-allowed; }

/* ---------- Pagine di login (cliente / admin) ---------- */
.auth-shell {
    min-height: 100vh; display: grid; place-items: center;
    background: linear-gradient(135deg, var(--bg-alt) 0%, var(--bg-soft) 100%);
    padding: 1.5rem;
}
.auth-card {
    background: #fff; padding: 2.25rem 2.5rem; max-width: 460px; width: 100%;
    border-radius: 10px; box-shadow: var(--shadow); border-top: 4px solid var(--gold);
}
.auth-card .brand-row {
    margin-bottom: 1.5rem;
    text-align: left;
}
.auth-card .brand-row::before {
    content: '';
    display: block;
    width: 36px; height: 2px;
    background: var(--gold);
    margin-bottom: .85rem;
}
.auth-card .brand-row strong {
    font-family: 'Cormorant Garamond', Georgia, serif;
    font-weight: 600;
    font-size: 1.5rem;
    color: var(--navy);
    line-height: 1.15;
    display: block;
}
.auth-card .brand-row .brand-sub {
    font-size: .72rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: .14em;
    margin-top: .35rem;
}
.auth-card h1 { font-size: 1.6rem; margin-bottom: .2rem; }
.auth-card p.lead { color: var(--text-muted); margin-top: 0; }
.auth-card .actions { display: flex; gap: .6rem; margin-top: 1rem; }
.auth-card .feedback { padding: .7rem .8rem; border-radius: 6px; font-size: .9rem; margin-top: .8rem; }
.auth-card .feedback.ok  { background: #e6f1e6; color: var(--success); }
.auth-card .feedback.err { background: #fbe3e1; color: var(--danger); }
.auth-card .small-note { font-size: .82rem; color: var(--text-muted); margin-top: 1.25rem; text-align: center; }

/* ---------- Chat ---------- */
.chat-window {
    border: 1px solid var(--line); border-radius: 8px;
    background: var(--bg); height: 460px; display: flex; flex-direction: column;
}
.chat-messages {
    flex: 1; overflow-y: auto; padding: 1rem 1.25rem;
    display: flex; flex-direction: column; gap: .6rem;
}
.msg { max-width: 78%; padding: .55rem .85rem; border-radius: 14px; line-height: 1.45; word-wrap: break-word; }
.msg .meta { font-size: .72rem; color: var(--text-muted); margin-top: .2rem; }
.msg.client { align-self: flex-end; background: var(--navy); color: #fff; }
.msg.client .meta { color: rgba(255,255,255,.7); }
.msg.studio { align-self: flex-start; background: var(--bg-alt); color: var(--text); }
.chat-input {
    border-top: 1px solid var(--line); padding: .65rem; display: flex; gap: .5rem;
}
.chat-input textarea {
    flex: 1; resize: none; border: 1px solid var(--line); border-radius: 6px;
    padding: .55rem .7rem; font: inherit; min-height: 44px; max-height: 140px;
}
.chat-input button { min-height: 44px; }
@media (max-width: 600px) {
    .chat-window { height: 60vh; min-height: 380px; }
    .chat-messages { padding: .75rem .85rem; }
    .msg { max-width: 86%; font-size: .94rem; }
}

/* Conversazioni studio: griglia 2-col desktop, stack su mobile */
.convo-grid { display: grid; grid-template-columns: 280px 1fr; gap: 1rem; min-height: 520px; }
.convo-grid > .card { margin-bottom: 0; }
@media (max-width: 800px) {
    .convo-grid { grid-template-columns: 1fr; min-height: 0; }
    .convo-grid .convo-list-card { max-height: 220px; overflow-y: auto; }
}

/* ---------- Tabs ---------- */
.tabs {
    display: flex; gap: 0; border-bottom: 1px solid var(--line); margin-bottom: 1.25rem;
    overflow-x: auto;
}
.tabs button {
    background: transparent; border: none; padding: .8rem 1.2rem; font-weight: 600;
    color: var(--text-muted); border-bottom: 3px solid transparent;
}
.tabs button.active { color: var(--navy); border-bottom-color: var(--gold); }
.tab-panel { display: none; }
.tab-panel.active { display: block; }

/* ---------- Toast ---------- */
.toast {
    position: fixed; bottom: 1.5rem; right: 1.5rem;
    background: var(--navy); color: #fff; padding: .8rem 1.1rem;
    border-radius: 6px; box-shadow: var(--shadow);
    opacity: 0; transform: translateY(10px); transition: all .25s;
    z-index: 1000; max-width: 360px;
}
.toast.show { opacity: 1; transform: none; }
.toast.err { background: var(--danger); }

/* ---------- Font face (self-hosted in assets/fonts/) ---------- */
@font-face {
    font-family: 'Cormorant Garamond';
    font-style: normal; font-weight: 400; font-display: swap;
    src: url('fonts/co3bmX5slCNuHLi8bLeY9MK7whWMhyjYqXtKky2F7g.woff2') format('woff2');
}
@font-face {
    font-family: 'Cormorant Garamond';
    font-style: normal; font-weight: 600; font-display: swap;
    src: url('fonts/co3bmX5slCNuHLi8bLeY9MK7whWMhyjYqXtKky2F7g.woff2') format('woff2');
}
@font-face {
    font-family: 'Lato';
    font-style: normal; font-weight: 400; font-display: swap;
    src: url('fonts/S6uyw4BMUTPHjxAwXjeu.woff2') format('woff2');
}
@font-face {
    font-family: 'Lato';
    font-style: normal; font-weight: 700; font-display: swap;
    src: url('fonts/S6u9w4BMUTPHh6UVSwiPGQ3q5d0.woff2') format('woff2');
}
