/* ============================================
   PRO CALCIO - TEMA PRINCIPALE
   Colori: Verde #0e5c2e / Oro #ffb400 / Rosso #e84c3d
   Font: Montserrat (titoli) / Open Sans (body)
   ============================================ */

/* --- CSS Variables --- */
:root {
    --pc-primary: #0e5c2e;
    --pc-primary-light: #218551;
    --pc-primary-dark: #094222;
    --pc-accent: #ffb400;
    --pc-accent-hover: #e6a200;
    --pc-danger: #e84c3d;
    --pc-danger-hover: #d13d2e;
    --pc-light: #f8f9fa;
    --pc-dark: #212529;
    --pc-gray: #6c757d;
    --pc-gray-light: #f3f3f3;
    --pc-border: #c8ced4;
    --pc-shadow: 0 5px 15px rgba(0, 0, 0, 0.05);
    --pc-shadow-lg: 0 8px 25px rgba(0, 0, 0, 0.1);
    --pc-transition: all 0.3s ease;
    --pc-radius: 8px;
}

/* --- Base --- */
html, body {
    margin: 0;
    padding: 0;
    min-height: 100vh;
}

body {
    font-family: 'Open Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background-color: var(--pc-gray-light);
    color: var(--pc-dark);
    display: flex;
    flex-direction: column;
}

h1, h2, h3, h4, h5, h6,
.navbar-brand, .nav-link, .btn {
    font-family: 'Montserrat', sans-serif;
}

h1, h2, h3, h4, h5, h6 {
    font-weight: 600;
}

a {
    transition: var(--pc-transition);
}

/* --- Header --- */
.header-main {
    background: linear-gradient(135deg, var(--pc-primary) 0%, var(--pc-primary-light) 100%);
    color: white;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    position: sticky;
    top: 0;
    z-index: 1030;
}

.brand-text {
    font-weight: 700;
    font-size: 1.25rem;
    letter-spacing: 1px;
}

.header-main .nav-link {
    color: rgba(255, 255, 255, 0.9) !important;
    font-weight: 500;
    padding: 0.75rem 1rem;
    border-radius: var(--pc-radius);
    transition: var(--pc-transition);
}

.header-main .nav-link:hover,
.header-main .nav-link.active {
    color: var(--pc-accent) !important;
    background-color: rgba(255, 255, 255, 0.1);
}

.header-main .dropdown-menu {
    border: none;
    border-radius: var(--pc-radius);
    box-shadow: var(--pc-shadow-lg);
    padding: 0.5rem;
}

.header-main .dropdown-item {
    padding: 0.6rem 1.2rem;
    border-radius: 4px;
    transition: var(--pc-transition);
    font-size: 0.9rem;
}

.header-main .dropdown-item:hover {
    background-color: rgba(14, 92, 46, 0.08);
}

.header-main .dropdown-item i {
    color: var(--pc-primary);
    margin-right: 8px;
    width: 20px;
    text-align: center;
}

/* --- Main Content --- */
.main-content {
    flex: 1;
}

.content-card {
    background-color: white;
    border-radius: var(--pc-radius);
    box-shadow: var(--pc-shadow);
    padding: 1.5rem;
}

@media (min-width: 768px) {
    .content-card {
        padding: 2rem;
    }
}

/* --- Footer --- */
.footer-main {
    background: linear-gradient(135deg, var(--pc-primary) 0%, var(--pc-primary-light) 100%);
    color: white;
    padding: 2.5rem 0 1.5rem;
    margin-top: auto;
}

.footer-main a.text-white:hover {
    color: var(--pc-accent) !important;
}

/* --- Buttons --- */
.btn {
    border-radius: 5px;
    padding: 0.5rem 1.5rem;
    transition: var(--pc-transition);
    text-transform: uppercase;
    font-size: 0.85rem;
    font-weight: 600;
    letter-spacing: 0.5px;
}

.btn-primary {
    background-color: var(--pc-primary);
    border-color: var(--pc-primary);
}

.btn-primary:hover {
    background-color: var(--pc-primary-dark);
    border-color: var(--pc-primary-dark);
}

.btn-accent {
    background-color: var(--pc-accent);
    border-color: var(--pc-accent);
    color: var(--pc-dark);
}

.btn-accent:hover {
    background-color: var(--pc-accent-hover);
    border-color: var(--pc-accent-hover);
    color: var(--pc-dark);
}

.btn-danger {
    background-color: var(--pc-danger);
    border-color: var(--pc-danger);
}

.btn-danger:hover {
    background-color: var(--pc-danger-hover);
    border-color: var(--pc-danger-hover);
}

/* --- Forms --- */
.form-control, .form-select {
    border-radius: 5px;
    padding: 0.65rem 1rem;
    border: 1px solid var(--pc-border);
    transition: var(--pc-transition);
}

.form-control:focus, .form-select:focus {
    box-shadow: 0 0 0 3px rgba(14, 92, 46, 0.2);
    border-color: var(--pc-primary);
}

.form-label {
    font-weight: 600;
    font-size: 0.875rem;
    color: var(--pc-gray);
    margin-bottom: 0.35rem;
}

.input-group-text {
    background-color: var(--pc-light);
    border-color: var(--pc-border);
    color: var(--pc-primary);
}

/* --- Cards --- */
.card-pro {
    background: white;
    border: 1px solid var(--pc-border);
    border-radius: var(--pc-radius);
    box-shadow: var(--pc-shadow);
    transition: var(--pc-transition);
    overflow: hidden;
}

/* --- Bordo globale per tutte le card --- */
.card {
    border: 1px solid var(--pc-border) !important;
}

.card-pro:hover {
    box-shadow: var(--pc-shadow-lg);
    transform: translateY(-2px);
}

.card-pro .card-header-pro {
    background: linear-gradient(135deg, var(--pc-primary) 0%, var(--pc-primary-light) 100%);
    color: white;
    padding: 1rem 1.25rem;
    font-family: 'Montserrat', sans-serif;
    font-weight: 600;
}

/* --- Tables --- */
.table-pro {
    border-radius: var(--pc-radius);
    overflow: hidden;
}

.table-pro thead th {
    background-color: var(--pc-primary);
    color: white;
    font-family: 'Montserrat', sans-serif;
    font-weight: 600;
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    padding: 0.75rem 1rem;
    border: none;
}

.table-pro tbody td {
    padding: 0.75rem 1rem;
    vertical-align: middle;
    border-color: var(--pc-border);
}

.table-pro tbody tr:hover {
    background-color: rgba(14, 92, 46, 0.04);
}

/* --- Badges --- */
.badge-success { background-color: var(--pc-primary); }
.badge-warning { background-color: var(--pc-accent); color: var(--pc-dark); }
.badge-danger { background-color: var(--pc-danger); }

/* --- Alerts --- */
.alert-pro {
    border: none;
    border-radius: var(--pc-radius);
    border-left: 4px solid;
}

.alert-pro.alert-success { border-left-color: var(--pc-primary); }
.alert-pro.alert-warning { border-left-color: var(--pc-accent); }
.alert-pro.alert-danger { border-left-color: var(--pc-danger); }

/* --- Modal --- */
.modal-content {
    border-radius: 10px;
    border: none;
    overflow: hidden;
}

.modal-header {
    background: linear-gradient(135deg, var(--pc-primary) 0%, var(--pc-primary-light) 100%);
    color: white;
    border-bottom: none;
}

.modal-footer {
    border-top: none;
    padding: 1rem 1.5rem;
}

/* --- Loading --- */
.spinner-pro {
    color: var(--pc-primary);
}

.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255, 255, 255, 0.85);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
}

/* --- Utilities --- */
.text-primary-pro { color: var(--pc-primary) !important; }
.text-accent { color: var(--pc-accent) !important; }
.bg-primary-pro { background-color: var(--pc-primary) !important; }
.bg-accent { background-color: var(--pc-accent) !important; }
.border-primary-pro { border-color: var(--pc-primary) !important; }

.section-title {
    font-family: 'Montserrat', sans-serif;
    font-weight: 700;
    color: var(--pc-primary);
    margin-bottom: 1.5rem;
    position: relative;
    padding-bottom: 0.75rem;
}

.section-title::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    width: 60px;
    height: 3px;
    background: var(--pc-accent);
    border-radius: 2px;
}

/* --- Validation (Blazor) --- */
h1:focus {
    outline: none;
}

.valid.modified:not([type=checkbox]) {
    outline: 1px solid var(--pc-primary);
}

.invalid {
    outline: 1px solid var(--pc-danger);
}

.validation-message {
    color: var(--pc-danger);
    font-size: 0.8rem;
    margin-top: 0.25rem;
}

/* --- Blazor Error UI --- */
.blazor-error-boundary {
    background: var(--pc-danger);
    padding: 1rem 1rem 1rem 3.7rem;
    color: white;
    border-radius: var(--pc-radius);
}

.blazor-error-boundary::after {
    content: "Si è verificato un errore."
}

#blazor-error-ui {
    background: var(--pc-danger);
    color: white;
    bottom: 0;
    box-shadow: 0 -4px 12px rgba(0, 0, 0, 0.15);
    display: none;
    left: 0;
    padding: 0.7rem 1.4rem;
    position: fixed;
    width: 100%;
    z-index: 1000;
    text-align: center;
}

#blazor-error-ui .dismiss {
    cursor: pointer;
    position: absolute;
    right: 0.75rem;
    top: 0.5rem;
}

#blazor-error-ui .reload {
    color: var(--pc-accent);
    font-weight: 600;
}

/* --- Responsive --- */
@media (max-width: 991px) {
    .navbar-collapse {
        background-color: rgba(14, 92, 46, 0.97);
        border-radius: var(--pc-radius);
        padding: 1rem;
        margin-top: 0.5rem;
    }
}

@media (max-width: 767px) {
    .btn {
        padding: 0.4rem 1rem;
        font-size: 0.8rem;
    }
    
    .content-card {
        padding: 1rem;
    }
}

/* --- Selezione Leva --- */
.btn-leva-card {
    background: white;
    border: 1px solid var(--pc-border) !important;
    border-radius: var(--pc-radius) !important;
    transition: var(--pc-transition);
    cursor: pointer;
    text-decoration: none;
}

.btn-leva-card:hover {
    box-shadow: var(--pc-shadow-lg);
    transform: translateY(-2px);
    border-color: var(--pc-primary) !important;
}

.btn-leva-card:disabled {
    opacity: 0.6;
    transform: none;
}

.btn-leva-card.leva-selezionata {
    border-color: var(--pc-primary) !important;
    border-width: 2px !important;
    background-color: #E8F5EC;
}

/* ============================================
   SIDEBAR NAVIGATION
   ============================================ */

:root {
    --sidebar-width: 260px;
    --sidebar-bg: #1a1f2e;
    --sidebar-header-bg: #151929;
    --sidebar-text: rgba(255, 255, 255, 0.75);
    --sidebar-text-hover: #ffffff;
    --sidebar-active-bg: rgba(14, 92, 46, 0.4);
    --sidebar-active-border: var(--pc-primary);
    --sidebar-section-text: rgba(255, 255, 255, 0.4);
    --sidebar-divider: rgba(255, 255, 255, 0.08);
}

/* --- Layout wrapper --- */
.app-layout {
    display: flex;
    min-height: calc(100vh - 56px); /* altezza viewport meno header */
    position: relative;
}

/* --- Sidebar base --- */
.sidebar {
    width: var(--sidebar-width);
    background-color: var(--sidebar-bg);
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 56px; /* sotto l'header */
    left: 0;
    bottom: 0;
    z-index: 1020;
    overflow-y: auto;
    overflow-x: hidden;
    transition: transform 0.3s ease;
    scrollbar-width: thin;
    scrollbar-color: rgba(255,255,255,0.15) transparent;
}

.sidebar::-webkit-scrollbar {
    width: 4px;
}

.sidebar::-webkit-scrollbar-thumb {
    background: rgba(255,255,255,0.15);
    border-radius: 2px;
}

/* --- Sidebar header (info utente) --- */
.sidebar-header {
    background-color: var(--sidebar-header-bg);
    padding: 1.25rem 1rem;
    border-bottom: 1px solid var(--sidebar-divider);
    position: relative;
}

.sidebar-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--pc-primary) 0%, var(--pc-primary-light) 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 1rem;
    flex-shrink: 0;
}

.sidebar-user-name {
    color: white;
    font-weight: 600;
    font-size: 0.9rem;
    line-height: 1.2;
}

.sidebar-user-role {
    color: var(--pc-accent);
    font-size: 0.75rem;
    font-weight: 500;
}

.sidebar-societa,
.sidebar-leva {
    color: var(--sidebar-text);
    font-size: 0.75rem;
}

.sidebar-close {
    position: absolute;
    top: 0.75rem;
    right: 0.75rem;
    background: none;
    border: none;
    color: var(--sidebar-text);
    font-size: 1.25rem;
    cursor: pointer;
    padding: 4px 8px;
    border-radius: 4px;
    transition: var(--pc-transition);
}

.sidebar-close:hover {
    color: white;
    background-color: rgba(255,255,255,0.1);
}

/* --- Navigazione --- */
.sidebar-nav {
    flex: 1;
    padding: 0.5rem 0;
}

.sidebar-section-title {
    color: var(--sidebar-section-text);
    font-size: 0.65rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1.5px;
    padding: 1rem 1.25rem 0.4rem;
    font-family: 'Montserrat', sans-serif;
}

.sidebar-link {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.6rem 1.25rem;
    color: var(--sidebar-text);
    text-decoration: none;
    font-size: 0.85rem;
    font-weight: 500;
    transition: var(--pc-transition);
    border-left: 3px solid transparent;
    cursor: pointer;
    background: none;
    border-right: none;
    border-top: none;
    border-bottom: none;
    width: 100%;
    text-align: left;
}

.sidebar-link:hover:not(.disabled) {
    color: var(--sidebar-text-hover);
    background-color: rgba(255, 255, 255, 0.06);
    border-left-color: rgba(255, 255, 255, 0.2);
}

.sidebar-link.active {
    color: white;
    background-color: var(--sidebar-active-bg);
    border-left-color: var(--sidebar-active-border);
    font-weight: 600;
}

.sidebar-link.active .sidebar-link-icon {
    color: var(--pc-accent);
}

.sidebar-link.disabled {
    color: rgba(255, 255, 255, 0.25);
    cursor: default;
}

.sidebar-link-icon {
    width: 20px;
    text-align: center;
    font-size: 0.9rem;
    flex-shrink: 0;
}

.sidebar-badge-soon {
    margin-left: auto;
    font-size: 0.6rem;
    background-color: rgba(255, 255, 255, 0.1);
    color: rgba(255, 255, 255, 0.4);
    padding: 2px 6px;
    border-radius: 8px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* --- Footer sidebar --- */
.sidebar-footer {
    border-top: 1px solid var(--sidebar-divider);
    padding: 0.5rem 0;
    margin-top: auto;
}

.sidebar-logout {
    color: var(--pc-danger) !important;
}

.sidebar-logout:hover {
    background-color: rgba(232, 76, 61, 0.1) !important;
}

/* --- Overlay (mobile) --- */
.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background-color: rgba(0, 0, 0, 0.5);
    z-index: 1015;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.sidebar-overlay.show {
    opacity: 1;
}

/* --- Main content offset --- */
.main-content.with-sidebar {
    margin-left: var(--sidebar-width);
    width: calc(100% - var(--sidebar-width));
}

.footer-main.with-sidebar {
    margin-left: var(--sidebar-width);
}

/* ============================================
   SIDEBAR RESPONSIVE
   ============================================ */

/* Desktop (>= 992px): sidebar sempre visibile */
@media (min-width: 992px) {
    .sidebar {
        transform: translateX(0);
    }

    .sidebar-overlay {
        display: none !important;
    }
}

/* Mobile (< 992px): sidebar nascosto, slide-in */
@media (max-width: 991.98px) {
    .sidebar {
        transform: translateX(-100%);
    }

    .sidebar.open {
        transform: translateX(0);
        box-shadow: 4px 0 20px rgba(0, 0, 0, 0.3);
    }

    .sidebar-overlay {
        display: block;
        pointer-events: none;
    }

    .sidebar-overlay.show {
        pointer-events: auto;
    }

    .main-content.with-sidebar {
        margin-left: 0;
        width: 100%;
    }

    .footer-main.with-sidebar {
        margin-left: 0;
    }
}

/* Header adjustment */
.header-main .navbar {
    min-height: 56px;
}

/* --- Banner impersonazione SuperAdmin --- */
.sidebar-impersonation-banner {
    background: linear-gradient(135deg, #E67E22, #F39C12);
    color: white;
    padding: 0.5rem 1rem;
    text-align: center;
    font-size: 0.75rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
}
