/* style.css */
:root {
  --navbar-height: 45px;
  --toolbar-min-height: 40px;
  --sidebar-width: 220px;
  --status-bar-height: 25px;
  --accent-color: #0078d4;
  --border-color-light: #dee2e6; /* Slightly lighter */
  --border-color-medium: #ced4da;
  --bg-light: #ffffff;
  --bg-medium: #f8f9fa; /* Sidebar/Status */
  --bg-dark: #f1f3f5; /* Editor area background - lighter grey */
  --text-color: #212529;
  --text-muted: #6c757d;
  --save-status-color: #198754; /* Bootstrap green */
  --error-color: #dc3545;
  --font-sans-serif: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji";
  --font-monospace: SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; font-family: var(--font-sans-serif); overflow: hidden; font-size: 14px; color: var(--text-color); background-color: var(--bg-dark); }
button, select, input { font-family: inherit; font-size: inherit; vertical-align: middle; }
button { cursor: pointer; background: none; border: none; padding: 0; }

/* --- App Layout --- */
.app-container { display: flex; flex-direction: column; height: 100vh; }

/* --- Navbar --- */
.navbar { display: flex; align-items: center; height: var(--navbar-height); padding: 0 15px; background-color: var(--bg-light); border-bottom: 1px solid var(--border-color-light); flex-shrink: 0; gap: 15px; flex-wrap: wrap; }
.navbar-brand { display: flex; align-items: center; font-weight: 600; font-size: 1.2em; color: var(--text-color); white-space: nowrap; }
.logo-icon { color: var(--accent-color); margin-right: 8px; font-size: 1.1em; }
.navbar-ops { display: flex; align-items: center; gap: 15px; flex-grow: 1; flex-wrap: wrap; }
.nav-group { display: flex; align-items: center; gap: 8px; }
.navbar-help { margin-left: auto; white-space: nowrap; }
.navbar button, .navbar select { padding: 5px 10px; border: 1px solid var(--border-color-medium); background-color: var(--bg-light); border-radius: 4px; font-size: 0.9em; height: 30px; line-height: 1.4; display: inline-flex; align-items: center; gap: 5px; transition: background-color 0.15s ease; white-space: nowrap; }
.navbar button:hover:not(:disabled) { background-color: #e9ecef; }
.navbar button i { color: var(--text-muted); }
.navbar button:hover:not(:disabled) i { color: var(--accent-color); }
.navbar select { min-width: 100px; }

/* --- Toolbar (Custom App Toolbar) --- */
.toolbar {
  display: flex;
  align-items: flex-start;
  min-height: var(--toolbar-min-height);
  height: auto;
  padding: 8px 10px 5px 10px; /* More top padding */
  background-color: #fdfdfd; /* Slightly off-white */
  border-bottom: 1px solid var(--border-color-light);
  flex-shrink: 0;
  gap: 12px; /* Slightly more gap */
  flex-wrap: wrap;
}
.tool-group {
  display: flex;
  align-items: center;
  gap: 6px; /* Slightly more gap */
  padding: 0 10px;
  margin-bottom: 5px;
  border-left: 2px solid var(--border-color-light);
  padding-left: 12px;
}
.tool-group:first-child { border-left: none; padding-left: 0; }
.group-label { font-size: 0.8em; color: var(--text-muted); margin-right: 8px; font-weight: 600; text-transform: uppercase; white-space: nowrap; }
.toolbar button, .toolbar select, .toolbar label { padding: 3px 6px; border: 1px solid transparent; background-color: transparent; border-radius: 3px; font-size: 0.9em; height: 28px; line-height: 1.4; display: inline-flex; align-items: center; gap: 4px; transition: background-color 0.15s ease, border-color 0.15s ease; white-space: nowrap; }
.toolbar label { padding: 3px 0; color: var(--text-muted); margin-right: -2px; }
.toolbar select { border: 1px solid var(--border-color-medium); background-color: var(--bg-light); min-width: 80px; }
.toolbar button:hover:not(:disabled) { background-color: #e9ecef; border-color: var(--border-color-medium); }
.toolbar button i { color: var(--text-muted); font-size: 1.1em; width: 1.2em; text-align: center; }
.toolbar button:hover:not(:disabled) i { color: var(--accent-color); }
.toolbar .separator { /* Was used for alignment buttons, no longer needed */ }

/* --- Main Area --- */
.main-area { display: flex; flex-grow: 1; overflow: hidden; background-color: var(--bg-dark); }

/* --- Sidebar --- */
.sidebar { width: var(--sidebar-width); background-color: var(--bg-medium); border-right: 1px solid var(--border-color-light); display: flex; flex-direction: column; height: 100%; flex-shrink: 0; overflow: hidden; }
.sidebar-header { padding: 10px; border-bottom: 1px solid var(--border-color-light); flex-shrink: 0; background-color: var(--bg-light); }
.add-slide-btn { display: flex; align-items: center; justify-content: center; width: 100%; padding: 8px 12px; font-size: 0.95em; font-weight: 500; color: var(--accent-color); background-color: #e7f3fe; border: 1px solid var(--accent-color); border-radius: 4px; transition: all 0.2s ease; }
.add-slide-btn:hover:not(:disabled) { background-color: #cfe7ff; border-color: #005a9e; }
.add-slide-btn i { margin-right: 6px; }
.slide-list { list-style: none; padding: 10px 5px; margin: 0; flex-grow: 1; overflow-y: auto; overflow-x: hidden; }
.slide-list-item { display: flex; align-items: center; padding: 6px; margin-bottom: 8px; border: 1px solid var(--border-color-light); background-color: var(--bg-light); cursor: grab; position: relative; border-radius: 3px; transition: background-color 0.15s ease, border-color 0.15s ease; min-height: 70px; }
.slide-list-item:hover { background-color: #f1f3f5; border-color: var(--border-color-medium); }
.slide-list-item.active { border-color: var(--accent-color); background-color: #e7f3fe; font-weight: bold; }
.slide-list-item:active { cursor: grabbing; }
.slide-number { position: absolute; top: 3px; left: 3px; font-size: 0.7em; color: var(--text-muted); background: rgba(255, 255, 255, 0.7); padding: 1px 3px; border-radius: 2px; line-height: 1; z-index: 1; }
.slide-thumbnail { width: 100px; height: 56.25px; border: 1px solid var(--border-color-light); margin-left: 10px; display: flex; justify-content: center; align-items: center; font-size: 0.8em; color: var(--text-muted); background-color: #e9ecef; overflow: hidden; position: relative; flex-shrink: 0; border-radius: 2px; }
.slide-thumbnail::before { content: 'HTML'; font-weight: 600; z-index: 1; background: rgba(233, 236, 239, 0.7); padding: 2px 4px; border-radius: 2px; }
.bg-preview { width: 100%; height: 100%; position: absolute; top: 0; left: 0; z-index: 0; opacity: 0.3; background-size: cover; background-position: center; border-radius: 2px; }

/* --- Editor Area --- */
.editor-area {
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    height: 100%;
    background-color: var(--bg-dark); /* Lighter grey */
    padding: 10px 15px 0 15px; /* Reduced top padding */
    overflow: hidden;
}
#editor-slide-wrapper {
    position: relative;
    width: 100%;
    max-width: 1100px;
    margin: 0 auto; /* Center horizontally */
    background-color: var(--bg-light); /* White background for the editing canvas */
    /* border: 1px solid var(--border-color-medium); */ /* Border handled by TinyMCE */
    border-top: 1px solid var(--border-color-light); /* Thin line separating from toolbar */
    box-shadow: 0 2px 8px rgba(0,0,0,0.08); /* Softer shadow */
    aspect-ratio: 16 / 9;
    max-height: calc(100% - var(--status-bar-height) - 10px); /* Account for status bar & bottom margin */
    display: flex;
    overflow: hidden; /* Crucial */
    flex-grow: 1; /* Allow wrapper to grow */
    margin-bottom: 10px; /* Space before status bar */
}

#slide-editor {
    width: 100%;
    height: 100%;
    visibility: hidden; /* Hide until TinyMCE initializes */
}

/* TinyMCE Specific Styling */
.tox-tinymce {
    border: none !important; /* Remove TinyMCE's default border */
    height: 100% !important;
    display: flex;
    flex-direction: column;
}
.tox-editor-container {
    flex-grow: 1;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}
.tox-edit-area {
    flex-grow: 1;
    overflow: hidden; /* Let iframe handle scroll */
    /* Removed overflow: auto; */
}
.tox-edit-area__iframe {
    height: 100% !important;
    width: 100% !important; /* Ensure iframe fills */
}
/* Optional: Style TinyMCE toolbar to blend better */
.tox .tox-toolbar, .tox .tox-toolbar__overflow, .tox .tox-toolbar__primary {
    background-color: #fdfdfd !important; /* Match custom toolbar bg */
    border-top: none !important; /* Remove potential top border */
    border-bottom: 1px solid var(--border-color-light) !important; /* Consistent bottom border */
    padding: 2px 4px !important; /* Adjust padding slightly */
}
.tox .tox-menubar {
     background-color: #fdfdfd !important; /* Match custom toolbar bg */
     border-bottom: 1px solid var(--border-color-light) !important;
}

/* Status Bar */
.editor-status {
    padding: 0 15px;
    font-size: 0.8em;
    color: var(--text-muted);
    border-top: 1px solid var(--border-color-light);
    height: var(--status-bar-height);
    line-height: var(--status-bar-height);
    flex-shrink: 0;
    display: flex;
    justify-content: space-between;
    align-items: center;
    /* margin-top: 10px; */ /* Removed margin, wrapper has bottom margin now */
    background-color: var(--bg-medium);
}
.save-status { font-style: italic; color: var(--save-status-color); opacity: 0; transition: opacity 0.5s ease-in-out; white-space: nowrap; }
.save-status.visible { opacity: 1; }
.save-status.error { color: var(--error-color); }

/* --- SortableJS --- */
.sortable-ghost { opacity: 0.4; background: #c8ebfb; border-style: dashed; }
.sortable-chosen { opacity: 0.9; background: #dcf0fb; box-shadow: 0 0 5px rgba(0,120,212,0.5); }

/* --- Modal --- */
.modal { display: none; position: fixed; z-index: 1051; left: 0; top: 0; width: 100%; height: 100%; overflow: auto; background-color: rgba(0,0,0,0.5); animation: fadeIn 0.3s ease; }
.modal-content { background-color: #fefefe; margin: 10% auto; padding: 25px; border: 1px solid #bbb; /* Softer border */ width: 80%; max-width: 700px; position: relative; border-radius: 5px; box-shadow: 0 4px 15px rgba(0,0,0,0.15); }
.modal-content h2, .modal-content h3 { margin-top: 0; margin-bottom: 15px; color: #333; font-weight: 600; }
.modal-content h3 { margin-top: 20px; border-bottom: 1px solid #eee; padding-bottom: 5px; font-size: 1.1em; font-weight: 500; }
.modal-content ul { list-style: disc; margin-left: 25px; margin-bottom: 15px; }
.modal-content ul ul { list-style: circle; margin-top: 5px; margin-bottom: 5px; }
.modal-content li { margin-bottom: 8px; line-height: 1.6; }
.modal-content code { background-color: #e9ecef; padding: 2px 5px; border-radius: 3px; font-family: var(--font-monospace); color: #d63384; font-size: 0.9em; }
.modal-content a { color: var(--accent-color); text-decoration: none; }
.modal-content a:hover { text-decoration: underline; }
.modal-close { color: #aaa; position: absolute; top: 10px; right: 15px; font-size: 28px; font-weight: bold; cursor: pointer; line-height: 1; }
.modal-close:hover, .modal-close:focus { color: black; text-decoration: none; }

@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

/* --- RevealJS Specific Overrides/Helpers --- */
.reveal .slides .v-align-top { display: flex !important; flex-direction: column !important; justify-content: flex-start !important; height: 100%; }
.reveal .slides .v-align-middle { display: flex !important; flex-direction: column !important; justify-content: center !important; height: 100%; }
.reveal .slides .v-align-bottom { display: flex !important; flex-direction: column !important; justify-content: flex-end !important; height: 100%; }
.reveal .slides .h-align-left { text-align: left !important; }
.reveal .slides .h-align-center { text-align: center !important; }
.reveal .slides .h-align-right { text-align: right !important; }
.reveal iframe { display: block; margin: 15px auto; max-width: 100%; border: 1px solid #ccc; }
.r-stretch { width: 100%; height: 100%; position: relative; }
.r-stretch > iframe, .r-stretch > video { width: 100%; height: 100%; position: absolute; top: 0; left: 0; }
.reveal .slides > section { padding: 30px; }
.reveal img { max-width: 100%; height: auto; display: block; margin: 0 auto; }
.reveal .r-fit-text { display: inline-block; white-space: nowrap; line-height: 1; }

/* --- Table Styling (Reveal) --- */
.reveal table { border-collapse: collapse; margin: 1em auto; width: auto; max-width: 95%; border: 1px solid #ccc; font-size: 0.8em; }
.reveal th, .reveal td { border: 1px solid #ddd; padding: 0.5em 0.75em; text-align: left; }
.reveal th { background-color: #f2f2f2; font-weight: bold; border-bottom-width: 2px; border-bottom-color: #ccc; }
.reveal tbody tr:nth-child(odd) { background-color: #f9f9f9; }
.reveal tbody tr:hover { background-color: #f1f1f1; }

/* --- Hidden File Input --- */
#import-file-input { display: none !important; visibility: hidden !important; width: 0 !important; height: 0 !important; position: absolute !important; left: -9999px !important; }

/* --- Disabled State --- */
button:disabled, select:disabled, input:disabled { opacity: 0.6; cursor: not-allowed !important; background-color: #f8f9fa !important; }
button:disabled, select:disabled { border-color: var(--border-color-light) !important; color: var(--text-muted) !important; }
.toolbar button:disabled:hover { border-color: var(--border-color-light) !important; background-color: #f8f9fa !important; }

/* --- Color Picker Popup --- */
.color-picker-popup { position: absolute; z-index: 1051; background: white; padding: 10px; border-radius: 5px; box-shadow: 0 2px 10px rgba(0,0,0,0.2); border: 1px solid var(--border-color-medium); display: flex; flex-direction: column; gap: 5px; }
.color-picker-popup input[type="color"] { width: 100px; height: 30px; padding: 0; border: 1px solid var(--border-color-medium); }
.color-picker-popup button { padding: 4px 8px; font-size: 0.9em; border: 1px solid var(--border-color-medium); border-radius: 3px; background-color: var(--bg-light); }
.color-picker-popup button:hover { background-color: var(--bg-dark); }
.color-picker-preview { width: 100px; height: 25px; border: 1px solid var(--border-color-medium); margin-bottom: 5px; }