/**
 * Sidebar Styles
 * Estratto da app.blade.php per una migliore manutenibilità
 */

/* ==========================================================================
   Base Sidebar
   ========================================================================== */

.sidebar {
    position: fixed;
    top: 0;
    left: 0;
    width: 60px;
    height: 100vh;
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.65) 0%, rgba(255, 255, 255, 0.55) 100%);
    backdrop-filter: blur(24px) saturate(200%);
    -webkit-backdrop-filter: blur(24px) saturate(200%);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.15), inset 0 0 0 1px rgba(255, 255, 255, 0.4);
    border-right: 1px solid rgba(255, 255, 255, 0.3);
    transition: width 0.3s ease-in-out;
    z-index: 1000;
    padding-top: 20px;
    overflow-y: auto;
    overflow-x: hidden;
    display: flex;
    flex-direction: column;
    padding-bottom: 60px;
    scrollbar-width: thin;
    scrollbar-color: #bbb transparent;
}

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

.sidebar::-webkit-scrollbar-thumb {
    background: rgba(0, 0, 0, .18);
    border-radius: 8px;
}

.sidebar::-webkit-scrollbar-track {
    background: transparent;
}

/* Espansione sidebar */
.sidebar.expanded {
    width: 250px;
}

.sidebar.peek {
    width: 250px;
}

/* ==========================================================================
   Sidebar Header
   ========================================================================== */

.sidebar-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 10px;
    min-height: 70px;
    border-bottom: 1px solid rgba(0, 0, 0, 0.06);
    margin-bottom: 8px;
}

.sidebar .logo {
    display: flex;
    align-items: center;
    justify-content: center;
    flex: 1;
    overflow: hidden;
}

.sidebar .logo img {
    width: 38px;
    height: 38px;
    object-fit: contain;
    transition: all 0.3s ease;
    filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.1));
}

.sidebar.expanded .logo img,
.sidebar.peek .logo img {
    width: auto;
    height: 45px;
    max-width: 160px;
}

/* Toggle Button */
.toggle-btn {
    background: rgba(230, 0, 35, 0.08);
    border: none;
    cursor: pointer;
    font-size: 1.2rem;
    color: #e60023;
    transition: all 0.2s ease;
    width: 36px;
    height: 36px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.toggle-btn:hover {
    background: rgba(230, 0, 35, 0.15);
    transform: scale(1.05);
}

/* Header layout quando collassata */
.sidebar:not(.expanded):not(.peek) .sidebar-header {
    flex-direction: column;
    gap: 8px;
    padding: 10px 8px;
}

.sidebar:not(.expanded):not(.peek) .sidebar-header .logo {
    order: 1;
}

.sidebar:not(.expanded):not(.peek) .sidebar-header .toggle-btn {
    order: 2;
}

/* ==========================================================================
   User Profile Section
   ========================================================================== */

.sidebar-user {
    display: flex;
    align-items: center;
    padding: 12px 10px;
    gap: 10px;
}

.sidebar-user .theme-toggle {
    margin-left: auto;
    display: none;
}

.sidebar.expanded .sidebar-user .theme-toggle,
.sidebar.peek .sidebar-user .theme-toggle {
    display: flex;
}

.user-avatar {
    width: 36px;
    height: 36px;
    min-width: 36px;
    border-radius: 50%;
    background: linear-gradient(135deg, #e60023 0%, #a80019 100%);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 13px;
    text-transform: uppercase;
    box-shadow: 0 2px 8px rgba(230, 0, 35, 0.3);
}

.user-info {
    display: none;
    flex-direction: column;
    overflow: hidden;
}

.sidebar.expanded .user-info,
.sidebar.peek .user-info {
    display: flex;
}

.user-name {
    font-weight: 700;
    font-size: 14px;
    color: #1a1a1a;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    text-shadow: 0 1px 2px rgba(255, 255, 255, 0.5);
}

.user-role {
    font-size: 11px;
    padding: 2px 8px;
    border-radius: 10px;
    display: inline-flex;
    align-items: center;
    width: fit-content;
}

.user-role.admin {
    background: linear-gradient(135deg, #ffd700 0%, #ffb700 100%);
    color: #6b5200;
}

.user-role.staff {
    background: #e9ecef;
    color: #6c757d;
}

/* ==========================================================================
   Navigation Links
   ========================================================================== */

.sidebar .nav-links {
    list-style: none;
    padding: 0;
    margin: 0;
    padding-bottom: 20px;
}

.nav-section {
    padding: 6px 10px;
}

.nav-section-title {
    font-size: 12px;
    letter-spacing: .08em;
    color: #7a7a7a;
    margin: 10px 10px 6px;
    text-transform: uppercase;
    display: none;
}

.sidebar.expanded .nav-section-title,
.sidebar.peek .nav-section-title {
    display: block;
}

.nav-divider {
    height: 1px;
    margin: 8px 12px;
    background: linear-gradient(90deg, rgba(0, 0, 0, 0) 0%, rgba(0, 0, 0, .12) 50%, rgba(0, 0, 0, 0) 100%);
}

.sidebar .nav-links li {
    padding: 0;
    margin: 0;
}

.sidebar .nav-links li a {
    display: flex;
    align-items: center;
    text-decoration: none;
    font-size: 18px;
    color: #2a2a2a;
    font-weight: 500;
    gap: 10px;
    padding: 12px 16px;
    border-radius: 10px;
    position: relative;
    transition: background 0.2s ease, color 0.2s ease, padding 0.2s ease;
    text-shadow: 0 1px 2px rgba(255, 255, 255, 0.4);
}

/* Icone */
.sidebar .nav-links li a .nav-icon {
    width: 26px;
    height: 26px;
    min-width: 26px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
}

.sidebar .nav-links li a .nav-icon i {
    font-size: 18px;
    color: var(--tenant-primary, #10b981);
    transition: transform 0.3s ease, color 0.3s ease;
}

.sidebar .nav-links li a:hover .nav-icon i {
    transform: scale(1.15);
    color: var(--tenant-primary-dark, #059669);
}

.sidebar .nav-links li a.active .nav-icon i {
    color: var(--tenant-primary, #10b981);
    filter: drop-shadow(0 2px 4px rgba(16, 185, 129, 0.3));
}

/* Fallback per icone Font Awesome (i) senza .nav-icon */
.sidebar .nav-links li a > i {
    font-size: 18px;
    width: 26px;
    min-width: 26px;
    text-align: center;
    color: var(--tenant-primary, #10b981);
    transition: all 0.3s ease;
}

.sidebar .nav-links li a:hover > i {
    transform: scale(1.1);
    color: var(--tenant-primary-dark, #059669);
}

.sidebar .nav-links li a.active > i {
    color: var(--tenant-primary-dark, #059669);
}

/* Link text */
.sidebar .nav-links li a .link-text {
    display: none;
    transition: opacity 0.3s;
}

.sidebar.expanded .nav-links li a .link-text,
.sidebar.peek .nav-links li a .link-text {
    display: inline;
    opacity: 1;
    margin-left: 10px;
}

/* Hover effect */
.sidebar .nav-links li a:hover {
    background: rgba(230, 0, 35, 0.08);
    color: #d1001e;
    padding-left: 20px;
}

/* Active state */
.sidebar .nav-links li a.active {
    background: rgba(230, 0, 35, 0.14);
    color: #d1001e;
}

.sidebar .nav-links li a.active::before {
    content: "";
    position: absolute;
    left: 0;
    top: 8px;
    bottom: 8px;
    width: 3px;
    border-radius: 0 4px 4px 0;
    background: #e60023;
}

/* ==========================================================================
   Super Admin Links (stile specifico)
   ========================================================================== */

.sidebar .nav-links li a.super-admin-link {
    border-left: 2px solid transparent;
}

.sidebar .nav-links li a.super-admin-link > i {
    color: #dc3545;
}

.sidebar .nav-links li a.super-admin-link:hover {
    background: rgba(220, 53, 69, 0.1);
    border-left-color: #dc3545;
}

.sidebar .nav-links li a.super-admin-link.active {
    background: rgba(220, 53, 69, 0.15);
    border-left-color: #dc3545;
}

.sidebar .nav-links li a.super-admin-link.active::before {
    background: #dc3545;
}

/* ==========================================================================
   Nav Badges
   ========================================================================== */

.nav-badge {
    display: none;
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 11px;
    font-weight: 600;
    margin-left: auto;
}

.sidebar.expanded .nav-badge,
.sidebar.peek .nav-badge {
    display: inline-block;
}

.nav-badge.available {
    background: color-mix(in srgb, var(--tenant-primary, #10b981) 15%, white);
    color: var(--tenant-primary-dark, #059669);
}

.nav-badge.active {
    background: #fff3cd;
    color: #856404;
}

/* Alert Dot */
.alert-dot {
    position: absolute;
    top: 8px;
    right: 8px;
    width: 8px;
    height: 8px;
    background: var(--tenant-accent, #f59e0b);
    border-radius: 50%;
    animation: pulse-dot 2s infinite;
}

@keyframes pulse-dot {
    0%, 100% {
        opacity: 1;
        transform: scale(1);
    }
    50% {
        opacity: 0.7;
        transform: scale(1.2);
    }
}

/* ==========================================================================
   Sidebar Stats
   ========================================================================== */

.sidebar-stats {
    display: none;
    padding: 10px;
    gap: 8px;
}

.sidebar.expanded .sidebar-stats,
.sidebar.peek .sidebar-stats {
    display: flex;
}

.stat-mini {
    flex: 1;
    background: rgba(255, 255, 255, 0.35);
    border-radius: 10px;
    padding: 10px 8px;
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
}

.stat-mini i {
    font-size: 16px;
}

.stat-mini .stat-value {
    font-size: 18px;
    font-weight: 700;
    color: #1a1a1a;
    text-shadow: 0 1px 2px rgba(255, 255, 255, 0.5);
}

.stat-mini .stat-label {
    font-size: 10px;
    color: #888;
    text-transform: uppercase;
}

/* ==========================================================================
   Theme Toggle
   ========================================================================== */

.theme-toggle {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    border: none;
    background: rgba(0, 0, 0, 0.06);
    color: #555;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

.theme-toggle:hover {
    background: rgba(230, 0, 35, 0.1);
    color: #e60023;
}

/* ==========================================================================
   Tooltip for collapsed sidebar
   ========================================================================== */

.sidebar:not(.expanded):not(.peek) .nav-links li a {
    position: relative;
    justify-content: center;
    padding: 14px 8px;
}

.sidebar:not(.expanded):not(.peek) .nav-links li a .nav-icon,
.sidebar:not(.expanded):not(.peek) .nav-links li a i {
    margin: 0;
}

.sidebar:not(.expanded):not(.peek) .nav-links li a::after {
    content: attr(title);
    position: absolute;
    left: 100%;
    top: 50%;
    transform: translateY(-50%);
    background: #333;
    color: white;
    padding: 6px 12px;
    border-radius: 6px;
    font-size: 13px;
    white-space: nowrap;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.2s, visibility 0.2s;
    margin-left: 10px;
    z-index: 1001;
    pointer-events: none;
}

.sidebar:not(.expanded):not(.peek) .nav-links li a:hover::after {
    opacity: 1;
    visibility: visible;
}

/* ==========================================================================
   Content Area
   ========================================================================== */

.content {
    margin-left: 60px;
    transition: margin-left 0.3s ease-in-out, width 0.3s ease-in-out;
}

.sidebar.expanded + .content {
    margin-left: 250px;
}

/* ==========================================================================
   Mobile Overlay & FAB
   ========================================================================== */

.sidebar-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.35);
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.2s ease;
    z-index: 900;
}

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

.sidebar-fab {
    position: fixed;
    bottom: 16px;
    left: 16px;
    width: 46px;
    height: 46px;
    border-radius: 50%;
    border: none;
    background: #e60023;
    color: #fff;
    display: none;
    align-items: center;
    justify-content: center;
    box-shadow: 0 6px 16px rgba(0, 0, 0, .25);
    z-index: 1100;
}

.sidebar-fab i {
    font-size: 18px;
}

/* ==========================================================================
   Responsive
   ========================================================================== */

@media (max-width: 992px) {
    .sidebar {
        transform: translateX(-100%);
        width: 250px;
        overflow-y: auto;
        overflow-x: hidden;
    }

    .sidebar.expanded {
        transform: translateX(0);
    }

    .content {
        margin-left: 0 !important;
    }

    .sidebar.expanded .sidebar-user .theme-toggle {
        display: flex;
    }

    .sidebar-fab {
        display: inline-flex;
    }
}

/* ==========================================================================
   Dark Theme Overrides
   ========================================================================== */

.dark-theme .sidebar {
    background: linear-gradient(180deg, rgba(30, 30, 40, 0.95) 0%, rgba(25, 25, 35, 0.98) 100%);
    border-right-color: rgba(255, 255, 255, 0.08);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4), inset 0 0 0 1px rgba(255, 255, 255, 0.05);
}

.dark-theme .sidebar-header {
    border-bottom-color: rgba(255, 255, 255, 0.08);
}

.dark-theme .sidebar .nav-links li a {
    color: #e0e0e0;
    text-shadow: none;
}

.dark-theme .sidebar .nav-links li a:hover {
    background: rgba(230, 0, 35, 0.15);
    color: #ff6b7a;
}

.dark-theme .sidebar .nav-links li a.active {
    background: rgba(230, 0, 35, 0.2);
    color: #ff6b7a;
}

.dark-theme .nav-section-title {
    color: #999;
}

.dark-theme .nav-divider {
    background: linear-gradient(90deg, rgba(255, 255, 255, 0) 0%, rgba(255, 255, 255, .1) 50%, rgba(255, 255, 255, 0) 100%);
}

.dark-theme .user-name {
    color: #f0f0f0;
    text-shadow: none;
}

.dark-theme .user-role.staff {
    background: rgba(108, 117, 125, 0.3);
    color: #d0d0d0;
}

.dark-theme .stat-mini {
    background: rgba(255, 255, 255, 0.08);
}

.dark-theme .stat-mini .stat-value {
    color: #f0f0f0;
    text-shadow: none;
}

.dark-theme .stat-mini .stat-label {
    color: #999;
}

.dark-theme .toggle-btn {
    background: rgba(230, 0, 35, 0.15);
}

.dark-theme .toggle-btn:hover {
    background: rgba(230, 0, 35, 0.25);
}

.dark-theme .theme-toggle {
    background: rgba(255, 255, 255, 0.1);
    color: #ccc;
}

.dark-theme .theme-toggle:hover {
    background: rgba(230, 0, 35, 0.2);
    color: #ff6b7a;
}
