/* Global Overrides */
body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    color: #333;
    line-height: 1.6;
    background-color: #f4f6f8;
    margin: 0;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
}

.section {
    background: #fff;
    border: 1px solid #e1e4e8;
    border-radius: 8px;
    padding: 25px;
    margin-bottom: 25px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
}

h1 {
    color: #2c3e50;
    margin-bottom: 30px;
    font-weight: 700;
}

h2 {
    color: #2c3e50;
    margin-top: 0;
    margin-bottom: 20px;
    padding-bottom: 10px;
    border-bottom: 2px solid #f1f3f5;
    font-size: 1.5rem;
}

/* Modal & Layout */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0,0,0,0.5);
    backdrop-filter: blur(2px);
}

.modal-content {
    background-color: #fff;
    margin: 3% auto;
    padding: 0; /* Reset padding for better header/body separation */
    border: 1px solid rgba(0,0,0,0.2);
    width: 85%;
    max-width: 1000px;
    border-radius: 12px;
    height: 85vh;
    display: flex;
    flex-direction: column;
    box-shadow: 0 10px 30px rgba(0,0,0,0.2);
    overflow: hidden; /* For header radius */
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px 20px;
    background: #f8f9fa;
    border-bottom: 1px solid #eee;
}

.modal-header h2 {
    margin: 0;
    font-size: 1.25rem;
    color: #2c3e50;
}

.close {
    color: #aaa;
    font-size: 24px;
    font-weight: bold;
    cursor: pointer;
    transition: color 0.2s;
}

.close:hover {
    color: #e74c3c;
}

/* Tabs */
.tabs {
    display: flex;
    background: #fff;
    border-bottom: 1px solid #ddd;
    padding: 0 20px;
}

.tab-btn {
    padding: 15px 20px;
    background: none;
    border: none;
    cursor: pointer;
    font-size: 15px;
    font-weight: 500;
    color: #666;
    border-bottom: 3px solid transparent;
    transition: all 0.2s;
}

.tab-btn:hover {
    color: #007aff;
    background: #f9f9f9;
}

.tab-btn.active {
    color: #007aff;
    border-bottom-color: #007aff;
}

.tab-content {
    display: none;
    flex-grow: 1;
    overflow-y: auto;
    padding: 20px;
    background: #fff;
}

.tab-content.active {
    display: block;
}

/* Config Subtabs */
.config-subtabs {
    display: flex;
    gap: 5px;
    margin-bottom: 20px;
    border-bottom: 1px solid #eee;
    padding-bottom: 10px;
}

.sub-tab-btn {
    padding: 8px 16px;
    background: #f1f3f5;
    border: 1px solid transparent;
    border-radius: 20px;
    cursor: pointer;
    font-size: 14px;
    color: #555;
    transition: all 0.2s;
}

.sub-tab-btn:hover {
    background: #e9ecef;
}

.sub-tab-btn.active {
    background: #007aff;
    color: white;
    font-weight: 500;
    box-shadow: 0 2px 4px rgba(0,122,255,0.3);
}

.config-section {
    display: none;
    animation: fadeIn 0.3s ease;
}

.config-section.active {
    display: block;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(5px); }
    to { opacity: 1; transform: translateY(0); }
}

/* Forms & Inputs */
.form-group-v {
    display: flex;
    flex-direction: column;
    margin-bottom: 20px;
}

.form-group-v label {
    margin-bottom: 8px;
    font-weight: 600;
    color: #34495e;
    font-size: 0.95rem;
}

textarea, input[type="text"], select {
    padding: 10px;
    border: 1px solid #ced4da;
    border-radius: 6px;
    font-family: 'SF Mono', 'Menlo', 'Monaco', 'Courier New', monospace;
    font-size: 14px;
    transition: border-color 0.2s;
}

textarea:focus, input[type="text"]:focus, select:focus {
    border-color: #007aff;
    outline: none;
    box-shadow: 0 0 0 3px rgba(0,122,255,0.1);
}

/* Article List (Modernized Row Layout) */
.article-list {
    list-style: none;
    padding: 0;
    margin: 0;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.article-card {
    background: #fff;
    border: 1px solid #e1e4e8;
    border-radius: 6px;
    padding: 12px 15px;
    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
    transition: transform 0.2s, box-shadow 0.2s, background-color 0.2s;
    cursor: grab;
    position: relative;
    border-left: 4px solid #007aff;
}

.article-card:hover {
    transform: translateX(2px);
    box-shadow: 0 2px 8px rgba(0,0,0,0.08);
    background-color: #f8f9fa;
}

.article-card.dragging {
    opacity: 0.5;
    cursor: grabbing;
    background: #eef2ff;
}

/* Removed .article-card-header as it is no longer used in JS */

.article-seq {
    background: #e9ecef;
    color: #495057;
    font-size: 0.85rem;
    font-weight: 700;
    padding: 4px 8px;
    border-radius: 4px;
    margin-right: 15px;
    min-width: 30px;
    text-align: center;
    flex-shrink: 0;
}

.article-title {
    font-weight: 600;
    font-size: 1.05rem;
    color: #2c3e50;
    margin: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    flex-grow: 1;
    margin-right: 20px;
    cursor: text;
}

.article-meta {
    font-size: 0.85rem;
    color: #6c757d;
    margin: 0 20px 0 0;
    white-space: nowrap;
    flex-shrink: 0;
    font-family: 'SF Mono', monospace;
}

.article-actions {
    display: flex;
    gap: 8px;
    flex-shrink: 0;
}

.btn-icon {
    background: #fff;
    border: 1px solid #dee2e6;
    border-radius: 4px;
    padding: 6px 10px;
    cursor: pointer;
    font-size: 14px;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #555;
}

.btn-edit:hover { background: #007aff; color: white; border-color: #007aff; }
.btn-delete:hover { background: #dc3545; color: white; border-color: #dc3545; }

/* Rename Input in Flex Row */
.rename-input {
    font-family: inherit;
    font-size: 1.05rem;
    font-weight: 600;
    color: #2c3e50;
    flex-grow: 1;
    border: 1px solid #007aff;
    border-radius: 4px;
    padding: 4px 8px;
    margin-right: 20px;
    background: #fff;
}
.editor-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    padding-bottom: 10px;
    border-bottom: 1px solid #eee;
}

.editor-header h3 {
    margin: 0;
    color: #2c3e50;
    font-size: 1.2rem;
}

.back-btn, .fullscreen-btn {
    background: none;
    border: 1px solid #ddd;
    padding: 6px 12px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 14px;
    color: #555;
    transition: all 0.2s;
}

.back-btn:hover, .fullscreen-btn:hover {
    background: #f1f1f1;
    color: #333;
}

/* Editor Layout */
.editor-container {
    display: flex;
    gap: 0; /* Remove gap, use border */
    height: 60vh;
    border: 1px solid #ddd;
    border-radius: 6px;
    overflow: hidden;
}

.editor-main {
    flex-grow: 1;
    display: flex;
    flex-direction: column;
}

#articleEditor {
    border: none;
    border-radius: 0;
    padding: 15px;
    height: 100%;
    resize: none;
}

.editor-sidebar {
    width: 220px;
    background: #f8f9fa;
    border-left: 1px solid #ddd;
    padding: 15px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.editor-sidebar h4 {
    margin: 0 0 10px 0;
    font-size: 0.9rem;
    text-transform: uppercase;
    color: #6c757d;
    letter-spacing: 0.5px;
    border-bottom: 1px solid #ddd;
    padding-bottom: 5px;
}

/* Toolbars */
.editor-toolbar {
    display: flex;
    gap: 5px;
    background: #f1f3f5;
    padding: 8px;
    border: 1px solid #ddd;
    border-bottom: none;
    border-radius: 6px 6px 0 0;
    flex-wrap: wrap;
    align-items: center;
}

.editor-toolbar button {
    padding: 6px 10px;
    background: #fff;
    border: 1px solid #ced4da;
    border-radius: 4px;
    cursor: pointer;
    font-size: 13px;
    color: #495057;
    min-width: 32px;
    transition: all 0.1s;
    box-shadow: 0 1px 2px rgba(0,0,0,0.05);
}

.editor-toolbar button:hover {
    background: #e9ecef;
    border-color: #adb5bd;
    transform: translateY(-1px);
}

.editor-toolbar .separator {
    width: 1px;
    height: 20px;
    background: #ccc;
    margin: 0 5px;
}

/* Helper Buttons in Sidebar */
.tag-btn {
    padding: 8px 12px;
    background: #fff;
    border: 1px solid #ddd;
    border-radius: 4px;
    cursor: pointer;
    text-align: left;
    font-size: 13px;
    color: #333;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    box-shadow: 0 1px 2px rgba(0,0,0,0.05);
}

.tag-btn:hover {
    background: #eef2ff;
    border-color: #007aff;
    color: #007aff;
}

.tag-btn::before {
    content: "›";
    margin-right: 8px;
    font-weight: bold;
    color: #aaa;
}

/* Cheat Sheet */
.cheat-sheet-container {
    font-size: 13px;
    color: #444;
    overflow-y: auto;
    max-height: 250px;
    background: #fff;
    border: 1px solid #eee;
    border-radius: 4px;
    padding: 10px;
}

.cheat-sheet-item {
    margin-bottom: 10px;
    padding-bottom: 10px;
    border-bottom: 1px solid #f0f0f0;
}

.cheat-sheet-item:last-child {
    border-bottom: none;
}

.cheat-sheet-title {
    font-weight: 700;
    color: #2c3e50;
    margin-bottom: 4px;
    display: block;
}

.cheat-sheet-code {
    font-family: monospace;
    background: #f8f9fa;
    padding: 2px 4px;
    border-radius: 3px;
    color: #d63384;
}

/* Buttons */
button.build {
    background-color: #007aff;
    color: white;
    padding: 10px 20px;
    border: none;
    border-radius: 6px;
    font-size: 16px;
    cursor: pointer;
    transition: background 0.2s;
}

button.build:hover {
    background-color: #0056b3;
}

button.save-btn {
    background-color: #28a745;
    color: white;
    padding: 12px 24px;
    border: none;
    border-radius: 6px;
    font-size: 16px;
    cursor: pointer;
    margin-top: 20px;
    width: 100%;
    font-weight: 600;
    box-shadow: 0 2px 4px rgba(40,167,69,0.3);
}

button.save-btn:hover {
    background-color: #218838;
}

/* Images */
.img-preview {
    border: 1px solid #dee2e6;
    padding: 4px;
    border-radius: 6px;
    background: #fff;
    box-shadow: 0 2px 5px rgba(0,0,0,0.05);
    object-fit: contain;
    width: auto;
    max-width: 100%;
    max-height: 150px;
}

/* Console */
#consoleOutput {
    background-color: #1e1e1e;
    color: #32cd32;
    font-family: 'SF Mono', 'Menlo', monospace;
    padding: 15px;
    border-radius: 8px;
    height: 300px;
    overflow-y: auto;
    white-space: pre-wrap;
    font-size: 13px;
    line-height: 1.4;
    border: 1px solid #333;
}

/* Restored Missing Styles */
.form-group {
    display: flex;
    gap: 10px;
    margin-bottom: 15px;
    align-items: center;
}

.edition-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

.edition-item {
    background: #f8f9fa;
    border: 1px solid #e9ecef;
    border-radius: 6px;
    padding: 15px;
    margin-bottom: 10px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    transition: all 0.2s;
}

.edition-item:hover {
    background: #fff;
    box-shadow: 0 2px 8px rgba(0,0,0,0.05);
    border-color: #dee2e6;
}

.edition-name {
    font-weight: 600;
    color: #34495e;
    font-size: 1.1rem;
}

.actions {
    display: flex;
    gap: 8px;
}

.actions button {
    padding: 6px 12px;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 14px;
    color: white;
    transition: opacity 0.2s;
}

.actions button:hover {
    opacity: 0.9;
}

.actions button.edit { background-color: #6c757d; }
/* .build is already defined but we can ensure specificity or let it cascade */
.actions button.build { background-color: #28a745; } 
.actions button.pdf { background-color: #17a2b8; }
.actions button.clean { background-color: #ffc107; color: #333; }
.actions button.delete { background-color: #dc3545; }

/* Sequence Number */
.article-seq {
    background: #e9ecef;
    color: #495057;
    font-size: 0.8rem;
    font-weight: bold;
    padding: 2px 6px;
    border-radius: 4px;
    margin-right: 8px;
    align-self: center;
}

/* Rename Input */
.rename-input {
    font-family: inherit;
    font-size: 1.1rem;
    font-weight: 600;
    color: #2c3e50;
    width: 100%;
    border: 1px solid #007aff;
    border-radius: 4px;
    padding: 2px 4px;
    margin: 0;
    background: #fff;
}

/* Image Grid Styles */
.image-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 15px;
    max-height: 50vh;
    overflow-y: auto;
    padding: 10px;
    border: 1px solid #eee;
    border-radius: 8px;
    background: #fcfcfc;
}

.image-card {
    background: #fff;
    border: 1px solid #eee;
    border-radius: 6px;
    padding: 8px;
    display: flex;
    flex-direction: column;
    align-items: center;
    cursor: pointer;
    transition: all 0.2s;
}

.image-card:hover {
    box-shadow: 0 4px 8px rgba(0,0,0,0.1);
    transform: translateY(-2px);
    border-color: #ddd;
}

.image-card.selected {
    border: 2px solid #007aff;
    background-color: #f0f7ff;
}

.image-card img {
    width: 100%;
    height: 100px;
    object-fit: contain;
    margin-bottom: 8px;
    border-radius: 4px;
    background-color: #f8f8f8;
}

.image-card p {
    margin: 0;
    font-size: 0.8rem;
    color: #555;
    text-align: center;
    word-break: break-all;
    max-width: 100%;
}

.image-actions {
    display: flex;
    gap: 5px;
    margin-top: 8px;
    width: 100%;
    justify-content: center;
}

.btn-mini {
    padding: 4px 8px;
    font-size: 12px;
    border-radius: 3px;
    border: none;
    cursor: pointer;
    color: white;
}

.btn-mini.delete { background: #dc3545; }
.btn-mini.rename { background: #6c757d; }
.btn-mini:hover { opacity: 0.8; }

.image-options {
    margin-top: 15px;
    padding-top: 15px;
    border-top: 1px solid #eee;
    display: flex;
    gap: 20px;
    align-items: center;
}

.option-group {
    display: flex;
    align-items: center;
    gap: 8px;
}

.option-group label {
    font-size: 0.9rem;
    font-weight: 600;
}
