:root {
    --bg-color: #0d1117;
    --surface: rgba(22, 27, 34, 0.6);
    --surface-hover: rgba(48, 54, 61, 0.8);
    --surface-border: rgba(255, 255, 255, 0.1);
    --primary: #5865F2;
    --primary-hover: #4752C4;
    --accent: #a78bfa;
    --text-primary: #ffffff;
    --text-secondary: #8b949e;
    --danger: #f85149;
    --success: #2ea043;
    --warning: #d29922;
    
    --sidebar-width: 260px;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: 'Inter', sans-serif;
    background: radial-gradient(circle at top left, #1a2035, var(--bg-color));
    color: var(--text-primary);
    min-height: 100vh;
    display: flex;
    overflow: hidden;
}

/* Scrollbar premium */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}
::-webkit-scrollbar-track {
    background: transparent;
}
::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.2);
    border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.3);
}

/* ===== LAYOUT: SIDEBAR ===== */
.sidebar {
    width: var(--sidebar-width);
    height: 100vh;
    background: var(--surface);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-right: 1px solid var(--surface-border);
    display: flex;
    flex-direction: column;
    padding: 24px 0;
    flex-shrink: 0;
    z-index: 10;
}

.sidebar-header {
    padding: 0 24px 32px 24px;
}

.logo {
    font-size: 20px;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 12px;
    background: linear-gradient(135deg, #a78bfa, #3b82f6);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.logo i {
    font-size: 24px;
}

.sidebar-nav {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 4px;
    padding: 0 12px;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    color: var(--text-secondary);
    text-decoration: none;
    border-radius: 12px;
    font-weight: 500;
    transition: all 0.2s ease;
    cursor: pointer;
}

.nav-item i {
    font-size: 18px;
    width: 24px;
    text-align: center;
}

.nav-item:hover {
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-primary);
}

.nav-item.active {
    background: rgba(88, 101, 242, 0.15);
    color: var(--primary);
}

.sidebar-footer {
    padding: 24px;
    border-top: 1px solid var(--surface-border);
}

.user-profile {
    display: flex;
    align-items: center;
    gap: 12px;
}

.user-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--primary), var(--accent));
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 14px;
}

.user-info {
    flex: 1;
    overflow: hidden;
}

.user-name {
    font-size: 14px;
    font-weight: 600;
    white-space: nowrap;
    text-overflow: ellipsis;
    overflow: hidden;
}

.user-role {
    font-size: 12px;
    color: var(--accent);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.logout-btn {
    background: none;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    font-size: 16px;
    transition: color 0.2s;
}

.logout-btn:hover {
    color: var(--danger);
}

/* ===== LAYOUT: MAIN CONTENT ===== */
.main-wrapper {
    flex: 1;
    height: 100vh;
    overflow-y: auto;
    position: relative;
}

/* Header superior dinâmico */
.topbar {
    height: 80px;
    padding: 0 40px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: sticky;
    top: 0;
    background: rgba(13, 17, 23, 0.8);
    backdrop-filter: blur(12px);
    z-index: 5;
    border-bottom: 1px solid var(--surface-border);
}

.page-title {
    font-size: 24px;
    font-weight: 600;
}

.topbar-actions {
    display: flex;
    gap: 16px;
}

.content-section {
    padding: 40px;
    display: none; /* Controlado via JS */
    animation: fadeIn 0.3s ease;
}

.content-section.active {
    display: block;
}

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

/* ===== COMPONENTES GERAIS ===== */
.btn {
    padding: 10px 20px;
    border-radius: 8px;
    font-weight: 600;
    font-size: 14px;
    cursor: pointer;
    transition: all 0.2s ease;
    border: none;
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.btn-primary {
    background: var(--primary);
    color: white;
}

.btn-primary:hover {
    background: var(--primary-hover);
    box-shadow: 0 4px 12px rgba(88, 101, 242, 0.3);
}

.btn-secondary {
    background: rgba(255, 255, 255, 0.1);
    color: white;
}

.btn-secondary:hover {
    background: rgba(255, 255, 255, 0.15);
}

.btn-danger {
    background: rgba(248, 81, 73, 0.1);
    color: var(--danger);
    border: 1px solid rgba(248, 81, 73, 0.2);
}

.btn-danger:hover {
    background: var(--danger);
    color: white;
}

.glass-card {
    background: var(--surface);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid var(--surface-border);
    border-radius: 16px;
    padding: 24px;
}

/* ===== DASHBOARD STATS ===== */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 24px;
    margin-bottom: 40px;
}

.stat-card {
    display: flex;
    align-items: center;
    gap: 20px;
}

.stat-icon {
    width: 56px;
    height: 56px;
    border-radius: 16px;
    background: rgba(88, 101, 242, 0.1);
    color: var(--primary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
}

.stat-info h3 {
    font-size: 32px;
    font-weight: 700;
    margin-bottom: 4px;
}

.stat-info p {
    color: var(--text-secondary);
    font-size: 14px;
    font-weight: 500;
}

/* ===== UPLOAD AREA ===== */
.upload-area {
    border: 2px dashed rgba(255, 255, 255, 0.2);
    border-radius: 24px;
    padding: 60px 24px;
    text-align: center;
    transition: all 0.3s ease;
    background: rgba(255, 255, 255, 0.02);
    cursor: pointer;
}

.upload-area:hover, .upload-area.dragover {
    border-color: var(--primary);
    background: rgba(88, 101, 242, 0.05);
}

.upload-icon {
    font-size: 64px;
    color: var(--primary);
    margin-bottom: 24px;
}

.upload-area h2 {
    font-size: 24px;
    margin-bottom: 8px;
}

.upload-area p {
    color: var(--text-secondary);
}

/* Progress Bar */
.progress-container {
    margin-top: 24px;
}
.progress-bar {
    height: 8px;
    background: rgba(255,255,255,0.1);
    border-radius: 4px;
    overflow: hidden;
    margin-top: 8px;
}
.progress-bar-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--primary), var(--accent));
    width: 0%;
    transition: width 0.3s ease;
}

/* ===== GALERIA DE VÍDEOS ===== */
.videos-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 24px;
}

.video-card {
    cursor: pointer;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.video-card:hover {
    transform: translateY(-4px);
    border-color: var(--primary);
    box-shadow: 0 12px 24px rgba(0,0,0,0.3);
}

.video-status {
    display: inline-block;
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
    margin-bottom: 12px;
}
.status-completed { background: rgba(46, 160, 67, 0.15); color: #4ade80; }
.status-pending { background: rgba(210, 153, 34, 0.15); color: #fbbf24; }
.status-error { background: rgba(248, 81, 73, 0.15); color: #f87171; }

.video-title {
    font-size: 16px;
    font-weight: 600;
    margin-bottom: 12px;
    word-break: break-all;
}

.video-meta {
    display: flex;
    justify-content: space-between;
    color: var(--text-secondary);
    font-size: 13px;
}

/* ===== CLIPS E GANCHOS ===== */
.clips-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 24px;
    margin-top: 24px;
}

.clip-card {
    display: flex;
    flex-direction: column;
}

.clip-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
}

.viral-badge {
    background: linear-gradient(45deg, #ff416c, #ff4b2b);
    color: white;
    padding: 4px 10px;
    border-radius: 8px;
    font-size: 12px;
    font-weight: 700;
}

.clip-text {
    font-size: 15px;
    line-height: 1.5;
    margin-bottom: 16px;
    font-style: italic;
    color: #e2e8f0;
}

.clip-headline {
    background: rgba(167, 139, 250, 0.1);
    padding: 12px;
    border-radius: 8px;
    border-left: 3px solid var(--accent);
    margin-bottom: 16px;
    font-size: 14px;
    font-weight: 500;
}

.clip-actions {
    display: flex;
    gap: 12px;
    margin-top: auto;
    flex-wrap: wrap;
}

.clip-actions .btn {
    flex: 1;
    justify-content: center;
}

/* ===== MODALS ===== */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.8);
    backdrop-filter: blur(5px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
}

.modal-overlay.active {
    opacity: 1;
    visibility: visible;
}

.modal {
    background: var(--bg-color);
    border: 1px solid var(--surface-border);
    border-radius: 20px;
    width: 90%;
    max-width: 500px;
    transform: translateY(20px) scale(0.95);
    transition: all 0.3s ease;
    overflow: hidden;
}

.modal-overlay.active .modal {
    transform: translateY(0) scale(1);
}

.modal-header {
    padding: 20px 24px;
    border-bottom: 1px solid var(--surface-border);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-body {
    padding: 24px;
}

.modal-body video {
    width: 100%;
    border-radius: 12px;
    max-height: 60vh;
}

/* ===== REEL PREVIEW 9:16 ===== */
.reel-modal {
    max-width: 420px;
}
.reel-frame-wrap {
    display: flex;
    justify-content: center;
    padding: 20px;
}
.reel-frame {
    width: 100%;
    max-width: 320px;
    aspect-ratio: 9 / 16;
    background: #000;
    border-radius: 24px;
    border: 8px solid #1a1a1a;
    box-shadow: 0 0 0 2px #2a2a2a, 0 20px 60px rgba(0,0,0,0.5);
    overflow: hidden;
    position: relative;
}
.reel-frame video {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 16px;
    max-height: none;
}

/* ===== FUNNEL ===== */
.funnel-step {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 16px;
    background: rgba(255,255,255,0.04);
    border-radius: 10px;
    border-left: 4px solid var(--primary);
    font-weight: 500;
}
.funnel-step .funnel-label {
    color: var(--text-secondary);
    font-size: 13px;
}
.funnel-step .funnel-value {
    font-size: 18px;
    font-weight: 700;
    color: white;
}
.funnel-step.step-videos    { border-color: #5865F2; }
.funnel-step.step-hooks     { border-color: #f87171; }
.funnel-step.step-clips     { border-color: #fbbf24; }
.funnel-step.step-scheduled { border-color: #a78bfa; }
.funnel-step.step-published { border-color: #4ade80; }

/* ===== TOP CLIPS ===== */
.top-clip-row {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
    background: rgba(255,255,255,0.03);
    border-radius: 10px;
}
.top-clip-rank {
    font-size: 18px;
    font-weight: 700;
    color: var(--accent);
    min-width: 28px;
    text-align: center;
}
.top-clip-info {
    flex: 1;
    overflow: hidden;
}
.top-clip-text {
    font-size: 13px;
    color: white;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.top-clip-stats {
    font-size: 11px;
    color: var(--text-secondary);
}

/* ===== ETA TEXT ===== */
.eta-text {
    font-size: 12px;
    color: var(--text-secondary);
    margin-top: 6px;
    font-style: italic;
}

/* ===== PLATAFORMAS NO AGENDAMENTO ===== */
.platform-grid {
    display: flex;
    flex-direction: column;
    gap: 10px;
}
.platform-option {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 14px;
    background: rgba(255,255,255,0.04);
    border: 1px solid rgba(255,255,255,0.08);
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.2s;
}
.platform-option.active {
    border-color: var(--primary);
    background: rgba(88, 101, 242, 0.08);
}
.platform-option.disabled {
    opacity: 0.5;
    cursor: not-allowed;
}
.platform-option input[type="checkbox"] {
    accent-color: var(--primary);
}
.platform-option i {
    font-size: 22px;
    width: 24px;
    text-align: center;
}
.platform-option span:nth-of-type(1) {
    flex: 1;
    font-weight: 500;
}
.platform-status {
    font-size: 11px;
    padding: 3px 8px;
    border-radius: 6px;
    text-transform: uppercase;
    font-weight: 600;
}
.status-active { background: rgba(46, 160, 67, 0.15); color: #4ade80; }
.status-soon { background: rgba(210, 153, 34, 0.15); color: #fbbf24; }

/* ===== CARDS DE PLATAFORMA ===== */
.platforms-cards-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
    gap: 20px;
}
.platform-card {
    background: var(--surface);
    backdrop-filter: blur(20px);
    border: 1px solid var(--surface-border);
    border-radius: 16px;
    padding: 24px;
    display: flex;
    flex-direction: column;
    gap: 14px;
    transition: transform 0.2s, border-color 0.2s;
}
.platform-card-active {
    border-color: rgba(46, 160, 67, 0.3);
}
.platform-card-active:hover {
    transform: translateY(-2px);
    border-color: rgba(46, 160, 67, 0.5);
}
.platform-card-soon {
    opacity: 0.7;
}
.platform-card-soon:hover { opacity: 0.95; }

.platform-card-header {
    display: flex;
    align-items: center;
    gap: 14px;
}
.platform-icon {
    width: 52px;
    height: 52px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    color: white;
    flex-shrink: 0;
}
.platform-card-header h3 {
    margin: 0 0 4px;
    font-size: 17px;
}
.platform-badge {
    display: inline-block;
    font-size: 11px;
    font-weight: 600;
    padding: 3px 8px;
    border-radius: 6px;
    text-transform: uppercase;
}
.badge-ready { background: rgba(46, 160, 67, 0.15); color: #4ade80; }
.badge-soon { background: rgba(210, 153, 34, 0.15); color: #fbbf24; }

.platform-desc {
    color: var(--text-secondary);
    font-size: 13px;
    line-height: 1.5;
    margin: 0;
}
.platform-features {
    list-style: none;
    padding: 0;
    margin: 0;
    display: flex;
    flex-direction: column;
    gap: 6px;
}
.platform-features li {
    font-size: 13px;
    color: var(--text-secondary);
}

/* ===== TOGGLE POOL GLOBAL ===== */
.toggle-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 0;
    border-bottom: 1px solid rgba(255,255,255,0.06);
}
.toggle-row:last-child { border-bottom: none; }
.toggle-label { color: white; font-weight: 500; }
.toggle-desc { color: var(--text-secondary); font-size: 13px; margin-top: 4px; }
.switch {
    position: relative;
    width: 50px; height: 26px;
    background: rgba(255,255,255,0.1);
    border-radius: 13px;
    cursor: pointer;
    transition: background 0.2s;
    flex-shrink: 0;
}
.switch.on { background: var(--primary); }
.switch::after {
    content: '';
    position: absolute;
    top: 3px; left: 3px;
    width: 20px; height: 20px;
    background: white;
    border-radius: 50%;
    transition: transform 0.2s;
}
.switch.on::after { transform: translateX(24px); }

/* ===== FILTROS DA BIBLIOTECA ===== */
.library-filters {
    display: flex;
    gap: 12px;
    margin-bottom: 20px;
    flex-wrap: wrap;
}
.library-filters input,
.library-filters select {
    background: rgba(0,0,0,0.3);
    border: 1px solid rgba(255,255,255,0.1);
    border-radius: 10px;
    padding: 10px 14px;
    color: white;
    font-family: inherit;
    font-size: 14px;
}
.library-filters input { flex: 1; min-width: 240px; }
.library-filters select { min-width: 180px; }
.library-filters input:focus,
.library-filters select:focus {
    outline: none;
    border-color: var(--primary);
}

/* ===== BEST TIME CARD ===== */
.best-time-card { display: flex; flex-direction: column; }
.best-time-source {
    font-size: 12px;
    color: var(--text-secondary);
    margin-bottom: 12px;
    font-style: italic;
}
.best-time-windows {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 12px;
}
.best-time-window {
    padding: 16px;
    background: rgba(167,139,250,0.08);
    border-left: 3px solid var(--accent);
    border-radius: 10px;
}
.best-time-window-rank {
    font-size: 11px;
    color: var(--accent);
    text-transform: uppercase;
    font-weight: 600;
    margin-bottom: 6px;
}
.best-time-window-when {
    font-size: 18px;
    font-weight: 700;
    color: white;
    margin-bottom: 4px;
}
.best-time-window-meta {
    font-size: 12px;
    color: var(--text-secondary);
}

/* ===== REFINE MODAL ===== */
.refine-suggestions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    margin-top: 12px;
}
.suggest-chip {
    background: rgba(167,139,250,0.1);
    border: 1px solid rgba(167,139,250,0.3);
    color: var(--accent);
    padding: 6px 12px;
    border-radius: 16px;
    font-size: 12px;
    cursor: pointer;
    transition: all 0.2s;
}
.suggest-chip:hover {
    background: rgba(167,139,250,0.2);
}

/* Responsivo: 2-col grids viram 1-col em telas pequenas */
@media (max-width: 900px) {
    #dashboard-grid-1, #dashboard-grid-2 {
        grid-template-columns: 1fr !important;
    }
}

/* Toast Notificações */
.toast-container {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.toast {
    background: var(--surface);
    backdrop-filter: blur(10px);
    border-left: 4px solid var(--primary);
    padding: 16px 24px;
    border-radius: 8px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.5);
    animation: slideInRight 0.3s ease forwards;
}

.toast.error { border-color: var(--danger); }
.toast.success { border-color: var(--success); }

@keyframes slideInRight {
    from { transform: translateX(100%); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}

/* Formulários */
.form-group {
    margin-bottom: 16px;
}
.form-group label {
    display: block;
    margin-bottom: 8px;
    color: var(--text-secondary);
    font-size: 14px;
}
.form-group input, .form-group select {
    width: 100%;
    background: rgba(0,0,0,0.3);
    border: 1px solid var(--surface-border);
    border-radius: 8px;
    padding: 12px;
    color: white;
    font-family: inherit;
}
.form-group input:focus {
    outline: none;
    border-color: var(--primary);
}
