/* ══════════════════════════════════════════════════════════════
   static/css/theme.css
   Sistema de diseño — The Sonic Curator
   Playlist Pilot v1.0.0
   ══════════════════════════════════════════════════════════════ */

/* ── Google Fonts ───────────────────────────────────────────── */
@import url('https://fonts.googleapis.com/css2?family=Plus+Jakarta+Sans:wght@400;500;600;700&family=Manrope:wght@400;500;600;700&display=swap');

/* ── Variables globales ─────────────────────────────────────── */
:root {
    /* Superficies */
    --surface:              #0e0e0e;
    --surface-low:          #131313;
    --surface-container:    #1a1a1a;
    --surface-highest:      #262626;
    --surface-high:         #202020;

    /* Colores primarios */
    --primary:              #72fe8f;
    --primary-container:    #1cb853;
    --on-primary:           #005f26;
    --primary-gradient:     linear-gradient(135deg, #72fe8f, #1cb853);

    /* Texto */
    --on-surface:           #e6e6e6;
    --on-surface-variant:   #adaaaa;
    --on-surface-muted:     #535353;

    /* Outline */
    --outline-variant:      #484847;
    --outline-opacity:      0.15;

    /* Tipografía */
    --font-display:         'Plus Jakarta Sans', sans-serif;
    --font-body:            'Manrope', sans-serif;
    --font-mono:            'Courier New', monospace;

    /* Escala tipográfica */
    --size-display-lg:      3.5rem;
    --size-display-md:      2.5rem;
    --size-display-sm:      2rem;
    --size-title-lg:        1.5rem;
    --size-title-md:        1.25rem;
    --size-title-sm:        1.1rem;
    --size-body-lg:         1rem;
    --size-body-md:         0.9rem;
    --size-body-sm:         0.85rem;
    --size-label-md:        0.8rem;
    --size-label-sm:        0.75rem;

    /* Pesos */
    --weight-regular:       400;
    --weight-medium:        500;
    --weight-semibold:      600;
    --weight-bold:          700;

    /* Letter spacing */
    --letter-tight:         -0.02em;
    --letter-normal:        0em;
    --letter-wide:          0.08em;

    /* Espaciado */
    --space-xs:             0.25rem;
    --space-sm:             0.5rem;
    --space-md:             1rem;
    --space-lg:             1.5rem;
    --space-xl:             2rem;
    --space-2xl:            3rem;
    --space-3xl:            4rem;

    /* Border radius */
    --radius-sm:            0.5rem;
    --radius-md:            0.75rem;
    --radius-lg:            1rem;
    --radius-xl:            1.5rem;
    --radius-pill:          9999px;

    /* Glassmorphism */
    --glass-bg-opacity:     0.60;
    --glass-blur:           20px;

    /* Sombras tonales */
    --shadow-ambient:       0 8px 40px rgba(114, 254, 143, 0.08);
    --shadow-hover:         0 4px 24px rgba(114, 254, 143, 0.12);

    /* Transiciones */
    --transition-fast:      150ms ease-out;
    --transition-base:      200ms ease-out;
    --transition-slow:      300ms ease-out;
}

/* ══════════════════════════════════════════════════════════════
   RESET Y BASE
   ══════════════════════════════════════════════════════════════ */

*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html, body {
    height: 100%;
    background-color: var(--surface);
    color: var(--on-surface);
    font-family: var(--font-body);
    font-size: 16px;
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4, h5, h6 {
    font-family: var(--font-display);
    letter-spacing: var(--letter-tight);
    color: var(--on-surface);
    line-height: 1.2;
}

a {
    color: var(--primary);
    text-decoration: none;
    transition: opacity var(--transition-base);
}

a:hover {
    opacity: 0.8;
}

/* ══════════════════════════════════════════════════════════════
   LAYOUT PRINCIPAL
   ══════════════════════════════════════════════════════════════ */

.app-layout {
    display: flex;
    height: 100vh;
    overflow: hidden;
}

/* ── Sidebar ────────────────────────────────────────────────── */
.sidebar {
    width: 240px;
    min-width: 240px;
    height: 100vh;
    background-color: rgba(14, 14, 14, 0.60);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    display: flex;
    flex-direction: column;
    padding: var(--space-lg) var(--space-md);
    overflow-y: auto;
    position: fixed;
    left: 0;
    top: 0;
    bottom: 0;
    z-index: 100;
}

/* ── Contenido principal ────────────────────────────────────── */
.main-content {
    margin-left: 240px;
    flex: 1;
    height: 100vh;
    overflow-y: auto;
    padding: var(--space-xl) var(--space-2xl);
    background-color: var(--surface);
}

/* ══════════════════════════════════════════════════════════════
   SIDEBAR — COMPONENTES
   ══════════════════════════════════════════════════════════════ */

.sidebar-logo {
    text-align: center;
    padding: var(--space-md) 0;
    margin-bottom: var(--space-md);
}

.sidebar-logo h2 {
    font-family: var(--font-display);
    color: var(--primary);
    font-size: var(--size-title-lg);
    letter-spacing: var(--letter-tight);
    margin: 0;
}

.sidebar-logo .version {
    font-family: var(--font-body);
    color: var(--on-surface-muted);
    font-size: var(--size-label-sm);
    letter-spacing: var(--letter-wide);
    margin-top: var(--space-xs);
}

.sidebar-divider {
    height: 1px;
    background: rgba(72, 72, 71, 0.15);
    margin: var(--space-sm) 0;
}

.sidebar-label {
    font-family: var(--font-body);
    color: var(--on-surface-muted);
    font-size: var(--size-label-sm);
    text-transform: uppercase;
    letter-spacing: var(--letter-wide);
    margin: var(--space-sm) 0 var(--space-xs) 0;
}

/* ── Navegación ─────────────────────────────────────────────── */
.nav-item {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    padding: var(--space-sm) var(--space-md);
    border-radius: var(--radius-pill);
    font-family: var(--font-body);
    font-size: var(--size-body-md);
    font-weight: var(--weight-medium);
    color: var(--on-surface-variant);
    cursor: pointer;
    transition: all var(--transition-base);
    border: none;
    background: transparent;
    width: 100%;
    text-align: left;
    text-decoration: none;
}

.nav-item:hover {
    background-color: var(--surface-container);
    color: var(--on-surface);
}

.nav-item.active {
    background: var(--primary-gradient);
    color: var(--on-primary);
    font-weight: var(--weight-semibold);
}

.nav-item.disabled {
    opacity: 0.4;
    cursor: not-allowed;
    pointer-events: none;
}

/* ── Info usuario ───────────────────────────────────────────── */
.user-info {
    margin-top: auto;
    padding-top: var(--space-md);
}

.user-name {
    font-family: var(--font-body);
    color: var(--on-surface);
    font-size: var(--size-body-sm);
    font-weight: var(--weight-semibold);
}

.user-email {
    font-family: var(--font-body);
    color: var(--on-surface-muted);
    font-size: var(--size-label-sm);
    margin-top: var(--space-xs);
}

.user-plan {
    font-family: var(--font-body);
    color: var(--primary);
    font-size: var(--size-label-sm);
    margin-top: var(--space-xs);
}

/* ══════════════════════════════════════════════════════════════
   BOTONES
   ══════════════════════════════════════════════════════════════ */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-sm);
    padding: 0.6rem 1.8rem;
    border-radius: var(--radius-pill);
    font-family: var(--font-body);
    font-weight: var(--weight-medium);
    font-size: var(--size-body-md);
    border: none;
    cursor: pointer;
    transition: all var(--transition-base);
    text-decoration: none;
}

.btn-primary {
    background: var(--primary-gradient);
    color: var(--on-primary);
    font-weight: var(--weight-semibold);
}

.btn-primary:hover {
    box-shadow: var(--shadow-hover);
    filter: brightness(1.08);
    color: var(--on-primary);
}

.btn-secondary {
    background-color: var(--surface-container);
    color: var(--on-surface);
}

.btn-secondary:hover {
    background-color: var(--surface-highest);
    color: var(--primary);
}

.btn-ghost {
    background: transparent;
    color: var(--on-surface-variant);
}

.btn-ghost:hover {
    background-color: var(--surface-container);
    color: var(--primary);
}

.btn-full {
    width: 100%;
}

.btn-logout {
    background-color: var(--surface-container);
    color: var(--on-surface-variant);
    width: 100%;
    margin-top: var(--space-sm);
}

.btn-logout:hover {
    background-color: var(--surface-highest);
    color: var(--on-surface);
}

/* ══════════════════════════════════════════════════════════════
   INPUTS
   ══════════════════════════════════════════════════════════════ */

.input {
    width: 100%;
    background-color: var(--surface-high);
    border: none;
    border-bottom: 2px solid transparent;
    border-radius: var(--radius-sm) var(--radius-sm) 0 0;
    padding: 0.6rem var(--space-md);
    color: var(--on-surface);
    font-family: var(--font-body);
    font-size: var(--size-body-md);
    transition: border-color var(--transition-base);
    outline: none;
}

.input:focus {
    border-bottom: 2px solid var(--primary);
    box-shadow: 0 2px 8px rgba(114, 254, 143, 0.15);
}

.input::placeholder {
    color: var(--on-surface-muted);
}

/* ══════════════════════════════════════════════════════════════
   CARDS
   ══════════════════════════════════════════════════════════════ */

.card {
    background-color: var(--surface-container);
    border-radius: var(--radius-md);
    padding: var(--space-md);
    box-shadow: var(--shadow-ambient);
    transition: box-shadow var(--transition-base);
}

.card:hover {
    box-shadow: var(--shadow-hover);
}

.card-title {
    font-family: var(--font-display);
    color: var(--primary);
    font-size: var(--size-title-sm);
    letter-spacing: var(--letter-tight);
    margin-bottom: var(--space-sm);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.card-meta {
    font-family: var(--font-body);
    color: var(--on-surface-variant);
    font-size: var(--size-body-sm);
    margin: 0.2rem 0;
}

/* ══════════════════════════════════════════════════════════════
   MÉTRICAS
   ══════════════════════════════════════════════════════════════ */

.metrics-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: var(--space-md);
    margin-bottom: var(--space-lg);
}

.metric-card {
    background-color: var(--surface-container);
    border-radius: var(--radius-md);
    padding: var(--space-md);
    box-shadow: var(--shadow-ambient);
    transition: box-shadow var(--transition-base);
}

.metric-card:hover {
    box-shadow: var(--shadow-hover);
}

.metric-label {
    font-family: var(--font-body);
    color: var(--on-surface-muted);
    font-size: var(--size-label-md);
    text-transform: uppercase;
    letter-spacing: var(--letter-wide);
    margin-bottom: var(--space-xs);
}

.metric-value {
    font-family: var(--font-display);
    color: var(--on-surface);
    font-size: var(--size-display-sm);
    font-weight: var(--weight-bold);
    line-height: 1;
}

/* ══════════════════════════════════════════════════════════════
   TABLAS
   ══════════════════════════════════════════════════════════════ */

.data-table {
    width: 100%;
    border-collapse: collapse;
    font-family: var(--font-body);
    font-size: var(--size-body-sm);
}

.data-table th {
    background-color: var(--surface-low);
    color: var(--on-surface-muted);
    font-size: var(--size-label-md);
    text-transform: uppercase;
    letter-spacing: var(--letter-wide);
    padding: var(--space-sm) var(--space-md);
    text-align: left;
    font-weight: var(--weight-semibold);
    border-bottom: 1px solid rgba(72, 72, 71, 0.15);
}

.data-table td {
    padding: var(--space-sm) var(--space-md);
    color: var(--on-surface-variant);
    border-bottom: 1px solid rgba(72, 72, 71, 0.08);
    transition: background-color var(--transition-fast);
}

.data-table tr:hover td {
    background-color: var(--surface-container);
    color: var(--on-surface);
    cursor: pointer;
}

.data-table tr.selected td {
    background-color: var(--surface-highest);
    color: var(--on-surface);
}

/* ══════════════════════════════════════════════════════════════
   SEPARADORES
   ══════════════════════════════════════════════════════════════ */

.divider {
    height: 1px;
    background: rgba(72, 72, 71, 0.15);
    margin: var(--space-lg) 0;
}

/* ══════════════════════════════════════════════════════════════
   EMPTY STATE
   ══════════════════════════════════════════════════════════════ */

.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: var(--space-3xl) var(--space-md);
    background-color: var(--surface-low);
    border-radius: var(--radius-lg);
    text-align: center;
}

.empty-state .emoji {
    font-size: 2.5rem;
    margin-bottom: var(--space-md);
}

.empty-state .message {
    font-family: var(--font-body);
    color: var(--on-surface-muted);
    font-size: var(--size-body-md);
}

.empty-state .submessage {
    font-family: var(--font-body);
    color: var(--on-surface-muted);
    font-size: var(--size-body-sm);
    margin-top: var(--space-xs);
    opacity: 0.7;
}

/* ══════════════════════════════════════════════════════════════
   SECTION LABEL
   ══════════════════════════════════════════════════════════════ */

.section-label {
    font-family: var(--font-body);
    color: var(--primary);
    font-size: var(--size-label-md);
    font-weight: var(--weight-semibold);
    text-transform: uppercase;
    letter-spacing: var(--letter-wide);
    margin: var(--space-md) 0 var(--space-sm) 0;
}

/* ══════════════════════════════════════════════════════════════
   SCROLLBAR
   ══════════════════════════════════════════════════════════════ */

::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: var(--surface-low); }
::-webkit-scrollbar-thumb {
    background: var(--surface-highest);
    border-radius: var(--radius-pill);
}
::-webkit-scrollbar-thumb:hover { background: var(--primary); }

/* ══════════════════════════════════════════════════════════════
   COVER PLACEHOLDER
   ══════════════════════════════════════════════════════════════ */

.cover-placeholder {
    width: 100%;
    aspect-ratio: 1/1;
    background-color: var(--surface-low);
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 2rem;
    color: var(--on-surface-muted);
}

/* ══════════════════════════════════════════════════════════════
   PLAYLIST ROWS — estado hover y selected
   ══════════════════════════════════════════════════════════════ */

.playlist-row td {
    transition: background-color var(--transition-fast);
}

.playlist-row:hover td {
    background-color: var(--surface-container);
    color: var(--on-surface);
}

.playlist-row.selected td {
    background-color: var(--surface-highest) !important;
    color: var(--on-surface) !important;
}

.playlist-row.selected td:first-child {
    border-left: 2px solid var(--primary);
}

/* ══════════════════════════════════════════════════════════════
   TRACK ROWS
   ══════════════════════════════════════════════════════════════ */

.track-row td {
    transition: background-color var(--transition-fast);
}

.track-row:hover td {
    background-color: var(--surface-container);
    color: var(--on-surface);
}

.track-row.selected td {
    background-color: var(--surface-highest) !important;
    color: var(--on-surface) !important;
}

.track-row.selected td:first-child {
    border-left: 2px solid var(--primary);
}

/* ══════════════════════════════════════════════════════════════
   AUDIO PLAYER
   ══════════════════════════════════════════════════════════════ */

audio {
    width: 100%;
    height: 36px;
    border-radius: var(--radius-pill);
    background-color: var(--surface-container);
    outline: none;
    filter: invert(0);
}

audio::-webkit-media-controls-panel {
    background-color: var(--surface-container);
}

/* ══════════════════════════════════════════════════════════════
   HTMX — indicador de carga
   ══════════════════════════════════════════════════════════════ */

.htmx-indicator {
    display: none;
}

.htmx-request .htmx-indicator {
    display: inline-block;
}

.htmx-request.htmx-indicator {
    display: inline-block;
}

.spinner {
    width: 16px;
    height: 16px;
    border: 2px solid var(--surface-highest);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
    display: inline-block;
    vertical-align: middle;
    margin-left: var(--space-xs);
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* ══════════════════════════════════════════════════════════════
   UTILIDADES
   ══════════════════════════════════════════════════════════════ */

.text-primary  { color: var(--primary); }
.text-muted    { color: var(--on-surface-muted); }
.text-variant  { color: var(--on-surface-variant); }
.text-display  { font-family: var(--font-display); }
.text-body     { font-family: var(--font-body); }
.mt-sm         { margin-top: var(--space-sm); }
.mt-md         { margin-top: var(--space-md); }
.mt-lg         { margin-top: var(--space-lg); }
.mb-sm         { margin-bottom: var(--space-sm); }
.mb-md         { margin-bottom: var(--space-md); }
.mb-lg         { margin-bottom: var(--space-lg); }
.w-full        { width: 100%; }
.flex          { display: flex; }
.flex-col      { flex-direction: column; }
.items-center  { align-items: center; }
.gap-sm        { gap: var(--space-sm); }
.gap-md        { gap: var(--space-md); }