* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background-color: #1e1e1e;
    color: #d4d4d4;
    height: 100vh;
    overflow: hidden;
}

/* Écran de sélection du dossier */
.folder-selector {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100vh;
    background: linear-gradient(135deg, #1e1e1e 0%, #2d2d30 100%);
}

.folder-selector-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 40px;
    background-color: #252526;
    border-radius: 12px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
    max-width: 500px;
}

.folder-selector-content h1 {
    font-size: 32px;
    margin-bottom: 20px;
    color: #ffffff;
    text-align: center;
}

.folder-selector-content p {
    font-size: 16px;
    color: #cccccc;
    margin-bottom: 30px;
    text-align: center;
}

.folder-info {
    font-size: 12px !important;
    color: #858585 !important;
    margin-top: 20px !important;
    text-align: center;
}

.btn-large {
    padding: 15px 30px !important;
    font-size: 16px !important;
}

.container {
    display: grid;
    grid-template-columns: 250px 1fr 1fr;
    height: 100vh;
    gap: 0;
}

/* Gestionnaire de fichiers */
.file-manager {
    background-color: #252526;
    border-right: 1px solid #3e3e42;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.file-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0;
    border-bottom: 1px solid #3e3e42;
}

.file-actions {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
    align-items: center;
    padding: 15px;
}

.action-icon {
    font-size: 20px;
    cursor: pointer;
    transition: transform 0.2s, opacity 0.2s;
    opacity: 0.8;
}

.action-icon:hover {
    transform: scale(1.2);
    opacity: 1;
}

.action-icon:active {
    transform: scale(1.1);
}

#refreshFilesBtn {
    padding: 15px;
}

.file-list {
    list-style: none;
    overflow-y: auto;
    flex: 1;
}

.file-item {
    padding: 10px 15px;
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    align-items: center;
    transition: background-color 0.2s;
    font-size: 13px;
    user-select: none;
}

.file-item.folder {
    font-weight: 500;
}

.file-item.nested {
    padding-left: 35px;
}

.file-item.nested.level-2 {
    padding-left: 55px;
}

.file-item.nested.level-3 {
    padding-left: 75px;
}

.file-item:hover {
    background-color: #2a2d2e;
}

.file-item.active {
    background-color: #37373d;
    border-left: 2px solid #007acc;
}

.file-name {
    display: flex;
    align-items: center;
    gap: 8px;
    flex: 1;
}

.folder-arrow {
    font-size: 10px;
    margin-right: 4px;
    transition: transform 0.2s;
}

.folder-arrow.collapsed {
    transform: rotate(-90deg);
}

.file-icon {
    font-size: 16px;
}

.delete-file-btn {
    background: none;
    border: none;
    color: #858585;
    cursor: pointer;
    padding: 4px;
    font-size: 14px;
    opacity: 0;
    transition: opacity 0.2s;
}

.file-item:hover .delete-file-btn,
.file-item:hover .rename-btn {
    opacity: 1;
}

.delete-file-btn:hover {
    color: #f48771;
}

.rename-btn {
    background: none;
    border: none;
    color: #858585;
    cursor: pointer;
    padding: 4px;
    font-size: 14px;
    opacity: 0;
    transition: opacity 0.2s;
    margin-right: 4px;
}

.rename-btn:hover {
    color: #4ec9b0;
}

/* Section éditeur */
.editor-section {
    background-color: #1e1e1e;
    display: flex;
    flex-direction: column;
    border-right: 1px solid #3e3e42;
}

.editor-header {
    padding: 10px 15px;
    background-color: #2d2d30;
    border-bottom: 1px solid #3e3e42;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.file-info {
    display: flex;
    align-items: center;
    gap: 10px;
}

#currentFileName {
    font-size: 10px;
    font-weight: 600;
    color: #cccccc;
}

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

.editor-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    border-bottom: 1px solid #3e3e42;
    position: relative;
}

.editor-container:last-child {
    border-bottom: none;
}

.editor-label {
    padding: 10px 15px;
    background-color: #2d2d30;
    font-size: 12px;
    font-weight: 600;
    color: #858585;
    letter-spacing: 0.5px;
    cursor: pointer;
    user-select: none;
    transition: background-color 0.2s;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.editor-label:hover {
    background-color: #3e3e42;
}

.editor-label:last-child {
    cursor: pointer;
}

.code-editor {
    flex: 1;
    background-color: #1e1e1e;
    color: #d4d4d4;
    border: none;
    font-family: 'Consolas', 'Courier New', monospace;
    font-size: 14px;
    line-height: 1.6;
    overflow: auto;
    position: relative;
    max-height: calc(50vh - 40px);
}

.code-editor.expanded {
    max-height: calc(100vh - 80px);
}

/* CodeMirror overrides */
.code-editor .cm-editor {
    height: auto;
    max-height: calc(50vh - 40px);
    font-size: 14px;
}

.code-editor.expanded .cm-editor {
    max-height: calc(100vh - 80px);
}

.code-editor .cm-scroller {
    font-family: 'Consolas', 'Courier New', monospace;
    line-height: 1.6;
    overflow: auto;
    max-height: calc(50vh - 40px);
}

.code-editor.expanded .cm-scroller {
    max-height: calc(100vh - 80px);
}


.code-editor .cm-gutters {
    background-color: #1e1e1e;
    border-right: 1px solid #3e3e42;
}

.code-editor::-webkit-scrollbar {
    width: 10px;
}

.code-editor::-webkit-scrollbar-track {
    background: #1e1e1e;
}

.code-editor::-webkit-scrollbar-thumb {
    background: #424242;
    border-radius: 5px;
}

.code-editor::-webkit-scrollbar-thumb:hover {
    background: #4e4e4e;
}

/* Section aperçu */
.preview-section {
    background-color: #252526;
    display: flex;
    flex-direction: column;
}

.preview-header {
    padding: 10px 15px;
    background-color: #2d2d30;
    border-bottom: 1px solid #3e3e42;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.preview-header h3 {
    font-size: 14px;
    font-weight: 600;
    color: #cccccc;
}

.preview-header h3 em {
    color: #999;
    font-style: italic;
    font-weight: 400;
}

.status-indicator {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
}

#autoSaveStatus {
    color: #4ec9b0;
    font-size: 8px;
}

#autoSaveStatus.saving {
    color: #ffa500;
    animation: pulse 1s infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

.preview-frame {
    flex: 1;
    width: 100%;
    border: none;
    background-color: white;
}

/* Boutons */
.btn {
    padding: 6px 12px;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 12px;
    font-weight: 500;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    gap: 4px;
}

.btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
}

.btn:active {
    transform: translateY(0);
}

.btn-primary {
    background-color: #007acc;
    color: white;
}

.btn-primary:hover {
    background-color: #0062a3;
}

.btn-secondary {
    background-color: #3e3e42;
    color: #cccccc;
}

.btn-secondary:hover {
    background-color: #505050;
}

.btn-success {
    background-color: #4ec9b0;
    color: #1e1e1e;
}

.btn-success:hover {
    background-color: #3fb89e;
}

.btn-danger {
    background-color: transparent;
    color: #858585;
    padding: 4px 8px;
}

.btn-danger:hover {
    background-color: #f48771;
    color: white;
}

/* Responsive */
@media (max-width: 1200px) {
    .container {
        grid-template-columns: 200px 1fr 1fr;
    }
}

@media (max-width: 768px) {
    .container {
        grid-template-columns: 1fr;
        grid-template-rows: auto 1fr 1fr;
    }
    
    .file-manager {
        border-right: none;
        border-bottom: 1px solid #3e3e42;
        max-height: 200px;
    }
    
    .editor-section {
        border-right: none;
    }
}

/* Editor Tools */
.editor-tools {
    display: flex;
    align-items: center;
    gap: 8px;
}

/* CSS Search */
.css-search-input {
    padding: 4px 8px;
    background: #3e3e42;
    border: 1px solid #555;
    border-radius: 4px;
    color: #cccccc;
    font-size: 12px;
    font-family: inherit;
    width: 150px;
    transition: all 0.3s;
    margin-right: 4px;
}

.css-search-input:focus {
    outline: none;
    border-color: #007acc;
    background: #2d2d30;
    width: 180px;
}

.css-search-input::placeholder {
    color: #999;
}

.css-search-counter {
    display: inline-block;
    padding: 4px 8px;
    background: #3e3e42;
    border-radius: 4px;
    color: #cccccc;
    font-size: 11px;
    font-family: 'Consolas', monospace;
    min-width: 40px;
    text-align: center;
    margin-right: 4px;
}

.css-search-nav-btn {
    padding: 4px 8px;
    background: #3e3e42;
    border: 1px solid #555;
    border-radius: 4px;
    color: #cccccc;
    font-size: 14px;
    cursor: pointer;
    transition: all 0.2s;
    margin-right: 4px;
}

.css-search-nav-btn:hover {
    background: #007acc;
    border-color: #007acc;
    color: #fff;
}

.css-search-nav-btn:active {
    transform: scale(0.95);
}

.css-search-clear-btn {
    padding: 4px 8px;
    background: transparent;
    border: 1px solid #555;
    border-radius: 4px;
    color: #999;
    font-size: 12px;
    cursor: pointer;
    margin-right: 8px;
    transition: all 0.2s;
}

.css-search-clear-btn:hover {
    background: #c74440;
    border-color: #c74440;
    color: #fff;
}

/* Color Picker */
.color-picker-icon {
    font-size: 16px;
    opacity: 0.7;
    cursor: pointer;
    transition: opacity 0.2s, transform 0.2s;
}

.color-picker-icon:hover {
    opacity: 1;
    transform: scale(1.1);
}

.color-picker-input {
    display: none;
}

.color-picker-input::-webkit-color-swatch-wrapper {
    padding: 0;
}

.color-picker-input::-webkit-color-swatch {
    border: none;
    border-radius: 2px;
}

.color-picker-input::-moz-color-swatch {
    border: none;
    border-radius: 2px;
}

/* Help Button */
.help-btn {
    background: none;
    border: none;
    font-size: 16px;
    cursor: pointer;
    padding: 0;
    margin: 0;
    opacity: 0.7;
    transition: opacity 0.2s, transform 0.2s;
}

.help-btn:hover {
    opacity: 1;
    transform: scale(1.1);
}

/* Modal Styles */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.8);
}

.modal.show {
    display: flex;
    justify-content: center;
    align-items: center;
}

.modal-content {
    background-color: #1e1e1e;
    border: 1px solid #3e3e42;
    border-radius: 8px;
    max-width: 700px;
    width: 90%;
    max-height: 80vh;
    display: flex;
    flex-direction: column;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.5);
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 25px;
    border-bottom: 1px solid #3e3e42;
}

.modal-header h2 {
    margin: 0;
    font-size: 20px;
    color: #cccccc;
}

.modal-close {
    font-size: 32px;
    color: #858585;
    cursor: pointer;
    line-height: 1;
    transition: color 0.2s;
}

.modal-close:hover {
    color: #ffffff;
}

.modal-body {
    padding: 20px 25px;
    overflow-y: auto;
    flex: 1;
}

.help-section-title {
    color: #ffffff;
    font-size: 15px;
    font-weight: 700;
    margin: 25px 0 15px 0;
    padding-bottom: 8px;
    border-bottom: 2px solid #007acc;
    letter-spacing: 0.5px;
}

.help-section-title:first-child {
    margin-top: 0;
}

.help-item {
    margin-bottom: 20px;
    padding: 15px;
    background-color: #252526;
    border-radius: 6px;
    border-left: 3px solid #007acc;
}

.help-item:last-child {
    margin-bottom: 0;
}

.help-title {
    font-family: 'Consolas', 'Courier New', monospace;
    font-size: 14px;
    color: #4ec9b0;
    margin-bottom: 8px;
    font-weight: 600;
}

.help-desc {
    font-size: 13px;
    color: #9cdcfe;
    line-height: 1.5;
}

/* Bibliothèque de Templates */
.template-btn {
    padding: 8px 16px;
    background: #007acc;
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 1.2rem;
    transition: background 0.3s;
    margin: 0 15px;
}

.template-btn:hover {
    background: #005a9e;
}

.template-modal-content {
    max-width: 1200px;
    width: 95%;
    max-height: 90vh;
}

.template-modal-body {
    display: flex;
    flex-direction: column;
    gap: 30px;
    max-height: calc(90vh - 120px);
}

.template-selection {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 30px;
}

.selection-section h3 {
    font-size: 1.1rem;
    margin-bottom: 15px;
    color: #ffffff;
    font-weight: 600;
}

.selection-buttons {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.content-option,
.style-option {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    padding: 15px;
    background-color: #2d2d30;
    border: 2px solid #3e3e42;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s;
    color: #cccccc;
    min-width: 100px;
}

.content-option:hover,
.style-option:hover {
    background-color: #37373d;
    border-color: #007acc;
}

.content-option.active,
.style-option.active {
    background-color: #007acc;
    border-color: #007acc;
    color: white;
}

.option-icon {
    font-size: 2rem;
}

.option-name {
    font-size: 0.9rem;
    font-weight: 500;
}

.template-preview-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.template-preview-container h3 {
    font-size: 1.1rem;
    color: #ffffff;
    font-weight: 600;
}

.template-preview-wrapper {
    flex: 1;
    background: #1e1e1e;
    border: 2px solid #3e3e42;
    border-radius: 8px;
    overflow: auto;
    position: relative;
    min-height: 500px;
    display: flex;
    justify-content: center;
    align-items: flex-start;
    padding: 20px;
}

#templatePreviewIframe {
    width: 1200px;
    height: 900px;
    border: none;
    transform: scale(0.7);
    transform-origin: top center;
    background: white;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
    border-radius: 4px;
}

.template-actions {
    display: flex;
    justify-content: flex-end;
    gap: 15px;
    padding-top: 20px;
    border-top: 1px solid #3e3e42;
}

.btn {
    padding: 12px 30px;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 1rem;
    font-weight: 600;
    transition: all 0.3s;
}

.btn-primary {
    background: #007acc;
    color: white;
}

.btn-primary:hover {
    background: #005a9e;
}

.btn-secondary {
    background: #3e3e42;
    color: #cccccc;
}

.btn-secondary:hover {
    background: #4e4e52;
}

@media (max-width: 900px) {
    .template-selection {
        grid-template-columns: 1fr;
    }
    
    .template-modal-content {
        width: 98%;
    }
    
    #templatePreviewIframe {
        width: 900px;
        height: 675px;
        transform: scale(0.6);
    }
    
    .template-preview-wrapper {
        min-height: 420px;
    }
}