@import url('https://fonts.googleapis.com/css2?family=Raleway:wght@300;400;600;700&display=swap');

/* === Override global style.css === */
html, body {
    height: 100%;
    margin: 0;
    padding: 0;
    font-family: 'Raleway', sans-serif;
    background-color: #f4f7f6;
    overflow: hidden !important;
}

/* === Page Layout - full viewport flex column === */
.editor-page {
    display: flex;
    flex-direction: column;
    height: 100vh;
    max-width: 100%;
    margin: 0;
    padding: 0;
}

/* === Header === */
.editor-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: #fff;
    padding: 16px 24px;
    border-radius: 10px 10px 0 0;
    border-bottom: 2px solid #2596be;
    box-shadow: 0 2px 8px rgba(0,0,0,0.06);
}

.editor-header h1 {
    font-size: 1.4em;
    font-weight: 700;
    color: #2c3e50;
    margin: 0;
    display: flex;
    align-items: center;
    gap: 10px;
}

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

/* === Auto-save Indicator === */
.autosave-indicator {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.85em;
    color: #7f8c8d;
    padding: 4px 12px;
    border-radius: 20px;
    background: #f0f0f0;
    transition: all 0.3s ease;
}

.autosave-indicator.saved {
    color: #27ae60;
    background: #e8f8f5;
}

.autosave-indicator.saving {
    color: #e67e22;
    background: #fef9e7;
}

.autosave-indicator .dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: currentColor;
}

/* === Editor Body === */
.editor-body {
    flex: 1;
    background: #fff;
    padding: 0 24px;
    overflow: hidden;
}

/* === Top Controls === */
.editor-top-controls {
    padding: 12px 0;
}

/* === Side-by-side container - pixel height set by JS === */
.side-by-side-container {
    display: flex;
    border: 1px solid #dfe6e9;
    border-radius: 6px;
    overflow: hidden;
}

/* === Pane header (shared) === */
.pane-header {
    padding: 8px 12px;
    background: #f8f9fa;
    border-bottom: 1px solid #dfe6e9;
    font-weight: 600;
    font-size: 0.85em;
    color: #2c3e50;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    flex-shrink: 0;
}

/* === Left: Editor pane === */
.editor-pane {
    width: 50%;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    border-right: 2px solid #dfe6e9;
}

/* === Right: Preview pane === */
.preview-pane {
    width: 50%;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.preview-pane .preview-content {
    overflow-y: auto;
    padding: 16px 20px;
    font-family: 'Raleway', sans-serif;
    font-size: 15px;
    line-height: 1.7;
    color: #333;
}

.preview-pane .preview-content img {
    max-width: 100%;
    height: auto !important;
    width: auto;
}

.preview-pane .preview-content img[style*="width"] {
    max-width: 100%;
}

/* === Image Browser Panel === */
.image-browser-overlay {
    position: fixed;
    top: 0; left: 0;
    width: 100%; height: 100%;
    background: rgba(0,0,0,0.5);
    z-index: 10000;
    display: flex;
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(3px);
}

.image-browser {
    background: #fff;
    width: 90%;
    max-width: 900px;
    height: 80vh;
    border-radius: 12px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.3);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.image-browser-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    border-bottom: 2px solid #2596be;
    flex-shrink: 0;
}

.image-browser-header h3 {
    margin: 0;
    font-size: 1.2em;
    color: #2c3e50;
}

.image-browser-header .close-btn {
    background: none;
    border: none;
    font-size: 1.4em;
    cursor: pointer;
    color: #7f8c8d;
    padding: 0; margin: 0; width: auto; line-height: 1;
}

.image-browser-header .close-btn:hover {
    color: #2c3e50;
}

.image-browser-search {
    padding: 12px 20px;
    border-bottom: 1px solid #e9ecef;
    flex-shrink: 0;
}

.image-browser-search input {
    width: 100%;
    padding: 10px 14px;
    font-size: 0.95em;
    border: 2px solid #dfe6e9;
    border-radius: 6px;
    box-sizing: border-box;
}

.image-browser-search input:focus {
    outline: none;
    border-color: #2596be;
}

.image-browser-grid {
    flex: 1;
    overflow-y: auto;
    padding: 16px 20px;
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 16px;
    align-content: start;
}

.image-card {
    border: 2px solid #e9ecef;
    border-radius: 8px;
    overflow: hidden;
    cursor: pointer;
    transition: border-color 0.2s, box-shadow 0.2s;
    display: block;
    min-height: 220px;
}

.image-card:hover {
    border-color: #2596be;
    box-shadow: 0 4px 12px rgba(37,150,190,0.2);
}

.image-card .thumb {
    width: 100% !important;
    height: 180px !important;
    max-width: 100% !important;
    object-fit: contain !important;
    background: #f8f9fa;
    padding: 12px;
    box-sizing: border-box;
    display: block !important;
    margin: 0 !important;
}

.image-card .card-info {
    padding: 8px 10px;
    border-top: 1px solid #e9ecef;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 6px;
}

.image-card .card-name {
    font-size: 0.75em;
    color: #2c3e50;
    word-break: break-all;
    line-height: 1.3;
    flex: 1;
}

.image-card .copy-btn {
    background: #2596be;
    color: white;
    border: none;
    border-radius: 4px;
    padding: 4px 8px;
    font-size: 0.7em;
    cursor: pointer;
    white-space: nowrap;
    flex-shrink: 0;
    width: auto; margin: 0;
}

.image-card .copy-btn:hover {
    background: #1e7fa0;
}

.image-browser-status {
    padding: 10px 20px;
    border-top: 1px solid #e9ecef;
    font-size: 0.85em;
    color: #7f8c8d;
    text-align: center;
    flex-shrink: 0;
}

/* === File Selector Row === */
.file-selector-row {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 8px;
}

.file-selector-row label {
    font-weight: 600;
    color: #2c3e50;
    white-space: nowrap;
    margin: 0;
    font-size: 0.9em;
}

.file-selector-row select {
    padding: 8px 12px;
    font-size: 0.95em;
    border: 2px solid #dfe6e9;
    border-radius: 6px;
    background: #fff;
    color: #2c3e50;
    cursor: pointer;
    transition: border-color 0.2s;
    margin: 0;
}

.file-selector-row select:focus {
    outline: none;
    border-color: #2596be;
}

#page-selector {
    flex: 1;
}

.upload-limit-text {
    font-size: 0.8em;
    color: #95a5a6;
    font-style: italic;
    margin: 0;
}

.latest-image-md {
    font-family: 'Courier New', monospace;
    font-size: 0.85em;
    background: #e9ecef;
    padding: 4px 10px;
    border-radius: 4px;
    color: #2c3e50;
    word-break: break-all;
}

#file-size-warning {
    display: none;
    background-color: #ffe6e6;
    color: #c0392b;
    border: 1px solid #e74c3c;
    padding: 10px;
    border-radius: 6px;
    margin-bottom: 12px;
    font-weight: bold;
    text-align: center;
}

/* === EasyMDE inside editor-pane === */
.editor-pane .EasyMDEContainer {
    flex: 1;
    display: flex !important;
    flex-direction: column;
    overflow: hidden;
    border: none;
}

.editor-pane .editor-toolbar {
    background: #f8f9fa;
    border: none;
    border-bottom: 1px solid #dfe6e9;
    border-radius: 0;
    padding: 4px;
    flex-shrink: 0;
}

.editor-pane .editor-toolbar button.active,
.editor-pane .editor-toolbar button:hover {
    background: #2596be;
    color: white;
    border-color: #2596be;
}

.editor-pane .CodeMirror {
    font-family: 'Courier New', Consolas, monospace;
    font-size: 14px;
    border: none;
    border-radius: 0;
}

.editor-pane .editor-statusbar {
    border-top: 1px solid #dfe6e9;
    flex-shrink: 0;
}

/* Hide EasyMDE's own preview */
.editor-preview, .editor-preview-side {
    display: none !important;
}

/* === Footer - stays pinned at bottom === */
.editor-footer {
    flex-shrink: 0;
    padding: 10px 24px 18px 24px;
    background: #fff;
    border-top: 2px solid #dfe6e9;
    box-shadow: 0 -2px 8px rgba(0,0,0,0.04);
}

#status-message {
    font-weight: 600;
    padding: 12px 24px;
    border-radius: 8px;
    display: none;
    text-align: center;
    font-size: 0.95em;
    position: fixed;
    top: 24px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 99999;
    min-width: 320px;
    max-width: 600px;
    box-shadow: 0 6px 24px rgba(0,0,0,0.2);
    animation: statusSlideIn 0.3s ease;
}

@keyframes statusSlideIn {
    from { top: -60px; opacity: 0; }
    to { top: 24px; opacity: 1; }
}

#status-message.success {
    background: #d4edda;
    color: #155724;
    border: 1px solid #c3e6cb;
}

#status-message.error {
    background: #f8d7da;
    color: #721c24;
    border: 1px solid #f5c6cb;
}

#status-message.warning {
    background: #fff3cd;
    color: #856404;
    border: 1px solid #ffeeba;
}

#status-message.info {
    background: #d1ecf1;
    color: #0c5460;
    border: 1px solid #bee5eb;
}

.footer-row {
    display: flex;
    align-items: center;
    gap: 16px;
    justify-content: space-between;
    flex-wrap: wrap;
}

.footer-row .name-input-group {
    display: flex;
    align-items: center;
    gap: 10px;
}

.footer-row label {
    font-weight: 600;
    color: #2c3e50;
    white-space: nowrap;
    margin: 0;
}

.footer-row input[type="text"] {
    padding: 10px 14px;
    font-size: 1em;
    border: 2px solid #dfe6e9;
    border-radius: 6px;
    width: 220px;
    margin: 0;
    transition: border-color 0.2s;
}

.footer-row input[type="text"]:focus {
    outline: none;
    border-color: #2596be;
}

.footer-actions {
    display: flex;
    gap: 12px;
    align-items: center;
    margin: 0;
}

.footer-actions button {
    padding: 10px 24px;
    font-size: 1em;
    font-weight: 600;
    background: #2596be;
    color: white;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    margin: 0;
    width: auto;
    transition: background 0.2s;
}

.footer-actions button:hover {
    background: #1e7fa0;
}

.footer-actions button:disabled {
    background: #a0a0a0;
    cursor: not-allowed;
}

.home-link {
    padding: 10px 20px;
    background-color: #6c757d;
    color: white;
    border-radius: 6px;
    text-decoration: none;
    font-weight: 600;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    transition: background 0.2s;
}

.home-link:hover {
    background-color: #5a6268;
    text-decoration: none;
    color: white;
}

/* === Draft Restore Modal === */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.5);
    z-index: 10000;
    display: flex;
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(3px);
}

.modal-content {
    background: #fff;
    padding: 32px;
    border-radius: 12px;
    max-width: 480px;
    width: 90%;
    box-shadow: 0 20px 60px rgba(0,0,0,0.3);
    text-align: center;
}

.modal-content h3 {
    margin: 0 0 12px 0;
    font-size: 1.3em;
    color: #2c3e50;
}

.modal-content p {
    color: #555;
    margin: 0 0 8px 0;
    line-height: 1.6;
}

.modal-content .draft-time {
    font-weight: 600;
    color: #2596be;
}

.modal-actions {
    display: flex;
    gap: 12px;
    justify-content: center;
    margin-top: 20px;
}

.modal-actions button {
    padding: 10px 24px;
    font-size: 1em;
    font-weight: 600;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    width: auto;
    margin: 0;
}

#restore-draft-btn {
    background: #2596be;
    color: white;
}

#restore-draft-btn:hover {
    background: #1e7fa0;
}

#discard-draft-btn {
    background: #e9ecef;
    color: #2c3e50;
}

#discard-draft-btn:hover {
    background: #dee2e6;
}

/* === Help Panel === */
.help-toggle-btn {
    padding: 8px 16px;
    font-size: 0.9em;
    background: #f0f0f0;
    border: 1px solid #ddd;
    border-radius: 6px;
    cursor: pointer;
    color: #2c3e50;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    margin: 0;
    width: auto;
    transition: all 0.2s;
}

.help-toggle-btn:hover {
    background: #e0e0e0;
}

.help-panel-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.3);
    z-index: 9000;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s;
}

.help-panel-overlay.active {
    opacity: 1;
    pointer-events: all;
}

.help-panel {
    position: fixed;
    top: 0;
    right: -400px;
    width: 380px;
    height: 100%;
    background: #fff;
    box-shadow: -4px 0 20px rgba(0,0,0,0.15);
    z-index: 9001;
    padding: 24px;
    overflow-y: auto;
    transition: right 0.3s ease;
}

.help-panel.active {
    right: 0;
}

.help-panel h3 {
    margin: 0 0 16px 0;
    padding-bottom: 10px;
    border-bottom: 2px solid #2596be;
    color: #2c3e50;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.help-panel .close-btn {
    background: none;
    border: none;
    font-size: 1.4em;
    cursor: pointer;
    color: #7f8c8d;
    padding: 0;
    margin: 0;
    width: auto;
    line-height: 1;
}

.help-panel .close-btn:hover {
    color: #2c3e50;
}

.help-panel h4 {
    margin: 16px 0 8px 0;
    color: #2c3e50;
    font-size: 1em;
}

.help-panel p {
    margin: 0 0 8px 0;
    font-size: 0.9em;
    color: #555;
    line-height: 1.5;
}

.help-panel code {
    background-color: #f0f0f0;
    padding: 2px 6px;
    border-radius: 3px;
    font-family: 'Courier New', monospace;
    font-size: 0.9em;
}

.help-panel hr {
    margin: 16px 0;
    border: none;
    border-top: 1px solid #e9ecef;
}

.cheatsheet-alert {
    background: #d1ecf1;
    border: 1px solid #bee5eb;
    border-radius: 6px;
    padding: 12px;
    margin-bottom: 12px;
    font-size: 0.9em;
    line-height: 1.6;
}

/* === Dev Mode Banner === */
.dev-banner {
    background: #fff3cd;
    color: #856404;
    border: 2px solid #ffc107;
    border-radius: 0;
    padding: 6px 20px;
    text-align: center;
    font-weight: 600;
    font-size: 0.85em;
    flex-shrink: 0;
}
