/* ─── RESET & TOKENS ─────────────────────────────────────────────── */
:root {
    --primary:      #6366f1;
    --primary-lt:   #e0e7ff;
    --pink:         #ec4899;
    --green:        #10b981;
    --amber:        #f59e0b;
    --amber-lt:     #fffbeb;
    --amber-border: #fde68a;

    --bg:           #f5f7ff;
    --sidebar-bg:   #ffffff;
    --card-inner:   #f8fafc;

    --text:         #1e293b;
    --muted:        #64748b;
    --border:       #e2e8f0;

    --radius:       1.25rem;
    --shadow-sm:    0 2px 8px rgba(0,0,0,0.06);
    --shadow-md:    0 8px 28px rgba(99,102,241,0.12);
    --shadow-lg:    0 20px 50px rgba(99,102,241,0.18);
    --t:            0.25s cubic-bezier(0.4,0,0.2,1);
}

*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    -webkit-tap-highlight-color: transparent;
}

html {
    height: 100%;
}

body {
    height: 100%;
    overflow: hidden;
    font-family: 'Inter', system-ui, sans-serif;
    background: var(--bg);
    color: var(--text);
    font-size: 15px;
    line-height: 1.5;
}

/* ─── BACKGROUND BLOBS ───────────────────────────────────────────── */
.bg-blobs {
    position: fixed;
    inset: 0;
    z-index: 0;
    pointer-events: none;
    overflow: hidden;
}

.blob {
    position: absolute;
    border-radius: 50%;
    filter: blur(80px);
    opacity: 0.11;
    animation: drift 18s ease-in-out infinite alternate;
}

.b1 {
    width: 500px; height: 500px;
    top: -150px; left: -150px;
    background: radial-gradient(circle, var(--primary) 0%, transparent 70%);
}
.b2 {
    width: 400px; height: 400px;
    bottom: -120px; right: -100px;
    background: radial-gradient(circle, var(--green) 0%, transparent 70%);
    animation-delay: -6s;
}
.b3 {
    width: 350px; height: 350px;
    top: 30%; right: 20%;
    background: radial-gradient(circle, var(--pink) 0%, transparent 70%);
    opacity: 0.07;
    animation-delay: -12s;
}

@keyframes drift {
    from { transform: translate(0, 0) scale(1); }
    to   { transform: translate(60px, 40px) scale(1.1); }
}

/* ─── APP SHELL ──────────────────────────────────────────────────── */
/*
 * Mobile  : column, full height — sidebar fills screen, detail hidden
 * Desktop : row, full height — sidebar left, detail right
 */
.app-shell {
    position: relative;
    z-index: 1;
    width: 100%;
    height: 100%;   /* fills body which is 100% of html which is 100vh */
    display: flex;
    flex-direction: column; /* MOBILE: vertical stack */
}

/* ─── SIDEBAR ────────────────────────────────────────────────────── */
.sidebar {
    /* Mobile: takes ALL available space, acting as the list screen */
    flex: 1 1 auto;
    min-height: 0;              /* allow flex shrinking past content */
    display: flex;
    flex-direction: column;
    background: var(--sidebar-bg);
    overflow: hidden;
}

/* Mobile: when an app is selected, sidebar slides out */
.sidebar.hidden {
    display: none;
}

.sidebar-header {
    flex-shrink: 0;
    padding: 1rem 1.25rem;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.logo {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.logo-icon {
    width: 38px; height: 38px;
    background: linear-gradient(135deg, var(--primary), var(--pink));
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.1rem;
    color: #fff;
    flex-shrink: 0;
}

.logo-title { font-size: 1rem; font-weight: 800; letter-spacing: -0.02em; }
.logo-sub   { font-size: 0.7rem; color: var(--muted); font-weight: 500; }

.app-count {
    background: var(--primary-lt);
    color: var(--primary);
    font-size: 0.72rem;
    font-weight: 700;
    padding: 0.2rem 0.6rem;
    border-radius: 99px;
    white-space: nowrap;
}

/* ─── APP LIST ───────────────────────────────────────────────────── */
.app-list {
    flex: 1 1 auto;
    min-height: 0;              /* critical: allows overflow-y to work */
    overflow-y: auto;
    padding: 0.6rem;
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
}

.app-item {
    display: flex;
    align-items: center;
    gap: 0.8rem;
    padding: 0.85rem 1rem;
    border-radius: 1rem;
    cursor: pointer;
    border: 1px solid transparent;
    transition: background var(--t), border-color var(--t), color var(--t);
    text-align: left;
    background: none;
    width: 100%;
    color: inherit;
    font-family: inherit;
    font-size: 0.95rem;
}

.app-item:hover {
    background: #f0f4ff;
    border-color: var(--primary-lt);
}

.app-item.active {
    background: var(--primary-lt);
    border-color: var(--primary);
    color: var(--primary);
}

/* Orange pulsing dot for dev apps */
.app-item.is-dev .item-name::after {
    content: '';
    display: inline-block;
    width: 7px; height: 7px;
    background: var(--amber);
    border-radius: 50%;
    margin-left: 7px;
    vertical-align: middle;
    animation: pulse-dot 2s ease-in-out infinite;
}

@keyframes pulse-dot {
    0%, 100% { opacity: 1; transform: scale(1); }
    50%       { opacity: 0.5; transform: scale(0.65); }
}

.item-icon {
    width: 36px; height: 36px;
    border-radius: 9px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.1rem;
    flex-shrink: 0;
    background: var(--bg);
    border: 1px solid var(--border);
    transition: background var(--t), border-color var(--t);
}

.app-item.active .item-icon {
    background: var(--primary);
    border-color: var(--primary);
    color: #fff;
}

.item-name {
    font-weight: 600;
    font-size: 0.92rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    flex: 1;
}

.item-arrow {
    margin-left: auto;
    color: var(--muted);
    font-size: 1.1rem;
    flex-shrink: 0;
    opacity: 0;
    transition: opacity var(--t);
}
.app-item:hover .item-arrow,
.app-item.active .item-arrow { opacity: 1; }

.legend {
    flex-shrink: 0;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem 0.75rem;
    font-size: 0.72rem;
    color: var(--muted);
}

.legend-dot {
    width: 7px; height: 7px;
    background: var(--amber);
    border-radius: 50%;
    flex-shrink: 0;
}

.sidebar-footer {
    flex-shrink: 0;
    padding: 0.75rem 1.25rem;
    border-top: 1px solid var(--border);
    font-size: 0.72rem;
    color: var(--muted);
}

/* ─── DETAIL PANEL ───────────────────────────────────────────────── */
/*
 * Mobile  : hidden by default, shown (.visible) when an app is selected
 * Desktop : always flex, fills remaining width
 */
.detail-panel {
    flex: 1 1 auto;
    min-height: 0;
    min-width: 0;
    display: none;              /* hidden on mobile by default */
    flex-direction: column;
}

.detail-panel.visible {
    display: flex;             /* shown on mobile after selection */
}

/* ─── BACK BUTTON (mobile) ───────────────────────────────────────── */
.back-btn {
    flex-shrink: 0;
    display: flex;
    align-items: center;
    gap: 0.4rem;
    align-self: flex-start;
    margin: 1rem 1.25rem 0;
    background: #fff;
    border: 1px solid var(--border);
    border-radius: 99px;
    padding: 0.45rem 1rem;
    font-size: 0.88rem;
    font-weight: 600;
    cursor: pointer;
    box-shadow: var(--shadow-sm);
    color: var(--text);
    font-family: inherit;
    transition: background var(--t);
}

.back-btn:hover { background: var(--bg); }

/* ─── DETAIL PLACEHOLDER ─────────────────────────────────────────── */
.detail-placeholder {
    display: none; /* Always hidden — first app auto-selected */
}

/* ─── DETAIL CONTENT ─────────────────────────────────────────────── */
.detail-content {
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
    padding: 2rem 1.5rem 2rem;
    animation: slideIn 0.3s ease-out;
    display: flex;
    flex-direction: column;
    justify-content: center; /* Vertically center content on large screens */
    max-width: 680px;
    width: 100%;
    align-self: center; /* Center in the panel horizontally */
}

@keyframes slideIn {
    from { opacity: 0; transform: translateY(10px); }
    to   { opacity: 1; transform: translateY(0); }
}

.detail-name {
    font-size: 1.9rem;
    font-weight: 900;
    letter-spacing: -0.04em;
    background: linear-gradient(135deg, var(--primary) 0%, var(--pink) 100%);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    line-height: 1.1;
}

.detail-title-row {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.75rem;
    margin-bottom: 1.25rem;
}

.detail-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    background: var(--amber-lt);
    color: #92400e;
    border: 1px solid var(--amber-border);
    padding: 0.3rem 0.8rem;
    border-radius: 99px;
    font-size: 0.72rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    white-space: nowrap;
    flex-shrink: 0;
}

.detail-desc {
    font-size: 1rem;
    color: var(--muted);
    line-height: 1.75;
    margin-bottom: 1.5rem;
}

.detail-card {
    background: var(--card-inner);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.1rem 1.25rem;
    margin-bottom: 1.5rem;
}

.detail-card-title {
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--primary);
    margin-bottom: 0.6rem;
    display: flex;
    align-items: center;
    gap: 0.4rem;
}

.detail-card-text {
    font-size: 0.92rem;
    color: var(--text);
    line-height: 1.7;
}

.detail-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.6rem;
    padding: 0.85rem 1.75rem;
    background: linear-gradient(135deg, var(--primary) 0%, #818cf8 100%);
    color: #fff;
    text-decoration: none;
    border-radius: 1rem;
    font-weight: 700;
    font-size: 0.95rem;
    box-shadow: var(--shadow-md);
    transition: all var(--t);
}

.detail-btn:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}

/* ─── SCROLLBAR ──────────────────────────────────────────────────── */
.app-list::-webkit-scrollbar,
.detail-content::-webkit-scrollbar { width: 4px; }

.app-list::-webkit-scrollbar-track,
.detail-content::-webkit-scrollbar-track { background: transparent; }

.app-list::-webkit-scrollbar-thumb,
.detail-content::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 99px;
}

/* ══════════════════════════════════════════════════════════════════
   DESKTOP — min 768px
   Layout switches to ROW: sidebar | detail
   ════════════════════════════════════════════════════════════════ */
@media (min-width: 768px) {

    .app-shell {
        flex-direction: row;   /* side-by-side */
    }

    /* Sidebar: fixed width, full height, internal scroll */
    .sidebar {
        flex: 0 0 270px;       /* don't grow or shrink, exact 270px */
        width: 270px;
        height: 100%;
        border-right: 1px solid var(--border);
    }

    /* Sidebar is ALWAYS visible on desktop (override .hidden) */
    .sidebar.hidden {
        display: flex !important;
    }

    /* Detail panel is ALWAYS visible on desktop */
    .detail-panel {
        display: flex !important;
        flex: 1 1 auto;
        height: 100%;
    }

    /* Back button hidden on desktop */
    .back-btn {
        display: none !important;
    }

    /* More room for content */
    .detail-content {
        padding: 2.5rem 3rem 3rem;
    }

    .detail-name { font-size: 2.4rem; }
    .detail-desc { font-size: 1.05rem; }
    .detail-card { max-width: 520px; }
}

@media (min-width: 1024px) {
    .sidebar { flex: 0 0 290px; width: 290px; }
    .detail-name { font-size: 2.75rem; }
}
