/* Momentran V2 — Layout: Topbar, Sidebar, Main Content */

.app-layout {
    display: grid;
    grid-template-columns: 280px 1fr;
    grid-template-rows: 56px 1fr;
    grid-template-areas: "topbar topbar" "sidebar main";
    min-height: 100vh;
}

/* ── Topbar ── */
.topbar {
    grid-area: topbar;
    position: sticky;
    top: 0;
    z-index: 100;
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 0 20px;
    background: var(--nav-bg);
    border-bottom: 1px solid var(--glass-border);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
}

.topbar-left {
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 0;
}

.topbar-brand {
    display: flex;
    align-items: center;
    gap: 8px;
    font-family: var(--font-display);
    font-weight: 700;
    font-size: 1.1rem;
    color: var(--text);
    white-space: nowrap;
}

.topbar-brand-icon {
    width: 32px; height: 32px;
    background: linear-gradient(135deg, var(--accent), var(--accent2));
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.topbar-brand-icon svg { width: 16px; height: 16px; fill: #fff; }

.topbar-brand-logo {
    height: 24px;
    width: auto;
    filter: brightness(0) invert(1);
}
[data-theme="light"] .topbar-brand-logo {
    filter: none;
}

.topbar-divider {
    width: 1px;
    height: 24px;
    background: var(--glass-border);
    flex-shrink: 0;
}

/* App Switcher */
.app-switcher {
    position: relative;
}

.app-switcher-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 12px;
    background: var(--bg3);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-sm);
    color: var(--text);
    font-family: var(--font-body);
    font-size: 0.87rem;
    cursor: pointer;
    transition: all var(--duration-fast) var(--ease-out);
    white-space: nowrap;
    max-width: 200px;
    overflow: hidden;
    text-overflow: ellipsis;
}

.app-switcher-btn:hover { border-color: var(--accent); }

.app-switcher-btn svg {
    width: 14px; height: 14px; flex-shrink: 0;
    stroke: var(--text3);
    transition: transform var(--duration-fast);
}

.app-switcher-btn.open svg { transform: rotate(180deg); }

.app-dropdown {
    position: absolute;
    top: calc(100% + 6px);
    left: 0;
    min-width: 220px;
    background: var(--bg3);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-md);
    padding: 6px;
    box-shadow: var(--shadow-3);
    display: none;
    z-index: 200;
}

.app-dropdown.open { display: block; animation: fadeIn 0.15s var(--ease-out); }

.app-dropdown-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 12px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-size: 0.87rem;
    color: var(--text);
    transition: background var(--duration-fast);
    border: none;
    background: none;
    width: 100%;
    text-align: left;
    font-family: var(--font-body);
}

.app-dropdown-item:hover { background: var(--bg4); }
.app-dropdown-item.active { background: var(--accent-glow); color: var(--accent); }

.app-dropdown-item .app-icon {
    width: 28px; height: 28px;
    border-radius: 6px;
    background: var(--bg4);
    display: flex; align-items: center; justify-content: center;
    font-size: 0.75rem; font-weight: 600;
    flex-shrink: 0;
}

/* Language Toggle (Dashboard) */
.topbar-right .lang-toggle {
    display: flex;
    align-items: center;
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    border-radius: 20px;
    padding: 3px;
    cursor: pointer;
    gap: 0;
}
.topbar-right .lang-toggle span {
    padding: 4px 10px;
    font-size: 12px;
    font-weight: 600;
    font-family: var(--font-display);
    border-radius: 16px;
    color: var(--text3);
    transition: all 0.15s ease;
    user-select: none;
}
.topbar-right .lang-toggle span.active {
    background: var(--accent);
    color: #fff;
}

/* Topbar Right */
.topbar-right {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-left: auto;
}

.topbar-btn {
    width: 36px; height: 36px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--glass-border);
    background: var(--bg3);
    color: var(--text2);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--duration-fast) var(--ease-out);
}

.topbar-btn:hover { background: var(--accent); color: #fff; border-color: var(--accent); }
.topbar-btn svg { width: 16px; height: 16px; }

.topbar-sync-btn {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 14px;
    background: var(--accent);
    color: #fff;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 0.8rem;
    font-family: var(--font-body);
    font-weight: 500;
    cursor: pointer;
    transition: all var(--duration-fast) var(--ease-out);
}

.topbar-sync-btn:hover { background: var(--accent2); transform: translateY(-1px); }
.topbar-sync-btn:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }
.topbar-sync-btn svg { width: 14px; height: 14px; }
.topbar-sync-btn.syncing svg { animation: spin 0.8s linear infinite; }

@keyframes spin { to { transform: rotate(360deg); } }

.topbar-user {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 4px 10px 4px 4px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: background var(--duration-fast);
}

.topbar-user:hover { background: var(--bg3); }

.topbar-avatar {
    width: 30px; height: 30px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--accent), var(--accent2));
    display: flex; align-items: center; justify-content: center;
    font-size: 0.75rem; font-weight: 700; color: #fff;
}

.topbar-user-info {
    display: flex;
    flex-direction: column;
    line-height: 1.2;
}

.topbar-user-name { font-size: 0.82rem; font-weight: 500; color: var(--text); }
.topbar-user-role { font-size: 0.7rem; color: var(--text3); text-transform: uppercase; letter-spacing: 0.03em; }

/* User Dropdown */
.topbar-user-wrap { position: relative; }

.user-dropdown {
    display: none;
    position: absolute;
    top: calc(100% + 6px);
    right: 0;
    min-width: 180px;
    background: var(--bg2);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-2);
    padding: 6px;
    z-index: 999;
    animation: dropdownFadeIn 0.15s var(--ease-out);
}

.user-dropdown.open { display: block; }

@keyframes dropdownFadeIn {
    from { opacity: 0; transform: translateY(-4px); }
    to { opacity: 1; transform: translateY(0); }
}

.user-dropdown-item {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    padding: 10px 14px;
    font-size: 0.82rem;
    font-weight: 500;
    color: var(--text2);
    background: none;
    border: none;
    border-radius: var(--radius-sm);
    cursor: pointer;
    text-decoration: none;
    transition: all var(--duration-fast) var(--ease-out);
    font-family: inherit;
}

.user-dropdown-item:hover {
    background: var(--bg3);
    color: var(--text);
}

.user-dropdown-item svg { flex-shrink: 0; opacity: 0.7; }

.user-dropdown-item:last-child {
    color: var(--coral);
}

.user-dropdown-item:last-child:hover {
    background: rgba(244,63,94,0.1);
    color: var(--coral);
}

/* Mobile menu toggle */
.mobile-menu-btn {
    display: none;
    width: 36px; height: 36px;
    border: none; background: none;
    color: var(--text);
    cursor: pointer;
    align-items: center;
    justify-content: center;
}

.mobile-menu-btn svg { width: 22px; height: 22px; }

/* ── Sidebar ── */
.sidebar {
    grid-area: sidebar;
    background: var(--nav-bg);
    border-right: 1px solid var(--glass-border);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    overflow-y: auto;
    display: flex;
    flex-direction: column;
}

.sidebar-header {
    padding: 16px 16px 12px;
    border-bottom: 1px solid var(--glass-border);
}

.sidebar-search {
    width: 100%;
    padding: 8px 12px 8px 34px;
    background: var(--bg3);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-sm);
    color: var(--text);
    font-family: var(--font-body);
    font-size: 0.82rem;
    outline: none;
    transition: border-color var(--duration-fast);
}

.sidebar-search:focus { border-color: var(--accent); }

.sidebar-search-wrap {
    position: relative;
}

.sidebar-search-wrap svg {
    position: absolute;
    left: 10px; top: 50%;
    transform: translateY(-50%);
    width: 14px; height: 14px;
    stroke: var(--text3);
    pointer-events: none;
}

.sidebar-list {
    flex: 1;
    overflow-y: auto;
    padding: 8px;
}

.sidebar-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all var(--duration-fast);
    border: none;
    background: none;
    width: 100%;
    text-align: left;
    font-family: var(--font-body);
    color: var(--text);
}

.sidebar-item:hover { background: var(--bg3); }
.sidebar-item.active { background: var(--accent-glow); border-left: 3px solid var(--accent); }

.sidebar-item-score {
    width: 10px; height: 10px;
    border-radius: 50%;
    flex-shrink: 0;
}

.sidebar-item-info { flex: 1; min-width: 0; }

.sidebar-item-name {
    font-size: 0.82rem;
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.sidebar-item-meta {
    font-size: 0.72rem;
    color: var(--text3);
    margin-top: 2px;
}

.sidebar-item-badge {
    font-size: 0.68rem;
    padding: 2px 6px;
    border-radius: 4px;
    font-weight: 600;
    font-family: var(--font-display);
    flex-shrink: 0;
}

.sidebar-empty {
    padding: 40px 20px;
    text-align: center;
    color: var(--text3);
    font-size: 0.85rem;
}

.sidebar-footer {
    padding: 12px 16px;
    border-top: 1px solid var(--glass-border);
    font-size: 0.75rem;
    color: var(--text3);
    text-align: center;
}

/* Sidebar overlay for mobile */
.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    z-index: 89;
}

/* ── Main Content ── */
.main-content {
    grid-area: main;
    overflow-y: auto;
    padding: 24px;
    max-height: calc(100vh - 56px);
}

.content-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 24px;
    flex-wrap: wrap;
    gap: 12px;
}

.content-title {
    font-family: var(--font-display);
    font-size: 1.4rem;
    font-weight: 700;
    color: var(--text);
}

.content-subtitle {
    font-size: 0.85rem;
    color: var(--text3);
    margin-top: 2px;
}

/* Section grouping */
.section {
    margin-bottom: 28px;
}

.section-title {
    font-family: var(--font-display);
    font-size: 1rem;
    font-weight: 600;
    color: var(--text);
    margin-bottom: 16px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.section-title svg { width: 18px; height: 18px; stroke: var(--accent); }

/* Grid layouts */
.grid-2 { display: grid; grid-template-columns: repeat(2, 1fr); gap: 16px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
.grid-4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; }
.grid-5 { display: grid; grid-template-columns: repeat(5, 1fr); gap: 16px; }

/* No campaign selected state */
.no-selection {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 60vh;
    color: var(--text3);
    gap: 16px;
}

.no-selection svg { width: 64px; height: 64px; stroke: var(--bg4); }
.no-selection h3 { font-size: 1.1rem; color: var(--text2); }
.no-selection p { font-size: 0.87rem; }

/* Loading skeleton */
.skeleton {
    background: linear-gradient(90deg, var(--bg3) 25%, var(--bg4) 50%, var(--bg3) 75%);
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite;
    border-radius: var(--radius-sm);
}

.skeleton-text { height: 16px; width: 60%; margin-bottom: 8px; }
.skeleton-card { height: 100px; width: 100%; }
