/* Hamburger Menu Button */
#menu-btn {
    background: transparent;
    border: none;
    padding: 8px;
    cursor: pointer;
    color: white;
    display: flex;
    align-items: center;
    border-radius: 6px;
    transition: background 0.3s;
}

#menu-btn:hover {
    background: rgba(255, 255, 255, 0.1);
}

#menu-btn svg {
    width: 24px;
    height: 24px;
}

/* Side Navigation - Modern Flat Design */
#side-nav {
    position: fixed;
    top: 60px;
    right: -280px; /* Start hidden off-screen to the right, matching --sidebar-width */
    width: 280px; /* Matched to --sidebar-width */
    height: calc(100vh - 60px);
    background: white;
    box-shadow: -2px 0 10px rgba(0, 0, 0, 0.1);
    transition: right 0.3s ease;
    z-index: 1001;
    overflow-y: auto;
}

#side-nav.open {
    right: 0; /* Slide in from right */
}

#nav-content {
    padding: 20px;
    height: 100%;
    display: flex;
    flex-direction: column;
}

/* Main Navigation Section */
#nav-main-section {
    flex: 1;
    overflow-y: auto;
}

/* New Worksheet Button */
#new-worksheet-btn {
    width: 100%;
    padding: 14px;
    background: #ff6b35;
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s;
    margin-bottom: 30px;
}

#new-worksheet-btn:hover {
    background: #e55a2b;
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(255, 107, 53, 0.3);
}

#new-worksheet-btn:active {
    transform: translateY(0);
}

/* History Section */
#history-heading {
    font-size: 0.9rem;
    font-weight: 600;
    color: #8b92a8;
    margin-bottom: 15px;
    padding-bottom: 10px;
    border-bottom: 2px solid #f0f2f5;
}

#history-list {
    list-style: none;
    padding: 0;
}

#history-list li {
    margin-bottom: 8px;
}

#history-list a {
    display: block;
    padding: 12px 16px;
    background: #f8f9fa;
    border-radius: 8px;
    text-decoration: none;
    color: #2d3436;
    transition: all 0.3s;
    border: 2px solid transparent;
}

#history-list a:hover {
    background: #fff5f3;
    border-color: #ff6b35;
    padding-right: 20px; /* RTL: indent to right on hover */
}

.history-empty-item,
.history-error-item {
    padding: 12px;
    color: #6c757d;
    font-size: 0.9rem;
    text-align: center;
    background: #f8f9fa;
    border-radius: 8px;
}

/* --- NEW USER MENU STYLES --- */
#nav-user-controls {
    padding-top: 20px;
    border-top: 2px solid #f0f2f5;
    margin-top: 20px;
    position: relative; /* For dropdown positioning */
}

.user-menu-toggle {
    display: flex;
    align-items: center;
    gap: 12px;
    width: 100%;
    background: #f8f9fa;
    border: 1px solid #e9ecef;
    border-radius: 8px;
    padding: 10px;
    cursor: pointer;
    text-align: right;
    transition: background-color 0.2s ease;
}

.user-menu-toggle:hover {
    background-color: #f1f3f5;
}

.user-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: #495057;
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 0.875rem;
    flex-shrink: 0;
}

.user-details {
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.user-email {
    font-size: 0.875rem;
    font-weight: 600;
    color: #2d3436;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.user-plan {
    font-size: 0.8125rem;
    color: #636e72;
}

.user-menu-chevron {
    color: #636e72;
    transition: transform 0.2s ease;
}

.user-menu-toggle[aria-expanded="true"] .user-menu-chevron {
    transform: rotate(180deg);
}

.user-menu-dropdown {
    position: absolute;
    bottom: calc(100% + 8px); /* Position above the toggle button */
    right: 0;
    width: 100%;
    background: white;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    border: 1px solid #e9ecef;
    z-index: 1002;
    padding: 8px;
    opacity: 0;
    visibility: hidden;
    transform: translateY(10px);
    transition: all 0.2s ease;
}

.user-menu-dropdown.open {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.dropdown-header {
    padding: 12px 12px 8px;
    border-bottom: 1px solid #f1f3f5;
    margin-bottom: 8px;
}

.user-email-dropdown {
    font-size: 0.875rem;
    font-weight: 600;
    color: #2d3436;
    word-break: break-all;
}

.dropdown-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
    border-radius: 6px;
    font-size: 0.9375rem;
    color: #2d3436;
    background: none;
    border: none;
    width: 100%;
    text-align: right;
    cursor: pointer;
    text-decoration: none;
}

.dropdown-item:hover {
    background-color: #f8f9fa;
}

.dropdown-item svg {
    width: 16px;
    height: 16px;
    color: #636e72;
}

#logout-btn-sidebar {
    color: #dc3545;
}

#logout-btn-sidebar:hover {
    background-color: #fff5f5;
    color: #c82333;
}
#logout-btn-sidebar:hover svg {
    color: #c82333;
}