/* Sidebar Styles */
.sidebar {
    position: fixed;
    top: 0;
    left: 0;
    width: var(--sidebar-width);
    height: 100vh;
    background-color: var(--card-bg);
    border-right: 1px solid var(--border-color);
    z-index: 1000;
    display: flex;
    flex-direction: column;
    transition: transform 0.3s ease;
}

.sidebar-header {
    height: var(--header-height);
    display: flex;
    align-items: center;
    padding: 0 1.5rem;
    border-bottom: 1px solid var(--border-color);
}

.sidebar-brand {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--primary);
    display: flex;
    align-items: center;
    gap: 0.5rem;
    text-decoration: none;
    width: 100%;
}

.sidebar-logo {
    max-height: 48px;
    max-width: 100%;
    width: auto;
    object-fit: contain;
    display: block;
    transition: transform 0.2s ease;
}

.sidebar-brand:hover .sidebar-logo {
    transform: scale(1.02);
}

.sidebar-menu {
    flex: 1;
    overflow-y: auto;
    padding: 1rem 0;
}

.menu-group {
    margin-bottom: 1.5rem;
}

.menu-label {
    padding: 0 1.5rem 0.5rem;
    font-size: 0.75rem;
    text-transform: uppercase;
    font-weight: 600;
    color: var(--text-secondary);
    letter-spacing: 0.05em;
}

.menu-item {
    display: flex;
    align-items: center;
    padding: 0.75rem 1.5rem;
    color: var(--text-main);
    transition: background-color 0.2s ease, color 0.2s ease;
    gap: 0.75rem;
}

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

.menu-icon {
    font-size: 1.1rem;
    width: 20px;
    text-align: center;
    color: var(--text-secondary);
}

.menu-item:hover .menu-icon, .menu-item.active .menu-icon {
    color: var(--primary);
}

.sidebar-footer {
    padding: 1rem 1.5rem;
    border-top: 1px solid var(--border-color);
}

/* Header Styles */
.top-header {
    height: var(--header-height);
    background-color: var(--card-bg);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 1.5rem;
    position: sticky;
    top: 0;
    z-index: 900;
}

.header-left {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.sidebar-toggle {
    background: none;
    border: none;
    font-size: 1.25rem;
    color: var(--text-secondary);
    cursor: pointer;
}

.sidebar-toggle:hover {
    color: var(--primary);
}

.header-search {
    display: flex;
    align-items: center;
    background-color: var(--background);
    border-radius: 20px;
    padding: 0.4rem 1rem;
    border: 1px solid transparent;
}

.header-search input {
    border: none;
    background: transparent;
    outline: none;
    padding-left: 0.5rem;
    color: var(--text-main);
}

.header-right {
    display: flex;
    align-items: center;
    gap: 1.5rem;
}

.header-action {
    position: relative;
    color: var(--text-secondary);
    cursor: pointer;
    font-size: 1.25rem;
}

.header-action:hover {
    color: var(--primary);
}

.header-action .badge,
.notifications .badge {
    position: absolute;
    top: -5px;
    right: -5px;
    background-color: var(--danger);
    color: white;
    font-size: 0.65rem;
    font-weight: bold;
    border-radius: 50%;
    width: 16px;
    height: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 3px 8px;
    font-size: 0.75rem;
    font-weight: 600;
    line-height: 1.2;
    border-radius: 6px;
}

/* User Profile & Account Dropdown */
.user-dropdown-container {
    position: relative;
    display: inline-block;
}

.user-profile {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    cursor: pointer;
    padding: 6px 10px;
    border-radius: 8px;
    transition: background-color 0.2s ease, box-shadow 0.2s ease;
    user-select: none;
}

.user-profile:hover,
.user-dropdown-container.open .user-profile {
    background-color: rgba(37, 135, 232, 0.08);
}

.avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background-color: var(--primary);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    flex-shrink: 0;
}

.user-info {
    display: flex;
    flex-direction: column;
}

.user-name {
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--text-main);
    line-height: 1.2;
}

.user-role {
    font-size: 0.75rem;
    color: var(--text-secondary);
    line-height: 1.2;
}

.user-dropdown-arrow {
    font-size: 0.8rem;
    color: var(--text-secondary);
    transition: transform 0.25s ease, color 0.2s ease;
    margin-left: 2px;
}

.user-dropdown-container.open .user-dropdown-arrow {
    transform: rotate(180deg);
    color: var(--primary);
}

/* Dropdown Menu Popup */
.user-dropdown-menu {
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    width: 250px;
    background-color: var(--card-bg, #ffffff);
    border: 1px solid var(--border-color, #E5E7EB);
    border-radius: 12px;
    box-shadow: 0 10px 25px -3px rgba(0, 0, 0, 0.12), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
    opacity: 0;
    visibility: hidden;
    transform: translateY(-8px) scale(0.98);
    transform-origin: top right;
    transition: opacity 0.2s ease, transform 0.2s ease, visibility 0.2s ease;
    z-index: 1000;
    overflow: hidden;
}

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

.user-dropdown-header {
    padding: 0.9rem 1.1rem;
    background: linear-gradient(180deg, rgba(37, 135, 232, 0.06) 0%, rgba(255, 255, 255, 0) 100%);
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

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

.dropdown-user-email {
    font-size: 0.78rem;
    color: var(--text-secondary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.dropdown-user-badge {
    display: inline-block;
    align-self: flex-start;
    margin-top: 4px;
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 0.72rem;
    font-weight: 600;
    background: rgba(37, 135, 232, 0.12);
    color: var(--primary);
    border: 1px solid rgba(37, 135, 232, 0.2);
}

.dropdown-divider {
    height: 1px;
    background-color: var(--border-color, #E5E7EB);
    margin: 4px 0;
}

.dropdown-list {
    list-style: none;
    padding: 4px 6px;
    margin: 0;
}

.dropdown-footer {
    padding: 4px 6px 6px;
    margin: 0;
}

.dropdown-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.6rem 0.85rem;
    border-radius: 8px;
    color: var(--text-main);
    font-size: 0.875rem;
    font-weight: 500;
    text-decoration: none;
    background: transparent;
    border: none;
    width: 100%;
    text-align: left;
    cursor: pointer;
    transition: background-color 0.15s ease, color 0.15s ease;
    box-sizing: border-box;
    font-family: inherit;
}

.dropdown-item:hover {
    background-color: var(--background, #F5F7FA);
    color: var(--primary);
}

.dropdown-icon {
    font-size: 0.95rem;
    width: 18px;
    text-align: center;
    color: var(--text-secondary);
    transition: color 0.15s ease;
}

.dropdown-item:hover .dropdown-icon {
    color: var(--primary);
}

.dropdown-item.logout-item {
    color: var(--danger, #EF5350);
    font-weight: 600;
}

.dropdown-item.logout-item .dropdown-icon {
    color: var(--danger, #EF5350);
}

.dropdown-item.logout-item:hover {
    background-color: rgba(239, 83, 80, 0.08);
    color: #dc2626;
}

.dropdown-item.logout-item:hover .dropdown-icon {
    color: #dc2626;
}

/* Sidebar overlay for mobile */
.sidebar-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background-color: rgba(0,0,0,0.5);
    z-index: 950;
    display: none;
}

/* Safe Revert Confirmation Banner & Math Challenge */
.safe-revert-banner {
    background: #fef2f2;
    border: 1px solid #fecaca;
    border-left: 4px solid #dc2626;
    border-radius: 8px;
    padding: 0.9rem 1rem;
    margin-bottom: 1rem;
    color: #7f1d1d;
}

.safe-revert-banner-header {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-weight: 700;
    font-size: 0.9rem;
    color: #991b1b;
    margin-bottom: 0.6rem;
}

.safe-revert-meta-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(155px, 1fr));
    gap: 0.5rem 0.85rem;
    background: #ffffff;
    border: 1px solid #fee2e2;
    border-radius: 6px;
    padding: 0.6rem 0.75rem;
    margin-bottom: 0.7rem;
    font-size: 0.8rem;
}

.safe-revert-meta-label {
    display: block;
    font-size: 0.68rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    color: #64748b;
}

.safe-revert-meta-value {
    font-weight: 700;
    color: #0f172a;
    word-break: break-word;
}

.safe-revert-impact-title {
    font-size: 0.76rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    color: #991b1b;
    margin-bottom: 0.3rem;
}

.safe-revert-impact-list {
    margin: 0;
    padding-left: 1.15rem;
    font-size: 0.8rem;
    color: #7f1d1d;
    line-height: 1.45;
}

.safe-revert-impact-list li {
    margin-bottom: 0.2rem;
}

.safe-revert-math-box {
    background: #fffbeb;
    border: 1px solid #fde68a;
    border-radius: 8px;
    padding: 0.85rem 1rem;
    transition: background-color 0.2s ease, border-color 0.2s ease;
}

.safe-revert-math-box.is-verified {
    background: #ecfdf5;
    border-color: #86efac;
}

.safe-revert-math-row {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    flex-wrap: wrap;
    margin-top: 0.5rem;
}

.safe-revert-math-eq {
    display: inline-flex;
    align-items: center;
    padding: 0.35rem 0.75rem;
    border-radius: 6px;
    background: #ffffff;
    border: 1px solid #fcd34d;
    font-size: 0.95rem;
    font-weight: 800;
    color: #92400e;
    font-family: monospace;
    letter-spacing: 0.03em;
}

.safe-revert-math-box.is-verified .safe-revert-math-eq {
    border-color: #86efac;
    color: #047857;
}

