body {
    font-family: Arial, sans-serif;
    margin: 0;
    padding: 0;
    display: flex;
    height: 100vh;
    flex-direction: column;
    background-color: #1a1a2e; /* A slightly darker background for the overall app */
    color: #f0f0f0; /* Default text color */
}

.toolbar {
    display: flex;
    flex-direction: column; /* Changed to column to stack groups */
    background: #2d2d2d;
    padding: 10px;
    gap: 10px;
    flex-shrink: 0; /* Prevent toolbar from shrinking */
}

/* Ensure button groups wrap if too many buttons */
.button-group {
    display: flex;
    gap: 5px;
    flex-wrap: wrap; /* Allow buttons to wrap to next line if needed */
}

.toolbar button {
    background: #007bff;
    color: white;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    padding: 6px 10px;
    font-size: large; /* Adjusted from x-large for better fit with multiple buttons */
    white-space: nowrap; /* Prevent text wrapping in buttons */
}

.toolbar button:hover {
    background: #0056b3;
}

.toolbar button:disabled {
    pointer-events: none;
    opacity: 0.5;
}


/* Main workspace layout */
.main-container {
    display: flex;
    flex: 1; /* Allows it to take remaining vertical space after toolbar */
    overflow: hidden; /* Important for containing resized children */
    flex-direction: row; /* Default to horizontal layout for sidebars */
}

/* VS Code–like Activity Bar */
#activity-bar {
    width: 48px;
    background-color: #252526;
    color: #cccccc;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 6px 0;
    gap: 6px;
    flex-shrink: 0;
}

#activity-bar .activity-item {
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: none;
    background: transparent;
    color: inherit;
    cursor: pointer;
    border-radius: 6px;
}

#activity-bar .activity-item:hover {
    background-color: #2d2d30;
}

#activity-bar .activity-item.active {
    background-color: #094771;
    color: #ffffff;
}

.file-explorer {
    width: 200px; /* Adjusted initial width */
    flex-shrink: 0; /* Prevent it from shrinking by default */
    background: #2d2d2d;
    color: #fff;
    padding: 10px;
    overflow-y: auto;
    /* Keeping resize properties from inline style, though often better to consolidate */
    position: relative; 
    resize: horizontal; 
    overflow: auto; 
    min-width: 100px; /* Adjusted min-width for better control */
    max-width: 500px; 
}

.file-explorer ul {
    list-style: none;
    padding: 0;
    margin: 0;
}

.file-explorer li {
    padding: 5px;
    cursor: pointer;
}

.file-explorer li.hover:hover {
    background: #444;
}

.file-explorer img {
    width: 90%;
    height: auto;
    border-radius: 5px;
    margin-top: 5px;
}

.editor-container {
    flex: 1; /* Allows it to take all remaining horizontal space */
    display: flex;
    flex-direction: column; /* Stack editor textareas and preview vertically */
    /* Removed max-width: 93%; - flex:1 will handle width */
}

/* Adjusted CodeMirror styles */
.CodeMirror {
    height: 100% !important; /* Make sure CodeMirror fills its parent */
    border-bottom: 1px solid #444;
}
/* You can uncomment these if you specifically need text wrapping */
/* .CodeMirror pre {
    white-space: pre-wrap;
    word-break: break-all;
} */

.preview-container {
    flex: 1; /* Takes remaining vertical space in editor-container */
    display: flex;
    flex-direction: column; /* Ensure iframe within also takes space */
}

.preview {
    flex: 1;
    border-left: 1px solid #444; /* Keep existing border for vertical split */
}

iframe {
    width: 100%;
    height: 100%;
    border: none;
}

.hidden {
    display: none !important;
}

.divider-text {
    display: flex;
    align-items: center;
    text-align: center;
    margin: 0; /* Adjusted from 10px margin-top/bottom to 0, use padding if needed */
    font-weight: bold;
    color: #555;
    padding: 10px 0; /* Add some padding for spacing */
}

.divider-text::before,
.divider-text::after {
    content: "";
    flex: 1;
    border-bottom: 1px solid #ccc;
    margin: 0 10px;
}

/* Floating Help Button */
.help-button {
    visibility: hidden; /* This makes it non-clickable */
    position: fixed;
    bottom: 20px;
    right: 20px;
    background-color: #007bff;
    color: white;
    border: none;
    border-radius: 50%;
    width: 50px;
    height: 50px;
    font-size: 24px;
    cursor: pointer;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
    z-index: 100; /* Ensure it's on top */
}

/* Chat Window */
.chat-window {
    position: fixed;
    bottom: 80px;
    right: 20px;
    width: 300px;
    background: white;
    border: 1px solid #ccc;
    border-radius: 10px;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
    display: none;
    flex-direction: column;
    z-index: 101; /* Ensure chat is on top of help button */
}

.chat-header {
    background: #007bff;
    color: white;
    padding: 10px;
    border-top-left-radius: 10px;
    border-top-right-radius: 10px;
    font-weight: bold;
}

.chat-body {
    flex: 1;
    padding: 10px;
    overflow-y: auto;
    max-height: 300px;
    color: #333; /* Ensure text is visible on white background */
}

.chat-footer {
    display: flex;
    padding: 10px;
    border-top: 1px solid #ccc;
}

.chat-footer input {
    flex: 1;
    padding: 8px;
    border: 1px solid #ccc;
    border-radius: 5px;
    margin-right: 10px;
}

.chat-footer button {
    background: #007bff;
    color: white;
    border: none;
    border-radius: 5px;
    padding: 8px 12px;
    cursor: pointer;
}

.message {
    margin-bottom: 10px;
}

.message.user {
    text-align: right;
}

.message.bot {
    text-align: left;
}

.message p {
    display: inline-block;
    padding: 8px;
    border-radius: 10px;
    max-width: 80%;
}

.message.user p {
    background: #007bff;
    color: white;
}

.message.bot p {
    background: #f1f1f1;
    color: #333;
}

/* Responsive Design for 7-inch Tablet */
@media (max-width: 600px) {
    .toolbar {
        gap: 3px;
        padding: 5px;
    }

    .toolbar button {
        padding: 4px 8px;
        font-size: 10px;
    }

    .main-container {
        flex-direction: column;
    }

    /* Adjust sidebars to take full width and stack vertically */
    .file-explorer {
        width: 100%;
        height: auto; /* Allow height to be determined by content or max-height */
        max-height: 200px; /* Limit height to prevent taking too much space */
        resize: vertical; /* Allow vertical resizing on small screens */
    }

    .editor-container {
        height: 50vh;
    }

    .preview-container {
        height: 30vh;
    }

    .help-button {
        bottom: 10px;
        right: 10px;
    }

    .chat-window {
        width: 90%;
        right: 5%;
        bottom: 70px;
    }
}

.divider {
    width: 2px;
    height: 24px;
    background-color: #ccc;
    margin: 0 10px;
}

/* Preview Layout Toggle */
.preview-right {
    flex-direction: row;
}

.preview-bottom {
    flex-direction: column;
}

.preview-bottom .preview {
    border-left: none;
    border-top: 1px solid #444;
}

#special-char-buttons {
    flex-basis: 100%;
}

#capsWarning {
    display: none;
    color: red;
    font-weight: bold;
    animation: blink 1s infinite alternate;
}

@keyframes blink {
    0% {
        opacity: 1;
    }

    50% {
        opacity: 0;
    }

    100% {
        opacity: 1;
    }
}

#saved-files-list li {
    color: #0ff;
    cursor: pointer;
    padding: 5px;
    border-bottom: 1px solid #555;
}

#saved-files-list li:hover {
    background-color: #33334d;
}

.modal {
  position: fixed;
  z-index: 9999;
  left: 0;
  top: 0;
  width: 100vw;
  height: 100vh;
  overflow: auto;
  background-color: rgba(0, 0, 0, 0.6);
  display: flex;
  align-items: center;
  justify-content: center;
}

.modal-content {
  background-color: #1a1a2e;
  color: #f0f0f0;
  padding: 20px;
  border-radius: 10px;
  width: 400px;
  max-height: 80vh;
  overflow-y: auto;
  box-shadow: 0 0 10px #000;
  position: relative;
}

.modal-content h2 {
  margin-top: 0;
  margin-bottom: 10px;
  text-align: center;
}

.modal-content ul {
  list-style: none;
  padding: 0;
}

.modal-content ul li {
  padding: 10px;
  background: #333;
  margin: 5px 0;
  cursor: pointer;
  border-radius: 5px;
  transition: background 0.2s;
}

.modal-content ul li:hover {
  background: #555;
}

.modal .close {
  position: absolute;
  top: 8px;
  right: 15px;
  font-size: 24px;
  color: #fff;
  cursor: pointer;
}

.hidden {
  display: none !important;
}

.sample-text-controls { display: flex; flex-direction: column; gap: 9px; padding: 4px 0 12px; }
.sample-text-controls label { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 6px; font-size: 12px; color: #cbd5e1; }
.sample-text-controls output { color: #a5b4fc; font-variant-numeric: tabular-nums; }
.sample-text-controls input { width: 100%; margin: 0; accent-color: #818cf8; }
.sample-text-controls button { padding: 8px; border: 1px solid #6366f1; border-radius: 5px; background: #37305c; color: white; cursor: pointer; }
.sample-text-controls button:hover { background: #494076; }
.sample-text-controls :focus-visible { outline: 2px solid #a5b4fc; outline-offset: 2px; }

.save-file-dialog { width: min(420px, calc(100vw - 48px)); box-sizing: border-box; padding: 24px; border: 1px solid #475569; border-radius: 12px; color: #f1f5f9; background: #1c2433; }
.save-file-dialog::backdrop { background: rgb(0 0 0 / 65%); }
.save-file-dialog h2 { margin: 0 0 20px; font-size: 20px; }
.save-file-dialog label { display: block; margin-bottom: 8px; }
.save-file-dialog input { width: 100%; box-sizing: border-box; padding: 10px; border: 1px solid #64748b; border-radius: 6px; background: #111827; color: white; font: inherit; }
.save-file-dialog input:focus { outline: 2px solid #a5b4fc; outline-offset: 2px; }
.save-file-dialog input[aria-invalid="true"] { border-color: #fda4af; }
#save-file-help { font-size: 12px; color: #cbd5e1; }
#save-file-error { color: #fda4af; font-size: 13px; min-height: 1em; }
.save-file-actions { display: flex; justify-content: flex-end; gap: 10px; }
.save-file-actions button { padding: 9px 16px; border: 1px solid #64748b; border-radius: 6px; background: #334155; color: white; cursor: pointer; }
#save-file-submit { background: #4f46e5; border-color: #818cf8; }
