/* CSS Reset & Base Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

/* CSS Variables for Themes */
:root {
    /* Light Theme */
    --bg-primary: #ffffff;
    --bg-secondary: #f8fafc;
    --bg-tertiary: #f1f5f9;
    --text-primary: #0f172a;
    --text-secondary: #475569;
    --text-muted: #64748b;
    --accent: #3b82f6;
    --accent-hover: #2563eb;
    --border: #e2e8f0;
    --border-light: #f1f5f9;
    --shadow: rgba(0, 0, 0, 0.1);
    --shadow-strong: rgba(0, 0, 0, 0.2);
    --success: #10b981;
    --warning: #f59e0b;
    --error: #ef4444;
    
    /* Glass morphism */
    --glass-bg: rgba(255, 255, 255, 0.1);
    --glass-border: rgba(255, 255, 255, 0.2);
    --glass-shadow: rgba(31, 38, 135, 0.37);
}

/* Dark Theme */
[data-theme="dark"] {
    --bg-primary: #0f172a;
    --bg-secondary: #1e293b;
    --bg-tertiary: #334155;
    --text-primary: #f8fafc;
    --text-secondary: #cbd5e1;
    --text-muted: #94a3b8;
    --accent: #6366f1;
    --accent-hover: #4f46e5;
    --border: #334155;
    --border-light: #475569;
    --shadow: rgba(0, 0, 0, 0.3);
    --shadow-strong: rgba(0, 0, 0, 0.5);
    --success: #10b981;
    --warning: #f59e0b;
    --error: #ef4444;
    
    /* Glass morphism */
    --glass-bg: rgba(15, 23, 42, 0.8);
    --glass-border: rgba(148, 163, 184, 0.1);
    --glass-shadow: rgba(0, 0, 0, 0.3);
}

/* Base Typography & Layout */
html {
    height: 100%;
    scroll-behavior: smooth;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, 'Open Sans', 'Helvetica Neue', sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.6;
    height: 100vh;
    overflow: hidden;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Glassmorphism Base */
.glass {
    background: var(--glass-bg);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid var(--glass-border);
    box-shadow: 0 8px 32px 0 var(--glass-shadow);
}

/* Header Styles */
.header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 2rem;
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border);
    position: relative;
    z-index: 100;
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
}

.logo {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-primary);
    user-select: none;
}

.logo-icon {
    margin-right: 0.25rem;
    border-radius: 6px;
    flex-shrink: 0;
}

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

.nav {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.nav-btn {
    background: transparent;
    border: 1px solid var(--border);
    color: var(--text-secondary);
    padding: 0.5rem;
    border-radius: 0.5rem;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
}

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

.nav-btn svg {
    width: 18px;
    height: 18px;
}

/* Theme Toggle */
.theme-icon {
    transition: all 0.3s ease;
}

[data-theme="dark"] .theme-icon.sun {
    opacity: 1;
}

[data-theme="dark"] .theme-icon.moon {
    opacity: 0;
    position: absolute;
}

[data-theme="light"] .theme-icon.sun {
    opacity: 0;
    position: absolute;
}

[data-theme="light"] .theme-icon.moon {
    opacity: 1;
}

/* Main Container */
.main-container {
    display: flex;
    height: calc(100vh - 80px - 40px); /* Header + Footer */
    position: relative;
}

/* Pane Styles */
.editor-pane,
.preview-pane {
    display: flex;
    flex-direction: column;
    background: var(--bg-primary);
    min-width: 300px;
    flex: 1;
}

.editor-pane {
    border-right: 1px solid var(--border);
}

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

.pane-title {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-primary);
}

.pane-actions {
    display: flex;
    gap: 0.5rem;
}

.action-btn {
    background: transparent;
    border: 1px solid var(--border);
    color: var(--text-secondary);
    padding: 0.25rem;
    border-radius: 0.25rem;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
}

.action-btn:hover {
    background: var(--bg-tertiary);
    color: var(--accent);
    border-color: var(--accent);
}

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

/* Editor Container */
.editor-container {
    flex: 1;
    display: flex;
    position: relative;
    background: var(--bg-primary);
    overflow: hidden;
}

.line-numbers {
    background: var(--bg-secondary);
    color: var(--text-muted);
    padding: 1rem 0.5rem;
    font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', 'Courier New', monospace;
    font-size: 14px;
    line-height: 1.5;
    text-align: right;
    user-select: none;
    min-width: 50px;
    border-right: 1px solid var(--border);
    white-space: pre;
    overflow: hidden;
}

.code-editor {
    flex: 1;
    background: var(--bg-primary);
    color: var(--text-primary);
    border: none;
    outline: none;
    padding: 1rem;
    font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', 'Courier New', monospace;
    font-size: 14px;
    line-height: 1.5;
    resize: none;
    white-space: pre;
    overflow-wrap: normal;
    overflow: auto;
    tab-size: 2;
    -moz-tab-size: 2;
}

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

.code-editor:focus {
    outline: none;
}

/* Custom Scrollbars */
.code-editor::-webkit-scrollbar,
.line-numbers::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

.code-editor::-webkit-scrollbar-track,
.line-numbers::-webkit-scrollbar-track {
    background: var(--bg-secondary);
}

.code-editor::-webkit-scrollbar-thumb,
.line-numbers::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 4px;
}

.code-editor::-webkit-scrollbar-thumb:hover,
.line-numbers::-webkit-scrollbar-thumb:hover {
    background: var(--accent);
}

/* Resizer */
.resizer {
    width: 4px;
    background: var(--border);
    cursor: col-resize;
    position: relative;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.resizer:hover {
    background: var(--accent);
    width: 6px;
}

.resizer-handle {
    width: 2px;
    height: 40px;
    background: var(--text-muted);
    border-radius: 1px;
    opacity: 0;
    transition: opacity 0.2s ease;
}

.resizer:hover .resizer-handle {
    opacity: 1;
}

/* Preview Container */
.preview-container {
    flex: 1;
    position: relative;
    background: var(--bg-primary);
}

.preview-frame {
    width: 100%;
    height: 100%;
    border: none;
    background: white;
}

/* Footer */
.footer {
    background: var(--bg-secondary);
    border-top: 1px solid var(--border);
    padding: 0.5rem 2rem;
    height: 40px;
    display: flex;
    align-items: center;
}

.footer-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
}

.footer-links {
    display: flex;
    gap: 1rem;
}

.footer-link {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 0.8rem;
    cursor: pointer;
    transition: color 0.2s ease;
}

.footer-link:hover {
    color: var(--accent);
}

.footer-brand {
    font-size: 0.8rem;
    color: var(--text-muted);
}

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

.footer-brand a:hover {
    text-decoration: underline;
}

/* Cookie Bar */
.cookie-bar {
    position: fixed;
    bottom: 20px;
    left: 20px;
    right: 20px;
    max-width: 600px;
    margin: 0 auto;
    padding: 1.5rem;
    border-radius: 1rem;
    z-index: 1000;
    transform: translateY(100px);
    opacity: 0;
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

.cookie-bar.show {
    transform: translateY(0);
    opacity: 1;
}

.cookie-content {
    margin-bottom: 1rem;
}

.cookie-title {
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 0.5rem;
    font-size: 1.1rem;
}

.cookie-text {
    color: var(--text-secondary);
    font-size: 0.9rem;
    line-height: 1.4;
}

.cookie-actions {
    display: flex;
    gap: 0.75rem;
    flex-wrap: wrap;
}

.btn-cookie {
    padding: 0.5rem 1rem;
    border-radius: 0.5rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    font-size: 0.9rem;
    border: 1px solid transparent;
}

.btn-cookie.accept {
    background: var(--success);
    color: white;
}

.btn-cookie.accept:hover {
    background: #059669;
}

.btn-cookie.decline {
    background: transparent;
    color: var(--text-secondary);
    border: 1px solid var(--border);
}

.btn-cookie.decline:hover {
    background: var(--bg-tertiary);
    color: var(--text-primary);
}

.btn-cookie.settings {
    background: transparent;
    color: var(--accent);
    border: 1px solid var(--accent);
}

.btn-cookie.settings:hover {
    background: var(--accent);
    color: white;
}

/* Modal Styles */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 2000;
    padding: 2rem;
    opacity: 0;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.modal-overlay.show {
    display: flex;
    opacity: 1;
}

.modal {
    max-width: 500px;
    width: 100%;
    border-radius: 1rem;
    max-height: 80vh;
    overflow: hidden;
    transform: scale(0.9) translateY(20px);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

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

.modal.large {
    max-width: 700px;
    max-height: 90vh;
}

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

.modal-header h3 {
    color: var(--text-primary);
    font-weight: 600;
}

.close-btn {
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: var(--text-muted);
    transition: color 0.2s ease;
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.close-btn:hover {
    color: var(--text-primary);
}

.modal-content {
    padding: 1.5rem;
    overflow-y: auto;
    max-height: 60vh;
}

.modal-content h4 {
    color: var(--text-primary);
    margin: 1.5rem 0 0.5rem 0;
    font-weight: 600;
}

.modal-content h5 {
    color: var(--accent);
    margin: 1rem 0 0.5rem 0;
    font-weight: 600;
}

.modal-content p {
    color: var(--text-secondary);
    margin-bottom: 1rem;
    line-height: 1.6;
}

.modal-content ul {
    color: var(--text-secondary);
    margin: 0.5rem 0 1rem 1.5rem;
}

.modal-content li {
    margin-bottom: 0.25rem;
}

.modal-footer {
    padding: 1.5rem;
    border-top: 1px solid var(--glass-border);
    display: flex;
    gap: 1rem;
    justify-content: flex-end;
}

.btn-primary,
.btn-secondary {
    padding: 0.5rem 1rem;
    border-radius: 0.5rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    border: 1px solid transparent;
}

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

.btn-primary:hover {
    background: var(--accent-hover);
}

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

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

/* Cookie Categories */
.cookie-category {
    margin-bottom: 1.5rem;
    padding: 1rem;
    background: rgba(var(--accent), 0.05);
    border-radius: 0.5rem;
    border: 1px solid rgba(var(--accent), 0.1);
}

.cookie-category-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.5rem;
}

.cookie-category h4 {
    margin: 0;
    color: var(--text-primary);
    font-size: 1rem;
}

.cookie-category p {
    color: var(--text-muted);
    font-size: 0.9rem;
    margin: 0;
}

/* Toggle Switch */
.toggle {
    position: relative;
    width: 48px;
    height: 24px;
    background: var(--border);
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.3s ease;
}

.toggle.active {
    background: var(--success);
}

.toggle.always-on {
    background: var(--success);
    cursor: not-allowed;
}

.toggle-slider {
    position: absolute;
    top: 2px;
    left: 2px;
    width: 20px;
    height: 20px;
    background: white;
    border-radius: 50%;
    transition: all 0.3s ease;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.toggle.active .toggle-slider {
    transform: translateX(24px);
}

/* Forget Section */
.forget-section {
    margin-top: 2rem;
    padding: 1rem;
    background: rgba(239, 68, 68, 0.05);
    border-radius: 0.5rem;
    border: 1px solid rgba(239, 68, 68, 0.1);
}

.forget-section h4 {
    color: var(--error);
    margin-top: 0;
}

.btn-forget {
    background: var(--error);
    color: white;
    border: none;
    padding: 0.5rem 1rem;
    border-radius: 0.5rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    margin-top: 0.5rem;
}

.btn-forget:hover {
    background: #dc2626;
}

/* Toast Notifications */
.toast {
    position: fixed;
    top: 100px;
    right: 20px;
    padding: 1rem 1.5rem;
    border-radius: 0.5rem;
    color: white;
    font-weight: 500;
    transform: translateX(100%);
    opacity: 0;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 3000;
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
}

.toast.show {
    transform: translateX(0);
    opacity: 1;
}

.toast-content {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.toast.success {
    background: var(--success);
}

.toast.error {
    background: var(--error);
}

.toast.info {
    background: var(--accent);
}

/* Responsive Design */
@media (max-width: 768px) {
    .header {
        padding: 1rem;
    }
    
    .nav {
        gap: 0.25rem;
    }
    
    .nav-btn {
        width: 36px;
        height: 36px;
    }
    
    .main-container {
        flex-direction: column;
        height: calc(100vh - 60px - 40px);
    }
    
    .editor-pane,
    .preview-pane {
        min-height: 250px;
        min-width: auto;
    }
    
    .resizer {
        width: 100%;
        height: 4px;
        cursor: row-resize;
    }
    
    .resizer:hover {
        height: 6px;
        width: 100%;
    }
    
    .resizer-handle {
        width: 40px;
        height: 2px;
    }
    
    .cookie-bar {
        left: 10px;
        right: 10px;
        bottom: 10px;
    }
    
    .cookie-actions {
        justify-content: center;
    }
    
    .footer-content {
        flex-direction: column;
        gap: 0.5rem;
        align-items: center;
    }
    
    .footer-links {
        gap: 0.5rem;
    }
    
    .modal-overlay {
        padding: 1rem;
    }
    
    .modal {
        max-width: 100%;
        max-height: 90vh;
    }
    
    .modal-content {
        max-height: 50vh;
    }
}

@media (max-width: 480px) {
    .header {
        padding: 0.75rem;
    }
    
    .logo {
        font-size: 1.25rem;
    }
    
    .nav-btn {
        width: 32px;
        height: 32px;
    }
    
    .nav-btn svg {
        width: 16px;
        height: 16px;
    }
    
    .pane-header {
        padding: 0.75rem;
    }
    
    .pane-title {
        font-size: 0.9rem;
    }
    
    .code-editor,
    .line-numbers {
        font-size: 13px;
    }
    
    .cookie-actions {
        flex-direction: column;
    }
    
    .btn-cookie {
        text-align: center;
    }
}