/* md2PDF Web - Modern Dark Theme */

:root {
    --bg-primary: #0a0f1a;
    --bg-secondary: #111827;
    --bg-tertiary: #1f2937;
    --bg-elevated: #252f3f;
    
    --text-primary: #f9fafb;
    --text-secondary: #9ca3af;
    --text-muted: #6b7280;
    
    --accent-blue: #3b82f6;
    --accent-blue-light: #60a5fa;
    --accent-red: #d62229;
    --accent-red-light: #ef4444;
    --accent-green: #10b981;
    
    --border-color: #374151;
    --border-subtle: #1f2937;
    
    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 14px;
    
    --shadow-sm: 0 1px 2px rgba(0,0,0,0.3);
    --shadow-md: 0 4px 12px rgba(0,0,0,0.4);
    --shadow-lg: 0 10px 40px rgba(0,0,0,0.5);
    
    --font-sans: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    --font-mono: 'JetBrains Mono', 'SF Mono', 'Monaco', monospace;
    
    --header-height: 64px;
    --sidebar-width: 240px;
}

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

html, body {
    height: 100%;
    font-family: var(--font-sans);
    background: var(--bg-primary);
    color: var(--text-primary);
    overflow: hidden;
}

/* ========== Layout ========== */

.app-container {
    display: flex;
    flex-direction: column;
    height: 100vh;
    background: linear-gradient(135deg, var(--bg-primary) 0%, #0f172a 100%);
}

/* ========== Header ========== */

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

.logo {
    display: flex;
    align-items: center;
    gap: 12px;
}

.logo-icon {
    width: 36px;
    height: 36px;
}

.logo-icon svg {
    width: 100%;
    height: 100%;
}

.logo-text {
    font-size: 1.4rem;
    font-weight: 700;
    background: linear-gradient(135deg, var(--accent-blue) 0%, var(--accent-blue-light) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.logo-subtitle {
    font-size: 0.75rem;
    color: var(--text-muted);
    font-weight: 500;
    padding-left: 12px;
    border-left: 1px solid var(--border-color);
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 8px;
}

.divider {
    width: 1px;
    height: 24px;
    background: var(--border-color);
    margin: 0 8px;
}

/* ========== Buttons ========== */

.btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 18px;
    border: none;
    border-radius: var(--radius-md);
    font-family: var(--font-sans);
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
}

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

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

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

.btn-primary {
    background: linear-gradient(135deg, var(--accent-red) 0%, var(--accent-red-light) 100%);
    color: white;
    box-shadow: 0 4px 14px rgba(214, 34, 41, 0.4);
}

.btn-primary:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 20px rgba(214, 34, 41, 0.5);
}

.btn-primary:active {
    transform: translateY(0);
}

/* ========== Main Content ========== */

.main-content {
    display: flex;
    flex: 1;
    overflow: hidden;
}

/* ========== Sidebar ========== */

.sidebar {
    width: var(--sidebar-width);
    background: var(--bg-secondary);
    border-right: 1px solid var(--border-color);
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 24px;
    overflow-y: auto;
    flex-shrink: 0;
}

.sidebar-section h3 {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 10px;
}

.select, .input {
    width: 100%;
    padding: 10px 12px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-family: var(--font-sans);
    font-size: 0.9rem;
    outline: none;
    transition: border-color 0.2s;
}

.select:focus, .input:focus {
    border-color: var(--accent-blue);
}

.size-control {
    display: flex;
    align-items: center;
    gap: 12px;
}

.slider {
    flex: 1;
    -webkit-appearance: none;
    height: 6px;
    background: var(--bg-tertiary);
    border-radius: 3px;
    outline: none;
}

.slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 18px;
    height: 18px;
    background: var(--accent-blue);
    border-radius: 50%;
    cursor: pointer;
    box-shadow: var(--shadow-sm);
}

.size-value {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--accent-blue);
    min-width: 36px;
}

.sidebar-help {
    margin-top: auto;
}

.help-items {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.help-items code {
    display: block;
    padding: 6px 10px;
    background: var(--bg-tertiary);
    border-radius: var(--radius-sm);
    font-family: var(--font-mono);
    font-size: 0.75rem;
    color: var(--text-secondary);
}

/* ========== Workspace ========== */

.workspace {
    flex: 1;
    display: flex;
    gap: 1px;
    background: var(--border-color);
    padding: 16px;
    padding-left: 0;
}

.panel {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: var(--bg-secondary);
    border-radius: var(--radius-lg);
    overflow: hidden;
    box-shadow: var(--shadow-md);
}

.panel-header {
    height: 44px;
    padding: 0 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: var(--bg-tertiary);
    border-bottom: 1px solid var(--border-color);
    flex-shrink: 0;
}

.panel-title {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-secondary);
}

.panel-title svg {
    color: var(--accent-blue);
}

.char-count {
    font-size: 0.75rem;
    color: var(--text-muted);
    font-family: var(--font-mono);
}

/* ========== Editor ========== */

.editor-panel {
    margin-right: 8px;
}

.editor {
    flex: 1;
    padding: 20px;
    background: var(--bg-secondary);
    border: none;
    color: var(--text-primary);
    font-family: var(--font-mono);
    font-size: 0.95rem;
    line-height: 1.7;
    resize: none;
    outline: none;
}

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

/* ========== Preview ========== */

.preview-panel {
    margin-left: 8px;
}

.preview {
    flex: 1;
    padding: 24px 28px;
    background: #ffffff;
    color: #1a1a1a;
    overflow-y: auto;
    font-family: 'Georgia', serif;
    font-size: 11pt;
    line-height: 1.6;
}

.preview h1 {
    font-family: 'Helvetica Neue', sans-serif;
    font-size: 22pt;
    border-bottom: 2px solid #333;
    padding-bottom: 8px;
    margin-bottom: 16px;
    color: #111;
}

.preview h2 {
    font-family: 'Helvetica Neue', sans-serif;
    font-size: 14pt;
    border-bottom: 1px solid #ccc;
    padding-bottom: 4px;
    margin-top: 24px;
    margin-bottom: 12px;
    color: #222;
}

.preview h3 {
    font-family: 'Helvetica Neue', sans-serif;
    font-size: 12pt;
    margin-top: 18px;
    margin-bottom: 8px;
    color: #333;
}

.preview p {
    margin-bottom: 10px;
}

.preview ul, .preview ol {
    margin: 10px 0;
    padding-left: 24px;
}

.preview li {
    margin-bottom: 4px;
}

.preview code {
    font-family: var(--font-mono);
    font-size: 0.85em;
    background: #f5f5f5;
    padding: 2px 6px;
    border-radius: 3px;
    color: #d14;
}

.preview pre {
    background: #f8f8f8;
    border: 1px solid #e0e0e0;
    border-left: 3px solid #666;
    padding: 12px 16px;
    margin: 12px 0;
    overflow-x: auto;
    border-radius: 4px;
}

.preview pre code {
    background: none;
    padding: 0;
    color: inherit;
}

.preview blockquote {
    margin: 16px 0;
    padding: 10px 16px;
    border-left: 4px solid #ddd;
    background: #fafafa;
    font-style: italic;
    color: #555;
}

.preview table {
    width: 100%;
    border-collapse: collapse;
    margin: 16px 0;
    font-size: 0.9em;
}

.preview th {
    background: #f5f5f5;
    font-weight: 600;
    text-align: left;
    padding: 8px 10px;
    border: 1px solid #ccc;
}

.preview td {
    padding: 6px 10px;
    border: 1px solid #ddd;
}

.preview tr:nth-child(even) {
    background: #fafafa;
}

.preview a {
    color: #0066cc;
}

.preview hr {
    border: none;
    border-top: 1px solid #ddd;
    margin: 24px 0;
}

/* ========== Toast ========== */

.toast {
    position: fixed;
    bottom: 24px;
    left: 50%;
    transform: translateX(-50%) translateY(100px);
    padding: 14px 24px;
    background: var(--bg-elevated);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    font-weight: 500;
    box-shadow: var(--shadow-lg);
    opacity: 0;
    transition: all 0.3s ease;
    z-index: 1000;
}

.toast.show {
    transform: translateX(-50%) translateY(0);
    opacity: 1;
}

.toast.success {
    border-color: var(--accent-green);
    background: linear-gradient(135deg, var(--bg-elevated) 0%, rgba(16, 185, 129, 0.1) 100%);
}

.toast.error {
    border-color: var(--accent-red);
    background: linear-gradient(135deg, var(--bg-elevated) 0%, rgba(214, 34, 41, 0.1) 100%);
}

/* ========== Loading Overlay ========== */

.loading-overlay {
    position: fixed;
    inset: 0;
    background: rgba(10, 15, 26, 0.9);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 16px;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
    z-index: 2000;
}

.loading-overlay.show {
    opacity: 1;
    visibility: visible;
}

.loading-spinner {
    width: 48px;
    height: 48px;
    border: 3px solid var(--border-color);
    border-top-color: var(--accent-blue);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

.loading-overlay p {
    color: var(--text-secondary);
    font-weight: 500;
}

/* ========== Responsive ========== */

@media (max-width: 1024px) {
    .sidebar {
        width: 200px;
    }
    
    .logo-subtitle {
        display: none;
    }
}

@media (max-width: 768px) {
    .sidebar {
        display: none;
    }
    
    .workspace {
        padding: 8px;
        flex-direction: column;
    }
    
    .panel {
        min-height: 40vh;
    }
    
    .editor-panel {
        margin-right: 0;
        margin-bottom: 8px;
    }
    
    .preview-panel {
        margin-left: 0;
    }
}
