/* Markdown Formatter & Previewer Styles */

/* ===== Base Styles ===== */
.markdown-formatter {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

/* ===== Toolbar Styles ===== */
.toolbar-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.5rem;
    border: 1px solid transparent;
    border-radius: 0.375rem;
    background-color: transparent;
    color: #374151;
    transition: all 0.15s ease-in-out;
    cursor: pointer;
    position: relative;
}

.toolbar-btn:hover {
    background-color: #f3f4f6;
    color: #111827;
}

.toolbar-btn:active,
.toolbar-btn.active {
    background-color: #e5e7eb;
    color: #1f2937;
}

.toolbar-btn:focus {
    outline: none;
    box-shadow: 0 0 0 2px #3b82f6;
}

/* Dropdown Styles */
.dropdown-trigger {
    position: relative;
}

.dropdown-menu {
    position: absolute;
    top: 100%;
    left: 0;
    min-width: 12rem;
    background: white;
    border: 1px solid #d1d5db;
    border-radius: 0.375rem;
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
    z-index: 50;
}

.dropdown-item {
    display: block;
    width: 100%;
    padding: 0.5rem 0.75rem;
    text-align: left;
    color: #374151;
    background: none;
    border: none;
    cursor: pointer;
    transition: background-color 0.15s ease-in-out;
    pointer-events: auto;
    font-size: 0.875rem;
    white-space: nowrap;
}

.dropdown-item:hover {
    background-color: #f3f4f6;
}

.dropdown-item:first-child {
    border-top-left-radius: 0.375rem;
    border-top-right-radius: 0.375rem;
}

.dropdown-item:last-child {
    border-bottom-left-radius: 0.375rem;
    border-bottom-right-radius: 0.375rem;
}

/* ===== Editor Container ===== */
.editor-container {
    display: flex;
    height: 70vh;
    min-height: 500px;
    border: 1px solid #e5e7eb;
    border-radius: 0.5rem;
    overflow: hidden;
}

.editor-pane,
.preview-pane {
    display: flex;
    flex-direction: column;
    background: white;
    min-width: 300px;
}

.editor-pane {
    flex: 1;
    border-right: 1px solid #e5e7eb;
}

.preview-pane {
    flex: 1;
}

/* Pane Headers */
.pane-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.75rem 1rem;
    background: #f9fafb;
    border-bottom: 1px solid #e5e7eb;
}

.pane-title {
    font-size: 0.875rem;
    font-weight: 600;
    color: #374151;
    margin: 0;
}

.pane-controls {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.pane-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

/* ===== Editor Styles ===== */
.editor-textarea {
    flex: 1;
    width: 100%;
    padding: 1rem;
    border: none;
    outline: none;
    resize: none;
    font-family: "SF Mono", "Monaco", "Inconsolata", "Roboto Mono", "Source Code Pro", monospace;
    font-size: 0.875rem;
    line-height: 1.5;
    color: #1f2937;
    background: white;
    tab-size: 2;
}

.editor-textarea::placeholder {
    color: #9ca3af;
}

.editor-textarea:focus {
    outline: none;
    box-shadow: inset 0 0 0 1px #3b82f6;
}

/* Editor Stats */
#editor-stats {
    font-family: monospace;
    font-size: 0.75rem;
}

/* ===== Resizer ===== */
.resizer {
    width: 4px;
    background: #e5e7eb;
    cursor: col-resize;
    position: relative;
    transition: background-color 0.15s ease-in-out;
}

.resizer:hover {
    background: #9ca3af;
}

.resizer:active {
    background: #6b7280;
}

.resizer::before {
    content: "";
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 2px;
    height: 20px;
    background: white;
    border-radius: 1px;
}

/* ===== Preview Styles ===== */
.preview-content {
    flex: 1;
    padding: 1rem;
    overflow-y: auto;
    background: white;
}

.preview-placeholder {
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* ===== Markdown Preview Styles ===== */
#markdown-preview {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    line-height: 1.6;
    color: #1f2937;
}

#markdown-preview h1 {
    font-size: 2rem;
    font-weight: 700;
    margin: 0 0 1rem 0;
    padding-bottom: 0.5rem;
    border-bottom: 2px solid #e5e7eb;
    color: #111827;
}

#markdown-preview h2 {
    font-size: 1.5rem;
    font-weight: 600;
    margin: 1.5rem 0 1rem 0;
    padding-bottom: 0.25rem;
    border-bottom: 1px solid #e5e7eb;
    color: #111827;
}

#markdown-preview h3 {
    font-size: 1.25rem;
    font-weight: 600;
    margin: 1.25rem 0 0.75rem 0;
    color: #111827;
}

#markdown-preview h4 {
    font-size: 1.125rem;
    font-weight: 600;
    margin: 1rem 0 0.5rem 0;
    color: #111827;
}

#markdown-preview h5 {
    font-size: 1rem;
    font-weight: 600;
    margin: 1rem 0 0.5rem 0;
    color: #111827;
}

#markdown-preview h6 {
    font-size: 0.875rem;
    font-weight: 600;
    margin: 1rem 0 0.5rem 0;
    color: #6b7280;
}

#markdown-preview p {
    margin: 0 0 1rem 0;
}

#markdown-preview ul,
#markdown-preview ol {
    margin: 0 0 1rem 0;
    padding-left: 2rem;
}

#markdown-preview li {
    margin: 0.25rem 0;
}

#markdown-preview blockquote {
    margin: 1rem 0;
    padding: 0.75rem 1rem;
    border-left: 4px solid #e5e7eb;
    background: #f9fafb;
    color: #6b7280;
    font-style: italic;
}

#markdown-preview blockquote p {
    margin: 0;
}

#markdown-preview code {
    padding: 0.125rem 0.25rem;
    background: #f3f4f6;
    color: #dc2626;
    border-radius: 0.25rem;
    font-family: "SF Mono", "Monaco", "Inconsolata", "Roboto Mono", "Source Code Pro", monospace;
    font-size: 0.875em;
}

#markdown-preview pre {
    margin: 1rem 0;
    padding: 1rem;
    background: #f9fafb;
    border: 1px solid #e5e7eb;
    border-radius: 0.5rem;
    overflow-x: auto;
}

#markdown-preview pre code {
    padding: 0;
    background: none;
    color: inherit;
    border-radius: 0;
}

#markdown-preview table {
    width: 100%;
    margin: 1rem 0;
    border-collapse: collapse;
    border: 1px solid #e5e7eb;
}

#markdown-preview th,
#markdown-preview td {
    padding: 0.75rem;
    text-align: left;
    border: 1px solid #e5e7eb;
}

#markdown-preview th {
    background: #f9fafb;
    font-weight: 600;
}

#markdown-preview tr:nth-child(even) {
    background: #f9fafb;
}

#markdown-preview a {
    color: #3b82f6;
    text-decoration: underline;
}

#markdown-preview a:hover {
    color: #2563eb;
}

#markdown-preview img {
    max-width: 100%;
    height: auto;
    border-radius: 0.5rem;
    margin: 1rem 0;
}

#markdown-preview hr {
    margin: 2rem 0;
    border: none;
    border-top: 1px solid #e5e7eb;
}

#markdown-preview strong {
    font-weight: 700;
}

#markdown-preview em {
    font-style: italic;
}

#markdown-preview del {
    text-decoration: line-through;
}

/* ===== Modal Styles ===== */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 1000;
}

.modal-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
}

.modal-content {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: white;
    border-radius: 0.5rem;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
    padding: 1.5rem;
    width: 90%;
    max-width: 500px;
}

.modal-title {
    font-size: 1.25rem;
    font-weight: 600;
    margin: 0 0 1rem 0;
    color: #111827;
}

.modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 0.75rem;
    margin-top: 1.5rem;
}

/* ===== Responsive Design ===== */
@media (max-width: 768px) {
    .editor-container {
        flex-direction: column;
        height: auto;
        min-height: 400px;
    }

    .editor-pane {
        border-right: none;
        border-bottom: 1px solid #e5e7eb;
        min-height: 200px;
    }

    .preview-pane {
        min-height: 200px;
    }

    .resizer {
        display: none;
    }

    .pane-header {
        padding: 0.5rem;
    }

    .pane-title {
        font-size: 0.75rem;
    }

    .editor-textarea {
        padding: 0.75rem;
        font-size: 0.8125rem;
    }

    .preview-content {
        padding: 0.75rem;
    }

    .toolbar-btn {
        padding: 0.375rem;
    }

    .modal-content {
        padding: 1rem;
        margin: 1rem;
        width: calc(100% - 2rem);
    }
}

@media (max-width: 480px) {
    .editor-container {
        min-height: 300px;
    }

    .editor-pane,
    .preview-pane {
        min-height: 150px;
    }

    .pane-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.5rem;
    }

    .pane-controls {
        align-self: flex-end;
    }

    #editor-stats {
        font-size: 0.625rem;
    }
}

/* ===== Loading States ===== */
.loading {
    opacity: 0.6;
    pointer-events: none;
}

.spinner {
    display: inline-block;
    width: 1rem;
    height: 1rem;
    border: 2px solid #e5e7eb;
    border-top: 2px solid #3b82f6;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% {
        transform: rotate(0deg);
    }
    100% {
        transform: rotate(360deg);
    }
}

/* ===== Validation Styles ===== */
.validation-error {
    color: #dc2626;
}

.validation-warning {
    color: #d97706;
}

.validation-success {
    color: #059669;
}

/* ===== Syntax Highlighting Prep ===== */
.hljs {
    background: #f8f9fa !important;
    color: #24292e !important;
}

.hljs-comment,
.hljs-quote {
    color: #6a737d !important;
    font-style: italic;
}

.hljs-keyword,
.hljs-selector-tag,
.hljs-type {
    color: #d73a49 !important;
}

.hljs-string,
.hljs-doctag {
    color: #032f62 !important;
}

.hljs-title,
.hljs-section,
.hljs-selector-id {
    color: #6f42c1 !important;
    font-weight: bold;
}

.hljs-function {
    color: #6f42c1 !important;
}

.hljs-tag,
.hljs-name,
.hljs-attribute {
    color: #22863a !important;
}

.hljs-variable,
.hljs-template-variable {
    color: #e36209 !important;
}

.hljs-number,
.hljs-literal {
    color: #005cc5 !important;
}

/* ===== Fullscreen Mode ===== */
.fullscreen {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 9999;
    background: white;
}

.fullscreen .editor-container {
    height: calc(100vh - 140px);
}

/* ===== Print Styles ===== */
@media print {
    .toolbar-btn,
    .pane-header,
    .modal {
        display: none !important;
    }

    .editor-container {
        height: auto;
        border: none;
    }

    .editor-pane {
        display: none;
    }

    .preview-pane {
        flex: none;
    }

    .preview-content {
        padding: 0;
    }
}
