/* ============================================================
 * main.css - Design system globale di SicurITIS
 * 
 * 
 *
 * @author Giannino
 * ============================================================ */

/* ---------- Variabili tema ---------- */
:root {
    /* Sfondi */
    --bg:           #000000;          /* sfondo principale */
    --surface:      #16181c;          /* card, sidebar */
    --surface-2:    #1d2025;          /* hover, input */
    --surface-3:    #22262c;          /* sfondi più chiari, tooltip */
    --border:       #2f3336;          /* divisori sottili */

    /* Testo */
    --text:         #e7e9ea;
    --text-muted:   #71767b;
    --text-strong:  #ffffff;

    /* Accenti */
    --accent:       #00d4ff;          /* cyan cyber: link, bottoni primari */
    --accent-hover: #00b8e0;
    --accent-soft:  rgba(0, 212, 255, 0.15);
    --success:      #00ba7c;
    --danger:       #f4212e;
    --danger-soft:  rgba(244, 33, 46, 0.12);
    --warning:      #ffad1f;

    /* Tipografia */
    --font-sans:    'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
    --font-mono:    'JetBrains Mono', 'Fira Code', Consolas, monospace;

    /* Raggi */
    --r-sm:   8px;
    --r-md:   12px;
    --r-lg:   16px;
    --r-pill: 9999px;

    /* Ombre */
    --shadow-sm:   0 1px 2px rgba(0, 0, 0, 0.4);
    --shadow-md:   0 4px 16px rgba(0, 0, 0, 0.5);
    --shadow-glow: 0 0 24px rgba(0, 212, 255, 0.25);

    /* Transizioni */
    --t-fast: 0.15s ease;
    --t-med:  0.3s ease;
}

/* ---------- Reset ---------- */
*, *::before, *::after {
    box-sizing: border-box;
}

html, body {
    margin: 0;
    padding: 0;
    background: var(--bg);
    color: var(--text);
    font-family: var(--font-sans);
    font-size: 15px;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    min-height: 100vh;
}

a {
    color: var(--accent);
    text-decoration: none;
    transition: color var(--t-fast);
}
a:hover { color: var(--accent-hover); }

button {
    font-family: inherit;
    cursor: pointer;
    border: none;
    background: none;
    color: inherit;
}

input, textarea, select {
    font-family: inherit;
    font-size: 1rem;
    color: var(--text);
}

img { max-width: 100%; display: block; }

h1, h2, h3, h4 {
    color: var(--text-strong);
    line-height: 1.25;
    margin: 0 0 0.5em 0;
    font-weight: 700;
}

h1 { font-size: 1.75rem; }
h2 { font-size: 1.4rem; }
h3 { font-size: 1.15rem; }

p { margin: 0 0 1em 0; }

/* Scrollbar custom (WebKit) */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: var(--bg); }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: var(--r-pill); }
::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }

/* ---------- Layout 3-colonne stile Twitter ---------- */
.app {
    display: grid;
    grid-template-columns: 275px minmax(0, 600px) 350px;
    gap: 0;
    max-width: 1280px;
    margin: 0 auto;
    min-height: 100vh;
}

.app__left  { border-right: 1px solid var(--border); position: sticky; top: 0; height: 100vh; overflow-y: auto; }
.app__main  { border-right: 1px solid var(--border); min-height: 100vh; }
.app__right { padding: 16px; position: sticky; top: 0; height: 100vh; overflow-y: auto; }

/* Header sticky in cima alla colonna centrale (stile Twitter) */
.main-header {
    position: sticky;
    top: 0;
    z-index: 10;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: saturate(180%) blur(12px);
    -webkit-backdrop-filter: saturate(180%) blur(12px);
    border-bottom: 1px solid var(--border);
    padding: 14px 18px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.main-header h1 {
    font-size: 1.25rem;
    margin: 0;
}

/* ---------- Bottoni ---------- */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 22px;
    border-radius: var(--r-pill);
    font-weight: 700;
    font-size: 0.95rem;
    transition: background var(--t-fast), transform var(--t-fast), box-shadow var(--t-fast);
    cursor: pointer;
    user-select: none;
    border: 1px solid transparent;
    color: var(--text-strong);
}

.btn-primary {
    background: var(--accent);
    color: #000;
}
.btn-primary:hover {
    background: var(--accent-hover);
    box-shadow: var(--shadow-glow);
}
.btn-primary:disabled {
    opacity: 0.5; cursor: not-allowed; box-shadow: none; transform: none;
}

.btn-ghost {
    background: transparent;
    color: var(--text);
    border-color: var(--border);
}
.btn-ghost:hover { background: var(--surface-2); }

.btn-danger {
    background: transparent;
    color: var(--danger);
    border-color: var(--danger);
}
.btn-danger:hover { background: var(--danger-soft); }

.btn-block { width: 100%; }

/* ---------- Form fields ---------- */
.field {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-bottom: 16px;
}

.field label {
    font-size: 0.85rem;
    color: var(--text-muted);
    font-weight: 600;
}

.field input,
.field textarea,
.field select {
    width: 100%;
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: var(--r-md);
    padding: 12px 14px;
    transition: border-color var(--t-fast), background var(--t-fast);
}

.field input:focus,
.field textarea:focus,
.field select:focus {
    outline: none;
    border-color: var(--accent);
    background: var(--surface);
}

.field .error-text {
    color: var(--danger);
    font-size: 0.85rem;
    margin-top: 4px;
}

/* ---------- Toast (notifiche flash) ---------- */
.toast-stack {
    position: fixed;
    bottom: 24px;
    right: 24px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    z-index: 9999;
    pointer-events: none;
}

.toast {
    background: var(--surface-2);
    border: 1px solid var(--border);
    color: var(--text);
    padding: 12px 18px;
    border-radius: var(--r-pill);
    box-shadow: var(--shadow-md);
    animation: toast-in 0.3s ease, toast-out 0.3s ease 2.7s forwards;
    max-width: 320px;
    pointer-events: auto;
}
.toast.success { border-color: var(--success); }
.toast.error   { border-color: var(--danger); }
.toast.warning { border-color: var(--warning); }

@keyframes toast-in {
    from { opacity: 0; transform: translateX(20px); }
    to   { opacity: 1; transform: translateX(0); }
}
@keyframes toast-out {
    to   { opacity: 0; transform: translateX(20px); }
}

/* ---------- Loader / spinner ---------- */
.loader {
    width: 32px;
    height: 32px;
    border: 3px solid var(--border);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin: 32px auto;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- Helpers ---------- */
.hidden { display: none !important; }
.center { text-align: center; }
.muted  { color: var(--text-muted); }
.divider { height: 1px; background: var(--border); margin: 16px 0; }

/* Empty state */
.empty {
    text-align: center;
    padding: 48px 24px;
    color: var(--text-muted);
}
.empty h3 { color: var(--text); margin-bottom: 8px; }

/* ---------- Responsive: tablet ---------- */
@media (max-width: 1100px) {
    .app {
        grid-template-columns: 88px minmax(0, 1fr) 0;
    }
    .app__right { display: none; }
    /* Sidebar sinistra collassata: solo icone (gestito in nav.css) */
}

/* ---------- Responsive: mobile ---------- */
@media (max-width: 720px) {
    .app {
        grid-template-columns: 1fr;
    }
    .app__left {
        display: none; /* sostituito da bottom-nav */
    }
    .app__main {
        border-right: none;
        padding-bottom: 72px; /* spazio per bottom nav */
    }
    .main-header {
        padding: 12px 14px;
    }
}

/* ============================================================
   RESPONSIVE MOBILE — aggiunte per schemi < 480px
   ============================================================ */

/* ── Tipografia scalabile ── */
@media (max-width: 480px) {
    :root {
        font-size: 15px;
    }
    h1 { font-size: 1.5rem; }
    h2 { font-size: 1.2rem; }
}

/* ── Layout principale su mobile piccolo ── */
@media (max-width: 480px) {
    .app__main {
        padding-bottom: 76px;
    }
    .main-header {
        padding: 10px 12px;
        font-size: 0.9rem;
    }
    .main-header h1,
    .main-header h2 {
        font-size: 1rem;
    }
}

/* ── Bottoni generici ── */
@media (max-width: 480px) {
    .btn {
        padding: 8px 14px;
        font-size: 0.85rem;
    }
    .btn-primary {
        width: 100%;
        justify-content: center;
    }
}

/* ── Form fields ── */
@media (max-width: 480px) {
    .field input,
    .field textarea,
    .field select {
        font-size: 16px; /* previene zoom iOS su focus */
    }
    .field label {
        font-size: 0.8rem;
    }
}

/* ── Pagine con padding laterale ── */
@media (max-width: 480px) {
    .page-content,
    .settings-page,
    .profile-content {
        padding: 12px;
    }
}
