/* ==========================================================================
   PALETAS DE CORES & TEMAS (ALTO CONTRASTE)
   ========================================================================== */

/* 1. TEMA PADRÃO: CLEAN LIGHT (BRANCO PURO) */
:root,
[data-theme="zen-light"] {
    --bg-main: #f8fafc;
    --bg-surface: #ffffff;
    --bg-card: #ffffff;
    --bg-card-hover: #f1f5f9;
    --border: #e2e8f0;
    --border-focus: #cbd5e1;
    --accent: #059669;
    --accent-glow: rgba(5, 150, 105, 0.15);
    --text-primary: #0f172a;
    --text-secondary: #334155;
    --text-muted: #64748b;
    --danger: #ef4444;
    --warning: #d97706;
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --font-main: 'Plus Jakarta Sans', system-ui, -apple-system, sans-serif;
    --font-mono: 'JetBrains Mono', monospace;
    --transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
    --safe-bottom: env(safe-area-inset-bottom, 0px);
}

/* 2. TEMA EMERALD DARK */
[data-theme="emerald-dark"] {
    --bg-main: #09090b;
    --bg-surface: #121215;
    --bg-card: #18181c;
    --bg-card-hover: #222228;
    --border: #27272a;
    --border-focus: #3f3f46;
    --accent: #10b981;
    --accent-glow: rgba(16, 185, 129, 0.25);
    --text-primary: #f8fafc;
    --text-secondary: #cbd5e1;
    --text-muted: #94a3b8;
}

/* 3. TEMA OBSIDIAN */
[data-theme="obsidian"] {
    --bg-main: #0b0813;
    --bg-surface: #140f24;
    --bg-card: #1c1533;
    --bg-card-hover: #281e4a;
    --border: #31255a;
    --border-focus: #483782;
    --accent: #c084fc;
    --accent-glow: rgba(192, 132, 252, 0.25);
    --text-primary: #f8fafc;
    --text-secondary: #cbd5e1;
    --text-muted: #94a3b8;
}

/* 4. TEMA AMBER / CYBERPUNK */
[data-theme="cyberpunk"] {
    --bg-main: #12110a;
    --bg-surface: #1c1a10;
    --bg-card: #262316;
    --bg-card-hover: #383420;
    --border: #423d26;
    --border-focus: #635b39;
    --accent: #fbbf24;
    --accent-glow: rgba(251, 191, 36, 0.25);
    --text-primary: #fefce8;
    --text-secondary: #fef08a;
    --text-muted: #ca8a04;
}

/* 5. TEMA NORDIC */
[data-theme="nordic"] {
    --bg-main: #070e14;
    --bg-surface: #0f1a24;
    --bg-card: #152433;
    --bg-card-hover: #1f364d;
    --border: #243f5a;
    --border-focus: #365e86;
    --accent: #38bdf8;
    --accent-glow: rgba(56, 189, 248, 0.25);
    --text-primary: #f8fafc;
    --text-secondary: #cbd5e1;
    --text-muted: #94a3b8;
}

/* ==========================================================================
   RESET & ESTRUTURA GLOBAL
   ========================================================================== */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    -webkit-tap-highlight-color: transparent;
}

body {
    background-color: var(--bg-main);
    color: var(--text-primary);
    font-family: var(--font-main);
    height: 100vh;
    height: 100dvh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

h1,
h2,
h3,
h4,
h5,
h6 {
    color: var(--text-primary);
    font-weight: 700;
}

/* ==========================================================================
   HEADER & CONTROLES
   ========================================================================== */
#top-bar {
    background: var(--bg-surface);
    border-bottom: 1px solid var(--border);
    padding: 10px 16px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    z-index: 20;
}

.top-bar-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
}

.brand {
    display: flex;
    align-items: center;
    gap: 8px;
}

.brand-badge {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: var(--accent);
    box-shadow: 0 0 10px var(--accent);
}

.brand h1 {
    font-size: 16px;
    font-weight: 800;
    letter-spacing: -0.02em;
}

.brand h1 span {
    color: var(--accent);
}

.pill {
    font-size: 10px;
    font-family: var(--font-mono);
    padding: 2px 7px;
    border-radius: 12px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    color: var(--text-secondary);
}

.pill.thinking {
    background: rgba(16, 185, 129, 0.15);
    border-color: var(--accent);
    color: var(--accent);
}

.quick-controls {
    display: flex;
    align-items: center;
    gap: 8px;
    overflow-x: auto;
    scrollbar-width: none;
    padding-bottom: 2px;
}

.quick-controls::-webkit-scrollbar {
    display: none;
}

.control-group {
    display: flex;
    align-items: center;
    gap: 6px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 4px 8px;
    font-size: 12px;
    color: var(--text-secondary);
}

.control-group select {
    background: transparent;
    border: none;
    color: var(--text-primary);
    font-size: 12px;
    font-family: var(--font-main);
    outline: none;
    cursor: pointer;
    max-width: 200px;
}

.control-group select option {
    background: var(--bg-surface);
    color: var(--text-primary);
}

.view-modes {
    display: flex;
    gap: 2px;
    background: var(--bg-card);
    padding: 2px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
}

.view-btn {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    font-size: 11px;
    padding: 4px 8px;
    border-radius: 4px;
    cursor: pointer;
    transition: var(--transition);
}

.view-btn.active {
    background: var(--bg-surface);
    color: var(--text-primary);
    font-weight: 700;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.mic-btn {
    background: var(--bg-card);
    border: 1px solid var(--border);
    color: var(--text-primary);
    padding: 6px 12px;
    border-radius: var(--radius-sm);
    font-size: 12px;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 6px;
    cursor: pointer;
    transition: var(--transition);
    white-space: nowrap;
}

.mic-btn.recording {
    background: rgba(239, 68, 68, 0.15);
    border-color: var(--danger);
    color: var(--danger);
    animation: pulse 1.5s infinite;
}

.mic-timer {
    font-family: var(--font-mono);
    font-size: 11px;
    color: var(--danger);
    font-weight: 700;
}

.kbd-shortcut {
    font-family: var(--font-mono);
    font-size: 10px;
    background: var(--bg-main);
    color: var(--text-muted);
    padding: 1px 4px;
    border-radius: 4px;
    border: 1px solid var(--border);
}

.user-actions {
    display: flex;
    align-items: center;
    gap: 6px;
}

.icon-btn,
.ghost-btn,
.primary-btn,
.upgrade-btn {
    font-family: var(--font-main);
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: var(--transition);
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.icon-btn {
    background: var(--bg-card);
    border: 1px solid var(--border);
    width: 32px;
    height: 32px;
    font-size: 14px;
    color: var(--text-primary);
}

.ghost-btn {
    background: transparent;
    border: 1px solid var(--border);
    color: var(--text-secondary);
    font-size: 11px;
    padding: 4px 8px;
}

.ghost-btn:hover {
    background: var(--bg-card-hover);
    color: var(--text-primary);
}

.primary-btn {
    background: var(--accent);
    color: #ffffff;
    font-weight: 700;
    border: none;
    font-size: 12px;
    padding: 6px 12px;
}

.primary-btn-sm {
    background: var(--accent);
    color: #ffffff;
    font-weight: 700;
    border: none;
    font-size: 11px;
    padding: 4px 8px;
    border-radius: var(--radius-sm);
}

.upgrade-btn {
    background: linear-gradient(135deg, #f59e0b, #d97706);
    color: #000000;
    font-weight: 800;
    border: none;
    padding: 6px 10px;
    font-size: 12px;
    gap: 4px;
}

.user-pill {
    background: var(--bg-card);
    border: 1px solid var(--border);
    padding: 3px 8px;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    color: var(--text-primary);
}

.user-pill button {
    background: transparent;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
}

.plan-badge {
    font-size: 9px;
    font-weight: 800;
    padding: 1px 4px;
    border-radius: 4px;
    font-family: var(--font-mono);
}

.plan-badge.free {
    background: var(--border);
    color: var(--text-secondary);
}

.plan-badge.pro {
    background: var(--warning);
    color: #000;
}

/* ==========================================================================
   WORKSPACE & PAINEIS
   ========================================================================== */
#workspace {
    flex: 1;
    display: grid;
    grid-template-columns: 1.1fr 1fr 1.2fr;
    gap: 12px;
    padding: 12px;
    overflow: hidden;
}

#workspace.layout-graph {
    grid-template-columns: 1fr 2fr;
}

#workspace.layout-graph .pane-mirror {
    display: none;
}

#workspace.layout-zen {
    grid-template-columns: 1fr;
    max-width: 850px;
    margin: 0 auto;
    width: 100%;
}

#workspace.layout-zen .pane-mirror,
#workspace.layout-zen .pane-graph {
    display: none;
}

.pane {
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.pane-header {
    padding: 10px 14px;
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: var(--bg-card);
}

.pane-title {
    display: flex;
    align-items: center;
    gap: 8px;
}

.pane-title h2 {
    font-size: 13px;
    font-weight: 700;
    color: var(--text-primary);
}

.dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--accent);
}

.dot.purple {
    background: #a855f7;
}

.dot.emerald {
    background: #10b981;
}

.editor-stats {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 11px;
    color: var(--text-muted);
}

#editor {
    flex: 1;
    background: transparent;
    border: none;
    padding: 16px;
    color: var(--text-primary);
    font-family: var(--font-main);
    font-size: 15px;
    resize: none;
    outline: none;
    line-height: 1.7;
}

#editor::placeholder {
    color: var(--text-muted);
}

.char-limit-bar {
    height: 2px;
    background: var(--border);
    width: 100%;
}

.char-progress {
    height: 100%;
    width: 0%;
    background: var(--accent);
    transition: width 0.2s;
}

.char-progress.warning {
    background: var(--warning);
}

.char-progress.danger {
    background: var(--danger);
}

.mirror-content {
    flex: 1;
    padding: 14px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.section-label {
    font-size: 10.5px;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    font-weight: 700;
    color: var(--text-muted);
    display: block;
    margin-bottom: 6px;
}

.glass-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    color: var(--text-primary);
    padding: 12px;
    border-radius: var(--radius-sm);
    font-size: 13px;
    line-height: 1.6;
    white-space: pre-wrap;
}

.glass-card.empty {
    color: var(--text-muted);
    font-style: italic;
}

.card-list {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.card-list li {
    background: var(--bg-card);
    border: 1px solid var(--border);
    color: var(--text-primary);
    padding: 8px 12px;
    border-radius: var(--radius-sm);
    font-size: 12.5px;
    line-height: 1.4;
}

.action-list li {
    cursor: pointer;
    border-left: 3px solid var(--accent);
    transition: var(--transition);
}

.action-list li:hover {
    background: var(--bg-card-hover);
}

/* Canvas e Grafo */
.canvas-container {
    flex: 1.2;
    position: relative;
    background: var(--bg-card);
    border-bottom: 1px solid var(--border);
    min-height: 180px;
}

#graph-canvas {
    width: 100%;
    height: 100%;
    display: block;
}

.canvas-hint {
    position: absolute;
    bottom: 8px;
    left: 50%;
    transform: translateX(-50%);
    font-size: 10px;
    color: var(--text-secondary);
    background: var(--bg-surface);
    border: 1px solid var(--border);
    padding: 2px 8px;
    border-radius: 10px;
    pointer-events: none;
    white-space: nowrap;
}

.graph-narrative-section {
    flex: 1;
    padding: 12px;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
}

.section-label-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 6px;
}

.narrative-actions {
    display: flex;
    gap: 6px;
}

.save-agent-btn {
    background: linear-gradient(135deg, #10b981, #059669);
    color: #ffffff;
    border: none;
    font-size: 11px;
    font-weight: 700;
    padding: 4px 8px;
    border-radius: var(--radius-sm);
    cursor: pointer;
}

/* ==========================================================================
   DRAWER DE CONFIGURAÇÕES (TEXTO E BOTÕES NÍTIDOS)
   ========================================================================== */
.drawer {
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    width: 320px;
    background: var(--bg-surface);
    border-left: 1px solid var(--border);
    padding: 20px;
    z-index: 100;
    overflow-y: auto;
    color: var(--text-primary);
    box-shadow: -10px 0 30px rgba(0, 0, 0, 0.2);
}

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

.drawer-header h3 {
    font-size: 16px;
    color: var(--text-primary);
}

.setting-group {
    margin-bottom: 20px;
}

.setting-group h4 {
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
    margin-bottom: 10px;
}

.theme-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
}

.theme-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    padding: 10px 8px;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--text-primary);
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
}

.theme-card:hover {
    background: var(--bg-card-hover);
}

.theme-card.active {
    border-color: var(--accent);
    background: var(--bg-card-hover);
    box-shadow: 0 0 0 1px var(--accent);
}

.preview-swatch {
    width: 14px;
    height: 14px;
    border-radius: 50%;
    flex-shrink: 0;
}

.setting-group label {
    font-size: 12px;
    color: var(--text-secondary);
    display: block;
    margin-bottom: 8px;
}

.setting-group input[type="range"] {
    width: 100%;
    accent-color: var(--accent);
}

/* ==========================================================================
   MODAIS & LINHA DO TEMPO
   ========================================================================== */
#time-travel-bar {
    background: var(--bg-surface);
    border-top: 1px solid var(--border);
    padding: 6px 16px;
    font-size: 12px;
    color: var(--text-secondary);
}

.time-travel-inner {
    display: flex;
    align-items: center;
    gap: 10px;
}

.time-travel-inner input[type="range"] {
    flex: 1;
    accent-color: var(--accent);
}

.backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
    z-index: 99;
}

.sprint-modal,
.paywall-modal {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: var(--bg-surface);
    border: 1px solid var(--border);
    color: var(--text-primary);
    border-radius: var(--radius-lg);
    padding: 24px;
    z-index: 100;
    width: 90%;
    max-width: 480px;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.25);
}

.sprint-header,
.paywall-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 14px;
}

.sprint-timer {
    font-size: 36px;
    font-weight: 800;
    font-family: var(--font-mono);
    color: var(--accent);
    text-align: center;
    margin-bottom: 10px;
}

.sprint-body textarea {
    width: 100%;
    height: 100px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    padding: 10px;
    font-family: var(--font-main);
    resize: none;
    margin-top: 6px;
    outline: none;
}

.checkout-stripe-btn {
    background: linear-gradient(135deg, #f59e0b, #d97706);
    color: #000000;
    font-weight: 800;
    border: none;
    padding: 12px;
    width: 100%;
    border-radius: var(--radius-sm);
    cursor: pointer;
}

.mobile-nav {
    display: none;
}

.hidden {
    display: none !important;
}

/* ==========================================================================
   RESPONSIVIDADE MOBILE
   ========================================================================== */
@media (max-width: 850px) {
    body {
        padding-bottom: calc(56px + var(--safe-bottom));
    }

    .desktop-only {
        display: none !important;
    }

    .kbd-shortcut {
        display: none;
    }

    #workspace {
        display: block;
        padding: 8px;
        height: calc(100dvh - 110px - 56px - var(--safe-bottom));
        position: relative;
    }

    .pane {
        display: none;
        height: 100%;
        border-radius: var(--radius-sm);
    }

    .pane.active-pane {
        display: flex;
    }

    .mobile-nav {
        display: flex;
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        height: calc(56px + var(--safe-bottom));
        padding-bottom: var(--safe-bottom);
        background: var(--bg-surface);
        border-top: 1px solid var(--border);
        z-index: 90;
        justify-content: space-around;
        align-items: center;
    }

    .mobile-tab-btn {
        flex: 1;
        height: 100%;
        background: transparent;
        border: none;
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        gap: 2px;
        color: var(--text-muted);
        font-size: 10px;
        font-family: var(--font-main);
        font-weight: 600;
        cursor: pointer;
    }

    .mobile-tab-btn.active {
        color: var(--accent);
    }

    .mobile-tab-btn .tab-icon {
        font-size: 16px;
    }

    .sprint-modal,
    .paywall-modal {
        top: auto;
        bottom: 0;
        left: 0;
        right: 0;
        transform: none;
        width: 100%;
        max-width: 100%;
        border-radius: var(--radius-lg) var(--radius-lg) 0 0;
        padding-bottom: calc(20px + var(--safe-bottom));
        animation: slideUp 0.25s ease-out;
    }

    .drawer {
        width: 85%;
        max-width: 320px;
    }

    #time-travel-bar {
        display: none;
    }
}

@keyframes slideUp {
    from {
        transform: translateY(100%);
    }

    to {
        transform: translateY(0);
    }
}

@keyframes pulse {

    0%,
    100% {
        opacity: 1;
    }

    50% {
        opacity: 0.6;
    }
}