﻿/* =============================================================================
   OiO Tasks — tema "Linear" con la palette di OiO.WebApp (oio-linear.css)
   -----------------------------------------------------------------------------
   Token su :root (chiaro, default) e [data-theme=dark]. Nei componenti si usano
   solo i token, mai valori esadecimali. Classi condivise da più componenti qui;
   gli stili propri di un componente stanno nel suo <style>.
   ============================================================================= */

:root,
[data-theme=light] {
    /* Accento: OTG Blue (design system OTG), come OiO.WebApp */
    --accent: #004680;
    --accent-rgb: 0, 70, 128;
    --accent-hover: #00365f;
    --accent-active: #002a4a;
    --accent-subtle: #e6eef5;
    --on-accent: #ffffff;

    /* Neutri */
    --bg: #fbfbfc;
    --surface: #ffffff;
    --surface-2: #f7f7f8;
    --sidebar-bg: #f7f7f8;
    --hover: rgba(15, 17, 23, 0.04);
    --active: rgba(15, 17, 23, 0.07);
    --border: #e8e8ec;
    --border-strong: #d9d9df;
    --text: #1f2023;
    --text-strong: #0f1117;
    --text-2: #5d6068;
    --text-3: #8a8f98;

    /* Semantici */
    --green: #1f8a4c;
    --green-bg: #e7f5ec;
    --amber: #b26a00;
    --amber-bg: #fdf3e1;
    --red: #c02b0a;
    --red-bg: #fdecea;
    --blue: #2563eb;
    --blue-bg: #e8effd;
    --violet: #6d4bd1;
    --violet-bg: #f0ebfc;
    --gray-bg: #f1f1f3;

    --radius-sm: 4px;
    --radius: 6px;
    --radius-lg: 8px;
    --radius-xl: 12px;

    --shadow-xs: 0 1px 2px rgba(15, 17, 23, 0.04);
    --shadow-pop: 0 0 0 1px rgba(15, 17, 23, 0.06), 0 4px 12px rgba(15, 17, 23, 0.08), 0 16px 32px -8px rgba(15, 17, 23, 0.10);
    --ring: 0 0 0 3px rgba(var(--accent-rgb), 0.18);
    --overlay: rgba(15, 17, 23, 0.32);

    --font: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    --font-mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    --sidebar-w: 232px;
    --header-h: 48px;
    --h-control: 30px;
}

[data-theme=dark] {
    --accent: #4b8fd6;
    --accent-rgb: 75, 143, 214;
    --accent-hover: #6aa3df;
    --accent-active: #8bb8e8;
    --accent-subtle: rgba(75, 143, 214, 0.16);
    --on-accent: #0b1220;

    --bg: #0f1013;
    --surface: #16171b;
    --surface-2: #1b1c21;
    --sidebar-bg: #121317;
    --hover: rgba(255, 255, 255, 0.05);
    --active: rgba(255, 255, 255, 0.08);
    --border: #26272d;
    --border-strong: #33343b;
    --text: #e3e4e8;
    --text-strong: #f5f5f7;
    --text-2: #a2a5ad;
    --text-3: #6f737c;

    --green: #4cc38a;
    --green-bg: rgba(76, 195, 138, 0.14);
    --amber: #f0b45b;
    --amber-bg: rgba(240, 180, 91, 0.14);
    --red: #f2785c;
    --red-bg: rgba(242, 120, 92, 0.14);
    --blue: #6f9cf5;
    --blue-bg: rgba(111, 156, 245, 0.14);
    --violet: #a58cf0;
    --violet-bg: rgba(165, 140, 240, 0.14);
    --gray-bg: rgba(255, 255, 255, 0.06);

    --shadow-xs: 0 1px 2px rgba(0, 0, 0, 0.3);
    --shadow-pop: 0 0 0 1px rgba(255, 255, 255, 0.06), 0 8px 24px rgba(0, 0, 0, 0.45);
    --overlay: rgba(0, 0, 0, 0.55);
}

/* ─── Base ────────────────────────────────────────────────────────────────── */

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

html, body { height: 100%; }

body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font-family: var(--font);
    font-size: 13px;
    line-height: 1.5;
    font-feature-settings: "cv11", "ss01";
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    letter-spacing: -0.005em;
}

h1, h2, h3, h4 { margin: 0; font-weight: 600; letter-spacing: -0.015em; color: var(--text-strong); }
h1 { font-size: 18px; }
h2 { font-size: 15px; }
h3 { font-size: 13px; }

a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-hover); }

::selection { background: rgba(var(--accent-rgb), 0.18); }

:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }

* { scrollbar-width: thin; scrollbar-color: var(--border-strong) transparent; }
*::-webkit-scrollbar { width: 10px; height: 10px; }
*::-webkit-scrollbar-thumb { background: var(--border-strong); border: 3px solid transparent; border-radius: 10px; background-clip: padding-box; }

.muted { color: var(--text-2); }
.faint { color: var(--text-3); }
.small { font-size: 12px; }
.xsmall { font-size: 11px; }
.mono { font-family: var(--font-mono); font-size: 12px; }
.num { font-variant-numeric: tabular-nums; }
.strong { font-weight: 600; }
.ellipsis { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.flex { display: flex; align-items: center; gap: 8px; }
.flex-col { display: flex; flex-direction: column; gap: 8px; }
.grow { flex: 1 1 auto; min-width: 0; }
.spacer { flex: 1 1 auto; }
.hidden { display: none !important; }

/* ─── Bottoni ─────────────────────────────────────────────────────────────── */

.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 6px;
    height: var(--h-control); padding: 0 12px;
    border: 1px solid var(--border-strong); border-radius: var(--radius);
    background: var(--surface); color: var(--text);
    font: inherit; font-weight: 500; white-space: nowrap;
    cursor: pointer; transition: background .12s, border-color .12s, color .12s;
}
.btn:hover { background: var(--surface-2); border-color: var(--border-strong); }
.btn:disabled { opacity: .45; cursor: default; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.btn-primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.btn-ghost { background: transparent; border-color: transparent; color: var(--text-2); }
.btn-ghost:hover { background: var(--hover); color: var(--text); }
.btn-danger { color: var(--red); }
.btn-danger:hover { background: var(--red-bg); border-color: var(--red); }
.btn-sm { height: 26px; padding: 0 8px; font-size: 12px; }
.btn-icon { width: var(--h-control); padding: 0; }
.btn-sm.btn-icon { width: 26px; }

/* ─── Form ────────────────────────────────────────────────────────────────── */

.form-input, .form-select, .form-textarea {
    width: 100%; min-height: var(--h-control); padding: 4px 10px;
    border: 1px solid var(--border-strong); border-radius: var(--radius);
    background: var(--surface); color: var(--text); font: inherit;
    transition: border-color .12s, box-shadow .12s;
}
.form-textarea { min-height: 72px; resize: vertical; padding: 8px 10px; }
.form-input:focus, .form-select:focus, .form-textarea:focus { outline: none; border-color: var(--accent); box-shadow: var(--ring); }
.form-input:disabled, .form-select:disabled, .form-textarea:disabled { background: var(--surface-2); color: var(--text-2); }
.form-label { display: block; margin-bottom: 4px; font-size: 12px; font-weight: 500; color: var(--text-2); }
.form-label.required::after { content: " *"; color: var(--red); }
.form-group { margin-bottom: 12px; }
.form-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 12px; }
.form-check { display: inline-flex; align-items: center; gap: 6px; cursor: pointer; user-select: none; }
.form-check input { accent-color: var(--accent); }
.search-input {
    height: var(--h-control); min-width: 220px; padding: 0 10px 0 30px;
    border: 1px solid var(--border-strong); border-radius: var(--radius); background: var(--surface) no-repeat 9px center;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%238a8f98' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='11' cy='11' r='8'/%3E%3Cpath d='m21 21-4.3-4.3'/%3E%3C/svg%3E");
    color: var(--text); font: inherit;
}
.search-input:focus { outline: none; border-color: var(--accent); box-shadow: var(--ring); }

/* ─── Badge, chip, avatar ─────────────────────────────────────────────────── */

.badge {
    display: inline-flex; align-items: center; gap: 4px; height: 20px; padding: 0 7px;
    border-radius: 999px; font-size: 11px; font-weight: 500; white-space: nowrap;
    background: var(--gray-bg); color: var(--text-2);
}
.badge-green { background: var(--green-bg); color: var(--green); }
.badge-amber { background: var(--amber-bg); color: var(--amber); }
.badge-red { background: var(--red-bg); color: var(--red); }
.badge-blue { background: var(--blue-bg); color: var(--blue); }
.badge-violet { background: var(--violet-bg); color: var(--violet); }
.badge-accent { background: var(--accent-subtle); color: var(--accent); }
.badge-outline { background: transparent; border: 1px solid var(--border-strong); }

.avatar {
    display: inline-flex; align-items: center; justify-content: center; flex: none;
    width: 20px; height: 20px; border-radius: 50%;
    background: var(--accent-subtle); color: var(--accent);
    font-size: 9px; font-weight: 600; letter-spacing: 0;
}
.avatar-lg { width: 28px; height: 28px; font-size: 11px; }

.task-id { font-family: var(--font-mono); font-size: 11px; color: var(--text-3); }

/* ─── Card, tabelle ───────────────────────────────────────────────────────── */

.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); box-shadow: var(--shadow-xs); }

.table { width: 100%; border-collapse: collapse; }
.table th {
    position: sticky; top: 0; z-index: 1;
    padding: 6px 12px; text-align: left; font-size: 11px; font-weight: 500; color: var(--text-3);
    background: var(--surface-2); border-bottom: 1px solid var(--border);
}
.table td { padding: 7px 12px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.table tr:last-child td { border-bottom: none; }
.table tr.clickable { cursor: pointer; }
.table tr.clickable:hover td { background: var(--hover); }

.empty { padding: 32px 16px; text-align: center; color: var(--text-3); }
.loading-fade { opacity: .55; transition: opacity .15s; pointer-events: none; }

/* ─── Toolbar di vista ────────────────────────────────────────────────────── */

.view { display: flex; flex-direction: column; height: 100%; min-height: 0; }
.view-header {
    display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
    min-height: var(--header-h); padding: 8px 20px; border-bottom: 1px solid var(--border); background: var(--surface);
}
.view-header h1 { font-size: 14px; }
.view-body { --view-pad-y: 16px; flex: 1 1 auto; min-height: 0; overflow: auto; padding: var(--view-pad-y) 20px; }
/* lo sticky si ferma sotto il padding del contenitore: l'header risale del padding, altrimenti le righe gli scorrono sopra */
.view-body .table th { top: calc(-1 * var(--view-pad-y)); }

/* ─── Menu a tendina ──────────────────────────────────────────────────────── */

.menu {
    position: absolute; z-index: 50; min-width: 180px; padding: 4px;
    background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); box-shadow: var(--shadow-pop);
}
.menu-item {
    display: flex; align-items: center; gap: 8px; width: 100%; padding: 6px 8px;
    border: none; border-radius: var(--radius-sm); background: none; color: var(--text); font: inherit; text-align: left; cursor: pointer;
}
.menu-item:hover { background: var(--hover); }
.menu-item.danger { color: var(--red); }
.menu-sep { height: 1px; margin: 4px 0; background: var(--border); }
.menu-label { padding: 4px 8px; font-size: 11px; color: var(--text-3); }

/* ─── Modale e pannello laterale ──────────────────────────────────────────── */

.overlay { position: fixed; inset: 0; z-index: 100; background: var(--overlay); display: flex; align-items: flex-start; justify-content: center; padding-top: 10vh; }
.modal-card { width: min(520px, calc(100vw - 32px)); max-height: 80vh; display: flex; flex-direction: column; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-xl); box-shadow: var(--shadow-pop); }
.modal-header { display: flex; align-items: center; gap: 8px; padding: 14px 16px; border-bottom: 1px solid var(--border); }
.modal-body { padding: 16px; overflow: auto; }
.modal-footer { display: flex; justify-content: flex-end; gap: 8px; padding: 12px 16px; border-top: 1px solid var(--border); }

/* ─── Toast ───────────────────────────────────────────────────────────────── */

.toasts { position: fixed; right: 16px; bottom: 16px; z-index: 300; display: flex; flex-direction: column; gap: 8px; }
.toast {
    display: flex; align-items: center; gap: 8px; min-width: 240px; max-width: 420px; padding: 10px 12px;
    background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); box-shadow: var(--shadow-pop);
}
.toast-success { border-left: 3px solid var(--green); }
.toast-error { border-left: 3px solid var(--red); }
.toast-info { border-left: 3px solid var(--accent); }

/* ─── Contenuti HTML (corpo, note, chat) ──────────────────────────────────── */

.rich { overflow-wrap: anywhere; }
.rich p { margin: 0 0 6px; }
.rich p:last-child { margin-bottom: 0; }
.rich img { max-width: 100%; height: auto; border-radius: var(--radius-sm); }
.rich ul, .rich ol { margin: 4px 0; padding-left: 20px; }
.rich hr { border: none; border-top: 1px dashed var(--border-strong); margin: 10px 0; }
.rich table { border-collapse: collapse; }
.rich td, .rich th { border: 1px solid var(--border); padding: 2px 6px; }
.rich pre, .rich code { font-family: var(--font-mono); font-size: 12px; background: var(--surface-2); border-radius: var(--radius-sm); }
.rich pre { padding: 8px; overflow: auto; }

/* ─── Boot ────────────────────────────────────────────────────────────────── */

#app-loading { position: fixed; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 12px; color: var(--text-2); }
/* Logo OiO (come WebApp); nel tema scuro su fondo chiaro, la scritta blu non si leggerebbe */
.brand-logo { display: block; flex: none; width: auto; }
[data-theme=dark] .brand-logo { background: #fff; border-radius: 6px; padding: 2px 4px; }

.logo-mark {
    display: inline-flex; align-items: center; justify-content: center; width: 28px; height: 28px;
    border-radius: 7px; background: var(--accent); color: var(--on-accent); font-weight: 700; font-size: 13px; letter-spacing: -0.02em;
}
.loading-bar { width: 140px; height: 2px; overflow: hidden; border-radius: 2px; background: var(--border); }
.loading-bar-inner { width: 40%; height: 100%; background: var(--accent); animation: loading 1s ease-in-out infinite; }
@keyframes loading { 0% { transform: translateX(-100%); } 100% { transform: translateX(350%); } }

/* Tabelle raggruppate delle liste (Task aperti, I miei task, Ricerca avanzata, Progetti) */
.ot-group { margin-bottom: 18px; }
.ot-group-head { display: flex; align-items: center; gap: 8px; padding: 4px 2px 8px; cursor: pointer; user-select: none; }
.ot-table { overflow: visible; }
.ot-table .table { table-layout: fixed; }
.ot-table .table th:first-child { border-top-left-radius: var(--radius-lg); }
.ot-table .table th:last-child { border-top-right-radius: var(--radius-lg); }
.row-menu { position: relative; }
.row-high td:first-child { box-shadow: inset 2px 0 0 var(--amber); }
.strong-ish { font-weight: 500; color: var(--text-strong); }
td.late { color: var(--red); font-weight: 500; }

/* Chip di persone con rimozione (follower dei progetti, membri dei gruppi) */
.pe-chips { display: flex; flex-wrap: wrap; gap: 4px; margin-bottom: 6px; }
.pe-chip { display: inline-flex; align-items: center; gap: 5px; height: 24px; padding: 0 4px 0 2px; border: 1px solid var(--border); border-radius: 999px; background: var(--surface); font-size: 12px; }
.pe-chip-x { display: inline-flex; padding: 2px; border: none; border-radius: 50%; background: none; color: var(--text-3); cursor: pointer; }
.pe-chip-x:hover { background: var(--hover); color: var(--text); }
.pe-add { width: 220px; }
