/* ==========================================================================
   SPUNTY S.r.l. - Foglio di Stile Area Privata Gestionale Aziendale
   ========================================================================== */

:root {
    --adm-bg: #f1f5f9;
    --adm-sidebar: #0f172a;
    --adm-sidebar-hover: #1e293b;
    --adm-primary: #b91c1c;
    --adm-primary-hover: #991b1b;
    --adm-green: #16a34a;
    --adm-red: #dc2626;
    --adm-blue: #2563eb;
    --adm-amber: #d97706;
    --adm-text: #1e293b;
    --adm-muted: #64748b;
    --adm-border: #e2e8f0;
    --adm-card: #ffffff;
}

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

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

.admin-wrapper {
    display: flex;
    min-height: 100vh;
}

/* Sidebar */
.admin-sidebar {
    width: 265px;
    background: var(--adm-sidebar);
    color: #f8fafc;
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
}

.sidebar-brand {
    padding: 20px 22px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.sidebar-brand h2 {
    font-size: 1.25rem;
    font-weight: 800;
    letter-spacing: 0.02em;
    color: #fff;
}

.role-badge {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 99px;
    font-size: 0.72rem;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.role-master { background: #dc2626; color: #fff; }
.role-socio { background: #2563eb; color: #fff; }
.role-operatore { background: #059669; color: #fff; }

.sidebar-user {
    padding: 16px 22px;
    background: rgba(255, 255, 255, 0.03);
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    font-size: 0.85rem;
}

.sidebar-user strong {
    display: block;
    color: #fff;
    font-size: 0.95rem;
    margin-bottom: 4px;
}

.sidebar-menu {
    list-style: none;
    padding: 16px 12px;
    flex: 1;
}

.sidebar-menu li {
    margin-bottom: 4px;
}

.sidebar-menu a {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 11px 14px;
    color: #cbd5e1;
    text-decoration: none;
    border-radius: 8px;
    font-weight: 600;
    font-size: 0.92rem;
    transition: all 0.15s;
}

.sidebar-menu a:hover,
.sidebar-menu a.active {
    background: var(--adm-primary);
    color: #ffffff;
}

/* Main Area */
.admin-main {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.admin-topbar {
    background: #ffffff;
    border-bottom: 1px solid var(--adm-border);
    padding: 14px 28px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 12px;
}

.admin-content {
    padding: 28px;
    max-width: 1440px;
    width: 100%;
    margin: 0 auto;
}

/* KPI Cards */
.kpi-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
    gap: 20px;
    margin-bottom: 28px;
}

.kpi-card {
    background: var(--adm-card);
    border-radius: 12px;
    padding: 22px;
    border: 1px solid var(--adm-border);
    box-shadow: 0 2px 6px rgba(15, 23, 42, 0.04);
}

.kpi-card .kpi-label {
    font-size: 0.82rem;
    font-weight: 700;
    text-transform: uppercase;
    color: var(--adm-muted);
    margin-bottom: 8px;
}

.kpi-card .kpi-value {
    font-size: 1.75rem;
    font-weight: 800;
    color: var(--adm-text);
}

.kpi-card .kpi-sub {
    font-size: 0.8rem;
    color: var(--adm-muted);
    margin-top: 6px;
}

/* Panels & Tables */
.panel {
    background: var(--adm-card);
    border-radius: 12px;
    border: 1px solid var(--adm-border);
    box-shadow: 0 2px 6px rgba(15, 23, 42, 0.04);
    margin-bottom: 28px;
    overflow: hidden;
}

.panel-header {
    padding: 18px 24px;
    border-bottom: 1px solid var(--adm-border);
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 12px;
    background: #f8fafc;
}

.panel-header h3 {
    font-size: 1.05rem;
    font-weight: 700;
    color: var(--adm-text);
}

.panel-body {
    padding: 24px;
}

.table-responsive {
    width: 100%;
    overflow-x: auto;
}

.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9rem;
}

.data-table th,
.data-table td {
    padding: 12px 16px;
    text-align: left;
    border-bottom: 1px solid var(--adm-border);
}

.data-table th {
    background: #f8fafc;
    font-weight: 700;
    color: #475569;
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.data-table tr:hover td {
    background: #f8fafc;
}

/* Badges & Buttons */
.badge {
    display: inline-block;
    padding: 3px 9px;
    border-radius: 6px;
    font-size: 0.76rem;
    font-weight: 700;
}

.badge-incasso, .badge-pagata { background: #dcfce7; color: #166534; }
.badge-spesa, .badge-da_pagare { background: #fee2e2; color: #991b1b; }
.badge-parziale { background: #fef3c7; color: #92400e; }
.badge-annullata { background: #e2e8f0; color: #475569; }

.btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 9px 16px;
    border-radius: 8px;
    font-weight: 600;
    font-size: 0.88rem;
    text-decoration: none;
    cursor: pointer;
    border: none;
    transition: all 0.15s;
}

.btn-sm {
    padding: 5px 10px;
    font-size: 0.78rem;
}

.btn-primary { background: var(--adm-primary); color: #fff; }
.btn-primary:hover { background: var(--adm-primary-hover); }
.btn-success { background: var(--adm-green); color: #fff; }
.btn-blue { background: var(--adm-blue); color: #fff; }
.btn-secondary { background: #e2e8f0; color: #1e293b; }
.btn-secondary:hover { background: #cbd5e1; }
.btn-danger { background: #fee2e2; color: #991b1b; }
.btn-danger:hover { background: #fecaca; }

/* Forms */
.form-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
    gap: 16px;
}

.form-group {
    margin-bottom: 14px;
}

.form-group label {
    display: block;
    font-size: 0.84rem;
    font-weight: 700;
    color: #334155;
    margin-bottom: 5px;
}

.form-control {
    width: 100%;
    padding: 9px 12px;
    border: 1px solid #cbd5e1;
    border-radius: 8px;
    font-size: 0.92rem;
    font-family: inherit;
    background: #fff;
}

.form-control:focus {
    outline: none;
    border-color: var(--adm-primary);
    box-shadow: 0 0 0 3px rgba(185, 28, 28, 0.12);
}

.alert {
    padding: 14px 18px;
    border-radius: 8px;
    margin-bottom: 20px;
    font-weight: 600;
    font-size: 0.92rem;
}

.alert-success { background: #dcfce7; color: #166534; border: 1px solid #bbf7d0; }
.alert-error { background: #fee2e2; color: #991b1b; border: 1px solid #fecaca; }

@media (max-width: 900px) {
    .admin-wrapper {
        flex-direction: column;
    }
    .admin-sidebar {
        width: 100%;
    }
}
