/* ========================================================================
   BidMaster Layout — App skeleton, sidebar, topbar, content area
   ======================================================================== */

/* ── App Layout ── */
.app-layout { display: flex; height: 100vh; overflow: hidden; }

/* ── Sidebar ── */
.sidebar {
    width: var(--sidebar-width);
    position: fixed;
    top: 0; bottom: 0; left: 0;
    background: linear-gradient(180deg, var(--bg-primary) 0%, color-mix(in srgb, var(--bg-primary) 96%, var(--bg-secondary)) 100%);
    border-right: 1px solid var(--border);
    padding: var(--space-4);
    display: flex;
    flex-direction: column;
    gap: var(--space-3);
    overflow-y: auto;
    overflow-x: hidden;
    z-index: var(--z-sidebar);
}

[data-theme="dark"] .sidebar {
    background: linear-gradient(180deg, rgba(11, 18, 32, 0.98), rgba(11, 18, 32, 0.96));
}

.sidebar-header {
    padding: var(--space-2) var(--space-2) var(--space-3);
    border-bottom: 1px solid var(--border-light);
}

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 10px;
    text-decoration: none;
    font-weight: var(--weight-extrabold);
    letter-spacing: 0.2px;
    font-size: var(--text-lg);
    color: var(--brand);
}

.brand-mark {
    width: 36px; height: 36px;
    border-radius: var(--radius);
    display: inline-flex; align-items: center; justify-content: center;
    background: linear-gradient(135deg, var(--brand), var(--accent));
    color: var(--text-inverse);
    box-shadow: 0 12px 26px rgba(15, 118, 110, 0.20);
    font-weight: 900; font-size: 1rem;
}

.sidebar-menu {
    padding: var(--space-1);
    display: flex;
    flex-direction: column;
    gap: var(--space-4);
    flex: 1;
}

.menu-section { display: flex; flex-direction: column; gap: var(--space-1); }

.menu-section:not(:last-child) {
    padding-bottom: var(--space-3);
    border-bottom: 1px solid var(--border-light);
}

.menu-label {
    font-size: var(--text-xs);
    font-weight: var(--weight-bold);
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.12em;
    padding: 6px 10px 2px;
}

.menu-item {
    display: flex; align-items: center; gap: 10px;
    padding: 9px 12px;
    color: var(--text-secondary);
    text-decoration: none;
    border-radius: var(--radius);
    transition: all var(--duration-fast) var(--ease-default);
    font-weight: var(--weight-medium);
    font-size: var(--text-base);
    position: relative;
}

.menu-item:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
    transform: translateX(2px);
}

.menu-item.active {
    background: var(--brand-soft);
    color: var(--brand);
    font-weight: var(--weight-semibold);
}

.menu-item.active::before {
    content: '';
    position: absolute; left: 0; top: 50%;
    transform: translateY(-50%);
    width: 3px; height: 55%;
    background: var(--brand);
    border-radius: 0 3px 3px 0;
}

.menu-icon { font-size: 1.1rem; width: 22px; text-align: center; flex-shrink: 0; }

.menu-badge {
    margin-left: auto;
    background: var(--brand);
    color: var(--text-inverse);
    font-size: var(--text-xs);
    font-weight: var(--weight-bold);
    padding: 2px 7px;
    border-radius: var(--radius-full);
    min-width: 18px; text-align: center;
}

.sidebar-footer {
    margin-top: auto;
    padding: var(--space-3) var(--space-2);
    border-top: 1px solid var(--border-light);
    display: flex; justify-content: space-between; align-items: center;
    gap: var(--space-2);
}

.sidebar-footer-status {
    display: flex; align-items: center; gap: 6px;
    font-size: var(--text-sm);
    color: var(--text-muted);
}

.status-indicator {
    width: 8px; height: 8px; border-radius: 50%;
    background: var(--success);
    animation: pulse 2s infinite;
}
.status-indicator.offline { background: var(--text-muted); animation: none; }

.sidebar-user {
    display: flex; align-items: center; gap: var(--space-2);
    padding: 6px; border-radius: var(--radius-sm);
    cursor: pointer;
    transition: background var(--duration-fast);
}
.sidebar-user:hover { background: var(--bg-hover); }

.user-avatar {
    width: 34px; height: 34px; border-radius: var(--radius-sm);
    background: linear-gradient(135deg, var(--brand), var(--accent));
    display: flex; align-items: center; justify-content: center;
    color: var(--text-inverse);
    font-weight: var(--weight-bold);
    font-size: var(--text-base);
}

/* ── Main Content ── */
.main-content {
    flex: 1;
    margin-left: var(--sidebar-width);
    min-width: 0;
    display: flex; flex-direction: column;
    height: 100vh; overflow: hidden;
}

/* ── Topbar ── */
.topbar {
    height: var(--topbar-height);
    flex-shrink: 0;
    z-index: var(--z-topbar);
    display: flex; align-items: center; justify-content: space-between;
    gap: var(--space-3);
    padding: var(--space-3) var(--space-6);
    background: color-mix(in srgb, var(--bg-primary) 85%, transparent);
    border-bottom: 1px solid var(--border);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
}

[data-theme="dark"] .topbar {
    background: color-mix(in srgb, var(--bg-primary) 80%, transparent);
}

.topbar-left, .topbar-right {
    display: flex; align-items: center; gap: var(--space-3); min-width: 0;
}

.project-selector { min-width: 200px; }

/* Custom Project Dropdown */
.project-selector-wrap { position: relative; }
.project-selector-btn {
    display: flex; align-items: center; gap: 0.5rem;
    background: var(--bg-secondary); border: 1px solid var(--border);
    border-radius: var(--radius-sm); padding: 0.4rem 0.75rem;
    cursor: pointer; min-width: 200px; transition: border-color 0.15s;
    font-size: var(--text-sm); color: var(--text-primary);
}
.project-selector-btn:hover { border-color: var(--brand); }
.project-dot {
    width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0;
    background: var(--text-muted);
}
.project-name {
    flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
    font-weight: var(--weight-medium);
}
.project-chevron { flex-shrink: 0; opacity: 0.5; transition: transform 0.2s; }
.project-selector-dropdown.open ~ .project-selector-btn .project-chevron,
.project-selector-btn[aria-expanded="true"] .project-chevron { transform: rotate(180deg); }

.project-selector-dropdown {
    display: none; position: absolute; top: calc(100% + 4px); left: 0;
    min-width: 240px; max-height: 300px; overflow-y: auto;
    background: var(--bg-primary); border: 1px solid var(--border);
    border-radius: var(--radius); box-shadow: var(--shadow-lg);
    z-index: var(--z-dropdown, 100); padding: 0.25rem;
}
.project-selector-dropdown.open { display: block; }

.project-dropdown-item {
    display: flex; align-items: center; gap: 0.5rem;
    padding: 0.5rem 0.75rem; border-radius: var(--radius-sm);
    cursor: pointer; transition: background 0.15s;
    font-size: var(--text-sm); color: var(--text-secondary);
}
.project-dropdown-item:hover { background: var(--bg-hover); }
.project-dropdown-item.active { background: color-mix(in srgb, var(--brand) 10%, transparent); color: var(--brand); font-weight: var(--weight-medium); }
.project-dropdown-dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }
.project-dropdown-name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.project-dropdown-badge { font-size: var(--text-xs); padding: 0.1rem 0.4rem; border-radius: 999px; }

/* ── Content Area ── */
.content-area {
    padding: var(--space-6);
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
}

/* ── Sidebar Overlay (mobile) ── */
.sidebar-overlay {
    position: fixed; inset: 0;
    background: rgba(0,0,0,0.5);
    z-index: var(--z-overlay);
    opacity: 0; pointer-events: none;
    transition: opacity 0.3s var(--ease-default);
}
.sidebar-overlay.visible { opacity: 1; pointer-events: auto; }

/* ── Mobile Layout ── */
@media (max-width: 1024px) {
    :root { --sidebar-width: 240px; }
}

@media (max-width: 768px) {
    :root { --sidebar-width: 0px; }
    html, body { overflow: auto; }
    body.mobile-menu-open { overflow: hidden; }

    .sidebar {
        transform: translateX(-100%);
        transition: transform 0.3s var(--ease-default);
        width: 280px;
        z-index: 200;
    }
    .sidebar.open { transform: translateX(0); }
    .main-content { margin-left: 0 !important; height: auto; min-height: 100vh; overflow: visible; }

    .content-area { padding: var(--space-4); }
}

@media (min-width: 769px) {
    .mobile-menu-toggle { display: none !important; }
    .sidebar-overlay { display: none !important; }
}
