/* Light Theme (Default) */
:root {
    --bg-primary: #ffffff;
    --bg-secondary: #f8fafc;
    --bg-tertiary: #f1f5f9;
    --text-primary: #1e293b;
    --text-secondary: #64748b;
    --accent-primary: #3b82f6;
    --accent-secondary: #8b5cf6;
    --border-color: #e2e8f0;
    --success-color: #22c55e;
    --error-color: #ef4444;
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
    --font-sans: 'Inter', system-ui, sans-serif;
    --font-mono: 'JetBrains Mono', monospace;
    /* Editor colors for light theme */
    --editor-bg: #ffffff;
    --editor-gutter-bg: #f8fafc;
    --editor-gutter-color: #94a3b8;
    --editor-active-line: #f1f5f9;
    --editor-cursor: #3b82f6;
    --editor-selection: rgba(59, 130, 246, 0.2);
}

/* Dark Theme */
[data-theme="dark"] {
    --bg-primary: #0f172a;
    --bg-secondary: #1e293b;
    --bg-tertiary: #334155;
    --text-primary: #f1f5f9;
    --text-secondary: #94a3b8;
    --accent-primary: #60a5fa;
    --accent-secondary: #a78bfa;
    --border-color: #334155;
    --success-color: #4ade80;
    --error-color: #f87171;
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.4);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.5);
    /* Editor colors for dark theme */
    --editor-bg: #1e293b;
    --editor-gutter-bg: #0f172a;
    --editor-gutter-color: #64748b;
    --editor-active-line: #334155;
    --editor-cursor: #60a5fa;
    --editor-selection: rgba(96, 165, 250, 0.25);
}

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

body {
    background-color: var(--bg-primary);
    color: var(--text-primary);
    font-family: var(--font-sans);
    line-height: 1.6;
    overflow-x: hidden;
}

.app-container {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

/* Header & Nav */
header {
    background-color: var(--bg-primary);
    backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--border-color);
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: var(--shadow-sm);
}

[data-theme="dark"] header {
    background-color: rgba(15, 23, 42, 0.95);
}

nav {
    max-width: 1400px;
    margin: 0 auto;
    padding: 1rem 2rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.logo-link {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    text-decoration: none;
    color: var(--text-primary);
    font-weight: 700;
    font-size: 1.25rem;
}

.logo-link i {
    color: var(--accent-primary);
}

/* Theme Toggle Button */
.theme-toggle {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    border-radius: 10px;
    border: 1px solid var(--border-color);
    background-color: var(--bg-secondary);
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.3s ease;
}

.theme-toggle:hover {
    background-color: var(--bg-tertiary);
    color: var(--accent-primary);
    border-color: var(--accent-primary);
}

.theme-toggle i {
    font-size: 1.1rem;
}

.nav-links {
    display: flex;
    gap: 2rem;
}

.nav-links a {
    text-decoration: none;
    color: var(--text-secondary);
    font-weight: 500;
    transition: color 0.3s;
}

.nav-links a:hover,
.nav-links a.active {
    color: var(--accent-primary);
}

.mobile-menu-btn {
    display: none;
    background: none;
    border: none;
    color: var(--text-primary);
    font-size: 1.5rem;
    cursor: pointer;
}

/* Main Layout */
main {
    flex: 1;
    display: flex;
    flex-direction: column;
}

.editor-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    height: auto;
    min-height: 600px; /* Reduced minimum height for a more compact editor */
    background-color: var(--bg-primary);
    position: relative;
    scroll-margin-top: 60px; /* Add space for fixed header when jumping to anchor */
}

/* Toolbar */
.toolbar {
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 1rem 2rem;
    background-color: var(--bg-secondary);
    border-bottom: 1px solid var(--border-color);
    /* Match editor width constraints */
    margin: 0 4rem;
    max-width: 1600px;
    align-self: center;
    width: calc(100% - 8rem);
    border-radius: 12px 12px 0 0;
    border: 1px solid var(--border-color);
    border-bottom: none;
}

.toolbar-group {
    display: flex;
    gap: 1rem;
}

.btn {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    border-radius: 6px;
    font-family: var(--font-sans);
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    border: 1px solid transparent;
    font-size: 0.9rem;
}

.btn i {
    font-size: 0.9rem;
}

.btn span {
    margin-left: 0.25rem;
}

.btn.primary {
    background: linear-gradient(135deg, var(--accent-primary), var(--accent-secondary));
    color: white;
    box-shadow: var(--shadow-md);
}

.btn.primary:hover {
    filter: brightness(1.05);
    transform: translateY(-1px);
    box-shadow: var(--shadow-lg);
}

.btn.secondary {
    background-color: var(--bg-tertiary);
    color: var(--text-secondary);
    border: 1px solid var(--border-color);
}

.btn.secondary:hover {
    background-color: var(--bg-secondary);
    color: var(--text-primary);
    border-color: var(--accent-primary);
}

/* Loading Animation Styles */
.loading-spinner {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    color: var(--text-secondary);
}

.loading-animation {
    display: flex;
    gap: 4px;
    justify-content: center;
    margin-bottom: 1rem;
}

.loading-bar {
    width: 4px;
    height: 32px;
    background: linear-gradient(to bottom, var(--accent-primary), var(--accent-secondary));
    border-radius: 2px;
    animation: loading-pulse 1.4s ease-in-out infinite both;
}

.loading-bar:nth-child(1) {
    animation-delay: -0.32s;
}

.loading-bar:nth-child(2) {
    animation-delay: -0.16s;
}

@keyframes loading-pulse {
    0%, 80%, 100% {
        transform: scale(0.8);
        opacity: 0.5;
    }
    40% {
        transform: scale(1);
        opacity: 1;
    }
}

/* Ace Editor Styling */
.monaco-wrapper {
    flex: 1;
    width: calc(100% - 8rem);
    position: relative;
    overflow: hidden;
    margin: 0 4rem;
    max-width: 1600px;
    align-self: center;
    border-radius: 0;
    border-left: 1px solid var(--border-color);
    border-right: 1px solid var(--border-color);
    border-top: none;
    border-bottom: none;
    box-shadow: none;
    transition: all 0.3s ease;
    min-height: 600px;
    background-color: var(--editor-bg);
}

.monaco-wrapper:hover {
    border-color: var(--accent-primary);
    box-shadow: var(--shadow-lg);
}

/* Ace Editor container */
.monaco-wrapper .ace_editor {
    border-radius: 12px;
    background-color: var(--editor-bg) !important;
}

.monaco-wrapper .ace_gutter {
    background-color: var(--editor-gutter-bg) !important;
    border-right: 1px solid var(--border-color);
}

.monaco-wrapper .ace_gutter-cell {
    color: var(--editor-gutter-color);
}

.monaco-wrapper .ace_gutter-active-line {
    background-color: var(--editor-active-line) !important;
    color: var(--accent-primary);
}

.monaco-wrapper .ace_active-line {
    background-color: var(--editor-active-line) !important;
}

.monaco-wrapper .ace_cursor {
    color: var(--editor-cursor);
    border-left: 2px solid var(--editor-cursor) !important;
}

.monaco-wrapper .ace_selection {
    background-color: var(--editor-selection) !important;
}

/* Scrollbar styling */
.monaco-wrapper .ace_scrollbar::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

.monaco-wrapper .ace_scrollbar::-webkit-scrollbar-track {
    background: var(--bg-tertiary);
}

.monaco-wrapper .ace_scrollbar::-webkit-scrollbar-thumb {
    background: var(--text-secondary);
    border-radius: 4px;
}

.monaco-wrapper .ace_scrollbar::-webkit-scrollbar-thumb:hover {
    background: var(--text-primary);
}

/* Status Bar */
.status-bar {
    background-color: var(--bg-secondary);
    border-top: 1px solid var(--border-color);
    padding: 0.5rem 2rem;
    display: flex;
    justify-content: space-between;
    color: var(--text-secondary);
    font-size: 0.8rem;
    font-family: var(--font-mono);
    /* Match editor width constraints */
    margin: 0 4rem;
    max-width: 1600px;
    align-self: center;
    width: calc(100% - 8rem);
    border-radius: 0 0 12px 12px;
    border: 1px solid var(--border-color);
    border-top: none;
}

/* Guide Section */
.content-section {
    background-color: var(--bg-secondary);
    padding: 4rem 2rem;
    border-top: 1px solid var(--border-color);
}

.container {
    max-width: 1200px;
    margin: 0 auto;
}

.section-header {
    text-align: center;
    margin-bottom: 3rem;
}

.section-header h2 {
    font-size: 2rem;
    margin-bottom: 1rem;
    color: var(--text-primary);
}

.grid-layout {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 2rem;
    margin-bottom: 4rem;
}

.card {
    background-color: var(--bg-tertiary);
    padding: 2rem;
    border-radius: 12px;
    border: 1px solid var(--border-color);
    transition: transform 0.3s, box-shadow 0.3s;
}

.card:hover {
    transform: translateY(-3px);
    box-shadow: var(--shadow-lg);
    border-color: var(--accent-primary);
}

.card h3 {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 1rem;
    color: var(--accent-primary);
}

.card ul {
    list-style: none;
}

.card li {
    margin-bottom: 0.5rem;
    padding-left: 1.5rem;
    position: relative;
}

.card li::before {
    content: '→';
    position: absolute;
    left: 0;
    color: var(--accent-primary);
}

.code-block {
    background-color: var(--bg-primary);
    padding: 1rem;
    border-radius: 6px;
    font-family: var(--font-mono);
    font-size: 0.9rem;
    color: var(--text-secondary);
    overflow-x: auto;
}

.seo-content {
    max-width: 800px;
    margin: 0 auto;
    text-align: center;
    color: var(--text-secondary);
}

/* Footer */
footer {
    background-color: var(--bg-primary);
    padding: 2rem;
    text-align: center;
    border-top: 1px solid var(--border-color);
    color: var(--text-secondary);
}

footer a {
    color: var(--accent-primary);
    text-decoration: none;
}

/* Toast Container */
.toast-container {
    position: fixed;
    top: 80px;
    right: 20px;
    z-index: 1000;
    pointer-events: none;
}

/* Toast Styles */
.toast {
    background-color: var(--bg-primary);
    backdrop-filter: blur(12px);
    border-left: 4px solid;
    border-radius: 8px;
    box-shadow: var(--shadow-lg);
    padding: 12px 16px;
    margin-bottom: 12px;
    min-width: 250px;
    max-width: 350px;
    display: flex;
    align-items: center;
    gap: 12px;
    pointer-events: auto;
    animation: slideInRight 0.3s ease-out;
    font-family: var(--font-sans);
    font-size: 14px;
    color: var(--text-primary);
    border: 1px solid var(--border-color);
}

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

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

.toast.info {
    border-left-color: var(--accent-primary);
}

.toast-icon {
    font-size: 16px;
    flex-shrink: 0;
}

.toast.success .toast-icon {
    color: var(--success-color);
}

.toast.error .toast-icon {
    color: var(--error-color);
}

.toast.info .toast-icon {
    color: var(--accent-primary);
}

.toast-message {
    flex: 1;
    font-weight: 500;
}

.toast.fade-out {
    animation: fadeOut 0.3s ease-out forwards;
}

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

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

/* Mobile Toast Position */
@media (max-width: 768px) {
    .toast-container {
        top: auto;
        bottom: 20px;
        right: 10px;
        left: 10px;
    }
    
    .toast {
        min-width: auto;
        max-width: none;
    }
}

/* Mobile Responsive */
@media (max-width: 768px) {
    /* Header */
    nav {
        padding: 0.75rem 1rem;
    }

    .nav-links {
        display: none;
    }
    
    .mobile-menu-btn {
        display: block;
    }

    .logo-link {
        font-size: 1.1rem;
    }

    /* Toolbar - full width on mobile */
    .toolbar {
        margin: 0;
        width: 100%;
        border-radius: 0;
        border-left: none;
        border-right: none;
        padding: 0.75rem 1rem;
        gap: 0.5rem;
    }

    .toolbar-group {
        justify-content: center;
        flex-wrap: wrap;
        gap: 0.5rem;
    }

    .btn {
        padding: 0.4rem 0.75rem;
        font-size: 0.8rem;
    }

    /* Editor - full width on mobile */
    .monaco-wrapper {
        margin: 0;
        width: 100%;
        border-radius: 0;
        border-left: none;
        border-right: none;
        min-height: 400px;
    }

    /* Status bar - full width on mobile */
    .status-bar {
        margin: 0;
        width: 100%;
        border-radius: 0;
        border-left: none;
        border-right: none;
        padding: 0.4rem 1rem;
        font-size: 0.75rem;
    }

    .editor-container {
        height: auto;
        min-height: 450px;
    }

    /* Guide Section */
    .content-section {
        padding: 2rem 1rem;
    }

    .section-header h2 {
        font-size: 1.5rem;
    }

    .grid-layout {
        grid-template-columns: 1fr;
        gap: 1rem;
    }

    .card {
        padding: 1.25rem;
    }

    .card h3 {
        font-size: 1rem;
    }

    .seo-content {
        padding: 0 0.5rem;
    }

    .seo-content h3 {
        font-size: 1.1rem;
    }

    /* Footer */
    footer {
        padding: 1.5rem 1rem;
        font-size: 0.85rem;
    }

    /* Theme toggle */
    .theme-toggle {
        width: 36px;
        height: 36px;
    }
}

/* Small mobile devices */
@media (max-width: 480px) {
    .toolbar-group {
        width: 100%;
    }

    .btn {
        flex: 1;
        justify-content: center;
        min-width: 0;
    }

    .btn span {
        display: none;
    }

    .btn i {
        margin: 0;
    }

    .logo-link span {
        display: none;
    }

    .logo-link i {
        font-size: 1.5rem;
    }
}
