/**
 * Modern Theme - Clean & Refined
 * Minimalist design with better typography and spacing
 */

/* Theme Variables Override */
:root {
    --modern-accent: #2563eb;
    --modern-accent-hover: #1d4ed8;
    --modern-accent-light: #eff6ff;
    --modern-surface: #ffffff;
    --modern-bg: #f8fafc;
    --modern-text: #1e293b;
    --modern-text-secondary: #64748b;
    --modern-border: #e2e8f0;
    --modern-shadow: 0 1px 3px rgba(0, 0, 0, 0.08), 0 1px 2px rgba(0, 0, 0, 0.06);
    --modern-shadow-lg: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -2px rgba(0, 0, 0, 0.1);
}

body {
    background: var(--modern-bg);
    color: var(--modern-text);
}

/* Page Header */
.page-header {
    text-align: center;
    margin-bottom: 2rem;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 1rem;
    flex-wrap: wrap;
}

.page-header h1 {
    font-size: 1.75rem;
    font-weight: 600;
    color: var(--modern-text);
    letter-spacing: -0.025em;
    flex: 1;
    text-align: center;
}

/* Toolbar Theme Switcher - Modern */
.toolbar-theme-switcher {
    position: absolute;
    right: 1.5rem;
}

.toolbar-theme-switcher select {
    background: var(--modern-surface);
    border: 1px solid var(--modern-border);
    color: var(--modern-text);
    padding: 0.5rem 0.875rem;
    border-radius: 8px;
    font-size: 0.8125rem;
    box-shadow: var(--modern-shadow);
}

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

/* Drop Zone - Clean Card Style */
.drop-zone {
    background: var(--modern-surface);
    border: 2px dashed var(--modern-border);
    border-radius: 16px;
    padding: 3rem 2rem;
    text-align: center;
    cursor: pointer;
    transition: all 0.2s ease;
    margin-bottom: 1.5rem;
}

.drop-zone:hover {
    border-color: var(--modern-accent);
    background: var(--modern-accent-light);
}

.drop-zone.active {
    border-color: var(--modern-accent);
    background: var(--modern-accent-light);
    border-style: solid;
}

.drop-zone-icon {
    width: 48px;
    height: 48px;
    margin: 0 auto 1rem;
    color: var(--modern-text-secondary);
}

.drop-zone h2 {
    font-size: 1.125rem;
    font-weight: 500;
    color: var(--modern-text);
    margin-bottom: 0.5rem;
}

.drop-zone p {
    font-size: 0.875rem;
    color: var(--modern-text-secondary);
}

/* File Info Bar - Floating Action Bar */
.file-info {
    background: var(--modern-surface);
    padding: 0.875rem 1.25rem;
    border-radius: 12px;
    margin-bottom: 1.5rem;
    box-shadow: var(--modern-shadow);
    display: none;
    border: 1px solid var(--modern-border);
}

.file-info.show {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.75rem;
}

.file-info .file-name {
    font-weight: 500;
    color: var(--modern-text);
    flex: 1;
    min-width: 200px;
}

.file-info .file-name strong {
    color: var(--modern-accent);
}

.file-info .actions {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

/* Buttons - Modern Style */
.btn-modern {
    display: inline-flex;
    align-items: center;
    gap: 0.375rem;
    padding: 0.5rem 1rem;
    border-radius: 8px;
    font-size: 0.875rem;
    font-weight: 500;
    border: none;
    cursor: pointer;
    transition: all 0.15s ease;
}

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

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

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

.btn-modern.secondary:hover {
    background: var(--modern-border);
}

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

/* Markdown Content - Clean Reading Experience */
.markdown-content {
    background: var(--modern-surface);
    padding: 3rem;
    border-radius: 16px;
    box-shadow: var(--modern-shadow);
    display: none;
    max-width: var(--content-max-width);
    margin: 0 auto;
    border: 1px solid var(--modern-border);
}

.markdown-content.show {
    display: block;
}

/* Typography - Refined */
.markdown-content h1 {
    font-size: 2rem;
    font-weight: 700;
    color: var(--modern-text);
    margin-bottom: 1.5rem;
    padding-bottom: 0.75rem;
    border-bottom: 1px solid var(--modern-border);
    letter-spacing: -0.025em;
    line-height: 1.2;
}

.markdown-content h2 {
    font-size: 1.5rem;
    font-weight: 600;
    color: var(--modern-text);
    margin-top: 2.5rem;
    margin-bottom: 1rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid var(--modern-border);
    letter-spacing: -0.02em;
    line-height: 1.3;
}

.markdown-content h3 {
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--modern-text);
    margin-top: 2rem;
    margin-bottom: 0.75rem;
    line-height: 1.4;
}

.markdown-content h4 {
    font-size: 1.125rem;
    font-weight: 600;
    color: var(--modern-text-secondary);
    margin-top: 1.5rem;
    margin-bottom: 0.5rem;
    line-height: 1.4;
}

.markdown-content p {
    margin-bottom: 1.25rem;
    line-height: 1.75;
    color: var(--modern-text);
}

/* Tables - Clean & Readable */
.markdown-content table {
    width: 100%;
    border-collapse: collapse;
    margin: 1.5rem 0;
    font-size: 0.9375rem;
}

.markdown-content th,
.markdown-content td {
    padding: 0.75rem 1rem;
    text-align: left;
    border-bottom: 1px solid var(--modern-border);
}

.markdown-content th {
    background: var(--modern-bg);
    font-weight: 600;
    color: var(--modern-text);
    font-size: 0.8125rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.markdown-content tr:hover {
    background: var(--modern-accent-light);
}

.markdown-content tr:last-child td {
    border-bottom: none;
}

/* Code - Refined Syntax Block */
.markdown-content code {
    font-family: var(--font-mono);
    font-size: 0.875em;
    background: #f1f5f9;
    padding: 0.2em 0.4em;
    border-radius: 4px;
    color: #be185d;
}

.markdown-content pre {
    background: #0f172a;
    color: #e2e8f0;
    padding: 1.25rem 1.5rem;
    border-radius: 12px;
    overflow-x: auto;
    margin: 1.5rem 0;
    font-size: 0.875rem;
    line-height: 1.6;
}

.markdown-content pre code {
    background: none;
    color: inherit;
    padding: 0;
    font-size: 1em;
}

/* Blockquote - Elegant Callout */
.markdown-content blockquote {
    border-left: 3px solid var(--modern-accent);
    background: var(--modern-accent-light);
    padding: 1rem 1.25rem;
    margin: 1.5rem 0;
    border-radius: 0 8px 8px 0;
    color: var(--modern-text);
    font-style: normal;
}

.markdown-content blockquote p:last-child {
    margin-bottom: 0;
}

/* Lists - Clean Spacing */
.markdown-content ul,
.markdown-content ol {
    margin: 1rem 0;
    padding-left: 1.5rem;
}

.markdown-content li {
    margin: 0.5rem 0;
    line-height: 1.6;
}

.markdown-content li::marker {
    color: var(--modern-accent);
}

/* Links - Subtle Underline */
.markdown-content a {
    color: var(--modern-accent);
    text-decoration: none;
    border-bottom: 1px solid transparent;
    transition: border-color 0.15s ease;
}

.markdown-content a:hover {
    border-bottom-color: var(--modern-accent);
}

/* Horizontal Rule */
.markdown-content hr {
    border: none;
    height: 1px;
    background: var(--modern-border);
    margin: 2.5rem 0;
}

/* Images - Centered with Subtle Shadow */
.markdown-content img {
    max-width: 100%;
    height: auto;
    display: block;
    margin: 2rem auto;
    border-radius: 12px;
    box-shadow: var(--modern-shadow-lg);
}

/* Mermaid Diagrams - Clean Card */
.markdown-content .mermaid {
    background: var(--modern-surface);
    padding: 1.5rem;
    border-radius: 12px;
    margin: 2rem 0;
    border: 1px solid var(--modern-border);
    text-align: center;
    overflow-x: auto;
}

.markdown-content .mermaid svg {
    max-width: 100%;
    height: auto;
}

/* Error Message */
.error {
    background: #fef2f2;
    color: #dc2626;
    padding: 1rem 1.25rem;
    border-radius: 8px;
    margin: 1rem 0;
    display: none;
    border: 1px solid #fecaca;
    font-size: 0.9375rem;
}

.error.show {
    display: block;
}

/* Loading State */
.loading {
    text-align: center;
    padding: 3rem;
    display: none;
}

.loading.show {
    display: block;
}

.loading p {
    margin-top: 1rem;
    color: var(--modern-text-secondary);
    font-size: 0.9375rem;
}

/* Theme Switcher */
/* Floating Theme Switcher - Modern */
.theme-switcher {
    position: fixed;
    bottom: 1.5rem;
    right: 1.5rem;
    z-index: 100;
}

.theme-switcher select {
    padding: 0.5rem 1rem;
    border-radius: 8px;
    border: 1px solid var(--modern-border);
    background: var(--modern-surface);
    font-size: 0.875rem;
    cursor: pointer;
    box-shadow: var(--modern-shadow);
}

/* Mermaid Theme - Modern */
.mermaid {
    background: #f1f5f9;
    border: 1px solid var(--modern-border);
    border-radius: 12px;
}

/* Modern Mermaid Color Overrides */
.mermaid .node rect {
    fill: #dbeafe !important;
    stroke: #3b82f6 !important;
}

.mermaid .node.default > rect {
    fill: #dbeafe !important;
    stroke: #3b82f6 !important;
}

.mermaid .label {
    color: #1e293b !important;
    fill: #1e293b !important;
}

.mermaid .cluster rect {
    fill: #f1f5f9 !important;
    stroke: #94a3b8 !important;
}

.mermaid .edgePath .path {
    stroke: #64748b !important;
}

.mermaid .arrowheadPath {
    fill: #64748b !important;
}

.mermaid .edgeLabel {
    background-color: #ffffff !important;
    color: #1e293b !important;
}

/* Force all Mermaid text to black (prevent white text) */
.mermaid text {
    fill: #1e293b !important;
    color: #1e293b !important;
}

.mermaid .nodeLabel,
.mermaid .node .label,
.mermaid .node text,
.mermaid .cluster text,
.mermaid .cluster .nodeLabel,
.mermaid tspan {
    fill: #1e293b !important;
    color: #1e293b !important;
}

.mermaid .labelText,
.mermaid .label text,
.mermaid .labelBox text,
.mermaid .actor text,
.mermaid .noteText,
.mermaid .messageText,
.mermaid .loopText,
.mermaid .sectionTitle,
.mermaid .taskText {
    fill: #1e293b !important;
    color: #1e293b !important;
}

/* Flowchart specific */
.mermaid .flowchart-label text,
.mermaid .flowchartTitleText {
    fill: #1e293b !important;
}

/* Sequence diagram specific */
.mermaid .sequenceNumber,
.mermaid .activation0,
.mermaid .activation1,
.mermaid .activation2 {
    fill: #1e293b !important;
}

/* Pie chart labels */
.mermaid .slice,
.mermaid .pieCircle text {
    fill: #1e293b !important;
}

/* Gantt chart */
.mermaid .taskTextOutsideRight,
.mermaid .taskTextOutsideLeft {
    fill: #1e293b !important;
}

/* Privacy Notice Banner */
.privacy-notice {
    background: var(--modern-accent-light);
    border: 1px solid #bfdbfe;
    border-radius: 12px;
    padding: 1rem 1.25rem;
    margin-bottom: 1.5rem;
    display: flex;
    align-items: center;
    gap: 1rem;
    font-size: 0.875rem;
    color: var(--modern-text);
}

.privacy-notice p {
    flex: 1;
    margin: 0;
    line-height: 1.5;
}

.privacy-notice button {
    background: var(--modern-accent);
    color: white;
    border: none;
    padding: 0.5rem 1.25rem;
    border-radius: 8px;
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    white-space: nowrap;
    transition: background 0.15s ease;
}

.privacy-notice button:hover {
    background: var(--modern-accent-hover);
}

/* History Section */
.history-section {
    background: var(--modern-surface);
    border: 1px solid var(--modern-border);
    border-radius: 16px;
    padding: 1.25rem 1.5rem;
    margin-bottom: 1.5rem;
    box-shadow: var(--modern-shadow);
}

.history-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    cursor: pointer;
    user-select: none;
    padding: 0.125rem 0;
}

.history-header h3 {
    font-size: 0.9375rem;
    font-weight: 600;
    color: var(--modern-text);
    margin: 0;
}

.history-count {
    font-weight: 400;
    color: var(--modern-text-secondary);
    font-size: 0.8125rem;
}

.history-toggle {
    font-size: 0.75rem;
    color: var(--modern-text-secondary);
    transition: transform 0.2s ease;
    display: inline-block;
}

.history-toggle.collapsed {
    transform: rotate(-90deg);
}

.history-body {
    max-height: 400px;
    overflow: hidden;
    transition: max-height 0.25s ease, opacity 0.2s ease, margin-top 0.25s ease;
    opacity: 1;
    margin-top: 0.75rem;
}

.history-body.collapsed {
    max-height: 0;
    opacity: 0;
    margin-top: 0;
}

.history-list {
    display: flex;
    flex-direction: column;
    gap: 0.375rem;
}

.history-item {
    display: flex;
    align-items: center;
    border-radius: 8px;
    transition: background 0.15s ease;
}

.history-item:hover {
    background: var(--modern-bg);
}

.history-item-info {
    flex: 1;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.625rem 0.75rem;
    cursor: pointer;
    min-width: 0;
}

.history-filename {
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--modern-accent);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.history-date {
    font-size: 0.75rem;
    color: var(--modern-text-secondary);
    white-space: nowrap;
    flex-shrink: 0;
}

.history-delete {
    background: none;
    border: none;
    color: var(--modern-text-secondary);
    font-size: 1.125rem;
    cursor: pointer;
    padding: 0.375rem 0.625rem;
    border-radius: 6px;
    line-height: 1;
    transition: all 0.15s ease;
    flex-shrink: 0;
}

.history-delete:hover {
    background: #fef2f2;
    color: #dc2626;
}

/* Mobile Responsive - Modern */
@media (max-width: 768px) {
    .drop-zone {
        padding: 2rem 1.5rem;
        border-radius: 12px;
    }

    .markdown-content {
        padding: 1.5rem;
        border-radius: 12px;
    }

    .markdown-content h1 {
        font-size: 1.5rem;
    }

    .markdown-content h2 {
        font-size: 1.25rem;
        margin-top: 2rem;
    }

    .markdown-content pre {
        padding: 1rem;
        border-radius: 8px;
        font-size: 0.8125rem;
    }

    .file-info.show {
        flex-direction: column;
        align-items: stretch;
    }

    .file-info .actions {
        justify-content: center;
    }

    .privacy-notice {
        flex-direction: column;
        text-align: center;
    }

    .history-item-info {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.25rem;
    }
}

@media (max-width: 480px) {
    .container {
        padding: 1rem;
    }

    .drop-zone {
        padding: 1.5rem 1rem;
    }

    .drop-zone h2 {
        font-size: 1rem;
    }

    .markdown-content {
        padding: 1rem;
    }

    .markdown-content h1 {
        font-size: 1.375rem;
    }

    .markdown-content h2 {
        font-size: 1.125rem;
    }

    .markdown-content table {
        font-size: 0.8125rem;
    }

    .markdown-content th,
    .markdown-content td {
        padding: 0.5rem 0.75rem;
    }

    .btn-modern {
        padding: 0.625rem 0.875rem;
        font-size: 0.8125rem;
    }

    .theme-switcher {
        bottom: 1rem;
        right: 1rem;
    }
}

/* Print Styles */
@media print {
    .drop-zone,
    .file-info,
    .theme-switcher,
    .progress-overlay,
    .history-section,
    .privacy-notice {
        display: none !important;
    }

    .markdown-content {
        box-shadow: none;
        border: none;
        padding: 0;
        max-width: 100%;
    }

    .markdown-content pre {
        background: #f8f8f8;
        color: #333;
    }
}
