/* ============================================================
   whatsapp.ilbarone.net — stile coerente con gli altri gestionali
   ============================================================ */

:root {
    --c-bg:        #f4f6fa;
    --c-surface:   #ffffff;
    --c-border:    #e3e8ef;
    --c-text:      #1a2233;
    --c-text-2:    #4b5567;
    --c-muted:     #7b8597;
    --c-primary:   #1e3a8a;
    --c-primary-2: #2563eb;
    --c-wa:        #25d366;
    --c-success:   #15803d;
    --c-danger:    #b91c1c;
    --c-warning:   #b45309;
    --c-dark:      #0b1426;
    --c-dark-2:    #15213b;
    --shadow:      0 1px 3px rgba(15, 23, 42, .08), 0 1px 2px rgba(15, 23, 42, .04);
    --radius:      6px;
}

* { box-sizing: border-box; }

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
    margin: 0;
    background: var(--c-bg);
    color: var(--c-text);
    font-size: 14px;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}
body.page { min-height: 100vh; display: flex; flex-direction: column; }

/* ---------- topbar ---------- */
.topbar {
    position: sticky; top: 0; z-index: 100;
    background: linear-gradient(180deg, var(--c-dark) 0%, var(--c-dark-2) 100%);
    border-bottom: 3px solid var(--c-wa);
    color: #fff;
    box-shadow: 0 2px 8px rgba(15, 23, 42, .15);
}
.topbar-inner {
    max-width: 1400px; margin: 0 auto; padding: 0 20px;
    display: flex; align-items: center; height: 60px; gap: 28px;
}
.brand-link { display: flex; align-items: center; gap: 10px; color: #fff; text-decoration: none; }
.brand-mark {
    display: inline-flex; align-items: center; justify-content: center;
    width: 32px; height: 32px; border-radius: var(--radius);
    background: var(--c-wa); color: #06301a; font-weight: 700; font-size: 13px;
}
.brand-text { font-weight: 600; letter-spacing: .2px; }
.mainnav { display: flex; gap: 4px; margin-right: auto; }
.mainnav a {
    color: #c9d2e3; text-decoration: none; padding: 8px 14px;
    border-radius: var(--radius); font-weight: 500;
}
.mainnav a:hover { background: rgba(255, 255, 255, .08); color: #fff; }
.mainnav a.is-active { background: rgba(37, 211, 102, .18); color: #fff; }
.topbar-right { display: flex; align-items: center; gap: 12px; }
.topbar-right .user { color: #9fb0c9; font-size: 13px; }

/* ---------- layout ---------- */
.wrap { flex: 1; max-width: 1400px; width: 100%; margin: 0 auto; padding: 24px 20px 48px; }
.page-title { font-size: 20px; margin: 0 0 18px; font-weight: 600; }
.grid-2 { display: grid; grid-template-columns: minmax(320px, 420px) 1fr; gap: 20px; align-items: start; }
@media (max-width: 900px) { .grid-2 { grid-template-columns: 1fr; } }

.card {
    background: var(--c-surface); border: 1px solid var(--c-border);
    border-radius: var(--radius); box-shadow: var(--shadow);
    padding: 18px; margin-bottom: 18px;
}
.card h2 { font-size: 15px; margin: 0 0 12px; font-weight: 600; color: var(--c-text-2); }

.footer { text-align: center; color: var(--c-muted); font-size: 12px; padding: 16px; }

/* ---------- form ---------- */
label { display: block; margin-bottom: 14px; font-weight: 500; color: var(--c-text-2); }
label.inline { display: inline-block; margin: 0 8px 0 0; }
label small { display: block; font-weight: 400; color: var(--c-muted); margin-top: 4px; }
input[type=text], input[type=password], textarea {
    width: 100%; margin-top: 6px; padding: 8px 10px;
    border: 1px solid #d8dee8; border-radius: var(--radius);
    font: inherit; color: var(--c-text); background: #fff;
}
input:focus, textarea:focus { outline: 2px solid rgba(37, 99, 235, .25); border-color: var(--c-primary-2); }
textarea { resize: vertical; }

.btn {
    display: inline-block; padding: 8px 16px; border: 1px solid transparent;
    border-radius: var(--radius); font: inherit; font-weight: 500;
    cursor: pointer; text-decoration: none;
}
.btn-primary { background: var(--c-primary); color: #fff; }
.btn-primary:hover { background: var(--c-primary-2); }
.btn-ghost { background: transparent; border-color: rgba(255, 255, 255, .25); color: #dbe3f0; }
.btn-ghost:hover { background: rgba(255, 255, 255, .1); }
.btn-sm { padding: 6px 12px; font-size: 13px; }
.btn-block { width: 100%; }

.toolbar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 14px; }
.toolbar input[type=text] { width: 200px; margin-top: 0; }
.auto-note { margin-left: auto; font-size: 12px; }

/* ---------- tabelle ---------- */
.table { width: 100%; border-collapse: collapse; font-size: 13px; }
.table th, .table td { padding: 8px 10px; border-bottom: 1px solid var(--c-border); text-align: left; vertical-align: top; }
.table thead th { background: #f8fafc; color: var(--c-text-2); font-weight: 600; white-space: nowrap; }
.table tbody tr:hover { background: #fbfcfe; }
.table-kv th { width: 200px; color: var(--c-text-2); font-weight: 500; }
.nowrap { white-space: nowrap; }
.col-body { max-width: 560px; }
.msg-body { white-space: pre-wrap; word-break: break-word; }
tr.dir-in  td:first-child { box-shadow: inset 3px 0 0 var(--c-wa); }
tr.dir-out td:first-child { box-shadow: inset 3px 0 0 var(--c-primary-2); }

/* ---------- badge / pill ---------- */
.badge, .pill {
    display: inline-block; padding: 2px 8px; border-radius: 999px;
    font-size: 11px; font-weight: 600; letter-spacing: .3px;
    background: #eef2f7; color: var(--c-text-2);
}
.pill-in  { background: #dcfce7; color: #14532d; }
.pill-out { background: #dbeafe; color: #1e3a8a; }
.badge-ok, .badge-delivered, .badge-read { background: #dcfce7; color: var(--c-success); }
.badge-received { background: #e0f2fe; color: #0369a1; }
.badge-sent { background: #fef3c7; color: var(--c-warning); }
.badge-err, .badge-failed { background: #fee2e2; color: var(--c-danger); }

.muted { color: var(--c-muted); }
.hint { color: var(--c-muted); font-size: 12px; margin-top: 12px; }
.err-text { color: var(--c-danger); font-size: 12px; margin-top: 4px; }
.alert { padding: 10px 12px; border-radius: var(--radius); margin-bottom: 14px; font-size: 13px; }
.alert-danger { background: #fee2e2; color: var(--c-danger); }

.code {
    background: #0b1426; color: #d6e2f5; padding: 12px; border-radius: var(--radius);
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: 12px; line-height: 1.45; overflow: auto; max-height: 480px; white-space: pre-wrap; word-break: break-word;
}
code { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 12px; }

.thumb { max-width: 180px; max-height: 180px; border-radius: var(--radius); border: 1px solid var(--c-border); margin-top: 6px; }
audio { display: block; margin-top: 6px; max-width: 320px; }

.log-entry summary { cursor: pointer; display: flex; gap: 10px; align-items: center; font-size: 13px; }
details summary { cursor: pointer; color: var(--c-text-2); }
details[open] > summary { margin-bottom: 10px; }

/* ---------- login ---------- */
.login-body {
    display: flex; align-items: center; justify-content: center; min-height: 100vh;
    background: linear-gradient(160deg, var(--c-dark) 0%, #1c2f52 100%);
}
.login-card {
    background: #fff; padding: 28px; border-radius: 10px; width: 340px;
    box-shadow: 0 10px 25px rgba(0, 0, 0, .35);
}
.login-brand { display: flex; align-items: center; gap: 10px; font-weight: 600; margin-bottom: 20px; }
