/* =====================================================
   SIDEBAR NAVIGATION - CASA DW REDESIGN V2
   ===================================================== */

/* Sidebar Container */
.sidebar {
    position: fixed;
    top: 0;
    left: 0;
    width: 260px;
    height: 100vh;
    background: var(--bg-secondary, #232936);
    border-right: 1px solid var(--border-color, #374151);
    display: flex;
    flex-direction: column;
    z-index: 1000;
    transition: transform 0.3s ease;
    overflow-y: auto;
}

/* Sidebar Logo Area */
.sidebar-logo {
    padding: 24px 20px;
    display: flex;
    align-items: center;
    gap: 14px;
    border-bottom: 1px solid var(--border-color, #374151);
    flex-shrink: 0;
}

.sidebar-logo img {
    width: 42px;
    height: 42px;
    border-radius: 10px;
    object-fit: contain;
    background: var(--bg-card, #2a3142);
    padding: 4px;
}

.sidebar-logo-text h2 {
    font-size: 16px;
    font-weight: 700;
    color: var(--text-primary, #fff);
    margin: 0;
    line-height: 1.2;
}

.sidebar-logo-text span {
    font-size: 11px;
    color: var(--text-muted, #6b7280);
    letter-spacing: 0.5px;
}

/* Navigation Menu */
.sidebar-nav {
    flex: 1;
    padding: 16px 0;
}

.sidebar-nav-label {
    padding: 8px 24px;
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 1.5px;
    color: var(--text-muted, #6b7280);
    font-weight: 600;
    margin-top: 8px;
}

.sidebar-nav a {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 24px;
    color: var(--text-secondary, #9ca3af);
    text-decoration: none;
    font-size: 14px;
    font-weight: 500;
    transition: all 0.2s ease;
    border-left: 3px solid transparent;
    margin: 2px 0;
}

.sidebar-nav a:hover {
    color: var(--text-primary, #fff);
    background: rgba(99, 102, 241, 0.08);
    border-left-color: rgba(99, 102, 241, 0.4);
}

.sidebar-nav a.active {
    color: var(--primary, #6366f1);
    background: rgba(99, 102, 241, 0.12);
    border-left-color: var(--primary, #6366f1);
    font-weight: 600;
}

.sidebar-nav a i {
    width: 20px;
    text-align: center;
    font-size: 16px;
}

.sidebar-nav a .nav-badge {
    margin-left: auto;
    background: var(--danger, #ef4444);
    color: white;
    font-size: 10px;
    font-weight: 700;
    padding: 2px 7px;
    border-radius: 10px;
    min-width: 18px;
    text-align: center;
}

/* Sidebar User Profile (Bottom) */
.sidebar-user {
    padding: 16px 20px;
    border-top: 1px solid var(--border-color, #374151);
    display: flex;
    align-items: center;
    gap: 12px;
    flex-shrink: 0;
}

.sidebar-user-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--gradient-primary, linear-gradient(135deg, #6366f1, #8b5cf6));
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: 700;
    font-size: 14px;
    flex-shrink: 0;
}

.sidebar-user-info {
    flex: 1;
    min-width: 0;
}

.sidebar-user-info .user-name {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-primary, #fff);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.sidebar-user-info .user-status {
    font-size: 11px;
    color: var(--success, #10b981);
    display: flex;
    align-items: center;
    gap: 4px;
}

.sidebar-user-info .user-status::before {
    content: '';
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--success, #10b981);
    display: inline-block;
}

.sidebar-logout {
    background: none;
    border: none;
    color: var(--text-muted, #6b7280);
    cursor: pointer;
    padding: 6px;
    border-radius: 6px;
    transition: all 0.2s;
    font-size: 16px;
}

.sidebar-logout:hover {
    color: var(--danger, #ef4444);
    background: rgba(239, 68, 68, 0.1);
}

/* Mobile Toggle Button */
.sidebar-toggle {
    display: none;
    position: fixed;
    top: 12px;
    left: 12px;
    z-index: 1001;
    background: var(--bg-card, #2a3142);
    border: 1px solid var(--border-color, #374151);
    color: var(--text-primary, #fff);
    width: 42px;
    height: 42px;
    border-radius: 10px;
    cursor: pointer;
    font-size: 18px;
    display: none;
    align-items: center;
    justify-content: center;
    box-shadow: var(--shadow, 0 4px 6px rgba(0,0,0,0.3));
}

/* Overlay for mobile */
.sidebar-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 999;
}

.sidebar-overlay.active {
    display: block;
}

/* =====================================================
   LAYOUT ADJUSTMENTS - Push content to the right
   ===================================================== */

/* Main app content shift */
body.has-sidebar .container,
body.has-sidebar .frota-container,
body.has-sidebar .manut-container,
body.has-sidebar .reports-container {
    margin-left: 260px;
    width: calc(100% - 260px);
    max-width: none;
}

/* Hide old navigation elements when sidebar is active */
body.has-sidebar .header {
    display: none;
}

body.has-sidebar .frota-header {
    padding-top: 20px;
}

body.has-sidebar .manut-header {
    padding-top: 20px;
}

/* Frota/Manutencoes - hide the Voltar/Dashboard buttons since sidebar has navigation */
body.has-sidebar #btnVoltar,
body.has-sidebar .frota-header-right .btn-secondary:last-child {
    /* Keep Voltar visible as users might expect it */
}

/* Reports back button - keep but adjust */
body.has-sidebar .back-button {
    display: none;
}

/* Login page should NOT have sidebar */
body.has-sidebar .login-page {
    margin-left: 0;
    width: 100%;
}

/* Don't shift login page */
.login-page ~ .sidebar,
#loginPage[style*="block"] ~ .sidebar {
    display: none;
}

/* =====================================================
   RESPONSIVE - MOBILE SIDEBAR
   ===================================================== */
@media (max-width: 1024px) {
    .sidebar {
        transform: translateX(-100%);
    }

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

    .sidebar-toggle {
        display: flex !important;
    }

    body.has-sidebar .container,
    body.has-sidebar .frota-container,
    body.has-sidebar .manut-container,
    body.has-sidebar .reports-container {
        margin-left: 0;
        width: 100%;
    }

    /* Show old header on mobile for back navigation */
    body.has-sidebar .header {
        display: none;
    }

    /* Add top padding for toggle button */
    body.has-sidebar .container,
    body.has-sidebar .frota-container,
    body.has-sidebar .manut-container,
    body.has-sidebar .reports-container {
        padding-top: 60px;
    }

    body.has-sidebar .frota-header,
    body.has-sidebar .manut-header {
        padding-top: 60px;
    }
}

@media (max-width: 768px) {
    .sidebar {
        width: 280px;
    }

    .sidebar-toggle {
        top: 10px;
        left: 10px;
        width: 38px;
        height: 38px;
        font-size: 16px;
    }
}

/* Print - hide sidebar */
@media print {
    .sidebar,
    .sidebar-toggle,
    .sidebar-overlay {
        display: none !important;
    }

    body.has-sidebar .container,
    body.has-sidebar .frota-container,
    body.has-sidebar .manut-container,
    body.has-sidebar .reports-container {
        margin-left: 0 !important;
        width: 100% !important;
    }
}
