/* Components — buttons, pills, cards, page header, kpi, badges, search. */

/* ── App shell content primitives ───────────────────────────────── */
.os-app-layout {
    display: flex;
    height: 100%;
    width: 100%;
    min-height: 0;
}
.os-app-sidebar {
    width: 250px;
    flex-shrink: 0;
    overflow-y: auto;
    padding: var(--space-4) var(--space-3);
    background:
        radial-gradient(circle at 0 0, rgba(124, 58, 237, 0.14), transparent 42%),
        var(--os-surface);
    border-inline-end: 1px solid var(--os-border);
}
.os-app-sidebar-block {
    padding: 0 0 var(--space-4);
    margin-bottom: var(--space-4);
    border-bottom: 1px solid var(--os-border);
}
.os-app-sidebar-block:last-child {
    margin-bottom: 0;
    border-bottom: 0;
}
.os-app-sidebar-title {
    font-size: var(--fs-overline);
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--os-text-muted);
    padding: 0 var(--space-3) var(--space-2);
}
.os-app-main {
    flex: 1;
    min-width: 0;
    overflow-y: auto;
    overflow-x: hidden;
    padding: var(--space-6) var(--space-8);
}
.os-app-panel {
    background:
        linear-gradient(180deg, rgba(255, 255, 255, 0.035), rgba(255, 255, 255, 0.015)),
        var(--os-surface);
    border: 1px solid var(--os-border);
    border-radius: var(--os-radius-lg);
    box-shadow: var(--shadow-md);
}
.os-toolbar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-3);
    padding: var(--space-4);
    border-bottom: 1px solid var(--os-border);
}
.os-toolbar-main {
    display: flex;
    flex: 1;
    min-width: 260px;
    align-items: center;
    gap: var(--space-3);
}
.os-toolbar-actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: var(--space-2);
}
.os-filter-group {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-2);
}
.os-filter-chip {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    min-height: 34px;
    padding: 0 var(--space-3);
    border-radius: var(--os-radius-full);
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid var(--os-border);
    color: var(--os-text-muted);
    font-size: var(--fs-caption);
    font-weight: 700;
    cursor: pointer;
    transition: all var(--duration-fast) var(--ease-default);
}
.os-filter-chip:hover {
    color: var(--os-text-main);
    border-color: rgba(168, 85, 247, 0.45);
    background: rgba(168, 85, 247, 0.08);
}
.os-filter-chip.active {
    color: #fff;
    border-color: transparent;
    background: linear-gradient(135deg, var(--os-purple-light), var(--os-purple));
    box-shadow: 0 8px 20px rgba(124, 58, 237, 0.28);
}
.os-form-select {
    height: 36px;
    min-width: 160px;
    padding: 0 var(--space-3);
    border-radius: var(--os-radius-sm);
    background: var(--os-surface-light);
    border: 1px solid var(--os-border);
    color: var(--os-text-main);
    font-size: var(--fs-small);
    font-weight: 600;
}
.os-form-select:focus {
    outline: 0;
    border-color: rgba(168, 85, 247, 0.7);
    box-shadow: 0 0 0 3px rgba(168, 85, 247, 0.16);
}
.os-count-pill {
    display: inline-flex;
    align-items: center;
    min-height: 32px;
    padding: 0 var(--space-3);
    border-radius: var(--os-radius-full);
    background: rgba(255, 255, 255, 0.045);
    border: 1px solid var(--os-border);
    color: var(--os-text-muted);
    font-size: var(--fs-caption);
    font-weight: 700;
    white-space: nowrap;
}
.os-cover-placeholder {
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.35rem;
    background:
        radial-gradient(circle at 30% 20%, rgba(192, 132, 252, 0.45), transparent 54%),
        radial-gradient(circle at 78% 82%, rgba(99, 102, 241, 0.32), transparent 52%),
        linear-gradient(135deg, #2a1859, #4c1d95 60%, #6d28d9);
    color: rgba(255, 255, 255, 0.88);
}
.os-cover-letter {
    font-size: clamp(2.2rem, 7vw, 4.1rem);
    font-weight: 800;
    line-height: 1;
    text-shadow: 0 8px 22px rgba(0, 0, 0, 0.38);
}
.os-cover-note {
    font-size: var(--fs-overline);
    color: rgba(237, 233, 254, 0.72);
    text-transform: uppercase;
    letter-spacing: 0.12em;
}

/* ── Buttons ────────────────────────────────────────────────────── */
.os-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    height: 38px;
    padding: 0 0.95rem;
    border-radius: var(--os-radius-sm);
    background: var(--os-surface-light);
    border: 1px solid var(--os-border);
    color: var(--os-text-main);
    font-size: var(--fs-small);
    font-weight: 600;
    cursor: pointer;
    transition: all var(--duration-fast) var(--ease-default);
}
.os-btn:hover { background: var(--os-surface-hover); border-color: var(--os-border-strong); }

.os-btn-primary {
    background: var(--os-accent);
    border-color: transparent;
    color: #fff;
}
.os-btn-primary:hover { background: var(--os-accent-hover); }

.os-btn-purple {
    background: var(--os-purple);
    border-color: transparent;
    color: #fff;
}
.os-btn-purple:hover { background: var(--os-purple-dark); }

.os-btn-ghost {
    background: transparent;
    border-color: transparent;
    color: var(--os-text-muted);
}
.os-btn-ghost:hover { background: rgba(255, 255, 255, 0.06); color: var(--os-text-main); }

.os-btn-icon {
    width: 38px; padding: 0; border-radius: 50%;
}

/* ── Pill / Badge ───────────────────────────────────────────────── */
.os-pill {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    padding: 0.2rem 0.65rem;
    border-radius: var(--os-radius-full);
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--os-border);
    font-size: var(--fs-caption);
    font-weight: 600;
    color: var(--os-text-muted);
}
.os-pill-accent {
    background: rgba(37, 99, 235, 0.15);
    border-color: rgba(37, 99, 235, 0.35);
    color: #60a5fa;
}
.os-pill-purple {
    background: rgba(124, 58, 237, 0.15);
    border-color: rgba(124, 58, 237, 0.35);
    color: #c4b5fd;
}

/* ── Page header ────────────────────────────────────────────────── */
.os-page-header {
    margin-bottom: 1.25rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 0.75rem;
}
.os-page-title {
    font-size: 1.35rem;
    font-weight: 700;
    color: var(--os-text-main);
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin: 0;
}
.os-page-subtitle {
    color: var(--os-text-muted);
    font-size: var(--fs-small);
    margin-top: 0.25rem;
}

/* ── Section ────────────────────────────────────────────────────── */
.os-section-head {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    margin: var(--space-8) 0 var(--space-4);
}
.os-section-head h2 { margin: 0; font-size: var(--fs-h3); }
.os-section-count { color: var(--os-text-muted); font-size: var(--fs-small); margin-inline-start: 8px; }

/* ── Cards / KPI ────────────────────────────────────────────────── */
.os-card {
    background: var(--os-surface);
    border: 1px solid var(--os-border);
    border-radius: var(--os-radius-md);
    padding: var(--space-4);
    box-shadow: var(--shadow-sm);
    transition: all var(--duration-normal) var(--ease-default);
}
.os-card:hover { border-color: var(--os-border-strong); }

.os-kpi-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 1rem;
    margin-bottom: var(--space-6);
}
.os-kpi-card .kpi-label {
    font-size: 0.72rem;
    color: var(--os-text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}
.os-kpi-card .kpi-value {
    font-size: 1.75rem;
    font-weight: 700;
    color: var(--os-text-main);
    line-height: 1;
    margin-top: 0.25rem;
}

/* ── Media card (Spotify-style tile) ────────────────────────────── */
.os-media-card {
    background: var(--os-surface);
    border: 1px solid var(--os-border);
    border-radius: var(--os-radius-md);
    padding: 0.75rem;
    cursor: pointer;
    transition: all var(--duration-normal) var(--ease-default);
    text-decoration: none;
    color: inherit;
    position: relative;
}
.os-media-card:hover {
    background: var(--os-surface-light);
    border-color: rgba(124, 58, 237, 0.4);
    transform: translateY(-3px);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4), 0 0 16px rgba(124, 58, 237, 0.15);
}
.os-media-cover {
    position: relative;
    aspect-ratio: 1 / 1;
    border-radius: 10px;
    overflow: hidden;
    margin-bottom: 0.65rem;
    background: linear-gradient(135deg, var(--os-purple-dark), #1e0d2e);
    box-shadow: var(--shadow-md);
}
.os-media-cover img {
    width: 100%; height: 100%;
    object-fit: cover;
    transition: transform var(--duration-slow) var(--ease-default);
}
.os-media-card:hover .os-media-cover img { transform: scale(1.05); }
.os-media-cover-fallback {
    width: 100%; height: 100%;
    display: flex; align-items: center; justify-content: center;
    font-size: 3rem;
    background: linear-gradient(135deg, var(--os-purple), var(--os-accent));
    color: rgba(255, 255, 255, 0.7);
}
.os-media-play {
    position: absolute;
    inset-inline-end: 10px; bottom: 10px;
    width: 44px; height: 44px;
    border-radius: 50%;
    background: var(--os-accent);
    color: #fff;
    display: flex; align-items: center; justify-content: center;
    box-shadow: 0 8px 16px rgba(0, 0, 0, 0.5);
    opacity: 0;
    transform: translateY(8px);
    transition: all var(--duration-normal) var(--ease-bounce);
    font-size: 16px;
    border: 0;
    cursor: pointer;
    pointer-events: auto;
}
.os-media-play:hover { background: var(--os-accent-hover); transform: scale(1.05); }
.os-media-card:hover .os-media-play { opacity: 1; transform: translateY(0); }
.os-media-title {
    font-weight: 600;
    color: var(--os-text-main);
    font-size: var(--fs-body);
    margin: 0 0 3px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.os-media-meta {
    color: var(--os-text-muted);
    font-size: var(--fs-caption);
}

/* ── Grid ────────────────────────────────────────────────────────── */
.os-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: var(--space-4);
}

/* ── Search input ───────────────────────────────────────────────── */
.os-search {
    position: relative;
    display: flex;
    align-items: center;
    background: var(--os-surface);
    border: 1px solid var(--os-border);
    border-radius: var(--os-radius-full);
    padding: 0 0.85rem 0 2.2rem;
    height: 36px;
    transition: all var(--duration-fast) var(--ease-default);
}
.os-search:focus-within {
    border-color: var(--os-accent);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.18);
}
.os-search .os-search-icon {
    position: absolute;
    inset-inline-start: 12px;
    color: var(--os-text-muted);
    font-size: 0.95rem;
    pointer-events: none;
}
.os-search input {
    flex: 1;
    background: transparent;
    border: 0; outline: 0;
    color: var(--os-text-main);
    font-size: var(--fs-small);
    width: 100%;
}

[dir="rtl"] .os-search {
    padding: 0 2.2rem 0 0.85rem;
}

/* ── Hero (app landing) ─────────────────────────────────────────── */
.os-hero {
    position: relative;
    padding: var(--space-10) var(--space-6);
    border-radius: var(--os-radius-lg);
    background:
        radial-gradient(circle at 80% 0%, rgba(124, 58, 237, 0.28), transparent 50%),
        radial-gradient(circle at 0% 100%, rgba(37, 99, 235, 0.18), transparent 50%),
        var(--os-surface);
    border: 1px solid var(--os-border);
    overflow: hidden;
    margin-bottom: var(--space-6);
}
.os-hero .os-hero-eyebrow {
    color: #c4b5fd;
    font-size: var(--fs-overline);
    letter-spacing: 0.12em;
    text-transform: uppercase;
    font-weight: 700;
    margin-bottom: var(--space-2);
}
.os-hero h1 {
    font-size: var(--fs-display);
    margin: 0 0 var(--space-2);
    background: linear-gradient(135deg, #f8fafc, #c4b5fd);
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
}
.os-hero p { color: var(--os-text-muted); max-width: 60ch; line-height: 1.6; }

/* ── Empty state ───────────────────────────────────────────────── */
.os-empty {
    text-align: center;
    padding: var(--space-12) var(--space-6);
    color: var(--os-text-muted);
}
.os-empty-icon { font-size: 2.8rem; margin-bottom: var(--space-3); opacity: 0.55; }
.os-empty-icon i { display: inline-block; }
.os-media-cover-fallback i { font-size: inherit; }

/* ── PRD-019: Shared empty / loading / error state boxes ─────────── */
.nx-state-box {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: var(--space-12) var(--space-8);
    gap: var(--space-4);
    min-height: 200px;
}
.nx-state-icon { font-size: 2.5rem; line-height: 1; opacity: 0.45; }
.nx-state-title {
    font-size: var(--fs-body);
    font-weight: 700;
    color: var(--os-text-main);
    margin: 0;
}
.nx-state-desc {
    font-size: var(--fs-small);
    color: var(--os-text-muted);
    max-width: 320px;
    line-height: 1.5;
    margin: 0;
}
.nx-state-loading .nx-state-icon {
    animation: nx-pulse 1.4s ease-in-out infinite;
}
@keyframes nx-pulse {
    0%, 100% { opacity: 0.25; }
    50%       { opacity: 0.65; }
}
.nx-state-error .nx-state-icon { opacity: 0.7; color: var(--os-danger); }
.nx-state-error .nx-state-title { color: var(--os-danger); }
