/* Layout Structure */
.app-container {
    display: flex;
    height: 100vh;
}

/* Sidebar - Global Drawer (Moved to bottom) */

.sidebar-header {
    height: 90px;
    display: flex;
    align-items: center;
    justify-content: center;
    /* Centered Logo */
    padding: 0 1.5rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

#sidebar-close {
    display: none;
    /* Removed X as requested */
}

.logo {
    max-height: 60px;
    /* Invert logo brightness if needed or assume white logo provided. 
       Adding a filter here just in case the logo is dark text */
    filter: brightness(0) invert(1);
    opacity: 0.9;
}

.sidebar-nav {
    flex: 1;
    padding: 1.5rem 0.75rem;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 1rem;
    text-decoration: none;
    color: var(--text-sidebar);
    border-radius: var(--radius-md);
    font-weight: 500;
    font-size: 1.1rem;
    transition: var(--transition);
}

.nav-item i {
    font-size: 1.3rem;
    width: 24px;
    /* Ensure consistent alignment */
    text-align: center;
}

.nav-item:hover {
    background-color: rgba(255, 255, 255, 0.05);
    color: var(--text-sidebar-active);
}

.nav-item.active {
    background-color: var(--primary-color);
    color: white;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
}

.sidebar-footer {
    padding: 1rem;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    background-color: rgba(0, 0, 0, 0.2);
}

.user-info {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.avatar {
    width: 36px;
    height: 36px;
    background: linear-gradient(135deg, var(--primary-color), var(--primary-active));
    color: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 0.85rem;
    box-shadow: var(--shadow-sm);
}

.user-details {
    display: flex;
    flex-direction: column;
}

.user-details .name {
    color: var(--text-sidebar-active);
    font-weight: 600;
    font-size: 0.9rem;
}

.user-details .role {
    font-size: 0.75rem;
    color: var(--text-sidebar);
}

/* Main Content */
.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    background-color: var(--bg-body);
    overflow: hidden;
}

.top-header {
    height: 70px;
    background-color: var(--bg-surface);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 2rem;
    box-shadow: var(--shadow-sm);
    z-index: 10;
}

#page-title {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--text-primary);
    letter-spacing: -0.025em;
    margin: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 1.5rem;
}

.search-bar {
    position: relative;
    width: 40px;
    /* Collapsed width */
    height: 40px;
    background-color: transparent;
    border-radius: 99px;
    /* Pill/Circle */
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    overflow: hidden;
    cursor: pointer;
    box-shadow: none;
    border: 1px solid transparent;
}

.search-bar.active {
    width: 320px;
    /* Expanded width */
    background-color: white;
    border-color: var(--border-color);
    box-shadow: var(--shadow-sm);
    cursor: text;
}

.search-bar i {
    position: absolute;
    left: 11px;
    /* Center icon in collapsed state (40px) */
    top: 50%;
    transform: translateY(-50%);
    width: 18px;
    height: 18px;
    color: var(--text-secondary);
    pointer-events: none;
    /* Icon clicks go to container */
    z-index: 2;
}

.search-bar input {
    position: absolute;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    padding: 0 1rem 0 2.5rem;
    /* Space for icon */
    background-color: transparent;
    border: none;
    font-size: 0.95rem;
    outline: none;
    color: var(--text-primary);
    opacity: 0;
    /* Hidden when collapsed */
    transform: translateX(10px);
    transition: all 0.3s ease;
}

.search-bar.active input {
    opacity: 1;
    transform: translateX(0);
}

.search-bar input:focus {
    box-shadow: none;
    /* Remove default focus outline */
}

/* Hover effect for collapsed state */
.search-bar:not(.active):hover {
    background-color: rgba(0, 0, 0, 0.03);
}

.icon-btn {
    background: none;
    border: none;
    cursor: pointer;
    color: var(--text-secondary);
    padding: 0.5rem;
    border-radius: 50%;
    transition: var(--transition);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.8rem;
    /* Base size for icon */
    width: 52px;
    /* Fixed width for better click area */
    height: 52px;
    /* Fixed height */
}

.icon-btn i {
    width: auto;
    height: auto;
    font-size: 1.8rem;
    /* Ensure FA icon scales */
}

.icon-btn:hover {
    background-color: var(--bg-body);
    color: var(--primary-color);
}

/* Content Area */
.content-area {
    flex: 1;
    padding: 2rem;
    overflow-y: auto;
}

/* Global Drawer Sidebar */
/* Global Sidebar */
.sidebar {
    width: 260px;
    background-color: var(--bg-sidebar);
    display: flex;
    flex-direction: column;
    z-index: 20;
    transition: transform 0.3s ease;
    border-right: 1px solid rgba(255, 255, 255, 0.1);
    /* Persistent on Desktop by default */
    position: relative;
    transform: none;
}

/* Mobile Drawer Overrides */
@media (max-width: 768px) {
    .sidebar {
        position: fixed;
        right: 0;
        top: 0;
        height: 100%;
        transform: translateX(100%);
        /* Hidden by default on mobile */
        box-shadow: 0 0 15px rgba(0, 0, 0, 0.5);
    }

    .sidebar.open {
        transform: translateX(0);
    }
}



.sidebar-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 15;
    opacity: 0;
    visibility: hidden;
    transition: var(--transition);
}

.sidebar.open+.sidebar-overlay {
    opacity: 1;
    visibility: visible;
}



@media (max-width: 768px) {
    #page-title {
        font-size: 1rem;
        max-width: 160px;
        /* Force truncation before hitting search/menu */
    }

    .top-header {
        padding: 0 1rem;
    }

    /* Show Search on mobile now that it's compact */
    .search-bar {
        display: block;
        /* Was none */
    }

    .search-bar.active {
        width: 180px;
        /* Reduced width for mobile */
        position: absolute;
        /* Float over title if needed, or just push */
        right: 60px;
        /* Avoid overlapping menu button */
        z-index: 20;
    }

    .header-actions {
        gap: 0.5rem;
    }

    /* Ensure specific icons are visible or hidden as desired */
    /* Removed redundant header icon logic */
    /* Ensure Menu Toggle is Visible */
    #menu-toggle {
        display: flex;
        font-size: 1.5rem;
    }
}