/* ============================================
   SIDEBAR LAYOUT - LIGHT & DARK THEME
   MqttWebService.V2
   ============================================ */

:root {
    --sidebar-width: 250px;
    --topbar-height: 56px;
    
    /* Light Theme Colors */
    --bg-body: #f8f9fa;
    --bg-card: #ffffff;
    --bg-sidebar: #ffffff;
    --bg-sidebar-hover: #f1f3f5;
    --text-primary: #212529;
    --text-secondary: #6c757d;
    --text-muted: #adb5bd;
    --border-color: #dee2e6;
    --shadow: 0 2px 4px rgba(0,0,0,0.08);
    --accent-primary: #0d6efd;
    --accent-hover: #0b5ed7;
}

/* Dark Theme Colors */
[data-theme="dark"] {
    --bg-body: #1a202c;
    --bg-card: #2d3748;
    --bg-sidebar: #111827;
    --bg-sidebar-hover: rgba(255, 255, 255, 0.06);
    --text-primary: #e2e8f0;
    --text-secondary: rgba(255, 255, 255, 0.6);
    --text-muted: rgba(255, 255, 255, 0.4);
    --border-color: rgba(255, 255, 255, 0.07);
    --shadow: 0 2px 4px rgba(0,0,0,0.3);
    --accent-primary: #3b82f6;
    --accent-hover: #60a5fa;
}

body {
    background-color: var(--bg-body);
    color: var(--text-primary);
    transition: background-color 0.3s ease, color 0.3s ease;
}

/* ==================== SIDEBAR ==================== */
.sidebar {
    position: fixed;
    top: 0;
    left: 0;
    height: 100vh;
    width: var(--sidebar-width);
    background-color: var(--bg-sidebar);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    z-index: 1040;
    overflow-y: auto;
    overflow-x: hidden;
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: var(--shadow);
}

.sidebar-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 1.25rem;
    height: var(--topbar-height);
    border-bottom: 1px solid var(--border-color);
    flex-shrink: 0;
}

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 0.625rem;
    font-weight: 700;
    font-size: 0.9rem;
    color: var(--text-primary);
    text-decoration: none;
}

.sidebar-brand i {
    font-size: 1.2rem;
    color: var(--accent-primary);
}

.sidebar-brand:hover {
    color: var(--accent-hover);
}

.sidebar-close-btn {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 0.25rem 0.5rem;
    font-size: 1.1rem;
    transition: color 0.2s;
}

.sidebar-close-btn:hover {
    color: var(--text-primary);
}

/* ==================== NAVIGATION ==================== */
.sidebar-nav {
    flex: 1;
    padding: 0.75rem 0;
    overflow-y: auto;
}

.sidebar-nav-list {
    list-style: none;
    margin: 0;
    padding: 0;
}

.sidebar-link {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.625rem 1.25rem;
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 0.88rem;
    font-weight: 500;
    transition: all 0.18s;
    border-left: 3px solid transparent;
}

.sidebar-link:hover {
    color: var(--text-primary);
    background-color: var(--bg-sidebar-hover);
    border-left-color: var(--accent-primary);
}

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

.sidebar-link i {
    width: 1.1rem;
    text-align: center;
    font-size: 0.9rem;
}

/* ==================== SIDEBAR FOOTER ==================== */
.sidebar-footer {
    padding: 0.625rem;
    border-top: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.sidebar-footer-btn {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    width: 100%;
    padding: 0.55rem 0.75rem;
    background: none;
    border: none;
    border-radius: 0.375rem;
    color: var(--text-secondary);
    font-size: 0.88rem;
    cursor: pointer;
    transition: all 0.18s;
    text-align: left;
}

.sidebar-footer-btn:hover {
    background-color: var(--bg-sidebar-hover);
    color: var(--text-primary);
}

.sidebar-footer-btn i {
    width: 1.1rem;
    text-align: center;
}

/* User Info */
.user-info {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem;
    border-bottom: 1px solid var(--border-color);
    margin-bottom: 0.5rem;
}

a.user-info {
    text-decoration: none;
    color: inherit;
    cursor: pointer;
    border-radius: 0.375rem;
    transition: background-color 0.18s;
}

a.user-info:hover {
    background-color: var(--bg-sidebar-hover);
}

.user-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background-color: var(--accent-primary);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
}

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

.user-name {
    font-weight: 600;
    color: var(--text-primary);
    font-size: 0.875rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.user-status {
    font-size: 0.75rem;
    color: var(--text-muted);
}

/* Footer Content */
.footer-content {
    background-color: var(--bg-card);
    text-align: center;
    padding: 1.5rem;
    border-top: 1px solid var(--border-color);
    color: var(--text-muted);
    font-size: 0.875rem;
}

.footer-content .container {
    max-width: 100%;
}

/* ==================== MOBILE OVERLAY ==================== */
.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background-color: rgba(0, 0, 0, 0.55);
    z-index: 1039;
    backdrop-filter: blur(2px);
}

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

/* ==================== MAIN WRAPPER ==================== */
.main-wrapper {
    margin-left: var(--sidebar-width);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    background-color: var(--bg-body, #1a202c);
    transition: margin-left 0.3s;
}

/* ==================== TOPBAR ==================== */
.topbar {
    position: sticky;
    top: 0;
    z-index: 1030;
    height: var(--topbar-height);
    background-color: var(--bg-card);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    padding: 0 1.5rem;
    gap: 1rem;
    box-shadow: var(--shadow);
}

.topbar-hamburger {
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 1.2rem;
    cursor: pointer;
    padding: 0.35rem 0.5rem;
    transition: all 0.2s;
}

.topbar-hamburger:hover {
    color: var(--text-primary);
}

.topbar-title {
    font-weight: 600;
    font-size: 0.95rem;
    color: var(--text-primary);
}

/* ==================== CONTENT AREA ==================== */
.content-area {
    flex: 1;
    padding: 1.5rem;
}

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

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

    .main-wrapper {
        margin-left: 0;
    }
}
