/* --- Base Styles --- */
:root {
    --primary-color: #007bff;
    --secondary-color: #6c757d;
    --background-color: #f0f2f5;
    --text-color: #212529;
    --border-color: #dee2e6;
    --card-bg: #ffffff;
    --secondary-bg: #f8f9fa;    
    --shadow-color: rgba(0,0,0,0.08);
    --input-bg: #fdfdfd;
    --input-text: #495057;
    --success-color: #28a745;
    --info-color: #17a2b8;
    --danger-color: #dc3545;
    --editor-font-size: 1rem;
    --editor-line-height: 1.7;
}

[data-theme="dark"] {
    --primary-color: #0d6efd;
    --secondary-color: #6c757d;
    --background-color: #121212;
    --text-color: #e9ecef;
    --border-color: #495057;
    --card-bg: #1e1e1e;
    --secondary-bg: #343a40;    
    --shadow-color: rgba(255,255,255,0.08);
    --input-bg: #2b2b2b;
    --input-text: #f8f9fa;
}

/* --- Layout --- */
.main-layout {
    display: flex;
    gap: 2rem;
    width: 100%;
    max-width: 1800px;
    max-height: calc(100vh - 125px);
    margin: 0 auto;
    padding: 2rem;
    overflow: auto;
    flex: 1;
}

.editor-column { flex: 3; display: flex; flex-direction: column; }
.info-column { flex: 2; display: flex; flex-direction: column; gap: 1rem; }

.container, .tab-container, .storage-controls {
    background-color: var(--card-bg);
    border-radius: 12px;
    box-shadow: 0 4px 12px var(--shadow-color);
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
}
.editor-column .container { height: 100%; }
.info-column .tab-container { flex-grow: 1; }

/* --- Editor --- */
.editor-wrapper {
    flex-grow: 1;
    display: flex;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    background-color: var(--input-bg);
    overflow: hidden;
}
.line-numbers {
    width: 50px;
    padding: 1rem 0;
    text-align: right;
    font-family: 'D2Coding', 'Courier New', monospace;
    font-size: var(--editor-font-size);
    line-height: var(--editor-line-height);
    color: var(--secondary-color);
    background-color: var(--secondary-bg);
    user-select: none;
    overflow: hidden;
}
.line-numbers div { height: calc(var(--editor-font-size) * var(--editor-line-height)); padding-right: 1rem; }
.line-numbers .highlight-line { background-color: var(--primary-color); color: white; }
#structureInput {
    width: 100%; border: none; padding: 1rem;
    font-family: 'D2Coding', 'Courier New', monospace;
    font-size: var(--editor-font-size);
    line-height: var(--editor-line-height);
    color: var(--input-text);
    resize: none; flex-grow: 1; background-color: transparent;
    white-space: pre; overflow-x: auto;
}
#structureInput:focus { outline: none; box-shadow: none; }

/* --- Controls & Buttons --- */
.controls { display: flex; gap: 1rem; margin-bottom: 1rem; }
input[type="text"] {
    flex-grow: 1; border: 1px solid var(--border-color); border-radius: 8px;
    padding: 0.75rem 1rem; font-size: 1rem; background-color: var(--input-bg); color: var(--input-text);
}
.project_tree_zip button {
    padding: 0.75rem 1.5rem; border: none; border-radius: 8px; background-color: var(--primary-color);
    color: white; font-size: 1rem; font-weight: 700; cursor: pointer; transition: background-color 0.2s ease, transform 0.1s ease;
}
.project_tree_zip button:hover { transform: translateY(-2px); }
.project_tree_zip button:active { transform: translateY(0); }
#generateBtn:hover { background-color: #0056b3; }
.secondary-btn { background-color: var(--secondary-color); }
.secondary-btn:hover { background-color: #5a6268; }
#newProjectBtn { background-color: var(--success-color); }
#newProjectBtn:hover { background-color: #218838; }
#saveProjectBtn { background-color: var(--info-color); }
#saveProjectBtn:hover { background-color: #138496; }

/* --- Tabs --- */
.tab-header { display: flex; border-bottom: 2px solid var(--border-color); margin-bottom: 1rem; }
.tab-link {
    padding: 0.75rem 1.5rem; cursor: pointer; border: none; background-color: transparent; color: var(--secondary-color);
    font-size: 1rem; font-weight: 700; transition: color 0.3s, border-bottom 0.3s;
    border-bottom: 3px solid transparent; margin-bottom: -2px; transform: none !important;
}
.tab-link:hover { color: var(--primary-color); background-color: transparent; }
.tab-link.active { color: var(--primary-color); border-bottom: 3px solid var(--primary-color); }
.tab-content { display: none; padding: 0 0.5rem; animation: fadeInContent 0.5s; flex-grow: 1; flex-direction: column; }
.tab-content.active { display: flex; }
@keyframes fadeInContent { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }
.tab-content h3 { color: var(--primary-color); margin-bottom: 1rem; padding-bottom: 0.5rem; border-bottom: 1px solid var(--border-color); }
.tab-content ul { list-style-position: inside; padding-left: 0.5rem; font-size: 0.95rem; }

/* --- Memo Tab --- */
.memo-main-container { display: flex; gap: 1rem; height: 100%; }
.memo-slots-container { display: flex; flex-direction: column; gap: 0.5rem; padding-top: 0.5rem; }
.memo-slot { width: 20px; height: 40px; border-radius: 5px; cursor: pointer; border: 2px solid transparent; transition: border-color 0.2s, transform 0.2s; }
.memo-slot:hover { transform: scale(1.1); }
.memo-slot.active { border-color: var(--primary-color); box-shadow: 0 0 8px var(--primary-color); }
.memo-editor-container { flex-grow: 1; display: flex; flex-direction: column; }
.memo-header { display: flex; align-items: center; gap: 0.75rem; margin-bottom: 0.75rem; }
.memo-icon { font-size: 1.5rem; }
#memoTitle {
    flex-grow: 1; border: none; background: transparent; font-size: 1.25rem; font-weight: 700;
    color: var(--text-color); padding: 0.5rem; border-radius: 6px;
}
#memoTitle:focus { outline: none; background-color: var(--secondary-bg); }
.memo-color-palette { display: flex; gap: 0.5rem; align-items: center; }
.color-swatch { width: 24px; height: 24px; border-radius: 50%; cursor: pointer; border: 2px solid var(--border-color); transition: transform 0.2s; }
.color-swatch:hover { transform: scale(1.2); }
#memo-area {
    width: 100%; flex-grow: 1; border: 1px solid var(--border-color); border-radius: 8px; padding: 1rem;
    font-family: 'Noto Sans KR', sans-serif; font-size: 1rem; line-height: 1.6;
    color: var(--input-text); resize: none; transition: background-color 0.3s ease;
}

/* --- Other Components --- */
pre { background-color: var(--secondary-bg); border: 1px solid var(--border-color); border-radius: 8px; padding: 1rem; margin-top: 0.5rem; white-space: pre-wrap; word-break: break-all; }
code { font-family: 'D2Coding', 'Courier New', monospace; }
.code-example-header { display: flex; justify-content: space-between; align-items: center; }
.code-example-header span { font-weight: bold; font-size: 0.9rem; color: var(--secondary-color); }
.code-example-header button { font-size: 0.8rem; padding: 0.3rem 0.8rem; background-color: var(--secondary-color); }
.search-wrapper { display: flex; gap: 0.5rem; margin-bottom: 1rem; }
#searchResults { overflow-y: auto; font-size: 0.9rem; line-height: 1.8; }
#searchResults .highlight { background-color: var(--primary-color); color: white; padding: 2px 4px; border-radius: 3px; }
#openStorageModalBtn { width: 100%; background-color: var(--info-color); }
#openStorageModalBtn:hover { background-color: #138496; }

/* --- Modal & Status --- */
#status {
    visibility: hidden; min-width: 250px; background-color: #333; color: #fff; text-align: center;
    border-radius: 8px; padding: 16px; position: fixed; z-index: 1001; left: 50%;
    transform: translateX(-50%); bottom: 30px; font-size: 1rem; font-weight: 700;
    box-shadow: 0 4px 12px rgba(0,0,0,0.2);
}
#status.show { visibility: visible; animation: fadeIn 0.5s, fadeOut 0.5s 3.5s; }
#status.success { background-color: var(--success-color); }
#status.info { background-color: var(--info-color); }
#status.danger { background-color: var(--danger-color); }
#status.primary { background-color: var(--primary-color); }
@keyframes fadeIn { from {bottom: 0; opacity: 0;} to {bottom: 30px; opacity: 1;} }
@keyframes fadeOut { from {bottom: 30px; opacity: 1;} to {bottom: 0; opacity: 0;} }

.project_tree_zip.modal {
    display: none; position: fixed; z-index: 1000; left: 0; top: 0; width: 100%; height: 100%;
    overflow: auto; background-color: rgba(0,0,0,0.6); justify-content: center; align-items: center;
}
.project_tree_zip.modal.show { display: flex; }
.project_tree_zip.modal-content {
    background-color: var(--card-bg); color: var(--text-color); padding: 2rem; border-radius: 12px;
    box-shadow: 0 5px 15px rgba(0,0,0,0.3); width: 90%; max-width: 800px; position: relative;
    animation: slideIn 0.4s cubic-bezier(0.250, 0.460, 0.450, 0.940);
}
@keyframes slideIn { from { transform: translateY(-40px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }
.project_tree_zip.modal-header { display: flex; justify-content: space-between; align-items: center; padding-bottom: 1rem; border-bottom: 1px solid var(--border-color); margin-bottom: 1.5rem; }
.project_tree_zip.modal-header h3 { color: var(--primary-color); margin: 0; font-size: 1.5rem; }
#closeModalBtnZip {
    background: transparent; border: none; font-size: 2.5rem; font-weight: 300; color: var(--secondary-color);
    cursor: pointer; padding: 0; line-height: 1; transition: color 0.2s ease;
}
#closeModalBtnZip:hover { color: var(--text-color); background-color: transparent; transform: none; }
.slots-container { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 0.75rem; }
.slot { display: flex; flex-direction: column; align-items: stretch; gap: 0.5rem; padding: 0.75rem; border: 1px solid var(--border-color); border-radius: 8px; background-color: var(--secondary-bg); }
.slot span { text-align: center; font-size: 0.85rem; color: #888; margin-bottom: 0.25rem; }
.slot .button-group { display: flex; gap: 0.5rem; }
.slot button { font-size: 0.8rem; padding: 0.4rem 0.8rem; font-weight: normal; flex: 1; }
.slot .save-btn { background-color: var(--success-color); }
.slot .save-btn:hover { background-color: #218838; }
.slot .load-btn { background-color: var(--info-color); }
.slot .load-btn:hover { background-color: #138496; }

/* --- Responsive --- */
@media (max-width: 1200px) {
    .main-layout { flex-direction: column; }
}