/*
Theme Name: Dashboard Theme
Theme URI: https://example.com/dashboard-theme
Author: GitHub Copilot
Author URI: https://github.com/
Description: A custom sidebar theme for WordPress.
Version: 1.0
License: GNU General Public License v2 or later
License URI: http://www.gnu.org/licenses/gpl-2.0.html
Text Domain: dashboard-theme
*/

:root {
    --primary-color: #0f5132; /* Dark green like the logo */
    --primary-light: #e8f5e9; /* Light green background for active items */
    --text-color: #333;
    --text-muted: #888;
    --bg-color: #f3f4f6;
    --sidebar-bg: #ffffff;
    --sidebar-width-collapsed: 88px;
    --sidebar-width-expanded: 280px;
    --transition-speed: 0.4s;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Inter', sans-serif;
}

/* Restore typography defaults */
p {
    margin-bottom: 1em;
    line-height: 1.5;
}

h1, h2, h3, h4, h5, h6 {
    margin-bottom: 1em;
    line-height: 1.2;
}

/* Main Layout Wrapper */
.site-main {
    flex: 1;
    min-width: 0; /* Critical for flexbox to handle overflow correctly */
    display: flex;
    flex-direction: column;
    position: relative;
}

body {
    background-color: var(--bg-color);
    display: flex;
    min-height: 100vh;
}

/* Fix for Elementor Canvas */
body.elementor-template-canvas {
    display: block;
}

/* Sidebar Container */
.sidebar {
    background-color: var(--sidebar-bg);
    width: var(--sidebar-width-collapsed);
    height: 100vh;
    display: flex;
    flex-direction: column;
    padding: 24px 20px; /* Increased side padding to center content (88 - 48 = 40 / 2 = 20) */
    transition: width var(--transition-speed) cubic-bezier(0.4, 0, 0.2, 1), padding var(--transition-speed) ease;
    overflow: hidden;
    border-right: 1px solid #e5e7eb;
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
}

/* Expand on Hover */
.sidebar:hover {
    width: var(--sidebar-width-expanded);
    padding: 24px 24px; /* Slightly more padding when expanded */
}

/* Logo Section */
.sidebar-header {
    margin-bottom: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    /* Ensure icon stays centered in collapsed state */
    padding-left: 8px; 
}

.logo {
    display: flex;
    align-items: center;
    gap: 12px;
    color: var(--primary-color);
    font-size: 28px;
    font-weight: 700;
    white-space: nowrap;
    text-decoration: none;
}

.logo i {
    min-width: 32px; /* Fixed width for icon alignment */
    display: flex;
    justify-content: center;
}

.logo-text {
    opacity: 0;
    transition: opacity 0.2s ease;
    white-space: nowrap;
}

.sidebar:hover .logo-text {
    opacity: 1;
    transition-delay: 0.1s;
}

/* Menu Items */
.sidebar-menu {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 24px;
    overflow-y: auto;
    /* Hide scrollbar */
    scrollbar-width: none; 
}
.sidebar-menu::-webkit-scrollbar { 
    display: none; 
}

.menu-section {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.section-title {
    font-size: 12px;
    font-weight: 600;
    color: #a0aec0;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 8px;
    white-space: nowrap;
    position: relative;
    height: 20px;
    display: flex;
    align-items: center;
}

.section-title span {
    opacity: 0;
    padding-left: 52px; /* Align with menu text (12px pad + 24px icon + 16px margin) */
    transition: opacity 0.2s ease;
}

.sidebar:hover .section-title span {
    opacity: 1;
    transition-delay: 0.1s;
}

.section-title::before {
    content: attr(data-initial);
    position: absolute;
    left: 24px; /* Center of the icon column (12px item pad + 12px half icon) */
    transform: translateX(-50%);
    opacity: 1;
    transition: opacity 0.2s ease;
}

.sidebar:hover .section-title::before {
    opacity: 0;
}

.menu-item {
    display: flex;
    align-items: center;
    text-decoration: none;
    color: var(--text-muted);
    padding: 12px;
    border-radius: 12px;
    transition: all 0.2s ease;
    white-space: nowrap;
    height: 48px;
    position: relative;
}

.menu-item:hover {
    color: var(--primary-color);
    background-color: rgba(0,0,0,0.02);
}

.menu-item.active {
    background-color: var(--primary-light);
    color: var(--primary-color);
    font-weight: 600;
}

.menu-item i {
    font-size: 24px;
    min-width: 24px;
    display: flex;
    justify-content: center;
    align-items: center;
}

.menu-text {
    margin-left: 16px;
    opacity: 0;
    white-space: nowrap;
    transition: opacity 0.2s ease;
    transition-delay: 0s;
}

.sidebar:hover .menu-text {
    opacity: 1;
    transition-delay: 0.15s; /* Wait for width to expand a bit */
}

/* Submenu Arrow */
.submenu-arrow {
    margin-left: auto;
    font-size: 16px !important;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.sidebar:hover .submenu-arrow {
    opacity: 1;
}

/* Toggle Switch (Dark Mode) */
.toggle-switch {
    width: 36px;
    height: 20px;
    background-color: #e2e8f0;
    border-radius: 20px;
    margin-left: auto;
    position: relative;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.toggle-switch::after {
    content: '';
    position: absolute;
    top: 2px;
    left: 2px;
    width: 16px;
    height: 16px;
    background-color: white;
    border-radius: 50%;
    box-shadow: 0 1px 2px rgba(0,0,0,0.1);
}

.sidebar:hover .toggle-switch {
    opacity: 1;
}

/* Footer / User Profile */
.sidebar-footer {
    margin-top: auto;
    display: flex;
    flex-direction: column;
    gap: 16px;
    padding-top: 20px;
    border-top: 1px solid transparent; /* Placeholder for separator if needed */
}

.user-profile {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 8px;
    white-space: nowrap;
    overflow: hidden;
    text-decoration: none;
    color: inherit;
    border-radius: 12px;
    transition: background-color 0.2s ease;
}

/* Fix avatar centering when collapsed */
.sidebar:not(:hover) .user-profile {
    padding-left: 0;
    padding-right: 0;
    justify-content: center;
    gap: 0;
}

.sidebar:not(:hover) .user-info {
    width: 0;
    opacity: 0;
    margin: 0;
    overflow: hidden;
}

.user-profile:hover {
    background-color: rgba(0,0,0,0.02);
}

.avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    object-fit: cover;
    min-width: 40px;
}

.user-info {
    display: flex;
    flex-direction: column;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.sidebar:hover .user-info {
    opacity: 1;
}

.user-name {
    font-weight: 600;
    font-size: 14px;
    color: var(--text-color);
}

.user-role {
    font-size: 12px;
    color: var(--text-muted);
}

.logout {
    margin-top: 8px;
}

/* Main Content Area (Just for demo) */
.content {
    flex: 1;
    padding: 40px;
}

/* Mobile Styles */
.mobile-header {
    display: none;
}

.overlay {
    display: none;
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.5);
    z-index: 99;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.overlay.active {
    display: block;
    opacity: 1;
}

@media (max-width: 768px) {
    .mobile-header {
        display: flex;
        justify-content: space-between;
        align-items: center;
        padding: 0 20px;
        background: white;
        position: fixed;
        top: 0; left: 0; right: 0;
        height: 64px;
        z-index: 98;
        box-shadow: 0 1px 3px rgba(0,0,0,0.1);
    }

    .logo-text-mobile {
        font-size: 20px;
        font-weight: 700;
        color: var(--primary-color);
    }

    .menu-toggle {
        background: transparent !important;
        border: none !important;
        box-shadow: none !important;
        padding: 0 !important;
        margin: 0 !important;
        border-radius: 0 !important;
        min-width: auto !important;
        min-height: auto !important;
        font-size: 24px;
        color: var(--text-color);
        cursor: pointer;
        display: flex;
        align-items: center;
        justify-content: center;
    }

    .content {
        margin-top: 64px; /* Space for header */
        padding: 20px;
    }
    
    /* Ensure site-main respects mobile header */
    .site-main {
        margin-top: 64px;
    }

    .sidebar {
        position: fixed;
        left: 0;
        top: 0;
        bottom: 0;
        width: var(--sidebar-width-expanded);
        transform: translateX(-100%);
        padding: 24px; /* Always expanded padding */
        transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
        box-shadow: 4px 0 24px rgba(0,0,0,0.1);
    }

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

    /* Force expanded state styles on mobile */
    .sidebar .menu-text, 
    .sidebar .section-title span,
    .sidebar .user-info,
    .sidebar .toggle-switch,
    .sidebar .submenu-arrow,
    .sidebar .logo-text {
        opacity: 1 !important;
        transform: none !important;
        position: static !important;
        pointer-events: auto !important;
        width: auto !important; /* Force width for user-info */
        overflow: visible !important;
    }

    /* Restore margins and paddings specifically */
    .sidebar .menu-text {
        margin-left: 16px !important;
    }

    .sidebar .section-title span {
        padding-left: 0 !important;
    }

    .sidebar .user-info {
        margin: 0 !important;
    }

    /* Fix user profile alignment on mobile */
    .sidebar .user-profile {
        justify-content: flex-start !important;
        gap: 12px !important;
        padding-left: 8px !important;
        padding-right: 8px !important;
    }
    
    .sidebar .section-title::before {
        opacity: 0 !important; /* Hide initials */
    }

    /* Adjust section title span padding specifically */
    .sidebar .section-title span {
        padding-left: 12px !important;
    }
}