:root {
    /* Colors - Dark Theme (Default) */
    --bg-color: #0f172a;
    --text-color: #e2e8f0;
    --text-muted: #94a3b8;
    --panel-bg: rgba(30, 41, 59, 0.7);
    --panel-border: rgba(148, 163, 184, 0.1);
    --primary: #8b5cf6;
    /* Violet */
    --primary-hover: #7c3aed;
    --secondary: #06b6d4;
    /* Cyan */
    --success: #10b981;
    --danger: #ef4444;
    --glass-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.37);

    /* Dimensions */
    --header-height: 70px;
    --sidebar-width: 260px;
    --radius: 12px;
}

[data-theme="light"] {
    --bg-color: #f8fafc;
    --text-color: #1e293b;
    --text-muted: #64748b;
    --panel-bg: rgba(255, 255, 255, 0.7);
    --panel-border: rgba(203, 213, 225, 0.4);
    --glass-shadow: 0 8px 32px 0 rgba(31, 38, 135, 0.1);
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: 'Inter', sans-serif;
    background-color: var(--bg-color);
    color: var(--text-color);
    overflow: hidden;
    /* App-like feel */
    transition: background-color 0.3s ease;
}

/* Background Shapes */
.bg-shape {
    position: fixed;
    border-radius: 50%;
    filter: blur(80px);
    z-index: -1;
    opacity: 0.4;
}

.shape-1 {
    width: 500px;
    height: 500px;
    background: var(--primary);
    top: -100px;
    left: -100px;
    animation: float 10s infinite alternate;
}

.shape-2 {
    width: 600px;
    height: 600px;
    background: var(--secondary);
    bottom: -100px;
    right: -100px;
    animation: float 12s infinite alternate-reverse;
}

@keyframes float {
    from {
        transform: translate(0, 0);
    }

    to {
        transform: translate(30px, 30px);
    }
}

/* App Container */
.app-container {
    display: flex;
    height: 100vh;
}

/* Glassmorphism Generic */
.glass-panel {
    background: var(--panel-bg);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid var(--panel-border);
    box-shadow: var(--glass-shadow);
}

@media (max-width: 768px) {
    .workspace {
        flex-direction: column;
        height: auto;
    }

    .panel {
        height: 50vh;
    }
}

/* Syntax Highlighting */
#output-highlight {
    width: 100%;
    height: 100%;
    margin: 0;
    padding: 15px;
    background: rgba(0, 0, 0, 0.2);
    border-radius: 12px;
    font-family: 'JetBrains Mono', monospace;
    font-size: 14px;
    color: var(--text-color);
    overflow: auto;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.hidden-editor {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    border: 0;
}

/* Sidebar */
.sidebar {
    width: var(--sidebar-width);
    display: flex;
    flex-direction: column;
    z-index: 100;
}

.brand {
    height: var(--header-height);
    display: flex;
    align-items: center;
    padding: 0 20px;
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-color);
    border-bottom: 1px solid var(--panel-border);
}

.brand-icon {
    color: var(--secondary);
    margin-inline-end: 10px;
}

.nav-menu {
    flex: 1;
    padding: 20px;
    overflow-y: auto;
}

.nav-group {
    margin-bottom: 30px;
}

.group-title {
    font-size: 0.75rem;
    font-weight: 700;
    color: var(--text-muted);
    display: block;
    margin-bottom: 10px;
    letter-spacing: 1px;
}

.nav-item {
    display: flex;
    align-items: center;
    width: 100%;
    padding: 12px 15px;
    margin-bottom: 5px;
    border: none;
    background: transparent;
    color: var(--text-muted);
    font-size: 0.95rem;
    cursor: pointer;
    border-radius: 8px;
    transition: all 0.2s;
    font-family: inherit;
    text-align: start;
}

.nav-item i {
    margin-inline-end: 12px;
    width: 20px;
    text-align: center;
}

.nav-item:hover,
.nav-item.active {
    background: rgba(139, 92, 246, 0.1);
    color: var(--primary);
}

.nav-item.active {
    font-weight: 600;
    border-inline-start: 3px solid var(--primary);
}

.sidebar-footer {
    padding: 20px;
    border-top: 1px solid var(--panel-border);
}

.settings-row {
    display: flex;
    justify-content: space-between;
    margin-top: 10px;
}

.icon-btn {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--panel-border);
    color: var(--text-color);
    padding: 8px;
    border-radius: 8px;
    cursor: pointer;
    transition: 0.2s;
}

.icon-btn:hover {
    background: rgba(255, 255, 255, 0.1);
}

/* Main Content */
.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    position: relative;
    overflow: hidden;
}

/* Header */
.top-bar {
    height: var(--header-height);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 30px;
    margin: 20px 30px 10px 30px;
    border-radius: var(--radius);
}

.top-bar h1 {
    font-size: 1.2rem;
    font-weight: 600;
    margin: 0;
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 15px;
}

.doc-link {
    color: var(--text-muted);
    text-decoration: none;
    font-size: 0.9rem;
    transition: 0.2s;
}

.doc-link:hover {
    color: var(--primary);
}

/* Workspace */
.converter-workspace {
    flex: 1;
    display: flex;
    padding: 20px 30px;
    gap: 20px;
    overflow: hidden;
}

.panel {
    flex: 1;
    display: flex;
    flex-direction: column;
    border-radius: var(--radius);
    overflow: hidden;
}

.panel-header {
    padding: 15px;
    background: rgba(0, 0, 0, 0.1);
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--panel-border);
}

.panel-title {
    font-weight: 600;
    font-size: 0.9rem;
    color: var(--text-muted);
}

.panel-actions {
    display: flex;
    gap: 8px;
}

.sm-btn {
    padding: 5px 10px;
    font-size: 0.75rem;
    border-radius: 4px;
    border: 1px solid var(--panel-border);
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-color);
    cursor: pointer;
}

.sm-btn:hover {
    background: rgba(255, 255, 255, 0.1);
}

.sm-btn.success:hover {
    color: var(--success);
    border-color: var(--success);
}

.sm-btn.danger:hover {
    color: var(--danger);
    border-color: var(--danger);
}

.editor-container {
    flex: 1;
    position: relative;
}

.code-editor {
    width: 100%;
    height: 100%;
    background: transparent;
    border: none;
    color: var(--text-color);
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.9rem;
    padding: 15px;
    resize: none;
    outline: none;
    line-height: 1.5;
}

/* Action Bar (Center Arrow) */
.action-bar {
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.convert-btn {
    background: linear-gradient(135deg, var(--secondary), var(--primary));
    color: white;
    border: none;
    padding: 15px 30px;
    border-radius: 50px;
    font-weight: 600;
    cursor: pointer;
    box-shadow: 0 4px 15px var(--primary);
    transition: transform 0.2s, box-shadow 0.2s;
    font-size: 1rem;
    white-space: nowrap;
}

.convert-btn:hover {
    transform: scale(1.05);
    box-shadow: 0 6px 20px var(--primary-hover);
}

/* Loader */
.loader-overlay {
    position: fixed;
    inset: 0;
    background: var(--bg-color);
    z-index: 9999;
    display: flex;
    justify-content: center;
    align-items: center;
    transition: opacity 0.5s;
    pointer-events: none;
}

.spinner {
    width: 40px;
    height: 40px;
    border: 4px solid rgba(255, 255, 255, 0.1);
    border-left-color: var(--primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    100% {
        transform: rotate(360deg);
    }
}

/* Ad Placeholders */
.ad-slot-sidebar {
    height: 250px;
    background: rgba(255, 255, 255, 0.02);
    margin-bottom: 20px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #444;
    font-size: 0.8rem;
    border: 1px dashed #444;
}

.ad-slot-header {
    width: 320px;
    height: 50px;
    background: rgba(255, 255, 255, 0.02);
    border-radius: 4px;
    display: none;
}

/* Hidden on mobile by default */
.ad-slot-footer {
    height: 90px;
    margin: 0 30px 20px 30px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #555;
    border: 1px dashed #555;
}

/* Mobile Responsive */
.mobile-only {
    display: none;
}

@media (max-width: 900px) {
    .sidebar {
        position: fixed;
        left: -100%;
        top: 0;
        bottom: 0;
        transition: 0.3s;
        background: var(--bg-color);
    }

    .sidebar.open {
        left: 0;
        box-shadow: 10px 0 30px rgba(0, 0, 0, 0.5);
    }

    .mobile-only {
        display: block;
        margin-right: 15px;
    }

    .converter-workspace {
        flex-direction: column;
        overflow-y: auto;
    }

    .action-bar {
        flex-direction: row;
        padding: 10px 0;
    }

    .panel {
        min-height: 300px;
    }

    .top-bar {
        margin: 10px;
        padding: 0 15px;
    }

    .converter-workspace {
        padding: 10px;
        margin-bottom: 60px;
    }

    /* Space for footer ad */
}

/* RTL Support via HTML dir="rtl" attribute */
html[dir="rtl"] {
    direction: rtl;
}

html[dir="rtl"] .brand-icon {
    margin-inline-end: 0;
    margin-inline-start: 10px;
}

html[dir="rtl"] .nav-item i {
    margin-inline-end: 0;
    margin-inline-start: 12px;
}

html[dir="rtl"] .nav-item {
    text-align: right;
}

html[dir="rtl"] .nav-item.active {
    border-inline-start: none;
    border-inline-end: 3px solid var(--primary);
}

html[dir="rtl"] .fa-arrow-right {
    transform: rotate(180deg);
}

/* Navigation Categories */
.nav-group {
    margin-bottom: 2rem;
}

.group-title {
    font-size: 0.75rem;
    letter-spacing: 1.5px;
    opacity: 0.6;
    margin-bottom: 0.8rem;
    display: block;
    padding-left: 1rem;
}

/* Preview Panel */
.preview-panel {
    position: absolute;
    inset: 0;
    padding: 1rem;
    overflow: auto;
    background: rgba(255, 255, 255, 0.95);
    /* Light bg for previewing content */
    color: #333;
    z-index: 10;
    border-radius: 0 0 12px 12px;
}

body.theme-dark .preview-panel {
    background: rgba(15, 23, 42, 0.95);
    color: #e2e8f0;
}

.hidden-panel {
    display: none !important;
}

.hidden-btn {
    display: none !important;
}

/* Preview Content Styling */
.preview-panel img {
    max-width: 100%;
    height: auto;
    display: block;
    margin: 0 auto;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

.preview-panel table {
    width: 100%;
    border-collapse: collapse;
    margin-bottom: 1rem;
}

.preview-panel th,
.preview-panel td {
    border: 1px solid #ccc;
    padding: 0.5rem;
    text-align: left;
}

.preview-panel h1,
.preview-panel h2,
.preview-panel h3 {
    margin-top: 0;
}

body.theme-dark .preview-panel table th,
body.theme-dark .preview-panel table td {
    border-color: #475569;
}

@media (max-width: 768px) {
    .preview-panel {
        position: relative;
        height: 300px;
    }
}