/* ===================================================
   Studio Commercialista - Admin CSS
   =================================================== */

:root {
    --primary:      #1e3a5f;
    --primary-light:#2e5082;
    --accent:       #e67e22;
    --accent-light: #f39c12;
    --success:      #27ae60;
    --danger:       #e74c3c;
    --warning:      #f39c12;
    --info:         #2980b9;
    --text:         #2c3e50;
    --text-muted:   #6c7a89;
    --bg:           #f0f3f8;
    --bg-card:      #ffffff;
    --border:       #dde3ee;
    --sidebar-w:    260px;
    --topbar-h:     64px;
    --shadow:       0 2px 12px rgba(30,58,95,0.08);
    --shadow-lg:    0 8px 32px rgba(30,58,95,0.12);
    --radius:       12px;
    --radius-sm:    8px;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body.admin-body {
    font-family: 'Inter', sans-serif;
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
    overflow-x: hidden;
}

/* ---- SIDEBAR ---- */
.sidebar {
    position: fixed;
    left: 0; top: 0; bottom: 0;
    width: var(--sidebar-w);
    background: var(--primary);
    display: flex;
    flex-direction: column;
    z-index: 1000;
    transition: transform .3s ease;
}

.sidebar-header {
    padding: 20px 20px 16px;
    border-bottom: 1px solid rgba(255,255,255,.1);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.sidebar-logo {
    display: flex;
    align-items: center;
    gap: 10px;
    color: #fff;
    font-family: 'Space Grotesk', sans-serif;
    font-size: 1.2rem;
}
.sidebar-logo i { color: var(--accent); font-size: 1.4rem; }
.sidebar-logo strong { color: var(--accent-light); }

.sidebar-nav {
    flex: 1;
    overflow-y: auto;
    padding: 16px 0;
}
.sidebar-nav::-webkit-scrollbar { width: 4px; }
.sidebar-nav::-webkit-scrollbar-thumb { background: rgba(255,255,255,.2); border-radius: 4px; }

.nav-section-label {
    font-size: .65rem;
    font-weight: 700;
    letter-spacing: .1em;
    text-transform: uppercase;
    color: rgba(255,255,255,.4);
    padding: 12px 20px 4px;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 20px;
    color: rgba(255,255,255,.75);
    text-decoration: none;
    font-size: .875rem;
    font-weight: 500;
    border-radius: 0;
    transition: all .2s;
    position: relative;
}
.nav-item:hover { background: rgba(255,255,255,.08); color: #fff; }
.nav-item.active {
    background: rgba(255,255,255,.12);
    color: #fff;
}
.nav-item.active::before {
    content: '';
    position: absolute;
    left: 0; top: 0; bottom: 0;
    width: 3px;
    background: var(--accent);
    border-radius: 0 3px 3px 0;
}
.nav-item i { width: 20px; text-align: center; font-size: .95rem; }

.sidebar-footer {
    padding: 16px 20px;
    border-top: 1px solid rgba(255,255,255,.1);
    display: flex;
    align-items: center;
    gap: 10px;
}
.admin-info { flex: 1; display: flex; align-items: center; gap: 10px; min-width: 0; }
.admin-avatar {
    width: 36px; height: 36px;
    background: var(--accent);
    border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    color: #fff; font-weight: 700; font-size: .875rem;
    flex-shrink: 0;
}
.admin-details { min-width: 0; }
.admin-name { color: #fff; font-size: .8rem; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.admin-role { color: rgba(255,255,255,.5); font-size: .7rem; text-transform: capitalize; }
.btn-logout {
    color: rgba(255,255,255,.5);
    text-decoration: none;
    font-size: 1rem;
    padding: 6px;
    border-radius: 6px;
    transition: all .2s;
    flex-shrink: 0;
}
.btn-logout:hover { color: var(--danger); background: rgba(231,76,60,.15); }

/* ---- MAIN CONTENT ---- */
.main-content {
    margin-left: var(--sidebar-w);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* ---- TOPBAR ---- */
.topbar {
    height: var(--topbar-h);
    background: var(--bg-card);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    padding: 0 28px;
    gap: 16px;
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: 0 1px 4px rgba(30,58,95,.06);
}
.page-title {
    font-family: 'Space Grotesk', sans-serif;
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--primary);
    flex: 1;
}
.topbar-actions { display: flex; gap: 10px; align-items: center; }

/* ---- FLASH MESSAGES ---- */
.alert-flash {
    margin: 16px 28px 0;
    padding: 12px 16px;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: .875rem;
    font-weight: 500;
    animation: slideDown .3s ease;
}
.alert-flash i { font-size: 1rem; flex-shrink: 0; }
.alert-flash-success { background: #d4edda; color: #1a6630; border: 1px solid #b8dac5; }
.alert-flash-error   { background: #fde8e8; color: #8b1a1a; border: 1px solid #f5c0c0; }
.alert-flash-info    { background: #d1ecf1; color: #0c5460; border: 1px solid #b8daff; }
.alert-flash-warning { background: #fff3cd; color: #856404; border: 1px solid #ffeeba; }
.alert-close {
    margin-left: auto;
    background: none;
    border: none;
    font-size: 1.2rem;
    cursor: pointer;
    opacity: .6;
    color: inherit;
    line-height: 1;
}
.alert-close:hover { opacity: 1; }

@keyframes slideDown {
    from { opacity: 0; transform: translateY(-10px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* ---- PAGE CONTENT ---- */
.page-content {
    padding: 24px 28px;
    flex: 1;
}

/* ---- CARDS ---- */
.card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}
.card-header {
    padding: 16px 20px;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}
.card-title {
    font-family: 'Space Grotesk', sans-serif;
    font-size: .95rem;
    font-weight: 600;
    color: var(--primary);
    margin: 0;
}
.card-body { padding: 20px; }

/* ---- STAT CARDS ---- */
.stat-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px;
    box-shadow: var(--shadow);
    display: flex;
    align-items: center;
    gap: 16px;
    transition: transform .2s, box-shadow .2s;
}
.stat-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-lg); }
.stat-icon {
    width: 52px; height: 52px;
    border-radius: 12px;
    display: flex; align-items: center; justify-content: center;
    font-size: 1.4rem;
    flex-shrink: 0;
}
.stat-icon.primary { background: rgba(30,58,95,.1); color: var(--primary); }
.stat-icon.success { background: rgba(39,174,96,.1); color: var(--success); }
.stat-icon.warning { background: rgba(243,156,18,.1); color: var(--warning); }
.stat-icon.danger  { background: rgba(231,76,60,.1); color: var(--danger); }
.stat-icon.info    { background: rgba(41,128,185,.1); color: var(--info); }
.stat-value { font-family: 'Space Grotesk', sans-serif; font-size: 1.8rem; font-weight: 700; color: var(--primary); line-height: 1; }
.stat-label { font-size: .8rem; color: var(--text-muted); margin-top: 4px; }

/* ---- TABLES ---- */
.table-container { overflow-x: auto; }
.table { margin: 0; }
.table thead th {
    font-size: .75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .05em;
    color: var(--text-muted);
    background: #f8fafc;
    border-bottom: 2px solid var(--border);
    padding: 10px 16px;
    white-space: nowrap;
}
.table tbody td {
    padding: 12px 16px;
    font-size: .875rem;
    vertical-align: middle;
    border-bottom: 1px solid #f0f3f8;
}
.table tbody tr:hover { background: #f8fafc; }
.table tbody tr:last-child td { border-bottom: none; }

/* ---- BADGES ---- */
.badge-stato {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 10px;
    border-radius: 20px;
    font-size: .7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .04em;
}
.badge-pagato     { background: #d4edda; color: #1a6630; }
.badge-non_pagato { background: #fde8e8; color: #8b1a1a; }
.badge-parziale   { background: #fff3cd; color: #856404; }
.badge-aperto     { background: #d1ecf1; color: #0c5460; }
.badge-in_attesa  { background: #fff3cd; color: #856404; }
.badge-completato { background: #d4edda; color: #1a6630; }
.badge-archiviato { background: #e9ecef; color: #495057; }

/* ---- BUTTONS ---- */
.btn-primary-custom {
    background: var(--primary);
    color: #fff;
    border: none;
    padding: 8px 18px;
    border-radius: var(--radius-sm);
    font-size: .875rem;
    font-weight: 500;
    cursor: pointer;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    transition: all .2s;
}
.btn-primary-custom:hover { background: var(--primary-light); color: #fff; transform: translateY(-1px); }

.btn-accent {
    background: var(--accent);
    color: #fff;
    border: none;
    padding: 8px 18px;
    border-radius: var(--radius-sm);
    font-size: .875rem;
    font-weight: 500;
    cursor: pointer;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    transition: all .2s;
}
.btn-accent:hover { background: var(--accent-light); color: #fff; }

/* ---- FORMS ---- */
.form-label {
    font-size: .8rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: .04em;
    margin-bottom: 6px;
}
.form-control, .form-select {
    border: 1.5px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 9px 13px;
    font-size: .875rem;
    transition: border-color .2s, box-shadow .2s;
}
.form-control:focus, .form-select:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(30,58,95,.1);
    outline: none;
}

/* ---- PROGRESS ---- */
.progress-bar-custom {
    height: 8px;
    background: var(--border);
    border-radius: 4px;
    overflow: hidden;
}
.progress-bar-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--primary), var(--accent));
    border-radius: 4px;
    transition: width .6s ease;
}

/* ---- UPLOAD ZONE ---- */
.upload-zone {
    border: 2px dashed var(--border);
    border-radius: var(--radius);
    padding: 40px 24px;
    text-align: center;
    cursor: pointer;
    transition: all .2s;
    background: #fafbfd;
}
.upload-zone:hover, .upload-zone.dragover {
    border-color: var(--primary);
    background: rgba(30,58,95,.03);
}
.upload-zone i { font-size: 2.5rem; color: var(--text-muted); margin-bottom: 12px; }
.upload-zone p { color: var(--text-muted); font-size: .9rem; margin: 0; }
.upload-zone strong { color: var(--primary); }

/* ---- MOBILE ---- */
.sidebar-toggle, .topbar-toggle {
    background: none;
    border: none;
    font-size: 1.1rem;
    cursor: pointer;
    color: var(--primary);
    padding: 6px;
}
.sidebar-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.4);
    z-index: 999;
    display: none;
}
.sidebar-overlay.show { display: block; }

@media (max-width: 991px) {
    .sidebar { transform: translateX(-100%); }
    .sidebar.open { transform: translateX(0); }
    .main-content { margin-left: 0; }
}

/* ---- EMPTY STATE ---- */
.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: var(--text-muted);
}
.empty-state i { font-size: 3rem; margin-bottom: 16px; opacity: .4; }
.empty-state h3 { font-size: 1.1rem; margin-bottom: 8px; color: var(--text); }
.empty-state p { font-size: .875rem; }

/* ---- LOGIN PAGE ---- */
.login-body {
    background: linear-gradient(135deg, var(--primary) 0%, #0a1f38 100%);
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}
.login-card {
    background: #fff;
    border-radius: 20px;
    padding: 48px 40px;
    width: 100%;
    max-width: 420px;
    box-shadow: 0 24px 64px rgba(0,0,0,.2);
}
.login-logo {
    text-align: center;
    margin-bottom: 32px;
}
.login-logo i { font-size: 2.5rem; color: var(--accent); }
.login-logo h1 {
    font-family: 'Space Grotesk', sans-serif;
    font-size: 1.5rem;
    color: var(--primary);
    margin-top: 8px;
}
.login-logo p { font-size: .8rem; color: var(--text-muted); }

/* ---- CLIENT AREA ---- */
.client-body {
    background: linear-gradient(135deg, #f0f3f8 0%, #e8ecf5 100%);
    min-height: 100vh;
    font-family: 'Inter', sans-serif;
}
.client-header {
    background: var(--primary);
    color: #fff;
    padding: 20px 28px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}
.client-header-logo {
    display: flex;
    align-items: center;
    gap: 10px;
    font-family: 'Space Grotesk', sans-serif;
    font-size: 1.1rem;
}
.client-header-logo i { color: var(--accent); }
.client-content { max-width: 900px; margin: 32px auto; padding: 0 20px; }

/* ── Badge status (usati nelle liste clienti, forfettari, aziende) ── */
.badge-status {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 20px;
    font-size: 11px;
    font-weight: 600;
    letter-spacing: .3px;
    white-space: nowrap;
}
.badge-status.badge-success,
.badge-status.bg-success    { background: #d4edda; color: #1a6630; }
.badge-status.badge-danger,
.badge-status.bg-danger      { background: #fde8e8; color: #8b1a1a; }
.badge-status.badge-warning,
.badge-status.bg-warning     { background: #fff3cd; color: #856404; }
.badge-status.badge-info,
.badge-status.bg-info        { background: #d1ecf1; color: #0c5460; }
.badge-status.badge-secondary,
.badge-status.bg-secondary   { background: #e9ecef; color: #495057; }
.badge-status.badge-primary,
.badge-status.bg-primary     { background: #cfe2ff; color: #084298; }