/* Reset & Base Styles */
:root {
    /* Light Theme */
    --primary: #2563eb;
    --primary-hover: #1d4ed8;
    --secondary: #64748b;
    --success: #10b981;
    --danger: #ef4444;
    --warning: #f59e0b;
    
    --bg-primary: #ffffff;
    --bg-secondary: #f8fafc;
    --bg-tertiary: #f1f5f9;
    --bg-code: #1e293b;
    --bg-ad: #f8fafc;
    
    --text-primary: #1e293b;
    --text-secondary: #64748b;
    --text-tertiary: #94a3b8;
    
    --border: #e2e8f0;
    --border-hover: #cbd5e1;
    
    --shadow-sm: 0 1px 2px 0 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);
    
    --radius-sm: 6px;
    --radius-md: 8px;
    --radius-lg: 12px;
    
    --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    --font-mono: 'JetBrains Mono', 'Courier New', monospace;
}

.dark-theme {
    --primary: #3b82f6;
    --primary-hover: #2563eb;
    
    --bg-primary: #0f172a;
    --bg-secondary: #1e293b;
    --bg-tertiary: #334155;
    --bg-code: #0a0f1a;
    --bg-ad: #1e293b;
    
    --text-primary: #f1f5f9;
    --text-secondary: #cbd5e1;
    --text-tertiary: #94a3b8;
    
    --border: #475569;
    --border-hover: #64748b;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: var(--font-sans);
    background-color: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.5;
    min-height: 100vh;
    transition: background-color 0.3s ease;
}

.container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 20px;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* Header */
.header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 0;
    margin-bottom: 24px;
    border-bottom: 1px solid var(--border);
}

.logo {
    display: flex;
    align-items: center;
    gap: 12px;
}

.logo i {
    font-size: 28px;
    color: var(--primary);
}

.logo h1 {
    font-size: 20px;
    font-weight: 700;
    margin-bottom: 4px;
}

.logo .subtitle {
    font-size: 13px;
    color: var(--text-secondary);
}

.nav {
    display: flex;
    align-items: center;
    gap: 12px;
}

.nav-link {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
    background: var(--bg-secondary);
    color: var(--text-primary);
    text-decoration: none;
    border-radius: var(--radius-sm);
    font-size: 14px;
    font-weight: 500;
    border: 1px solid var(--border);
    transition: all 0.2s ease;
}

.nav-link:hover {
    background: var(--bg-tertiary);
    border-color: var(--border-hover);
}

.theme-btn {
    width: 40px;
    height: 40px;
    border-radius: var(--radius-sm);
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    color: var(--text-primary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    transition: all 0.2s ease;
}

.theme-btn:hover {
    background: var(--bg-tertiary);
    border-color: var(--border-hover);
}

/* Main Content - Fixed Height Columns */
.main-content {
    flex: 1;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 24px;
    margin-bottom: 32px;
    min-height: 0;
}

@media (max-width: 1024px) {
    .main-content {
        grid-template-columns: 1fr;
        gap: 32px;
    }
}

/* Columns - Fixed Height */
.column {
    display: flex;
    flex-direction: column;
    gap: 20px;
    height: 620px; /* Fixed height */
}

/* Panels - Fixed Height with Scroll */
.panel {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    overflow: hidden;
    display: flex;
    flex-direction: column;
    flex: 1;
    min-height: 0;
}

.panel-header {
    padding: 16px 20px;
    background: var(--bg-tertiary);
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-shrink: 0;
}

.panel-header h2 {
    font-size: 16px;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 8px;
}

/* Tabs */
.tabs {
    display: flex;
    gap: 4px;
    background: var(--bg-primary);
    border-radius: var(--radius-sm);
    padding: 4px;
    border: 1px solid var(--border);
}

.tab-btn {
    padding: 6px 16px;
    background: transparent;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 13px;
    font-weight: 500;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.2s ease;
    white-space: nowrap;
}

.tab-btn:hover {
    color: var(--primary);
    background: var(--bg-tertiary);
}

.tab-btn.active {
    background: var(--primary);
    color: white;
}

.panel-actions {
    display: flex;
    gap: 8px;
}

.btn-icon {
    width: 32px;
    height: 32px;
    border-radius: var(--radius-sm);
    background: var(--bg-primary);
    border: 1px solid var(--border);
    color: var(--text-secondary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 13px;
    transition: all 0.2s ease;
}

.btn-icon:hover:not(:disabled) {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
}

.btn-icon:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Panel Body - Fixed Height with Scroll */
.panel-body {
    flex: 1;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    min-height: 0;
}

/* Editor Area */
.textarea-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 0;
    overflow: hidden;
}

textarea {
    flex: 1;
    padding: 20px;
    background: var(--bg-primary);
    border: none;
    resize: none;
    font-family: var(--font-mono);
    font-size: 13px;
    line-height: 1.6;
    color: var(--text-primary);
    outline: none;
    overflow-y: auto;
}

textarea:focus {
    background: var(--bg-secondary);
}

textarea::placeholder {
    color: var(--text-tertiary);
}

.textarea-info {
    padding: 12px 20px;
    border-top: 1px solid var(--border);
    background: var(--bg-tertiary);
    font-size: 12px;
    color: var(--text-secondary);
    flex-shrink: 0;
}

/* Panel Footer */
.panel-footer {
    padding: 16px 20px;
    border-top: 1px solid var(--border);
    background: var(--bg-tertiary);
    flex-shrink: 0;
}

.conversion-controls {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.options {
    display: flex;
    gap: 20px;
    flex-wrap: wrap;
}

.checkbox {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    font-size: 13px;
    color: var(--text-secondary);
}

.checkbox input {
    display: none;
}

.checkmark {
    width: 16px;
    height: 16px;
    border: 2px solid var(--border);
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

.checkbox input:checked + .checkmark {
    background: var(--primary);
    border-color: var(--primary);
}

.checkmark:after {
    content: '';
    width: 4px;
    height: 8px;
    border: solid white;
    border-width: 0 2px 2px 0;
    transform: rotate(45deg);
    opacity: 0;
}

.checkbox input:checked + .checkmark:after {
    opacity: 1;
}

.convert-btn {
    width: 100%;
    padding: 12px;
    background: var(--primary);
    color: white;
    border: none;
    border-radius: var(--radius-md);
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: all 0.2s ease;
}

.convert-btn:hover {
    background: var(--primary-hover);
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
}

/* Code Output */
.code-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 0;
    overflow: hidden;
}

.code-header {
    padding: 12px 20px;
    background: var(--bg-tertiary);
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 12px;
    color: var(--text-secondary);
    flex-shrink: 0;
}

.code-content {
    flex: 1;
    overflow: auto;
    background: var(--bg-code);
}

pre {
    padding: 20px;
    margin: 0;
    font-family: var(--font-mono);
    font-size: 12px;
    line-height: 1.5;
    color: #e2e8f0;
    white-space: pre-wrap;
    word-wrap: break-word;
    min-height: 100%;
}

code {
    font-family: inherit;
    color: inherit;
}

/* Preview */
.preview-container {
    flex: 1;
    overflow: hidden;
    background: white;
}

iframe {
    width: 100%;
    height: 100%;
    border: none;
    background: white;
}

/* Tab Content */
.tab-content {
    flex: 1;
    display: none;
    flex-direction: column;
    min-height: 0;
    overflow: hidden;
}

.tab-content.active {
    display: flex;
}

/* Reset Button */
.reset-btn {
    width: 100%;
    padding: 12px;
    background: var(--bg-primary);
    color: var(--text-primary);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: all 0.2s ease;
}

.reset-btn:hover {
    background: var(--bg-tertiary);
    border-color: var(--border-hover);
}

/* Quick Guide */
.quick-guide {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 16px;
    flex-shrink: 0;
}

.quick-guide h3 {
    font-size: 14px;
    font-weight: 600;
    margin-bottom: 12px;
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--text-primary);
}

.guide-items {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 8px;
}

.guide-item {
    background: var(--bg-primary);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 8px 12px;
    transition: all 0.2s ease;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.guide-item:hover {
    border-color: var(--primary);
}

.guide-item code {
    font-family: var(--font-mono);
    font-size: 12px;
    color: var(--primary);
    font-weight: 500;
    word-break: break-all;
}

.guide-item span {
    font-size: 11px;
    color: var(--text-tertiary);
}

/* Ad Space */
.ad-space {
    background: var(--bg-ad);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 16px;
    flex-shrink: 0;
    height: 300px; /* Fixed height for ad */
    display: flex;
    flex-direction: column;
}

.ad-label {
    text-align: center;
    margin-bottom: 12px;
}

.ad-label span {
    font-size: 11px;
    color: var(--text-tertiary);
    text-transform: uppercase;
    letter-spacing: 1px;
}

.ad-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: var(--bg-primary);
    border-radius: var(--radius-md);
    border: 1px dashed var(--border);
    color: var(--text-secondary);
    font-size: 13px;
    text-align: center;
    padding: 20px;
}

.ad-content p {
    margin-bottom: 4px;
}

/* Footer */
.footer {
    margin-top: 32px;
    padding-top: 24px;
    border-top: 1px solid var(--border);
}

.footer-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
    flex-wrap: wrap;
    gap: 16px;
}

.footer-info p {
    font-size: 13px;
    color: var(--text-secondary);
    margin-bottom: 4px;
}

.footer-info a {
    color: var(--primary);
    text-decoration: none;
}

.footer-info a:hover {
    text-decoration: underline;
}

.footer-links {
    display: flex;
    gap: 16px;
}

.footer-links a {
    font-size: 13px;
    color: var(--text-secondary);
    text-decoration: none;
}

.footer-links a:hover {
    color: var(--primary);
}

.copyright {
    text-align: center;
    padding-top: 16px;
    border-top: 1px solid var(--border);
    font-size: 12px;
    color: var(--text-tertiary);
}

/* Toast Notification */
.toast {
    position: fixed;
    bottom: 24px;
    right: 24px;
    background: var(--success);
    color: white;
    padding: 12px 20px;
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    display: flex;
    align-items: center;
    gap: 8px;
    transform: translateY(100px);
    opacity: 0;
    transition: all 0.3s ease;
    z-index: 1000;
    pointer-events: none;
}

.toast.show {
    transform: translateY(0);
    opacity: 1;
}

.toast-content i {
    font-size: 16px;
}

/* Scrollbar Styling */
textarea::-webkit-scrollbar,
.code-content::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

textarea::-webkit-scrollbar-track,
.code-content::-webkit-scrollbar-track {
    background: transparent;
}

textarea::-webkit-scrollbar-thumb,
.code-content::-webkit-scrollbar-thumb {
    background: var(--primary);
    border-radius: 4px;
}

textarea::-webkit-scrollbar-thumb:hover,
.code-content::-webkit-scrollbar-thumb:hover {
    background: var(--primary-hover);
}

/* Responsive */
@media (max-width: 768px) {
    .container {
        padding: 16px;
    }
    
    .header {
        flex-direction: column;
        gap: 16px;
        text-align: center;
    }
    
    .logo {
        flex-direction: column;
        text-align: center;
    }
    
    .nav {
        width: 100%;
        justify-content: center;
    }
    
    .main-content {
        gap: 24px;
    }
    
    .column {
        height: auto;
        min-height: 500px;
    }
    
    .panel-header {
        flex-direction: column;
        align-items: stretch;
        gap: 12px;
    }
    
    .tabs {
        width: 100%;
    }
    
    .tab-btn {
        flex: 1;
        text-align: center;
    }
    
    .panel-actions {
        width: 100%;
        justify-content: center;
    }
    
    .footer-content {
        flex-direction: column;
        text-align: center;
        gap: 12px;
    }
    
    .footer-links {
        justify-content: center;
    }
    
    .toast {
        left: 16px;
        right: 16px;
        bottom: 16px;
        text-align: center;
        justify-content: center;
    }
}

@media (max-width: 480px) {
    .guide-items {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .options {
        flex-direction: column;
        gap: 12px;
    }
}