/* ========================================
   PROFESSIONAL SIDEBAR NAVIGATION STYLES
   ======================================== */

:root {
    --sidebar-width: 280px;
    --sidebar-width-collapsed: 80px;
    --sidebar-bg: #1a1f2e;
    --sidebar-text: #f0f0f0;
    --sidebar-hover-bg: #2a3142;
    --sidebar-accent: #4ecdc4;
    --sidebar-accent-dark: #3aadac;
    --sidebar-border: rgba(255, 255, 255, 0.1);
    --topbar-height: 60px;
    --transition-speed: 0.3s;
}

[data-theme="light"] {
    --sidebar-bg: #ffffff;
    --sidebar-text: #2c3e50;
    --sidebar-hover-bg: #ecf0f1;
    --sidebar-accent: #0052cc;
    --sidebar-accent-dark: #003d99;
    --sidebar-border: #e2e8f0;
}

[data-theme="dark"] {
    --sidebar-bg: #1a1f2e;
    --sidebar-text: #f0f0f0;
    --sidebar-hover-bg: #2a3142;
    --sidebar-accent: #4ecdc4;
    --sidebar-accent-dark: #3aadac;
    --sidebar-border: rgba(255, 255, 255, 0.1);
}

/* ========================================
   MAIN LAYOUT STRUCTURE
   ======================================== */

.sidebar-layout {
    display: flex;
    flex-direction: column;
}

.topbar {
    position: sticky;
    top: 0;
    z-index: 1030;
    height: var(--topbar-height);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.topbar .navbar {
    padding: 0.75rem 1rem;
    min-height: var(--topbar-height);
}

.main-layout {
    display: flex;
    flex-grow: 1;
    overflow: hidden;
    margin-top: var(--topbar-height);
}

/* ========================================
   SIDEBAR STYLES (Desktop)
   ======================================== */

.sidebar {
    background-color: var(--sidebar-bg);
    color: var(--sidebar-text);
    width: var(--sidebar-width);
    height: calc(100vh - var(--topbar-height));
    border-right: 1px solid var(--sidebar-border);
    display: flex;
    flex-direction: column;
    transition: width var(--transition-speed) ease;
    overflow: hidden;
    position: relative;
}

/* Ensure dark mode text is bright */
[data-theme="dark"] .sidebar,
html:not([data-theme]) .sidebar {
    color: #f0f0f0 !important;
}

[data-theme="light"] .sidebar {
    color: #2c3e50;
}

.sidebar.show {
    width: var(--sidebar-width);
}

/* Sidebar Content */
.sidebar-content {
    display: flex;
    flex-direction: column;
    height: 100%;
    overflow-y: auto;
    scrollbar-width: thin;
    scrollbar-color: var(--sidebar-accent) transparent;
}

.sidebar-content::-webkit-scrollbar {
    width: 6px;
}

.sidebar-content::-webkit-scrollbar-track {
    background: transparent;
}

.sidebar-content::-webkit-scrollbar-thumb {
    background: var(--sidebar-accent);
    border-radius: 3px;
}

.sidebar-content::-webkit-scrollbar-thumb:hover {
    background: var(--sidebar-accent-dark);
}

/* Sidebar Header */
.sidebar-header {
    padding: 1.5rem 1.25rem;
    border-bottom: 1px solid var(--sidebar-border);
    font-size: 0.95rem;
    gap: 0.5rem;
}

.sidebar-header h6 {
    color: var(--sidebar-text);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    font-size: 0.85rem;
}

.sidebar-collapse-btn {
    background: none;
    border: none;
    color: var(--sidebar-text);
    padding: 0.25rem 0.5rem;
    cursor: pointer;
    transition: all var(--transition-speed) ease;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.sidebar-collapse-btn:hover {
    color: var(--sidebar-accent);
    transform: scale(1.1);
}

/* ========================================
   SIDEBAR NAVIGATION
   ======================================== */

.sidebar-nav {
    flex: 1;
    padding: 1.5rem 0.75rem;
    overflow-y: auto;
}

.nav-group {
    margin-bottom: 2rem;
}

.nav-group:last-child {
    margin-bottom: 0;
}

.nav-group-title {
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--sidebar-text);
    opacity: 0.85;
    padding: 0.5rem 1rem 0.75rem;
    margin: 0;
}

[data-theme="light"] .nav-group-title {
    color: #2c3e50;
    opacity: 0.8;
}

[data-theme="dark"] .nav-group-title {
    color: #f0f0f0;
    opacity: 0.9;
}

/* Navigation Items */
.nav-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 1rem;
    margin: 0.35rem 0;
    border-radius: 0.5rem;
    color: var(--sidebar-text) !important;
    text-decoration: none;
    transition: all var(--transition-speed) ease;
    cursor: pointer;
    position: relative;
    font-weight: 600;
    font-size: 0.95rem;
    white-space: nowrap;
    opacity: 1;
}

.nav-item:hover {
    background-color: var(--sidebar-hover-bg);
    color: var(--sidebar-accent);
    transform: translateX(5px);
    font-weight: 700;
}

.nav-item:active,
.nav-item.active {
    background: rgba(0, 82, 204, 0.1);
    color: var(--sidebar-accent);
    border-left: 3px solid var(--sidebar-accent);
    padding-left: calc(1rem - 3px);
    font-weight: 700;
}

[data-theme="light"] .nav-item {
    color: #1a3a52 !important;
    font-weight: 600;
}

[data-theme="light"] .nav-item:hover {
    color: #0052cc !important;
    background-color: #e8f0fb;
    font-weight: 700;
}

[data-theme="light"] .nav-item:active,
[data-theme="light"] .nav-item.active {
    background: rgba(0, 82, 204, 0.12);
    color: #0052cc !important;
    border-left: 3px solid #0052cc;
    font-weight: 700;
}

[data-theme="dark"] .nav-item {
    color: #f0f0f0 !important;
    font-weight: 600;
}

[data-theme="dark"] .nav-item:hover {
    color: #4ecdc4 !important;
    background-color: #2a3142;
    font-weight: 700;
}

[data-theme="dark"] .nav-item:active,
[data-theme="dark"] .nav-item.active {
    color: #4ecdc4 !important;
    border-left: 3px solid #4ecdc4;
    font-weight: 700;
}

.nav-item i {
    font-size: 1.1rem;
    min-width: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--transition-speed) ease;
}

[data-theme="light"] .nav-item i {
    color: #1a3a52;
}

[data-theme="dark"] .nav-item i {
    color: #f0f0f0;
}

.nav-item span {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    color: inherit;
}

[data-theme="light"] .nav-item span {
    color: #1a3a52;
}

[data-theme="dark"] .nav-item span {
    color: #f0f0f0;
}

/* Navigation Badge */
.nav-badge {
    display: inline-block;
    padding: 0.25rem 0.5rem;
    background-color: var(--sidebar-accent);
    color: white;
    border-radius: 12px;
    font-size: 0.65rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    white-space: nowrap;
    margin-left: auto;
}

.nav-badge.bg-primary {
    background-color: #3498db;
}

/* ========================================
   SIDEBAR FOOTER
   ======================================== */

.sidebar-footer {
    padding: 1rem 0.75rem;
    border-top: 1px solid var(--sidebar-border);
    margin-top: auto;
}

.btn-sidebar-logout {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
    padding: 0.75rem 1rem;
    background-color: transparent;
    color: var(--sidebar-text);
    border: 2px solid var(--sidebar-accent);
    border-radius: 0.5rem;
    font-weight: 600;
    transition: all var(--transition-speed) ease;
    cursor: pointer;
}

.btn-sidebar-logout:hover {
    background-color: #e74c3c;
    border-color: #e74c3c;
    color: white;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(231, 76, 60, 0.3);
}

.btn-sidebar-logout i {
    font-size: 1.1rem;
}

/* ========================================
   TOPBAR USER MENU
   ======================================== */

.user-menu-link {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem !important;
    border-radius: 0.4rem;
    transition: all var(--transition-speed) ease;
}

.user-menu-link:hover {
    background-color: rgba(255, 255, 255, 0.1);
    color: var(--sidebar-accent) !important;
}

/* ========================================
   CONTENT WRAPPER
   ======================================== */

.content-wrapper {
    flex: 1;
    display: flex;
    flex-direction: column;
    background-color: #0f1419;
    overflow-y: auto;
}

[data-theme="light"] .content-wrapper {
    background-color: #f8f9fa;
}

[data-theme="dark"] .content-wrapper {
    background-color: #0f1419;
}

.content-area {
    padding: 2rem 1.5rem;
    flex-grow: 1;
}

/* ========================================
   RESPONSIVE - MOBILE & TABLET
   ======================================== */

@media (max-width: 991.98px) {
    /* Let Bootstrap offcanvas handle positioning and animations */
    .sidebar {
        width: min(280px, 80vw) !important;
        z-index: 1050 !important;
        position: fixed !important;
        top: 0 !important;
        bottom: 0 !important;
        left: -100% !important;
        height: 100vh !important;
        transition: left var(--transition-speed) ease !important;
    }

    .sidebar.show {
        left: 0 !important;
    }

    .sidebar.offcanvas-start {
        border-right: 1px solid var(--sidebar-border);
    }

    /* Offcanvas header styling */
    .sidebar .offcanvas-header {
        background-color: var(--sidebar-bg);
        border-bottom: 1px solid var(--sidebar-border);
        padding: 1rem 0.75rem;
    }

    .sidebar .offcanvas-header .offcanvas-title {
        color: var(--sidebar-text);
        font-weight: 600;
        display: flex;
        align-items: center;
        gap: 0.5rem;
    }

    .sidebar .offcanvas-header .btn-close {
        filter: invert(1);
        opacity: 0.8;
    }

    [data-theme="light"] .sidebar .offcanvas-header .btn-close {
        filter: invert(0);
    }

    /* Offcanvas body */
    .sidebar .offcanvas-body {
        padding: 0 !important;
        overflow-y: auto !important;
    }

    /* Offcanvas backdrop */
    .offcanvas-backdrop.show {
        opacity: 0.5;
        background-color: rgba(0, 0, 0, 0.5);
    }

    .main-layout {
        margin-top: 0;
    }
}

/* DESKTOP: Show sidebar permanently */
@media (min-width: 992px) {
    .sidebar {
        position: static !important;
        height: calc(100vh - var(--topbar-height)) !important;
        width: var(--sidebar-width) !important;
        z-index: auto !important;
        visibility: visible !important;
        left: auto !important;
        top: auto !important;
        border-right: 1px solid rgba(255, 255, 255, 0.1) !important;
        box-shadow: none !important;
    }

    .sidebar.offcanvas-start {
        transform: none !important;
    }

    .offcanvas-backdrop {
        display: none !important;
    }

    .offcanvas-header {
        display: none !important;
    }
}

@media (max-width: 768px) {
    .content-area {
        padding: 1.5rem 1rem;
    }

    .nav-item {
        padding: 0.65rem 0.75rem;
        gap: 0.5rem;
    }

    .nav-group-title {
        padding: 0.4rem 0.75rem 0.5rem;
    }

    .sidebar-header {
        padding: 1rem 0.75rem;
    }

    .sidebar-footer {
        padding: 0.75rem 0.5rem;
    }
}

/* ========================================
   ALERTS & MESSAGES
   ======================================== */

.alert {
    border: none;
    border-left: 4px solid;
    border-radius: 0.5rem;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.alert-success {
    border-left-color: #27ae60;
    background-color: rgba(39, 174, 96, 0.1);
    color: #27ae60;
}

.alert-danger {
    border-left-color: #e74c3c;
    background-color: rgba(231, 76, 60, 0.1);
    color: #e74c3c;
}

.alert i {
    margin-right: 0.5rem;
}

/* ========================================
   TOPBAR BRAND & TOGGLE
   ======================================== */

.sidebar-toggle {
    border: none;
    background: transparent;
    color: white;
    font-size: 1.5rem;
    padding: 0.25rem;
    transition: all var(--transition-speed) ease;
}

.sidebar-toggle:hover {
    color: var(--sidebar-accent);
}

.sidebar-toggle:focus {
    box-shadow: none;
    color: var(--sidebar-accent);
}

/* ========================================
   DROPDOWN MENU STYLES
   ======================================== */

.dropdown-menu {
    background-color: #1a1f2e;
    border-color: rgba(255, 255, 255, 0.1);
    border-radius: 0.5rem;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

[data-theme="light"] .dropdown-menu {
    background-color: #ffffff;
    border-color: #e0e0e0;
}

.dropdown-item {
    color: var(--sidebar-text);
    transition: all var(--transition-speed) ease;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.dropdown-item:hover {
    background-color: var(--sidebar-hover-bg);
    color: var(--sidebar-accent);
}

.dropdown-divider {
    border-color: rgba(255, 255, 255, 0.1);
}

/* ========================================
   ACCESSIBILITY
   ======================================== */

.nav-item:focus,
.btn-sidebar-logout:focus {
    outline: 2px solid var(--sidebar-accent);
    outline-offset: 2px;
}

/* Keyboard navigation */
.nav-item:focus-visible,
.btn-sidebar-logout:focus-visible {
    outline: 2px solid var(--sidebar-accent);
    outline-offset: 2px;
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
    .sidebar,
    .nav-item,
    .btn-sidebar-logout,
    .sidebar-collapse-btn,
    .user-menu-link {
        transition: none;
    }
}

/* ========================================
   PRINT STYLES
   ======================================== */

@media print {
    .sidebar,
    .topbar,
    .fullscreen-footer {
        display: none !important;
    }

    .main-layout {
        margin: 0;
    }

    .content-wrapper {
        background-color: white;
    }
}

/* ========================================
   FOOTER (Updated for Layout)
   ======================================== */

.fullscreen-footer {
    width: 100%;
    background-color: var(--sidebar-bg);
    color: var(--sidebar-text);
    border-top: 2px solid rgba(52, 152, 219, 0.3);
    padding: 3rem 0 1.5rem 0;
    margin-top: auto;
}

[data-theme="light"] .fullscreen-footer {
    background-color: #f8f9fa;
    border-top-color: rgba(0, 82, 204, 0.2);
}

.fullscreen-footer .footer-content {
    width: 100%;
    max-width: 1400px;
    margin: 0 auto;
    padding: 0 1rem;
}

.footer-section {
    padding: 0.5rem 0;
    text-align: center;
}

.footer-title {
    color: var(--sidebar-accent);
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1px;
    font-size: 1.1rem;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 1rem;
}

.footer-title img {
    display: block;
}

.footer-subtitle {
    color: var(--sidebar-text);
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    font-size: 0.95rem;
    text-align: center;
}

.footer-desc {
    font-size: 0.95rem;
    color: var(--sidebar-text);
    opacity: 0.85;
    line-height: 1.6;
    margin: 0;
    text-align: center;
}

[data-theme="light"] .footer-desc {
    color: #4a5568;
}

.footer-links {
    list-style: none;
    padding: 0;
    margin: 0;
    display: flex;
    justify-content: center;
    flex-wrap: wrap;
    gap: 1.5rem;
}

.footer-links li {
    margin-bottom: 0;
}

.footer-links a {
    color: var(--sidebar-text);
    opacity: 0.85;
    text-decoration: none;
    font-size: 0.95rem;
    transition: all var(--transition-speed) ease;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
}

[data-theme="light"] .footer-links a {
    color: #4a5568;
}

.footer-links a:hover {
    color: var(--sidebar-accent);
    opacity: 1;
    transform: translateX(0);
    text-decoration: none;
}

.fullscreen-footer .social-links {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    justify-content: center;
}

.fullscreen-footer .social-links .social-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background-color: rgba(255, 255, 255, 0.1);
    color: var(--sidebar-text);
    transition: all var(--transition-speed) ease;
    font-size: 1.2rem;
    text-decoration: none;
    border: 2px solid transparent;
}

[data-theme="light"] .fullscreen-footer .social-links .social-icon {
    background-color: rgba(0, 82, 204, 0.08);
    color: #0052cc;
    border: 2px solid rgba(0, 82, 204, 0.2);
}

.fullscreen-footer .social-links .social-icon:hover {
    background-color: var(--sidebar-accent);
    color: white;
    transform: scale(1.15) rotate(5deg);
    border-color: var(--sidebar-accent);
    box-shadow: 0 4px 12px rgba(52, 152, 219, 0.3);
}

.footer-divider {
    border-color: var(--sidebar-border) !important;
    margin: 2rem 0 1.5rem 0 !important;
}

.footer-bottom {
    font-size: 0.9rem;
    color: var(--sidebar-text);
    opacity: 0.8;
    text-align: center;
}

[data-theme="light"] .footer-bottom {
    color: #4a5568;
}

.footer-bottom small {
    display: block;
    margin-bottom: 0.5rem;
}

[data-theme="light"] .footer-bottom small:last-child {
    margin-bottom: 0;
}

.footer-bottom strong {
    color: var(--sidebar-accent);
    font-weight: 600;
}

/* ========================================
   FOOTER RESPONSIVE STYLES
   ======================================== */

@media (max-width: 991px) {
    .fullscreen-footer {
        padding: 2.5rem 0 1rem 0;
    }

    .footer-section {
        margin-bottom: 1.5rem;
    }

    .footer-title,
    .footer-subtitle {
        text-align: center;
    }

    .footer-links {
        justify-content: center;
    }

    .fullscreen-footer .social-links {
        justify-content: center;
    }
}

@media (max-width: 767px) {
    .fullscreen-footer {
        padding: 2rem 0 1rem 0;
    }

    .footer-bottom {
        text-align: center;
    }

    .footer-bottom small {
        margin-bottom: 0.5rem;
    }

    .footer-links {
        flex-direction: column;
        align-items: center;
    }

    .footer-links li {
        text-align: center;
    }
}

/* ========================================
   UTILITY CLASSES
   ======================================== */

.btn-ghost {
    background: none;
    border: none;
}

.text-muted {
    color: rgba(255, 255, 255, 0.6) !important;
}

[data-theme="light"] .text-muted {
    color: rgba(44, 62, 80, 0.6) !important;
}
