:root {
    --sidebar-width: 260px;
    --sidebar-bg: #1e293b;
    --sidebar-border: rgba(255, 255, 255, 0.05);
    /* Subtler border */
    --content-bg: #0f172a;
    --active-item-bg: rgba(99, 102, 241, 0.15);
    --active-item-border: #6366f1;
    --hover-item-bg: rgba(255, 255, 255, 0.03);
    --text-main: #f1f5f9;
    --text-dim: #94a3b8;
}

body {
    margin: 0;
    overflow: hidden;
    /* App-like feel */
    background: var(--content-bg);
}

/* Layout Container */
.settings-container {
    display: block;
    /* Switch to block layout */
    width: 100vw;
    height: 100vh;
    overflow: hidden;
}

/* Sidebar */
.settings-sidebar {
    position: fixed;
    /* Fixed Layout Strategy */
    top: 0;
    left: 0;
    bottom: 0;
    width: var(--sidebar-width);
    background: var(--sidebar-bg);
    border-right: 1px solid var(--sidebar-border);
    display: flex;
    flex-direction: column;
    z-index: 100;
}

.sidebar-header {
    height: 70px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    padding: 0 20px;
    border-bottom: 1px solid var(--sidebar-border);
}

.sidebar-brand {
    font-size: 1.2rem;
    font-weight: 800;
    color: white;
    display: flex;
    align-items: center;
    gap: 10px;
}

.sidebar-brand i {
    color: var(--active-item-border);
}

.sidebar-role-badge {
    font-size: 0.75rem;
    color: var(--text-dim);
    margin-top: 4px;
    background: rgba(255, 255, 255, 0.05);
    padding: 2px 8px;
    border-radius: 12px;
    align-self: flex-start;
}

.sidebar-nav {
    flex: 1;
    overflow-y: auto;
    padding: 20px 15px;
    display: flex;
    flex-direction: column;
    gap: 5px;
}

/* Scrollbar for sidebar */
.sidebar-nav::-webkit-scrollbar {
    width: 6px;
}

.sidebar-nav::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 3px;
}

/* Navigation Items */
.nav-item {
    display: flex;
    align-items: center;
    padding: 12px 15px;
    border-radius: 10px;
    color: var(--text-dim);
    text-decoration: none;
    cursor: pointer;
    transition: all 0.2s ease;
    font-size: 0.95rem;
    font-weight: 500;
}

.nav-item:hover {
    background: var(--hover-item-bg);
    color: var(--text-main);
}

.nav-item.active {
    background: var(--active-item-bg);
    color: #818cf8;
    /* Light Indigo */
    font-weight: 700;
}

.nav-item i {
    width: 24px;
    text-align: center;
    margin-right: 12px;
    font-size: 1.1rem;
}

/* Market Button Special Styling */
.nav-item.market-btn {
    background: linear-gradient(135deg, rgba(255, 193, 7, 0.1), rgba(255, 152, 0, 0.1));
    color: #fbbf24;
    border: 1px solid rgba(251, 191, 36, 0.2);
    margin-bottom: 20px;
}

.nav-item.market-btn:hover {
    background: linear-gradient(135deg, rgba(255, 193, 7, 0.2), rgba(255, 152, 0, 0.2));
    border-color: rgba(251, 191, 36, 0.4);
}

.nav-item.market-btn.active {
    background: rgba(251, 191, 36, 0.2);
    border-color: #fbbf24;
}

/* Sub-items and Dividers */
.nav-sub-divider {
    height: 1px;
    background: var(--sidebar-border);
    margin: 8px 15px;
    opacity: 0.5;
}

.nav-item.sub-item {
    margin-left: 10px;
    padding: 10px 15px;
    font-size: 0.85rem;
    opacity: 0.85;
}

.nav-item.sub-item i {
    font-size: 1rem;
    margin-right: 10px;
}

.nav-item.sub-item:hover,
.nav-item.sub-item.active {
    opacity: 1;
}


/* Navigation Groups */
.nav-group {
    margin-bottom: 20px;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.nav-group-title {
    padding: 0 15px;
    margin-bottom: 8px;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: #64748b;
    font-weight: 800;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

/* Sidebar User Section (Moved to Top) */
.sidebar-user-section {
    padding: 20px 15px;
    border-bottom: 1px solid var(--sidebar-border);
    background: rgba(0, 0, 0, 0.05);
}

.user-mini-profile {
    display: flex;
    align-items: center;
    gap: 12px;
    cursor: pointer;
    padding: 10px;
    border-radius: 10px;
    transition: background 0.2s;
}

.user-mini-profile:hover {
    background: rgba(255, 255, 255, 0.05);
}

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

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

.user-name {
    font-size: 0.9rem;
    font-weight: 700;
    color: white;
}

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

/* Main Content Area */
.settings-content {
    /* Layout handled by settings-repair.css or absolute positioning */
    /* margin-left: var(--sidebar-width); REMOVED: using absolute/fixed positioning */
    /* width: calc(100% - var(--sidebar-width)); REMOVED */
    height: 100vh;
    /* display: flex; REMOVED: causes centering issues */
    /* flex-direction: column; REMOVED */
    overflow: hidden;
    position: relative;
    background: var(--content-bg);
}

.content-header {
    height: 70px;
    display: flex;
    align-items: center;
    padding: 0 40px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    background: rgba(15, 23, 42, 0.8);
    backdrop-filter: blur(10px);
    flex-shrink: 0;
}

.content-title {
    font-size: 1.5rem;
    font-weight: 800;
    color: white;
    margin: 0;
    display: flex;
    align-items: center;
    gap: 12px;
}

.content-title i {
    color: var(--active-item-border);
}

/* Panels */
.settings-panel {
    display: none;
    flex-grow: 1;
    /* Allow it to fill remaining space */
    overflow-y: auto;
    /* Scroll ONLY the panel content */
    padding: 30px 40px;
    width: 100%;
    box-sizing: border-box;
    /* Animation */
    animation: fadeIn 0.3s ease-out;
}

.settings-panel.active {
    display: block;
    /* Use normal flow */
    animation: fadeIn 0.3s ease-out;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Card overrides for better fit in new layout */
.config-card {
    background: #1e293b;
    /* Maintain card bg */
    border: 1px solid rgba(255, 255, 255, 0.05);
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    margin-bottom: 25px;
    width: 100% !important;
    max-width: none !important;
    box-sizing: border-box;
}

.stats-strip {
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid rgba(255, 255, 255, 0.05);
    border-radius: 12px;
    padding: 20px;
    margin-bottom: 25px;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 20px;
    width: 100%;
    box-sizing: border-box;
}

/* Responsive */
@media (max-width: 1024px) {
    :root {
        --sidebar-width: 220px;
    }

    .settings-panel {
        padding: 20px;
    }
}