/* ========== RESET ========== */
* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }
:root {
    --bg: #0a0a14;
    --surface: #14141f;
    --surface-2: #1c1c2b;
    --border: rgba(255,255,255,0.08);
    --text: #e8e8f0;
    --text-dim: #8a8a9a;
    --primary: #7c5cff;
    --primary-2: #5c3dff;
    --accent: #22c55e;
    --danger: #ef4444;
    --radius: 14px;
    --radius-sm: 10px;
}
html, body {
    height: 100%;
    background: var(--bg);
    color: var(--text);
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
    font-size: 15px;
    line-height: 1.5;
    overflow-x: hidden;
}

/* ========== DESKTOP LAYOUT ========== */
body {
    display: grid;
    grid-template-columns: 260px 1fr;
    min-height: 100vh;
}

/* -------- Sidebar -------- */
.sidebar {
    background: linear-gradient(180deg, #10101c, #0a0a14);
    border-right: 1px solid var(--border);
    padding: 24px 16px;
    display: flex;
    flex-direction: column;
    position: sticky;
    top: 0;
    height: 100vh;
}
.logo {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 1.2rem;
    font-weight: 800;
    padding: 8px 12px 28px;
    letter-spacing: -0.5px;
}
.logo-icon {
    width: 34px; height: 34px;
    background: linear-gradient(135deg, var(--primary), var(--primary-2));
    border-radius: 10px;
    display: grid; place-items: center;
    font-size: 1.2rem;
    box-shadow: 0 4px 20px rgba(124,92,255,0.4);
}
.nav { display: flex; flex-direction: column; gap: 4px; }
.nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 11px 14px;
    border-radius: var(--radius-sm);
    color: var(--text-dim);
    text-decoration: none;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.15s;
}
.nav-item:hover { background: var(--surface); color: var(--text); }
.nav-item.active {
    background: linear-gradient(135deg, rgba(124,92,255,0.18), rgba(92,61,255,0.12));
    color: var(--text);
    box-shadow: inset 0 0 0 1px rgba(124,92,255,0.3);
}
.nav-icon { font-size: 1.1rem; }
.sidebar-footer { margin-top: auto; padding-top: 20px; }
.user-badge {
    display: flex; align-items: center; gap: 10px;
    padding: 10px;
    border-radius: var(--radius-sm);
    background: var(--surface);
}
.avatar {
    width: 36px; height: 36px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--primary), var(--primary-2));
    display: grid; place-items: center;
    font-weight: 800;
    flex-shrink: 0;
}
.avatar.small { width: 32px; height: 32px; font-size: 0.85rem; }
.user-name { font-weight: 600; font-size: 0.9rem; }
.user-plan { font-size: 0.75rem; color: var(--text-dim); }

/* -------- Main -------- */
.main {
    padding: 40px 48px;
    max-width: 900px;
    width: 100%;
    margin: 0 auto;
}
.app-header { display: none; }

.view { display: none; animation: fadeIn 0.25s ease; }
.view.active { display: block; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

.page-header { margin-bottom: 28px; }
.page-header h1 {
    font-size: 2rem;
    font-weight: 800;
    letter-spacing: -0.8px;
    background: linear-gradient(135deg, #fff, #b8b8d0);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}
.page-header p { color: var(--text-dim); margin-top: 4px; }

/* -------- Card -------- */
.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 24px;
    margin-bottom: 20px;
}

/* -------- Form -------- */
.field { margin-bottom: 18px; }
.field label {
    display: block;
    font-weight: 600;
    font-size: 0.85rem;
    margin-bottom: 8px;
    color: var(--text);
}
.hint { font-weight: 400; color: var(--text-dim); font-size: 0.78rem; }
input[type="text"], input[type="number"], textarea, select {
    width: 100%;
    padding: 13px 15px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    background: var(--surface-2);
    color: var(--text);
    font-size: 1rem;
    font-family: inherit;
    transition: all 0.15s;
    resize: vertical;
}
select { cursor: pointer; }
input:focus, textarea:focus, select:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(124,92,255,0.18);
}
input::placeholder, textarea::placeholder { color: #55556a; }

/* -------- Chips -------- */
.chips {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 10px;
}
.chip {
    padding: 6px 12px;
    border-radius: 100px;
    border: 1px solid var(--border);
    background: var(--surface-2);
    color: var(--text-dim);
    font-size: 0.78rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.15s;
    font-family: inherit;
}
.chip:hover {
    border-color: var(--primary);
    color: var(--text);
    background: rgba(124,92,255,0.12);
}

/* -------- Buttons -------- */
.btn-primary {
    position: relative;
    width: 100%;
    padding: 15px;
    border: none;
    border-radius: var(--radius-sm);
    background: linear-gradient(135deg, var(--primary), var(--primary-2));
    color: #fff;
    font-size: 1rem;
    font-weight: 700;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    transition: transform 0.1s, box-shadow 0.2s;
    box-shadow: 0 8px 24px rgba(124,92,255,0.3);
}
.btn-primary:hover:not(:disabled) { transform: translateY(-1px); box-shadow: 0 12px 28px rgba(124,92,255,0.4); }
.btn-primary:active:not(:disabled) { transform: translateY(0); }
.btn-primary:disabled { opacity: 0.6; cursor: not-allowed; }
.btn-secondary {
    display: inline-block;
    padding: 12px 22px;
    background: var(--accent);
    color: #fff;
    text-decoration: none;
    border-radius: var(--radius-sm);
    font-weight: 700;
    font-size: 0.92rem;
    text-align: center;
    transition: opacity 0.15s;
}
.btn-secondary:hover { opacity: 0.88; }
.btn-icon {
    width: 38px; height: 38px;
    display: grid; place-items: center;
    border-radius: 50%;
    background: var(--surface-2);
    color: var(--text);
    text-decoration: none;
    font-size: 1rem;
    flex-shrink: 0;
    border: none;
    cursor: pointer;
    transition: background 0.15s;
}
.btn-icon:hover { background: rgba(124,92,255,0.2); }

/* -------- Spinner -------- */
.spinner {
    width: 18px; height: 18px;
    border: 2px solid rgba(255,255,255,0.3);
    border-top-color: #fff;
    border-radius: 50%;
    animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.hidden { display: none !important; }

/* -------- Status -------- */
.status {
    padding: 14px 18px;
    border-radius: var(--radius-sm);
    background: var(--surface);
    border: 1px solid var(--border);
    margin-bottom: 20px;
    font-size: 0.92rem;
}

/* -------- Player -------- */
.player { text-align: center; }
.player-header {
    display: flex; align-items: center; gap: 14px;
    margin-bottom: 18px;
    text-align: left;
}
.disc {
    width: 52px; height: 52px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--primary), var(--primary-2));
    display: grid; place-items: center;
    font-size: 1.3rem;
    flex-shrink: 0;
    box-shadow: 0 4px 20px rgba(124,92,255,0.4);
}
.disc.small { width: 42px; height: 42px; font-size: 1rem; }
.track-title { font-weight: 700; }
.track-sub { font-size: 0.82rem; color: var(--text-dim); }
.player audio { width: 100%; margin-bottom: 16px; border-radius: var(--radius-sm); }

/* -------- Biblioteca -------- */
.library-list { display: flex; flex-direction: column; gap: 12px; }
.library-item { display: flex; align-items: center; gap: 14px; padding: 14px 18px; margin: 0; }
.library-info { flex: 1; min-width: 0; }
.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: var(--text-dim);
}
.empty-icon { font-size: 3rem; margin-bottom: 12px; opacity: 0.4; }

/* -------- Ajustes -------- */
.setting-row {
    display: flex; justify-content: space-between; align-items: center;
    padding: 14px 0;
    border-bottom: 1px solid var(--border);
}
.setting-row:last-child { border-bottom: none; }
.badge-ok, .badge-err, .badge-neutral {
    padding: 4px 12px;
    border-radius: 100px;
    font-size: 0.8rem;
    font-weight: 600;
}
.badge-ok { background: rgba(34,197,94,0.15); color: var(--accent); }
.badge-err { background: rgba(239,68,68,0.15); color: var(--danger); }
.badge-neutral { background: var(--surface-2); color: var(--text-dim); }

/* -------- Bottom nav (escondido no desktop) -------- */
.bottom-nav { display: none; }

/* ========== MOBILE (estrutura de app) ========== */
@media (max-width: 768px) {
    body {
        display: block;
        padding-bottom: calc(72px + env(safe-area-inset-bottom));
    }
    .sidebar { display: none; }
    .main {
        padding: 0 16px 24px;
        padding-top: env(safe-area-inset-top);
        max-width: 100%;
    }
    .app-header {
        display: flex;
        justify-content: space-between;
        align-items: center;
        padding: 14px 4px;
        position: sticky;
        top: 0;
        background: rgba(10,10,20,0.85);
        backdrop-filter: blur(16px);
        -webkit-backdrop-filter: blur(16px);
        z-index: 50;
        margin: 0 -16px 8px;
        padding-left: 20px;
        padding-right: 20px;
        border-bottom: 1px solid var(--border);
    }
    .app-title {
        font-weight: 800;
        font-size: 1.15rem;
        letter-spacing: -0.4px;
    }
    .page-header { margin-bottom: 20px; }
    .page-header h1 { font-size: 1.6rem; }
    .page-header p { font-size: 0.88rem; }
    .card { padding: 18px; border-radius: 16px; }
    input[type="text"], input[type="number"], textarea, select {
        font-size: 16px;
        padding: 14px 16px;
    }
    .btn-primary { padding: 16px; font-size: 1.02rem; border-radius: 12px; }
    .btn-secondary { width: 100%; padding: 14px; }
    .player audio { width: 100%; }
    .bottom-nav {
        display: flex;
        position: fixed;
        bottom: 0; left: 0; right: 0;
        background: rgba(16,16,28,0.92);
        backdrop-filter: blur(20px);
        -webkit-backdrop-filter: blur(20px);
        border-top: 1px solid var(--border);
        padding: 8px 8px calc(8px + env(safe-area-inset-bottom));
        z-index: 100;
        justify-content: space-around;
    }
    .bottom-item {
        flex: 1;
        display: flex;
        flex-direction: column;
        align-items: center;
        gap: 3px;
        padding: 8px 4px;
        color: var(--text-dim);
        text-decoration: none;
        font-size: 0.7rem;
        font-weight: 600;
        cursor: pointer;
        border-radius: 10px;
        transition: color 0.15s;
    }
    .bottom-icon {
        font-size: 1.35rem;
        transition: transform 0.15s;
    }
    .bottom-item.active { color: var(--primary); }
    .bottom-item.active .bottom-icon { transform: scale(1.12); }
    .library-item { padding: 12px 14px; }
}

/* ========== TABLET ========== */
@media (max-width: 1024px) and (min-width: 769px) {
    body { grid-template-columns: 220px 1fr; }
    .sidebar { padding: 20px 12px; }
    .main { padding: 32px 28px; }
    .page-header h1 { font-size: 1.7rem; }
}

/* ========== SCROLLBAR (desktop) ========== */
@media (min-width: 769px) {
    ::-webkit-scrollbar { width: 10px; }
    ::-webkit-scrollbar-track { background: var(--bg); }
    ::-webkit-scrollbar-thumb { background: var(--surface-2); border-radius: 5px; }
    ::-webkit-scrollbar-thumb:hover { background: #2a2a3d; }
}