/* ==========================================
   Club de Audio Historias - Dark Theme
   ========================================== */

/* ---------- CSS Variables ---------- */
:root {
    --bg-primary: #0f0f0f;
    --bg-secondary: #1a1a2e;
    --bg-card: #16213e;
    --bg-elevated: #1e2a4a;
    --bg-input: #1a1a2e;

    --text-primary: #e8e8e8;
    --text-secondary: #8892b0;
    --text-muted: #5a6380;

    --accent: #e94560;
    --accent-hover: #ff6b81;
    --accent-muted: rgba(233, 69, 96, 0.15);
    --accent-gradient: linear-gradient(135deg, #e94560, #c23152);

    --success: #2ed573;
    --warning: #ffa502;
    --error: #ff4757;

    --border: #2a2a4a;
    --border-light: #1e2a4a;

    --radius: 14px;
    --radius-sm: 8px;
    --radius-lg: 20px;
    --radius-full: 50%;

    --shadow-sm: 0 2px 8px rgba(0,0,0,0.3);
    --shadow-md: 0 4px 20px rgba(0,0,0,0.4);
    --shadow-lg: 0 8px 40px rgba(0,0,0,0.5);

    --navbar-height: 65px;
    --mini-player-height: 64px;

    --safe-bottom: env(safe-area-inset-bottom, 0px);
}

/* ---------- Reset ---------- */
*, *::before, *::after {
    margin: 0; padding: 0; box-sizing: border-box;
}

html {
    font-size: 16px;
    -webkit-tap-highlight-color: transparent;
    -webkit-text-size-adjust: 100%;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.5;
    overflow-x: hidden;
    min-height: 100vh;
    min-height: 100dvh;
}

a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-hover); }

img { max-width: 100%; display: block; }

button {
    font-family: inherit;
    font-size: inherit;
    cursor: pointer;
    border: none;
    background: none;
    color: inherit;
}

input, textarea, select {
    font-family: inherit;
    font-size: 1rem;
    background: var(--bg-input);
    color: var(--text-primary);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 12px 16px;
    width: 100%;
    outline: none;
    transition: border-color 0.2s;
}

input:focus, textarea:focus, select:focus {
    border-color: var(--accent);
}

/* ---------- Splash Screen ---------- */
.splash {
    position: fixed; inset: 0;
    background: var(--bg-primary);
    display: flex; align-items: center; justify-content: center;
    z-index: 9999;
    transition: opacity 0.4s;
}
.splash.fade-out { opacity: 0; pointer-events: none; }
.splash-content { text-align: center; }
.splash-logo { font-size: 4rem; margin-bottom: 16px; }
.splash-content h1 { font-size: 1.4rem; color: var(--text-primary); margin-bottom: 24px; }
.splash-loader {
    width: 40px; height: 40px; margin: 0 auto;
    border: 3px solid var(--border);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- App Layout ---------- */
#app {
    min-height: 100vh;
    min-height: 100dvh;
}

.page {
    padding: 20px 16px;
    padding-bottom: calc(var(--navbar-height) + var(--safe-bottom) + 20px);
    max-width: 600px;
    margin: 0 auto;
    animation: fadeIn 0.25s ease;
}

.page.with-player {
    padding-bottom: calc(var(--navbar-height) + var(--mini-player-height) + var(--safe-bottom) + 20px);
}

@keyframes fadeIn { from { opacity: 0; transform: translateY(8px); } }

/* ---------- Typography ---------- */
.page-title {
    font-size: 1.6rem;
    font-weight: 700;
    margin-bottom: 20px;
}

.section-title {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--text-secondary);
    margin: 24px 0 12px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    font-size: 0.8rem;
}

/* ---------- Buttons ---------- */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 8px;
    padding: 12px 24px;
    border-radius: var(--radius-sm);
    font-weight: 600;
    font-size: 0.95rem;
    transition: all 0.2s;
    white-space: nowrap;
}

.btn-primary {
    background: var(--accent-gradient);
    color: #fff;
}
.btn-primary:hover { transform: translateY(-1px); box-shadow: var(--shadow-md); }
.btn-primary:active { transform: translateY(0); }

.btn-secondary {
    background: var(--bg-elevated);
    color: var(--text-primary);
    border: 1px solid var(--border);
}

.btn-outline {
    background: transparent;
    color: var(--accent);
    border: 1px solid var(--accent);
}

.btn-full { width: 100%; }

.btn-icon {
    width: 44px; height: 44px;
    border-radius: var(--radius-full);
    padding: 0;
    display: flex; align-items: center; justify-content: center;
}

.btn:disabled {
    opacity: 0.5; cursor: not-allowed; transform: none !important;
}

/* ---------- Cards ---------- */
.card {
    background: var(--bg-card);
    border-radius: var(--radius);
    overflow: hidden;
    transition: transform 0.2s;
}
.card:active { transform: scale(0.98); }

/* ---------- Episode Card ---------- */
.episode-card {
    display: flex;
    gap: 12px;
    padding: 12px;
    cursor: pointer;
    border-bottom: 1px solid var(--border-light);
}

.episode-card-cover {
    width: 72px; height: 72px;
    border-radius: var(--radius-sm);
    background: var(--bg-elevated);
    flex-shrink: 0;
    object-fit: cover;
}

.episode-card-info {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.episode-card-title {
    font-weight: 600;
    font-size: 0.95rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.episode-card-meta {
    display: flex; gap: 8px; align-items: center;
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-top: 4px;
}

.episode-card-progress {
    height: 3px;
    background: var(--border);
    border-radius: 2px;
    margin-top: 8px;
    overflow: hidden;
}

.episode-card-progress-fill {
    height: 100%;
    background: var(--accent);
    border-radius: 2px;
    transition: width 0.3s;
}

/* ---------- Badge ---------- */
.badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}
.badge-free { background: var(--success); color: #000; }
.badge-premium { background: var(--accent-muted); color: var(--accent); }
.badge-category { background: var(--bg-elevated); color: var(--text-secondary); }

/* ---------- Form ---------- */
.form-group {
    margin-bottom: 16px;
}

.form-label {
    display: block;
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--text-secondary);
    margin-bottom: 6px;
}

.form-error {
    color: var(--error);
    font-size: 0.8rem;
    margin-top: 4px;
}

.form-link {
    font-size: 0.9rem;
    text-align: center;
    margin-top: 16px;
}

.form-divider {
    text-align: center;
    color: var(--text-muted);
    margin: 20px 0;
    position: relative;
}
.form-divider::before,
.form-divider::after {
    content: '';
    position: absolute;
    top: 50%;
    width: 40%;
    height: 1px;
    background: var(--border);
}
.form-divider::before { left: 0; }
.form-divider::after { right: 0; }

/* ---------- Auth Pages ---------- */
.auth-page {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    min-height: 100dvh;
    padding: 40px 20px;
}

.auth-logo {
    font-size: 3rem;
    margin-bottom: 8px;
}

.auth-title {
    font-size: 1.4rem;
    font-weight: 700;
    margin-bottom: 4px;
}

.auth-subtitle {
    color: var(--text-secondary);
    font-size: 0.9rem;
    margin-bottom: 32px;
}

.auth-form {
    width: 100%;
    max-width: 380px;
}

/* ---------- Tabs ---------- */
.tabs {
    display: flex;
    gap: 4px;
    background: var(--bg-secondary);
    border-radius: var(--radius-sm);
    padding: 4px;
    margin-bottom: 16px;
}

.tab {
    flex: 1;
    padding: 10px;
    text-align: center;
    font-size: 0.85rem;
    font-weight: 500;
    border-radius: 6px;
    color: var(--text-muted);
    transition: all 0.2s;
}

.tab.active {
    background: var(--bg-elevated);
    color: var(--text-primary);
}

/* ---------- Empty State ---------- */
.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: var(--text-muted);
}
.empty-state-icon { font-size: 3rem; margin-bottom: 12px; }
.empty-state-text { font-size: 1rem; }

/* ---------- Category Chips ---------- */
.category-chips {
    display: flex;
    gap: 8px;
    overflow-x: auto;
    padding-bottom: 8px;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
}
.category-chips::-webkit-scrollbar { display: none; }

.category-chip {
    padding: 8px 16px;
    background: var(--bg-card);
    border-radius: 20px;
    font-size: 0.85rem;
    white-space: nowrap;
    color: var(--text-secondary);
    border: 1px solid var(--border);
    transition: all 0.2s;
    cursor: pointer;
}
.category-chip.active {
    background: var(--accent-muted);
    color: var(--accent);
    border-color: var(--accent);
}

/* ---------- Navbar ---------- */
.navbar {
    position: fixed;
    bottom: 0; left: 0; right: 0;
    height: var(--navbar-height);
    padding-bottom: var(--safe-bottom);
    background: var(--bg-secondary);
    border-top: 1px solid var(--border);
    display: flex;
    justify-content: space-around;
    align-items: center;
    z-index: 100;
}

.nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    padding: 8px 16px;
    color: var(--text-muted);
    font-size: 0.7rem;
    font-weight: 500;
    transition: color 0.2s;
    cursor: pointer;
}
.nav-item.active { color: var(--accent); }
.nav-icon { font-size: 1.3rem; }

/* ---------- Toast ---------- */
.toast-container {
    position: fixed;
    top: 20px;
    left: 50%; transform: translateX(-50%);
    z-index: 10000;
    display: flex;
    flex-direction: column;
    gap: 8px;
    width: 90%; max-width: 400px;
}

.toast {
    padding: 14px 18px;
    border-radius: var(--radius-sm);
    font-size: 0.9rem;
    font-weight: 500;
    animation: toastIn 0.3s ease;
    display: flex; align-items: center; gap: 10px;
}
.toast.fade-out { animation: toastOut 0.3s ease forwards; }
.toast-success { background: #1a3a2a; color: var(--success); border: 1px solid #2a4a3a; }
.toast-error   { background: #3a1a1a; color: var(--error); border: 1px solid #4a2a2a; }
.toast-info    { background: #1a2a3a; color: #60a5fa; border: 1px solid #2a3a4a; }

@keyframes toastIn { from { opacity: 0; transform: translateY(-20px); } }
@keyframes toastOut { to { opacity: 0; transform: translateY(-20px); } }

/* ---------- Loading Skeleton ---------- */
.skeleton {
    background: linear-gradient(90deg, var(--bg-card) 25%, var(--bg-elevated) 50%, var(--bg-card) 75%);
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite;
    border-radius: var(--radius-sm);
}
@keyframes shimmer { 0% { background-position: 200% 0; } 100% { background-position: -200% 0; } }

/* ---------- Subscribe CTA ---------- */
.subscribe-cta {
    background: var(--accent-gradient);
    border-radius: var(--radius);
    padding: 24px;
    text-align: center;
    margin: 20px 0;
}
.subscribe-cta h3 { font-size: 1.2rem; margin-bottom: 8px; }
.subscribe-cta p { font-size: 0.9rem; opacity: 0.9; margin-bottom: 16px; }

/* ---------- Profile ---------- */
.profile-header {
    display: flex;
    align-items: center;
    gap: 16px;
    margin-bottom: 24px;
}

.profile-avatar {
    width: 64px; height: 64px;
    border-radius: var(--radius-full);
    background: var(--accent-gradient);
    display: flex; align-items: center; justify-content: center;
    font-size: 1.5rem; font-weight: 700;
    color: #fff;
    flex-shrink: 0;
}

.profile-info h2 { font-size: 1.2rem; }
.profile-info p { color: var(--text-secondary); font-size: 0.85rem; }

.profile-stats {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
    margin-bottom: 24px;
}

.stat-card {
    background: var(--bg-card);
    border-radius: var(--radius-sm);
    padding: 16px;
    text-align: center;
}
.stat-value { font-size: 1.4rem; font-weight: 700; color: var(--accent); }
.stat-label { font-size: 0.75rem; color: var(--text-muted); margin-top: 4px; }

/* ---------- Subscription Status ---------- */
.sub-status {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 16px;
    border-radius: var(--radius-sm);
    font-size: 0.9rem;
    font-weight: 500;
}
.sub-active { background: #1a3a2a; color: var(--success); }
.sub-inactive { background: #3a2a1a; color: var(--warning); }
.sub-dot {
    width: 8px; height: 8px;
    border-radius: 50%;
    background: currentColor;
}

/* ---------- Admin ---------- */
.admin-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
    margin-bottom: 24px;
}

.admin-stat {
    background: var(--bg-card);
    border-radius: var(--radius);
    padding: 20px;
}
.admin-stat-value { font-size: 1.8rem; font-weight: 700; }
.admin-stat-label { font-size: 0.8rem; color: var(--text-muted); margin-top: 4px; }

.admin-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.85rem;
}
.admin-table th {
    text-align: left;
    padding: 10px 12px;
    color: var(--text-muted);
    font-weight: 500;
    border-bottom: 1px solid var(--border);
}
.admin-table td {
    padding: 12px;
    border-bottom: 1px solid var(--border-light);
}
.admin-table tr:hover td { background: var(--bg-secondary); }

.admin-actions { display: flex; gap: 8px; }

/* ---------- Upload ---------- */
.upload-area {
    border: 2px dashed var(--border);
    border-radius: var(--radius);
    padding: 40px 20px;
    text-align: center;
    cursor: pointer;
    transition: all 0.2s;
}
.upload-area:hover { border-color: var(--accent); background: var(--accent-muted); }
.upload-area.dragging { border-color: var(--accent); background: var(--accent-muted); }
.upload-icon { font-size: 2.5rem; margin-bottom: 12px; }
.upload-text { color: var(--text-secondary); font-size: 0.9rem; }
.upload-hint { color: var(--text-muted); font-size: 0.8rem; margin-top: 4px; }

.upload-progress {
    margin-top: 16px;
}
.upload-progress-bar {
    height: 6px;
    background: var(--border);
    border-radius: 3px;
    overflow: hidden;
}
.upload-progress-fill {
    height: 100%;
    background: var(--accent-gradient);
    border-radius: 3px;
    transition: width 0.3s;
}
.upload-progress-text {
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-top: 4px;
    text-align: center;
}

/* ---------- Episode Detail ---------- */
.episode-hero {
    text-align: center;
    margin-bottom: 24px;
}

.episode-cover-large {
    width: 200px; height: 200px;
    border-radius: var(--radius);
    margin: 0 auto 16px;
    object-fit: cover;
    box-shadow: var(--shadow-lg);
    background: var(--bg-card);
}

.episode-title-large {
    font-size: 1.3rem;
    font-weight: 700;
    margin-bottom: 4px;
}

.episode-meta-large {
    color: var(--text-muted);
    font-size: 0.85rem;
    display: flex;
    justify-content: center;
    gap: 12px;
}

.episode-description {
    color: var(--text-secondary);
    font-size: 0.9rem;
    line-height: 1.6;
    margin: 16px 0;
}

.episode-actions {
    display: flex;
    gap: 12px;
    justify-content: center;
    margin-top: 20px;
}

/* ---------- Scrollbar ---------- */
::-webkit-scrollbar { width: 4px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }

/* ---------- Hidden utility ---------- */
.hidden { display: none !important; }

/* ---------- Subscribe page ---------- */
.subscribe-features {
    text-align: left;
    margin: 20px 0;
}
.subscribe-feature {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 0;
    font-size: 0.95rem;
}
.subscribe-feature-icon {
    width: 36px; height: 36px;
    border-radius: var(--radius-full);
    background: var(--accent-muted);
    display: flex; align-items: center; justify-content: center;
    font-size: 1.1rem;
    flex-shrink: 0;
}
