/* ═══════════════════════════════════════════════════════════════
   Gestionale SaaS — Stylesheet
   ═══════════════════════════════════════════════════════════════ */

:root {
    --primary: #1f4e79;
    --primary-light: #2d6da3;
    --primary-dark: #163d5e;
    --accent: #e67e22;
    --accent-dark: #d35400;
    --success: #27ae60;
    --success-light: #d4edda;
    --error: #c0392b;
    --error-light: #f8d7da;
    --warning: #f39c12;
    --warning-light: #fff3cd;
    --info: #3498db;
    --info-light: #d1ecf1;
    --bg: #f0f2f5;
    --card: #ffffff;
    --text: #333333;
    --text-light: #666666;
    --text-muted: #999999;
    --border: #e0e0e0;
    --sidebar-w: 260px;
    --header-h: 60px;
    --radius: 12px;
    --shadow: 0 2px 12px rgba(0,0,0,.06);
    --shadow-hover: 0 4px 20px rgba(0,0,0,.12);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
    font-family: 'Segoe UI', -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.6;
}

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

/* ── Layout ──────────────────────────────────────────────── */
.app-layout {
    display: flex;
    min-height: 100vh;
}

/* ── Sidebar ─────────────────────────────────────────────── */
.sidebar {
    width: var(--sidebar-w);
    background: linear-gradient(180deg, var(--primary) 0%, var(--primary-dark) 100%);
    color: #fff;
    position: fixed;
    top: 0;
    left: 0;
    height: 100vh;
    display: flex;
    flex-direction: column;
    z-index: 100;
    transition: transform .3s;
}

.sidebar-brand {
    padding: 20px 20px 16px;
    border-bottom: 1px solid rgba(255,255,255,.1);
}
.sidebar-brand h2 {
    font-size: 17px;
    font-weight: 700;
    letter-spacing: -0.3px;
}
.sidebar-brand small {
    font-size: 11px;
    opacity: .6;
}

.sidebar-nav {
    padding: 12px 0;
    flex: 1;
    overflow-y: auto;
    min-height: 0;
}
.sidebar-section {
    padding: 8px 20px 4px;
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 1.5px;
    opacity: .4;
    margin-top: 8px;
}
.sidebar-link {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 20px;
    color: rgba(255,255,255,.75);
    font-size: 14px;
    transition: all .15s;
    border-left: 3px solid transparent;
}
.sidebar-link:hover {
    background: rgba(255,255,255,.08);
    color: #fff;
}
.sidebar-link.active {
    background: rgba(255,255,255,.12);
    color: #fff;
    border-left-color: var(--accent);
}
.sidebar-link .icon {
    font-size: 18px;
    width: 24px;
    text-align: center;
}
.sidebar-link .badge-lock {
    margin-left: auto;
    background: rgba(255,255,255,.15);
    padding: 2px 8px;
    border-radius: 10px;
    font-size: 10px;
}

/* sidebar-user rimosso — utente e esci spostati nel brand in alto */

/* ── Main content ────────────────────────────────────────── */
.main-content {
    margin-left: var(--sidebar-w);
    flex: 1;
    min-height: 100vh;
}

.topbar {
    background: var(--card);
    height: var(--header-h);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 28px;
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 50;
}
.topbar h1 {
    font-size: 20px;
    font-weight: 600;
    color: var(--text);
}
.topbar-right {
    display: flex;
    align-items: center;
    gap: 16px;
}

.page-content {
    padding: 28px;
}

/* ── Cards ────────────────────────────────────────────────── */
.card {
    background: var(--card);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 24px;
    margin-bottom: 24px;
}
.card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--border);
}
.card-header h3 {
    font-size: 16px;
    font-weight: 600;
    color: var(--primary);
}

/* ── Stat cards ───────────────────────────────────────────── */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 20px;
    margin-bottom: 28px;
}
.stat-card {
    background: var(--card);
    border-radius: var(--radius);
    padding: 20px;
    box-shadow: var(--shadow);
    display: flex;
    align-items: center;
    gap: 16px;
}
.stat-icon {
    font-size: 32px;
    width: 52px;
    height: 52px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 12px;
    background: var(--bg);
}
.stat-info h4 {
    font-size: 24px;
    font-weight: 700;
    color: var(--text);
    line-height: 1.2;
}
.stat-info span {
    font-size: 13px;
    color: var(--text-muted);
}

/* ── Buttons ──────────────────────────────────────────────── */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 20px;
    border: none;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all .15s;
    text-decoration: none;
}
.btn:active { transform: scale(.97); }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); color: #fff; }
.btn-accent { background: var(--accent); color: #fff; }
.btn-accent:hover { background: var(--accent-dark); color: #fff; }
.btn-success { background: var(--success); color: #fff; }
.btn-danger { background: var(--error); color: #fff; }
.btn-outline {
    background: transparent;
    color: var(--primary);
    border: 2px solid var(--primary);
}
.btn-outline:hover { background: var(--primary); color: #fff; }
.btn-sm { padding: 6px 14px; font-size: 13px; }
.btn-lg { padding: 14px 28px; font-size: 16px; }

/* ── Forms ─────────────────────────────────────────────────── */
.form-group {
    margin-bottom: 16px;
}
.form-group label {
    display: block;
    font-size: 13px;
    font-weight: 600;
    color: var(--text-light);
    margin-bottom: 6px;
}
.form-control {
    width: 100%;
    padding: 10px 14px;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 14px;
    font-family: inherit;
    transition: border-color .15s, box-shadow .15s;
}
.form-control:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(31,78,121,.1);
}
select.form-control { appearance: auto; }
textarea.form-control { min-height: 100px; resize: vertical; }

.form-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
}

/* ── Tables ────────────────────────────────────────────────── */
.table-wrapper {
    overflow-x: auto;
}
table.data-table {
    width: 100%;
    border-collapse: collapse;
}
table.data-table th {
    background: var(--primary);
    color: #fff;
    padding: 10px 14px;
    text-align: left;
    font-size: 13px;
    font-weight: 600;
    white-space: nowrap;
}
table.data-table td {
    padding: 10px 14px;
    border-bottom: 1px solid #f0f0f0;
    font-size: 14px;
}
table.data-table tr:hover { background: #f8f9fa; }
table.data-table tr:nth-child(even) { background: #fafbfc; }
table.data-table tr:nth-child(even):hover { background: #f0f2f5; }

/* ── Alerts ────────────────────────────────────────────────── */
.alert {
    padding: 14px 18px;
    border-radius: 8px;
    margin-bottom: 16px;
    font-size: 14px;
    display: flex;
    align-items: center;
    gap: 10px;
}
.alert-success { background: var(--success-light); color: #155724; border: 1px solid #c3e6cb; }
.alert-error   { background: var(--error-light); color: #721c24; border: 1px solid #f5c6cb; }
.alert-warning { background: var(--warning-light); color: #856404; border: 1px solid #ffeeba; }
.alert-info    { background: var(--info-light); color: #0c5460; border: 1px solid #bee5eb; }

/* ── Trial banner ──────────────────────────────────────────── */
.trial-banner {
    background: linear-gradient(135deg, var(--accent) 0%, var(--accent-dark) 100%);
    color: #fff;
    padding: 12px 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 14px;
}
.trial-banner strong { font-size: 15px; }
.trial-banner .btn { background: #fff; color: var(--accent-dark); }

/* ── Module lock overlay ───────────────────────────────────── */
.module-locked {
    position: relative;
    opacity: .6;
    pointer-events: none;
}
.module-locked::after {
    content: '🔒 Modulo non attivo';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(0,0,0,.8);
    color: #fff;
    padding: 12px 24px;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    pointer-events: auto;
    cursor: pointer;
}

/* ── Auth pages ────────────────────────────────────────────── */
.auth-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-light) 50%, var(--bg) 100%);
}
.auth-box {
    background: var(--card);
    border-radius: 16px;
    box-shadow: 0 8px 40px rgba(0,0,0,.15);
    padding: 40px;
    width: 100%;
    max-width: 440px;
}
.auth-box h1 {
    font-size: 24px;
    color: var(--primary);
    margin-bottom: 8px;
    text-align: center;
}
.auth-box .subtitle {
    text-align: center;
    color: var(--text-muted);
    margin-bottom: 28px;
    font-size: 14px;
}
.auth-box .btn { width: 100%; justify-content: center; padding: 12px; }
.auth-box .auth-footer {
    text-align: center;
    margin-top: 20px;
    font-size: 13px;
    color: var(--text-muted);
}

/* ── Responsive ───────────────────────────────────────────── */
.menu-toggle {
    display: none;
    background: none;
    border: none;
    font-size: 24px;
    cursor: pointer;
    color: var(--text);
}

@media (max-width: 768px) {
    .sidebar {
        transform: translateX(-100%);
    }
    .sidebar.open {
        transform: translateX(0);
    }
    .main-content {
        margin-left: 0;
    }
    .menu-toggle {
        display: block;
    }
    .stats-grid {
        grid-template-columns: 1fr 1fr;
    }
    .page-content {
        padding: 16px;
    }
}

@media (max-width: 480px) {
    .stats-grid {
        grid-template-columns: 1fr;
    }
    .auth-box {
        margin: 16px;
        padding: 28px;
    }
}
