/* ============================================================================
   Site CSS - FileInsoluti
   Stili per il layout con sidebar verticale
   ============================================================================ */

/* === Variabili CSS === */
:root {
    --primary-color: #3b82f6;
    --primary-dark: #2563eb;
    --secondary-color: #64748b;
    --success-color: #22c55e;
    --danger-color: #ef4444;
    --warning-color: #f59e0b;
    --text-color: #1e293b;
    --text-muted: #64748b;
    --bg-color: #f1f5f9;
    --border-color: #e2e8f0;
    --shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
    --sidebar-width: 260px;
    --sidebar-collapsed-width: 70px;
}

/* === Reset e Base === */
html {
    font-size: 14px;
    position: relative;
    min-height: 100%;
}

@media (min-width: 768px) {
    html {
        font-size: 16px;
    }
}

body {
    margin: 0;
    padding: 0;
    font-family: system-ui, -apple-system, 'Segoe UI', Roboto, 'Helvetica Neue', sans-serif;
    background-color: var(--bg-color);
    color: var(--text-color);
    overflow-x: hidden;
}

/* === Focus States === */
.btn:focus, .btn:active:focus, .btn-link.nav-link:focus, .form-control:focus, .form-check-input:focus {
    box-shadow: 0 0 0 0.1rem white, 0 0 0 0.25rem var(--primary-color);
}

/* ============================================================================
   SIDEBAR NAVIGATION
   ============================================================================ */

.sidebar {
    position: fixed;
    left: 0;
    top: 0;
    bottom: 0;
    width: var(--sidebar-width);
    background: linear-gradient(180deg, #1e293b 0%, #0f172a 100%);
    color: white;
    display: flex;
    flex-direction: column;
    box-shadow: 2px 0 10px rgba(0, 0, 0, 0.1);
    z-index: 1000;
    transition: transform 0.3s ease, width 0.3s ease;
}

.sidebar.collapsed {
    width: var(--sidebar-collapsed-width);
}

/* Sidebar Header */
.sidebar-header {
    padding: 1.5rem 1rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    background: rgba(0, 0, 0, 0.2);
}

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    font-size: 1.25rem;
    font-weight: 700;
    white-space: nowrap;
}

.brand-icon {
    font-size: 1.75rem;
    flex-shrink: 0;
}

.brand-icon i {
    color: #22c55e;
}

.brand-text {
    transition: opacity 0.3s ease;
}

.sidebar.collapsed .brand-text {
    opacity: 0;
    width: 0;
    overflow: hidden;
}

/* Sidebar Navigation */
.sidebar-nav {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 1rem 0;
}

.nav-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

.nav-item {
    margin: 0.25rem 0;
}

.sidebar .nav-link {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.875rem 1.25rem;
    color: rgba(255, 255, 255, 0.8);
    text-decoration: none;
    transition: all 0.2s ease;
    cursor: pointer;
    position: relative;
    white-space: nowrap;
}

.sidebar .nav-link:hover {
    background-color: rgba(255, 255, 255, 0.1);
    color: white;
}

.sidebar .nav-link.active {
    background-color: rgba(37, 99, 235, 0.2);
    color: white;
    border-left: 4px solid var(--primary-color);
}

.nav-icon {
    font-size: 1.25rem;
    flex-shrink: 0;
    width: 1.5rem;
    text-align: center;
}

.nav-text {
    flex: 1;
    font-size: 0.95rem;
    font-weight: 500;
    transition: opacity 0.3s ease;
}

.sidebar.collapsed .nav-text {
    opacity: 0;
    width: 0;
    overflow: hidden;
}

/* Submenu */
.has-submenu .nav-link {
    justify-content: flex-start;
}

.submenu-arrow {
    font-size: 0.75rem;
    transition: transform 0.3s ease, opacity 0.3s ease;
    flex-shrink: 0;
    margin-right: 0.5rem;
    order: -1;
}

.nav-item.open .submenu-arrow i {
    transform: rotate(90deg);
}

.sidebar.collapsed .submenu-arrow {
    opacity: 0;
}

.nav-submenu {
    list-style: none;
    padding: 0;
    margin: 0;
    background-color: rgba(0, 0, 0, 0.2);
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s ease;
}

.nav-item.open .nav-submenu {
    max-height: 500px;
}

.nav-subitem {
    margin: 0;
}

.nav-sublink {
    display: flex;
    align-items: center;
    padding: 0.75rem 1.25rem 0.75rem 3.5rem;
    color: rgba(255, 255, 255, 0.7);
    text-decoration: none;
    font-size: 0.9rem;
    transition: all 0.2s ease;
}

.sidebar.collapsed .nav-sublink {
    padding-left: 1.25rem;
}

.nav-sublink:hover {
    background-color: rgba(255, 255, 255, 0.1);
    color: white;
}

.nav-sublink.active {
    background-color: rgba(37, 99, 235, 0.3);
    color: white;
    font-weight: 600;
}

.nav-subtext {
    transition: opacity 0.3s ease;
}

.sidebar.collapsed .nav-subtext {
    opacity: 0;
}

/* Sidebar Footer */
.sidebar-footer {
    padding: 1rem;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.75rem;
}

.version-info {
    font-size: 0.75rem;
    color: rgba(255, 255, 255, 0.5);
    transition: opacity 0.3s ease;
}

.sidebar.collapsed .version-info {
    opacity: 0;
}

/* Sidebar Toggle Button */
.sidebar-toggle-btn {
    width: 32px;
    height: 32px;
    background: rgba(255, 255, 255, 0.1);
    color: white;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1rem;
    transition: all 0.3s ease;
    position: absolute;
    bottom: 100%;
    right: 1rem;
    margin-bottom: 0.5rem;
}

.sidebar-toggle-btn:hover {
    background: rgba(255, 255, 255, 0.2);
    transform: scale(1.05);
}

.toggle-icon {
    font-size: 1rem;
    font-weight: normal;
    line-height: 1;
    transition: transform 0.3s ease;
}

.sidebar.collapsed .toggle-icon i {
    transform: rotate(180deg);
}

/* ============================================================================
   MAIN CONTENT AREA
   ============================================================================ */

.main-content {
    margin-left: var(--sidebar-width);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    transition: margin-left 0.3s ease;
    background-color: var(--bg-color);
}

.main-content.sidebar-collapsed {
    margin-left: var(--sidebar-collapsed-width);
}

/* Top Header */
.top-header {
    background: white;
    border-bottom: 1px solid var(--border-color);
    padding: 1.5rem 2rem;
    box-shadow: var(--shadow);
}

.header-content {
    max-width: 1400px;
    margin: 0 auto;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 2rem;
    flex-wrap: wrap;
}

.header-left {
    flex: 1;
}

.header-right {
    display: flex;
    align-items: center;
    gap: 1.5rem;
    margin-left: auto;
}

.page-title {
    font-size: 1.75rem;
    font-weight: 700;
    color: var(--text-color);
    margin: 0;
}

/* Content Wrapper */
.content-wrapper {
    flex: 1;
    padding: 2rem;
    max-width: 1400px;
    width: 100%;
    margin: 0 auto;
    box-sizing: border-box;
}

/* Footer */
.content-footer {
    background-color: var(--text-color);
    color: white;
    padding: 1.5rem 2rem;
    text-align: center;
    margin-top: auto;
}

.footer-content {
    max-width: 1400px;
    margin: 0 auto;
}

.footer-content p {
    margin: 0;
    opacity: 0.8;
    font-size: 0.9rem;
}

/* ============================================================================
   USER MENU
   ============================================================================ */

.user-menu {
    position: relative;
}

.user-info {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    background: transparent;
    border-radius: 6px;
    cursor: pointer;
    transition: background 0.3s;
    border: none;
}

.user-info:hover {
    background: rgba(0, 0, 0, 0.05);
}

.user-icon {
    font-size: 1.2rem;
    color: var(--text-color);
}

.user-name {
    font-size: 0.95rem;
    font-weight: 500;
    color: var(--text-color);
}

.user-badge-role {
    background: #ef4444;
    color: white;
    padding: 4px 10px;
    border-radius: 12px;
    font-size: 0.75rem;
    font-weight: 600;
}

.user-dropdown {
    display: none;
    position: absolute;
    right: 0;
    top: 100%;
    background: white;
    border-radius: 8px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.15);
    min-width: 200px;
    z-index: 1001;
    overflow: hidden;
    margin-top: 5px;
}

.user-menu:hover .user-dropdown {
    display: block;
}

.user-dropdown-content {
    padding: 8px 0;
}

.dropdown-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 16px;
    color: #374151;
    text-decoration: none;
    transition: background 0.2s;
}

.dropdown-item:hover {
    background: #f3f4f6;
}

.dropdown-item.logout {
    border-top: 1px solid #e5e7eb;
    color: #dc2626;
}

.dropdown-item.logout:hover {
    background: #fee2e2;
}

/* ============================================================================
   PAGE HEADER
   ============================================================================ */

.page-header {
    margin-bottom: 2rem;
}

.page-header h1 {
    font-size: 1.75rem;
    font-weight: 700;
    color: var(--text-color);
    margin-bottom: 0.5rem;
}

.page-header p {
    color: var(--text-muted);
    font-size: 1rem;
    margin: 0;
}

/* ============================================================================
   BUTTONS
   ============================================================================ */

.btn {
    padding: 0.625rem 1.25rem;
    border-radius: 0.5rem;
    font-weight: 500;
    font-size: 0.875rem;
    cursor: pointer;
    transition: all 0.2s ease;
    border: none;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
}

.btn-primary {
    background: linear-gradient(135deg, #2563eb 0%, #1e40af 100%);
    color: white;
}

.btn-primary:hover {
    background: linear-gradient(135deg, #1e40af 0%, #1e3a8a 100%);
    transform: translateY(-1px);
    box-shadow: var(--shadow-lg);
    color: white;
}

.btn-secondary {
    background: var(--secondary-color);
    color: white;
}

.btn-secondary:hover {
    background: #475569;
    color: white;
}

.btn-success {
    background: var(--success-color);
    color: white;
}

.btn-success:hover {
    background: #16a34a;
    color: white;
}

.btn-danger {
    background: var(--danger-color);
    color: white;
}

.btn-danger:hover {
    background: #dc2626;
    color: white;
}

.btn-warning {
    background: var(--warning-color);
    color: white;
}

.btn-warning:hover {
    background: #d97706;
    color: white;
}

.btn-info {
    background: #0ea5e9;
    color: white;
}

.btn-info:hover {
    background: #0284c7;
    color: white;
}

.btn-sm {
    padding: 0.375rem 0.75rem;
    font-size: 0.75rem;
}

/* ============================================================================
   BADGES
   ============================================================================ */

.badge {
    padding: 0.25rem 0.75rem;
    border-radius: 9999px;
    font-size: 0.75rem;
    font-weight: 600;
    display: inline-block;
}

.badge-primary {
    background: rgba(59, 130, 246, 0.1);
    color: var(--primary-color);
}

.badge-success {
    background: rgba(34, 197, 94, 0.1);
    color: var(--success-color);
}

.badge-danger {
    background: rgba(239, 68, 68, 0.1);
    color: var(--danger-color);
}

.badge-secondary {
    background: rgba(100, 116, 139, 0.1);
    color: var(--secondary-color);
}

.badge-warning {
    background: rgba(245, 158, 11, 0.1);
    color: var(--warning-color);
}

/* ============================================================================
   RESPONSIVE
   ============================================================================ */

@media screen and (max-width: 768px) {
    .sidebar {
        transform: translateX(-100%);
    }

    .sidebar.mobile-open {
        transform: translateX(0);
    }

    .main-content {
        margin-left: 0;
    }

    .main-content.sidebar-collapsed {
        margin-left: 0;
    }

    .content-wrapper {
        padding: 1rem;
    }

    .top-header {
        padding: 1rem;
    }

    .page-title {
        font-size: 1.25rem;
    }

    .header-content {
        gap: 1rem;
    }
}

/* ============================================================================
   UTILITY CLASSES
   ============================================================================ */

.text-center {
    text-align: center;
}

.text-muted {
    color: var(--text-muted);
}

.mb-3 {
    margin-bottom: 1rem;
}

.mt-3 {
    margin-top: 1rem;
}

.container-fluid {
    width: 100%;
    padding: 0;
}
