/* ══════════ FIX SIDEBAR LAYOUT ══════════ */
:root {
    --sidebar-width: 260px;
    --sidebar-collapsed-width: 72px;
    --header-height: 64px;
}

.dark {
    --bg-primary: #0f172a;
    --bg-secondary: #1e293b;
    --bg-tertiary: #334155;
    --text-primary: #f8fafc;
    --text-secondary: #94a3b8;
    --text-tertiary: #64748b;
    --border-color: #334155;
    --card-shadow: 0 4px 24px rgba(0, 0, 0, 0.4);
}

.light {
    --bg-primary: #f8fafc;
    --bg-secondary: #ffffff;
    --bg-tertiary: #f1f5f9;
    --text-primary: #0f172a;
    --text-secondary: #475569;
    --text-tertiary: #94a3b8;
    --border-color: #e2e8f0;
    --card-shadow: 0 4px 24px rgba(0, 0, 0, 0.08);
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    background: var(--bg-primary);
    color: var(--text-primary);
    font-family: 'Inter', sans-serif;
    overflow-x: hidden;
}

/* ══════════ TICKER BAR ══════════ */
.ticker-bar {
    position: sticky;
    top: 0;
    z-index: 50;
    height: 40px;
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border-color);
    overflow: hidden;
    display: flex;
    align-items: center;
    padding: 0;
}

.ticker-content {
    display: inline-flex;
    animation: tickerScroll 40s linear infinite;
    white-space: nowrap;
}

.ticker-content:hover {
    animation-play-state: paused;
}

@keyframes tickerScroll {
    0% {
        transform: translateX(0);
    }

    100% {
        transform: translateX(-50%);
    }
}

.ticker-content>div {
    padding: 0 20px;
}

.crypto-logo-sm {
    width: 18px;
    height: 18px;
    border-radius: 50%;
    object-fit: cover;
    background: var(--bg-tertiary);
    flex-shrink: 0;
}

/* ══════════ SIDEBAR — FIXED POSITION ══════════ */
.sidebar {
    position: fixed;
    top: 40px;
    /* ticker height */
    left: 0;
    bottom: 0;
    width: var(--sidebar-width);
    background: var(--bg-secondary);
    border-right: 1px solid var(--border-color);
    z-index: 40;
    transition: width 0.3s cubic-bezier(0.4, 0, 0.2, 1), transform 0.3s;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.sidebar.collapsed {
    width: var(--sidebar-collapsed-width);
}

.sidebar.collapsed .sidebar-label,
.sidebar.collapsed .sidebar-badge,
.sidebar.collapsed .sidebar-logo-text,
.sidebar.collapsed .sidebar-section-title,
.sidebar.collapsed .sidebar-pro-card {
    display: none;
}

.sidebar.collapsed .sidebar-item {
    justify-content: center;
    padding: 10px;
}

.sidebar-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
    border-radius: 10px;
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 14px;
    font-weight: 500;
    transition: all 0.15s;
    cursor: pointer;
    border: none;
    background: none;
    width: 100%;
    text-align: left;
    margin-bottom: 2px;
    white-space: nowrap;
    font-family: inherit;
}

.sidebar-item:hover {
    background: var(--bg-tertiary);
    color: var(--text-primary);
}

.sidebar-item.active {
    background: linear-gradient(135deg, rgba(59, 130, 246, 0.15), rgba(139, 92, 246, 0.08));
    color: #3b82f6;
    font-weight: 600;
}

.sidebar-label {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Mobile: sidebar hidden by default */
@media (max-width: 1023px) {
    .sidebar {
        top: 0;
        transform: translateX(-100%);
        z-index: 60;
        width: var(--sidebar-width) !important;
    }

    .sidebar.mobile-open {
        transform: translateX(0);
        box-shadow: 4px 0 32px rgba(0, 0, 0, 0.4);
    }
}

.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.55);
    z-index: 55;
    backdrop-filter: blur(3px);
}

.sidebar-overlay.active {
    display: block;
}

/* ══════════ MAIN CONTENT — MARGIN LEFT FOR SIDEBAR ══════════ */
.main-content {
    margin-left: var(--sidebar-width);
    /* ⭐ THIS FIXES THE OVERLAP */
    transition: margin-left 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    min-width: 0;
    display: flex;
    flex-direction: column;
}

.main-content.sidebar-collapsed {
    margin-left: var(--sidebar-collapsed-width);
}

/* On mobile: no margin */
@media (max-width: 1023px) {
    .main-content {
        margin-left: 0 !important;
    }
}

/* ══════════ HEADER ══════════ */
.main-header {
    height: var(--header-height);
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border-color);
    position: sticky;
    top: 40px;
    /* below ticker */
    z-index: 30;
    backdrop-filter: blur(12px);
}

/* ═══════════════════════════════════
           SETTINGS SPECIFIC
        ═══════════════════════════════════ */
.section-title {
    font-size: 18px;
    font-weight: 700;
    margin-bottom: 4px;
}

.section-subtitle {
    font-size: 13px;
    color: var(--text-secondary);
}

.settings-nav-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    border-radius: 10px;
    color: var(--text-secondary);
    font-size: 14px;
    font-weight: 500;
    transition: all 0.15s;
    cursor: pointer;
    border: none;
    background: none;
    width: 100%;
    text-align: left;
    margin-bottom: 2px;
    white-space: nowrap;
    font-family: inherit;
}

.settings-nav-item:hover {
    background: var(--bg-tertiary);
    color: var(--text-primary);
}

.settings-nav-item.active {
    background: linear-gradient(135deg, rgba(59, 130, 246, 0.15), rgba(139, 92, 246, 0.08));
    color: #3b82f6;
    font-weight: 600;
}

.toggle {
    width: 42px;
    height: 24px;
    background: var(--bg-tertiary);
    border-radius: 100px;
    position: relative;
    cursor: pointer;
    border: none;
    transition: background 0.3s;
    flex-shrink: 0;
}

.toggle::after {
    content: '';
    position: absolute;
    width: 18px;
    height: 18px;
    background: white;
    border-radius: 50%;
    top: 3px;
    left: 3px;
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.25);
}

.toggle.on {
    background: linear-gradient(135deg, #3b82f6, #8b5cf6);
}

.toggle.on::after {
    transform: translateX(18px);
}

.form-label {
    display: block;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-tertiary);
    margin-bottom: 6px;
}

.form-input,
.form-select,
.form-textarea {
    width: 100%;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 11px 14px;
    font-size: 14px;
    color: var(--text-primary);
    outline: none;
    transition: all 0.2s;
    font-family: inherit;
}

.form-input:focus,
.form-select:focus,
.form-textarea:focus {
    border-color: #3b82f6;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.12);
}

.form-input::placeholder,
.form-textarea::placeholder {
    color: var(--text-tertiary);
}

.form-select {
    appearance: none;
    cursor: pointer;
    padding-right: 36px;
}

.form-textarea {
    resize: vertical;
    min-height: 90px;
}

.settings-panel {
    display: none;
}

.settings-panel.active {
    display: block;
    animation: fadeIn 0.2s ease-out;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(6px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.setting-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 14px;
    border-radius: 12px;
    transition: background 0.15s;
    gap: 16px;
}

.setting-row:hover {
    background: var(--bg-tertiary);
}

.setting-row-info {
    min-width: 0;
    flex: 1;
}

.info-tile {
    background: var(--bg-tertiary);
    border-radius: 12px;
    padding: 12px 14px;
    display: flex;
    align-items: center;
    gap: 12px;
}

.plan-card {
    border: 2px solid var(--border-color);
    border-radius: 16px;
    padding: 20px;
    cursor: pointer;
    transition: all 0.2s;
    position: relative;
    background: var(--bg-secondary);
}

.plan-card:hover {
    border-color: rgba(59, 130, 246, 0.35);
}

.plan-card.selected {
    border-color: #3b82f6;
    background: linear-gradient(135deg, rgba(59, 130, 246, 0.05), rgba(139, 92, 246, 0.03));
}

.plan-tag {
    position: absolute;
    top: -11px;
    left: 50%;
    transform: translateX(-50%);
    background: linear-gradient(135deg, #3b82f6, #8b5cf6);
    color: white;
    font-size: 10px;
    font-weight: 700;
    padding: 4px 14px;
    border-radius: 100px;
}

.color-dot {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    cursor: pointer;
    border: 3px solid transparent;
    transition: all 0.2s;
    flex-shrink: 0;
}

.color-dot.chosen {
    border-color: var(--text-primary);
    transform: scale(1.15);
}

.lang-tile {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px;
    border-radius: 12px;
    cursor: pointer;
    border: 2px solid var(--border-color);
    transition: all 0.2s;
    background: var(--bg-secondary);
}

.lang-tile:hover {
    border-color: rgba(59, 130, 246, 0.35);
}

.lang-tile.chosen {
    border-color: #3b82f6;
    background: linear-gradient(135deg, rgba(59, 130, 246, 0.05), rgba(139, 92, 246, 0.03));
}

.theme-preview {
    cursor: pointer;
    border-radius: 14px;
    overflow: hidden;
    border: 2px solid var(--border-color);
    transition: all 0.2s;
}

.theme-preview.chosen {
    border-color: #3b82f6;
}

.avatar-wrap {
    position: relative;
    display: inline-block;
    cursor: pointer;
}

.avatar-overlay {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    border-radius: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.2s;
}

.avatar-wrap:hover .avatar-overlay {
    opacity: 1;
}

input[type="range"] {
    width: 100%;
    accent-color: #3b82f6;
}

.day-btn {
    padding: 8px 14px;
    border-radius: 10px;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    border: none;
    transition: all 0.15s;
    font-family: inherit;
}

.day-btn.on {
    background: linear-gradient(135deg, rgba(59, 130, 246, 0.15), rgba(139, 92, 246, 0.08));
    color: #3b82f6;
}

.day-btn.off {
    background: var(--bg-tertiary);
    color: var(--text-secondary);
}

#toast {
    position: fixed;
    bottom: 16px;
    right: 16px;
    left: 16px;
    max-width: 380px;
    margin-left: auto;
    z-index: 9999;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 14px;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.35);
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 16px;
    transform: translateY(120px);
    opacity: 0;
    transition: all 0.35s cubic-bezier(0.34, 1.56, 0.64, 1);
}

#toast.show {
    transform: translateY(0);
    opacity: 1;
}

.main-content {
    flex: 1;
    width: 100%;
    min-width: 0;
    overflow-x: hidden;
}

.main-wrapper {
    display: flex;
    width: 100%;
    min-width: 0;
}

@media (min-width:1024px) {
    .main-content {
        margin-left: var(--sidebar-width);
        width: calc(100% - var(--sidebar-width));
    }
}