/**
 * Markdown Viewer - Common Styles
 * Shared variables, reset, and utilities
 */

/* CSS Variables */
:root {
    /* Colors - Light Mode */
    --bg-primary: #f5f5f5;
    --bg-secondary: #ffffff;
    --bg-tertiary: #f8f9fa;
    --text-primary: #333333;
    --text-secondary: #666666;
    --text-muted: #999999;
    --accent-color: #4CAF50;
    --accent-hover: #45a049;
    --accent-light: #f0f8f0;
    --border-color: #e0e0e0;
    --border-light: #eeeeee;
    --shadow-light: rgba(0, 0, 0, 0.1);
    --shadow-medium: rgba(0, 0, 0, 0.15);

    /* Editor Colors (Dark) */
    --editor-bg: #1e1e1e;
    --editor-surface: #2d2d2d;
    --editor-border: #404040;
    --editor-text: #d4d4d4;
    --editor-text-muted: #888888;

    /* Typography */
    --font-sans: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Helvetica Neue', Arial, sans-serif;
    --font-mono: 'Monaco', 'Menlo', 'Ubuntu Mono', 'Consolas', monospace;
    --font-emoji: 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol';

    /* Spacing */
    --space-xs: 4px;
    --space-sm: 8px;
    --space-md: 16px;
    --space-lg: 24px;
    --space-xl: 32px;
    --space-xxl: 48px;

    /* Border Radius */
    --radius-sm: 4px;
    --radius-md: 8px;
    --radius-lg: 12px;
    --radius-xl: 16px;

    /* Transitions */
    --transition-fast: 0.15s ease;
    --transition-normal: 0.3s ease;

    /* Content Width */
    --content-max-width: 900px;
    --container-max-width: 1200px;
}

/* Reset */
*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    font-size: 16px;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

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

/* Utilities */
.container {
    max-width: var(--container-max-width);
    margin: 0 auto;
    padding: var(--space-lg);
}

.hidden {
    display: none !important;
}

.show {
    display: block !important;
}

/* Spinner Animation */
@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.spinner {
    border: 4px solid var(--border-light);
    border-top: 4px solid var(--accent-color);
    border-radius: 50%;
    width: 40px;
    height: 40px;
    animation: spin 1s linear infinite;
}

/* Button Base */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-sm);
    padding: var(--space-sm) var(--space-md);
    border: none;
    border-radius: var(--radius-sm);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition-fast);
    white-space: nowrap;
}

.btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

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

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

.btn-secondary {
    background: #6366f1;
    color: white;
}

.btn-secondary:hover:not(:disabled) {
    background: #5558e3;
}

.btn-ghost {
    background: transparent;
    color: var(--text-secondary);
}

.btn-ghost:hover:not(:disabled) {
    background: var(--bg-tertiary);
}

/* Progress Overlay */
.progress-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    display: none;
    justify-content: center;
    align-items: center;
    z-index: 9999;
}

.progress-overlay.show {
    display: flex;
}

.progress-box {
    background: white;
    padding: var(--space-xl) var(--space-xxl);
    border-radius: var(--radius-xl);
    text-align: center;
    box-shadow: 0 10px 40px var(--shadow-medium);
}

.progress-box .spinner {
    width: 60px;
    height: 60px;
    border-width: 5px;
    margin: 0 auto var(--space-lg);
}

.progress-box h3 {
    color: var(--text-primary);
    margin-bottom: var(--space-sm);
    font-size: 18px;
}

.progress-box p {
    color: var(--text-secondary);
    font-size: 14px;
}

/* Page Header with Toolbar */
.page-header {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-md);
    flex-wrap: wrap;
}

.toolbar-theme-switcher {
    display: none;
    align-items: center;
    gap: var(--space-sm);
}

.toolbar-theme-switcher select {
    padding: 6px 12px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    background: var(--bg-secondary);
    color: var(--text-primary);
    font-size: 13px;
    cursor: pointer;
    transition: border-color var(--transition-fast);
}

.toolbar-theme-switcher select:hover {
    border-color: var(--accent-color);
}

/* Mermaid Unified Styles */
.mermaid {
    display: flex;
    justify-content: center;
    margin: var(--space-lg) 0;
    padding: var(--space-md);
    background: var(--bg-tertiary);
    border-radius: var(--radius-md);
    overflow-x: auto;
}

/* Mermaid Node Sizes - Unified */
.mermaid .node rect,
.mermaid .node circle,
.mermaid .node ellipse,
.mermaid .node polygon,
.mermaid .node path {
    stroke-width: 2px !important;
}

/* Flowchart node sizing */
.mermaid .flowchart-link {
    stroke-width: 2px !important;
}

.mermaid .node .label {
    font-size: 14px !important;
    font-weight: 500 !important;
}

/* Ensure minimum node dimensions */
.mermaid .node rect {
    rx: 6px !important;
    ry: 6px !important;
}

/* Cluster (subgraph) styling */
.mermaid .cluster rect {
    rx: 8px !important;
    ry: 8px !important;
    stroke-width: 2px !important;
}

.mermaid .cluster .cluster-label .nodeLabel {
    font-size: 14px !important;
    font-weight: 600 !important;
}

/* Edge labels */
.mermaid .edgeLabel {
    font-size: 12px !important;
    background: var(--bg-secondary) !important;
    padding: 2px 6px !important;
    border-radius: 4px !important;
}

/* Sequence diagram */
.mermaid .actor {
    stroke-width: 2px !important;
}

.mermaid .actor-line {
    stroke-width: 1px !important;
}

.mermaid .messageLine0,
.mermaid .messageLine1 {
    stroke-width: 1.5px !important;
}

/* Pie chart */
.mermaid .pieTitleText {
    font-size: 16px !important;
    font-weight: 600 !important;
}

.mermaid .slice {
    stroke-width: 2px !important;
}

/* Gantt chart */
.mermaid .taskText {
    font-size: 12px !important;
}

.mermaid .sectionTitle {
    font-size: 14px !important;
    font-weight: 600 !important;
}

/* Responsive Breakpoints */
@media (max-width: 1024px) {
    :root {
        --container-max-width: 100%;
    }

    .container {
        padding: var(--space-md);
    }
}

@media (max-width: 768px) {
    :root {
        --space-lg: 16px;
        --space-xl: 24px;
    }

    html {
        font-size: 15px;
    }
}

@media (max-width: 480px) {
    html {
        font-size: 14px;
    }

    .container {
        padding: var(--space-sm);
    }
}
