/* ============================================================
   Asset Tracking SaaS — app.css
   Tema: Industrial/Utilitarian — pulito, professionale, leggibile
   Font: DM Sans (corpo) + DM Mono (codici/dati)
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=DM+Sans:wght@300;400;500;600&family=DM+Mono:wght@400;500&display=swap');

/* --- Variabili --- */
:root {
    --bg:           #F4F3F0;
    --surface:      #FFFFFF;
    --border:       #E0DED9;
    --text:         #1A1917;
    --text-muted:   #7A7874;
    --primary:      #1A1917;
    --primary-hover:#3D3B38;
    --accent:       #D95F2B;        /* arancio industriale */
    --success:      #2A7A4B;
    --success-bg:   #EAF5EE;
    --error:        #B83232;
    --error-bg:     #FAEAEA;
    --radius:       6px;
    --shadow:       0 2px 8px rgba(0,0,0,0.08);
    --shadow-lg:    0 8px 32px rgba(0,0,0,0.12);
    --font:         'DM Sans', sans-serif;
    --font-mono:    'DM Mono', monospace;
}

/* --- Reset --- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { font-size: 16px; -webkit-font-smoothing: antialiased; }

body {
    font-family: var(--font);
    background: var(--bg);
    color: var(--text);
    line-height: 1.6;
    min-height: 100vh;
}

/* ============================================================
   LAYOUT AUTH (login, registra, cambia password)
   ============================================================ */
.auth-body {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    padding: 2rem 1rem;
    background: var(--bg);
    /* Pattern sottile industriale */
    background-image: radial-gradient(circle, #D0CEC9 1px, transparent 1px);
    background-size: 24px 24px;
}

.auth-box {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    padding: 2.5rem 2rem;
    width: 100%;
    max-width: 420px;
    animation: fadeUp 0.3s ease;
}

.auth-box--wide {
    max-width: 620px;
}

.auth-logo {
    text-align: center;
    margin-bottom: 2rem;
    padding-bottom: 1.5rem;
    border-bottom: 1px solid var(--border);
}

.auth-logo h1 {
    font-size: 1.4rem;
    font-weight: 600;
    letter-spacing: -0.02em;
    color: var(--text);
}

/* .auth-logo h1::before {
    content: '▸ ';
    color: var(--accent);
} */

.auth-logo p {
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-top: 0.3rem;
}

.auth-footer {
    text-align: center;
    margin-top: 1.5rem;
    font-size: 0.85rem;
    color: var(--text-muted);
}

.auth-footer a {
    color: var(--accent);
    text-decoration: none;
    font-weight: 500;
}

.auth-footer a:hover { text-decoration: underline; }

/* ============================================================
   FORM
   ============================================================ */
.form-sezione {
    font-size: 0.75rem;
    font-weight: 600;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--text-muted);
    margin: 1.5rem 0 1rem;
    padding-bottom: 0.4rem;
    border-bottom: 1px solid var(--border);
}

.campo {
    margin-bottom: 1.1rem;
}

.campo label {
    display: block;
    font-size: 0.82rem;
    font-weight: 500;
    margin-bottom: 0.35rem;
    color: var(--text);
}

.campo label small {
    font-weight: 400;
    color: var(--text-muted);
}

.campo input,
.campo select,
.campo textarea {
    width: 100%;
    padding: 0.6rem 0.8rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-family: var(--font);
    font-size: 0.9rem;
    color: var(--text);
    background: var(--surface);
    transition: border-color 0.15s, box-shadow 0.15s;
    outline: none;
}

.campo input:focus,
.campo select:focus,
.campo textarea:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(26,25,23,0.08);
}

.campo input::placeholder { color: #BDBBB7; }

.form-group {
    margin-bottom: 1.1rem;
}

.form-label {
    display: block;
    font-size: 0.82rem;
    font-weight: 500;
    margin-bottom: 0.35rem;
    color: var(--text);
}

.form-control {
    width: 100%;
    padding: 0.6rem 0.8rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-family: var(--font);
    font-size: 0.9rem;
    color: var(--text);
    background: var(--surface);
    transition: border-color 0.15s, box-shadow 0.15s;
    outline: none;
}

.form-control:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(26,25,23,0.08);
}

.form-control::placeholder { color: #BDBBB7; }

/* Tab filtri */
.tab-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    padding: 0.35rem 0.85rem;
    border-radius: 20px;
    font-size: 0.8rem;
    font-weight: 500;
    text-decoration: none;
    color: var(--text-muted);
    background: var(--surface);
    border: 1px solid var(--border);
    transition: all 0.15s;
    cursor: pointer;
}

.tab-btn:hover {
    border-color: var(--accent);
    color: var(--accent);
}

.tab-btn-active {
    background: var(--accent);
    color: #fff;
    border-color: var(--accent);
}

.tab-count {
    font-family: var(--font-mono);
    font-size: 0.72rem;
    opacity: 0.8;
}

/* Badge aggiuntivi */
.badge-in-attesa  { background: #FFF6E5; color: #8A5A00; }
.badge-sospesa    { background: #EEF4FF; color: #2A4E9A; }
.badge-dismesso   { background: var(--bg); color: var(--text-muted); }

.campo-gruppo {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
}

@media (max-width: 480px) {
    .form-group {
    margin-bottom: 1.1rem;
}

.form-label {
    display: block;
    font-size: 0.82rem;
    font-weight: 500;
    margin-bottom: 0.35rem;
    color: var(--text);
}

.form-control {
    width: 100%;
    padding: 0.6rem 0.8rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-family: var(--font);
    font-size: 0.9rem;
    color: var(--text);
    background: var(--surface);
    transition: border-color 0.15s, box-shadow 0.15s;
    outline: none;
}

.form-control:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(26,25,23,0.08);
}

.form-control::placeholder { color: #BDBBB7; }

/* Tab filtri */
.tab-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    padding: 0.35rem 0.85rem;
    border-radius: 20px;
    font-size: 0.8rem;
    font-weight: 500;
    text-decoration: none;
    color: var(--text-muted);
    background: var(--surface);
    border: 1px solid var(--border);
    transition: all 0.15s;
    cursor: pointer;
}

.tab-btn:hover {
    border-color: var(--accent);
    color: var(--accent);
}

.tab-btn-active {
    background: var(--accent);
    color: #fff;
    border-color: var(--accent);
}

.tab-count {
    font-family: var(--font-mono);
    font-size: 0.72rem;
    opacity: 0.8;
}

/* Badge aggiuntivi */
.badge-in-attesa  { background: #FFF6E5; color: #8A5A00; }
.badge-sospesa    { background: #EEF4FF; color: #2A4E9A; }
.badge-dismesso   { background: var(--bg); color: var(--text-muted); }

.campo-gruppo { grid-template-columns: 1fr; }
}

/* ============================================================
   BOTTONI
   ============================================================ */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.6rem 1.2rem;
    border-radius: var(--radius);
    font-family: var(--font);
    font-size: 0.88rem;
    font-weight: 500;
    cursor: pointer;
    border: 1px solid transparent;
    transition: background 0.15s, color 0.15s, border-color 0.15s, transform 0.1s;
    text-decoration: none;
}

.btn:active { transform: translateY(1px); }

.btn-primary {
    background: var(--primary);
    color: #fff;
    border-color: var(--primary);
}
.btn-primary:hover { background: var(--primary-hover); }

.btn-accent {
    background: var(--accent);
    color: #fff;
    border-color: var(--accent);
}
.btn-accent:hover { background: #C04E20; }

.btn-outline {
    background: transparent;
    color: var(--primary);
    border-color: var(--border);
}
.btn-outline:hover { border-color: var(--primary); }

.btn-danger {
    background: var(--error-bg);
    color: var(--error);
    border-color: #F0CACA;
}
.btn-danger:hover { background: #F5D5D5; }

.btn-sm { padding: 0.35rem 0.8rem; font-size: 0.8rem; }
.btn-block { width: 100%; justify-content: center; margin-top: 0.5rem; }

/* ============================================================
   ALERT
   ============================================================ */
.alert {
    padding: 0.75rem 1rem;
    border-radius: var(--radius);
    font-size: 0.875rem;
    margin-bottom: 1.2rem;
    border: 1px solid transparent;
}

.alert-errore {
    background: var(--error-bg);
    color: var(--error);
    border-color: #F0CACA;
}

.alert-successo {
    background: var(--success-bg);
    color: var(--success);
    border-color: #C2E0CE;
}

.alert-info {
    background: #EEF4FF;
    color: #2A4E9A;
    border-color: #C5D8F5;
}

/* ============================================================
   LAYOUT PRINCIPALE (dashboard e pagine interne)
   ============================================================ */
.app-wrapper {
    display: grid;
    grid-template-columns: 220px 1fr;
    grid-template-rows: auto 1fr;
    min-height: 100vh;
}

/* Topbar */
.topbar {
    position: sticky;
    top: 0;
    z-index: 50;    
    grid-column: 1 / -1;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 1.5rem;
    height: 52px;
    background: var(--primary);
    color: #fff;
    border-bottom: 2px solid var(--accent);
}

.topbar-brand {
    font-size: 0.95rem;
    font-weight: 600;
    letter-spacing: -0.01em;
}

.topbar-brand span { color: var(--accent); }

.topbar-user {
    font-size: 0.8rem;
    color: #AAA8A4;
    display: flex;
    align-items: center;
    gap: 1rem;
}

.topbar-user a {
    color: #AAA8A4;
    text-decoration: none;
    transition: color 0.15s;
}

.topbar-user a:hover { color: #fff; }

/* Sidebar */
.sidebar {
    background: var(--surface);
    border-right: 1px solid var(--border);
    padding: 1.5rem 0;
}

.sidebar-nav a {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    padding: 0.55rem 1.2rem;
    font-size: 0.875rem;
    color: var(--text-muted);
    text-decoration: none;
    transition: background 0.15s, color 0.15s;
    border-left: 3px solid transparent;
}

.sidebar-nav a:hover,
.sidebar-nav a.attivo {
    background: var(--bg);
    color: var(--text);
    border-left-color: var(--accent);
}

.sidebar-nav .nav-sezione {
    font-size: 0.68rem;
    font-weight: 600;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: #BDBBB7;
    padding: 1.2rem 1.2rem 0.3rem;
}

/* Contenuto principale */
.main-content {
    padding: 2rem;
    overflow-y: auto;
}

.page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1.5rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid var(--border);
}

.page-header h1 {
    font-size: 1.3rem;
    font-weight: 600;
    letter-spacing: -0.02em;
}

/* ============================================================
   CARD
   ============================================================ */
.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.5rem;
    box-shadow: var(--shadow);
}

.card-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.stat-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.2rem 1.5rem;
    box-shadow: var(--shadow);
}

.stat-card .stat-label {
    font-size: 0.72rem;
    font-weight: 600;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--text-muted);
    margin-bottom: 0.4rem;
}

.stat-card .stat-value {
    font-size: 1.8rem;
    font-weight: 300;
    font-family: var(--font-mono);
    color: var(--text);
    line-height: 1;
}

.stat-card .stat-sub {
    font-size: 0.78rem;
    color: var(--text-muted);
    margin-top: 0.3rem;
}

/* Barra di progresso */
.progress-bar {
    height: 4px;
    background: var(--border);
    border-radius: 2px;
    margin-top: 0.6rem;
    overflow: hidden;
}

.progress-bar-fill {
    height: 100%;
    background: var(--accent);
    border-radius: 2px;
    transition: width 0.4s ease;
}

.progress-bar-fill.warning { background: #E8A020; }
.progress-bar-fill.danger  { background: var(--error); }

/* ============================================================
   TABELLA
   ============================================================ */
.table-wrapper {
    overflow-x: auto;
    border: 1px solid var(--border);
    border-radius: var(--radius);
}

table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.875rem;
}

thead th {
    background: var(--bg);
    padding: 0.65rem 1rem;
    text-align: left;
    font-size: 0.72rem;
    font-weight: 600;
    letter-spacing: 0.07em;
    text-transform: uppercase;
    color: var(--text-muted);
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
}

tbody td {
    padding: 0.7rem 1rem;
    border-bottom: 1px solid var(--border);
    color: var(--text);
    vertical-align: middle;
}

tbody tr:last-child td { border-bottom: none; }
tbody tr:hover { background: #FAFAF8; }

/* Badge stato */
.badge {
    display: inline-block;
    padding: 0.2rem 0.6rem;
    border-radius: 20px;
    font-size: 0.72rem;
    font-weight: 500;
    font-family: var(--font-mono);
    letter-spacing: 0.02em;
}

.badge-disponibile  { background: var(--success-bg); color: var(--success); }
.badge-in_uso       { background: #EEF4FF; color: #2A4E9A; }
.badge-manutenzione { background: #FFF6E5; color: #8A5A00; }
.badge-dismesso     { background: var(--bg); color: var(--text-muted); }
.badge-trial        { background: #FFF6E5; color: #8A5A00; }
.badge-attiva       { background: var(--success-bg); color: var(--success); }
.badge-scaduta      { background: var(--error-bg); color: var(--error); }

/* ============================================================
   ANIMAZIONI
   ============================================================ */
@keyframes fadeUp {
    from { opacity: 0; transform: translateY(12px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* ============================================================
   RESPONSIVE
   ============================================================ */
@media (max-width: 1199px) {
    .app-wrapper {
        grid-template-columns: 1fr;
    }
    .sidebar {
        display: none;
    }
    .main-content {
        padding: 1.5rem 0.5rem;
    }
}