@import url('https://fonts.googleapis.com/css2?family=Fira+Code:wght@400;500;600&display=swap');

:root {
    --bg-primary: #0d0d0d;
    --bg-secondary: #161616;
    --bg-tertiary: #1e1e1e;
    --bg-editor: #1e1e1e;
    --accent-blue: #3b82f6;
    --accent-purple: #8b5cf6;
    --accent-cyan: #06b6d4;
    --accent-green: #22c55e;
    --accent-orange: #f97316;
    --accent-red: #ef4444;
    --accent-yellow: #eab308;
    --text-primary: #e5e5e5;
    --text-secondary: #a3a3a3;
    --text-muted: #737373;
    --border-color: #2d2d2d;
    --border-active: #3d3d3d;
    --shadow-glow: rgba(59, 130, 246, 0.15);
    --glass-bg: rgba(22, 22, 22, 0.8);
    --glass-border: rgba(255, 255, 255, 0.05);
}

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

html {
    scroll-behavior: smooth;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.6;
    overflow-x: hidden;
}

::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: var(--bg-secondary);
}

::-webkit-scrollbar-thumb {
    background: var(--border-active);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--text-muted);
}

::selection {
    background: var(--accent-blue);
    color: white;
}

header {
    background: var(--glass-bg);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-bottom: 1px solid var(--glass-border);
}

header .flex > a {
    position: relative;
}

header .flex > a::after {
    content: '';
    position: absolute;
    bottom: -4px;
    left: 0;
    width: 0;
    height: 2px;
    background: linear-gradient(90deg, var(--accent-blue), var(--accent-purple));
    transition: width 0.3s ease;
}

header .flex > a:hover::after {
    width: 100%;
}

#hero {
    min-height: calc(100vh - 64px);
    background: 
        radial-gradient(ellipse 80% 50% at 50% -20%, rgba(59, 130, 246, 0.15), transparent),
        radial-gradient(ellipse 60% 40% at 100% 100%, rgba(139, 92, 246, 0.1), transparent),
        var(--bg-primary);
}

#editors-panel {
    background: var(--bg-editor);
    display: flex;
    flex-direction: column;
    min-height: calc(100vh - 64px);
}

.tab-btn {
    color: var(--text-muted);
    background: transparent;
    border: 1px solid transparent;
}

.tab-btn:hover {
    color: var(--text-secondary);
    background: rgba(255, 255, 255, 0.05);
}

.tab-btn.active {
    color: var(--text-primary);
    background: var(--bg-tertiary);
    border-color: var(--border-active);
    box-shadow: 0 0 20px var(--shadow-glow);
}

.editor-panel {
    display: none;
    flex-direction: column;
    flex: 1;
    overflow: hidden;
}

.editor-panel.active {
    display: flex;
}

.editor-panel textarea {
    width: 100%;
    height: 100%;
    padding: 16px;
    background: #1e1e1e;
    border: none;
    outline: none;
    resize: none;
    font-family: 'Fira Code', 'Consolas', monospace;
    font-size: 14px;
    line-height: 1.6;
    color: #e5e5e5;
    tab-size: 2;
    white-space: pre;
    overflow-wrap: normal;
    overflow-x: auto;
}

.editor-panel textarea::placeholder {
    color: var(--text-muted);
    opacity: 0.6;
}

.editor-panel textarea:focus {
    outline: none;
}

.cm-editor {
    height: 100% !important;
    font-family: 'Fira Code', monospace !important;
}

.cm-editor .cm-scroller {
    font-family: 'Fira Code', monospace !important;
}

.cm-editor .cm-content {
    padding: 16px !important;
}

.cm-editor .cm-gutters {
    background: var(--bg-secondary) !important;
    border-right: 1px solid var(--border-color) !important;
    color: var(--text-muted) !important;
}

.cm-editor .cm-activeLineGutter {
    background: var(--bg-tertiary) !important;
}

.cm-editor .cm-activeLine {
    background: rgba(255, 255, 255, 0.03) !important;
}

.cm-editor .cm-selectionBackground {
    background: rgba(59, 130, 246, 0.3) !important;
}

.cm-editor.cm-focused .cm-selectionBackground {
    background: rgba(59, 130, 246, 0.4) !important;
}

.cm-editor .cm-line {
    padding-left: 8px !important;
}

#preview-panel {
    background: white;
    display: flex;
    flex-direction: column;
    min-height: calc(100vh - 64px);
}

#preview-panel.dark-preview {
    background: var(--bg-editor);
}

#preview-frame {
    display: block;
    background: white;
}

#preview-panel.dark-preview #preview-frame {
    background: #1a1a1a;
}

#btn-run {
    background: linear-gradient(135deg, var(--accent-blue), var(--accent-purple));
    position: relative;
    overflow: hidden;
}

#btn-run::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.2), transparent);
    transition: left 0.5s ease;
}

#btn-run:hover::before {
    left: 100%;
}

#btn-clear:hover {
    background: rgba(239, 68, 68, 0.2);
    color: var(--accent-red);
}

#btn-fullscreen:hover {
    background: var(--accent-blue);
}

#toggle-theme:checked ~ svg {
    color: var(--accent-yellow);
}

#recursos {
    background: linear-gradient(180deg, var(--bg-primary) 0%, var(--bg-secondary) 100%);
}

#recursos .group {
    transition: all 0.3s ease;
}

#recursos .group:hover {
    transform: translateY(-4px);
    box-shadow: 0 20px 40px -20px var(--shadow-glow);
}

#ferramentas {
    position: relative;
}

#ferramentas::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 1px;
    background: linear-gradient(90deg, transparent, var(--border-active), transparent);
}

#ferramentas textarea {
    transition: border-color 0.3s ease, box-shadow 0.3s ease;
}

#ferramentas textarea:focus {
    border-color: var(--accent-blue);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

#ferramentas button {
    transition: all 0.3s ease;
}

#ferramentas button:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(59, 130, 246, 0.3);
}

#faq details {
    transition: all 0.3s ease;
}

#faq details[open] {
    background: var(--bg-tertiary);
}

#faq summary {
    transition: all 0.2s ease;
}

#faq summary:hover {
    color: var(--accent-blue);
}

#faq details[open] summary {
    border-bottom: 1px solid var(--border-color);
    margin-bottom: 0;
}

footer {
    background: var(--bg-primary);
}

@keyframes pulse-glow {
    0%, 100% {
        box-shadow: 0 0 5px var(--accent-green), 0 0 10px var(--accent-green);
    }
    50% {
        box-shadow: 0 0 10px var(--accent-green), 0 0 20px var(--accent-green);
    }
}

.animate-pulse {
    animation: pulse-glow 2s ease-in-out infinite;
}

@media (max-width: 1024px) {
    #hero {
        flex-direction: column;
    }

    #editors-panel,
    #preview-panel {
        width: 100% !important;
        min-height: 50vh;
    }

    #preview-panel {
        border-top: 1px solid var(--border-color);
    }
}

@media (max-width: 768px) {
    header .max-w-screen-2xl {
        padding: 0 12px;
    }

    header h1 {
        font-size: 16px;
    }

    header nav {
        display: none;
    }

    header .flex > button {
        padding: 8px 12px;
        font-size: 13px;
    }

    header .flex > button span:first-child {
        display: none;
    }

    #recursos .grid {
        grid-template-columns: 1fr;
    }

    #ferramentas .grid {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 480px) {
    header .flex > button svg {
        width: 16px;
        height: 16px;
    }

    .tab-btn {
        padding: 8px 12px;
        font-size: 12px;
    }

    .tab-btn svg {
        width: 14px;
        height: 14px;
    }

    #editors-panel .flex items-center gap-1 {
        gap: 4px;
    }

    .editor-panel textarea {
        font-size: 12px;
        padding: 12px;
    }
}

.ligth-theme {
    --bg-primary: #ffffff;
    --bg-secondary: #f5f5f5;
    --bg-tertiary: #eeeeee;
    --bg-editor: #fafafa;
    --text-primary: #1a1a1a;
    --text-secondary: #4a4a4a;
    --text-muted: #737373;
    --border-color: #e5e5e5;
    --border-active: #d5d5d5;
    --glass-bg: rgba(255, 255, 255, 0.9);
}

.ligth-theme header {
    background: rgba(255, 255, 255, 0.95);
}

.ligth-theme #recursos .group {
    background: white;
}

.ligth-theme #faq details {
    background: white;
}

.output-error {
    color: var(--accent-red);
    background: rgba(239, 68, 68, 0.1);
    border: 1px solid rgba(239, 68, 68, 0.3);
}

.output-success {
    color: var(--accent-green);
    background: rgba(34, 197, 94, 0.1);
    border: 1px solid rgba(34, 197, 94, 0.3);
}