/* Reset et styles de base */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    color: #333;
}

.container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 20px;
    background: white;
    margin-top: 20px;
    margin-bottom: 20px;
    border-radius: 15px;
    box-shadow: 0 20px 40px rgba(0,0,0,0.1);
}

/* Toolbar */
.toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    padding: 15px 20px;
    background: #f8f9fa;
    border-radius: 10px;
    border: 1px solid #e9ecef;
    flex-wrap: wrap;
    gap: 10px;
}

.toolbar-group {
    display: flex;
    gap: 10px;
    align-items: center;
}

.toolbar button {
    padding: 10px 15px;
    border: none;
    border-radius: 8px;
    background: linear-gradient(145deg, #ffffff, #f0f0f0);
    color: #2c3e50;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    transition: all 0.3s ease;
    box-shadow: 0 2px 5px rgba(0,0,0,0.1);
    display: flex;
    align-items: center;
    gap: 8px;
}

.toolbar button:hover {
    background: linear-gradient(145deg, #3498db, #2980b9);
    color: white;
    transform: translateY(-2px);
    box-shadow: 0 4px 10px rgba(52, 152, 219, 0.3);
}

.toolbar button:active {
    transform: translateY(0);
}

.toolbar button i {
    font-size: 16px;
}

/* Container principal */
.editor-container {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    margin-bottom: 20px;
    min-height: 600px;
}

.editor-panel,
.preview-panel {
    background: #fff;
    border: 1px solid #e1e8ed;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 4px 15px rgba(0,0,0,0.05);
    transition: all 0.3s ease;
}

.editor-panel:hover,
.preview-panel:hover {
    box-shadow: 0 8px 25px rgba(0,0,0,0.1);
}

.editor-panel h3,
.preview-panel h3 {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 15px 20px;
    font-size: 1.1em;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 10px;
}

/* Éditeur Quill */
#editor {
    height: 500px;
    border: none;
}

.ql-editor {
    font-size: 16px;
    line-height: 1.6;
    padding: 20px;
}

.ql-toolbar {
    border-bottom: 1px solid #e1e8ed;
    background: #f8f9fa;
}

/* Zone de texte Markdown */
#markdownInput {
    width: 100%;
    height: 500px;
    border: none;
    padding: 20px;
    font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', monospace;
    font-size: 14px;
    line-height: 1.6;
    resize: none;
    outline: none;
    background: #fafafa;
    color: #2c3e50;
}

#markdownInput:focus {
    background: #fff;
}

/* Aperçu */
#preview {
    padding: 20px;
    height: 500px;
    overflow-y: auto;
    line-height: 1.6;
    font-size: 16px;
}

/* Styles pour le contenu Markdown rendu */
#preview h1, #preview h2, #preview h3, #preview h4, #preview h5, #preview h6 {
    margin: 20px 0 10px 0;
    color: #2c3e50;
    font-weight: 600;
}

#preview h1 {
    font-size: 2em;
    border-bottom: 2px solid #3498db;
    padding-bottom: 10px;
}

#preview h2 {
    font-size: 1.5em;
    border-bottom: 1px solid #bdc3c7;
    padding-bottom: 5px;
}

#preview p {
    margin: 15px 0;
    text-align: justify;
}

#preview ul, #preview ol {
    margin: 15px 0;
    padding-left: 30px;
}

#preview li {
    margin: 5px 0;
}

#preview blockquote {
    border-left: 4px solid #3498db;
    margin: 20px 0;
    padding: 10px 20px;
    background: #f8f9fa;
    font-style: italic;
}

#preview code {
    background: #f8f9fa;
    padding: 2px 6px;
    border-radius: 4px;
    font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', monospace;
    font-size: 0.9em;
    color: #e74c3c;
}

#preview pre {
    background: #2c3e50;
    color: #ecf0f1;
    padding: 20px;
    border-radius: 8px;
    overflow-x: auto;
    margin: 20px 0;
}

#preview pre code {
    background: none;
    padding: 0;
    color: inherit;
}

#preview table {
    width: 100%;
    border-collapse: collapse;
    margin: 20px 0;
}

#preview th, #preview td {
    border: 1px solid #bdc3c7;
    padding: 12px;
    text-align: left;
}

#preview th {
    background: #3498db;
    color: white;
    font-weight: 600;
}

#preview tr:nth-child(even) {
    background: #f8f9fa;
}

#preview a {
    color: #3498db;
    text-decoration: none;
    border-bottom: 1px dotted #3498db;
}

#preview a:hover {
    border-bottom: 1px solid #3498db;
}

#preview img {
    max-width: 100%;
    height: auto;
    border-radius: 8px;
    margin: 10px 0;
}

/* Barre de statistiques */
.stats-bar {
    display: flex;
    justify-content: center;
    gap: 30px;
    padding: 15px;
    background: #f8f9fa;
    border-radius: 10px;
    border: 1px solid #e9ecef;
    font-size: 14px;
    color: #6c757d;
}

.stats-bar span {
    font-weight: 500;
}

/* Modal */
.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(5px);
}

.modal-content {
    background-color: #fff;
    margin: 5% auto;
    padding: 30px;
    border-radius: 15px;
    width: 90%;
    max-width: 600px;
    position: relative;
    box-shadow: 0 20px 40px rgba(0,0,0,0.2);
}

.close {
    position: absolute;
    top: 15px;
    right: 25px;
    color: #aaa;
    font-size: 28px;
    font-weight: bold;
    cursor: pointer;
    transition: color 0.3s;
}

.close:hover {
    color: #e74c3c;
}

.shortcuts {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 15px;
    margin-top: 20px;
}

.shortcuts div {
    padding: 10px;
    background: #f8f9fa;
    border-radius: 8px;
    display: flex;
    align-items: center;
    gap: 15px;
}

kbd {
    background: #2c3e50;
    color: white;
    padding: 5px 10px;
    border-radius: 5px;
    font-family: monospace;
    font-size: 12px;
    min-width: 120px;
    text-align: center;
}

/* Mode responsive */
@media (max-width: 1024px) {
    .editor-container {
        grid-template-columns: 1fr;
    }
    
    .preview-panel {
        order: -1;
    }
    
    .container {
        margin: 10px;
        padding: 15px;
    }
    
    .brand-section {
        flex-direction: column;
        gap: 10px;
        text-align: center;
    }
    
    .title-section {
        align-items: center;
    }
    
    .brand-logo {
        height: 45px;
    }
    
    header h1 {
        font-size: 2em;
    }
    
    .toolbar {
        flex-direction: column;
        align-items: stretch;
    }
    
    .toolbar-group {
        justify-content: center;
    }
}

@media (max-width: 768px) {
    .toolbar button {
        padding: 8px 12px;
        font-size: 12px;
    }
    
    .toolbar button span {
        display: none;
    }
    
    #editor,
    #markdownInput,
    #preview {
        height: 400px;
    }
    
    .stats-bar {
        flex-direction: column;
        gap: 10px;
        text-align: center;
    }
    
    .shortcuts {
        grid-template-columns: 1fr;
    }
}

/* Animations */
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}

.editor-panel,
.preview-panel {
    animation: fadeIn 0.5s ease;
}

/* Scrollbar personnalisée */
#preview::-webkit-scrollbar,
#markdownInput::-webkit-scrollbar {
    width: 8px;
}

#preview::-webkit-scrollbar-track,
#markdownInput::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 4px;
}

#preview::-webkit-scrollbar-thumb,
#markdownInput::-webkit-scrollbar-thumb {
    background: #bdc3c7;
    border-radius: 4px;
}

#preview::-webkit-scrollbar-thumb:hover,
#markdownInput::-webkit-scrollbar-thumb:hover {
    background: #95a5a6;
}

/* États actifs */
.toolbar button.active {
    background: linear-gradient(145deg, #3498db, #2980b9);
    color: white;
}

/* Mode plein écran pour les panneaux */
.fullscreen {
    grid-column: 1 / -1;
}

.hidden {
    display: none !important;
}

/* Bandeau de restauration */
.restore-banner {
    background: linear-gradient(135deg, #ffd89b 0%, #19547b 100%);
    color: white;
    padding: 15px 20px;
    margin-bottom: 20px;
    border-radius: 10px;
    box-shadow: 0 4px 15px rgba(0,0,0,0.1);
    animation: slideDown 0.3s ease-out;
}

@keyframes slideDown {
    from {
        opacity: 0;
        transform: translateY(-20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.restore-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 20px;
    flex-wrap: wrap;
}

.restore-info {
    flex: 1;
    min-width: 300px;
}

.restore-info h4 {
    margin-bottom: 8px;
    font-size: 16px;
    font-weight: 600;
}

.restore-info h4 i {
    margin-right: 8px;
    color: #ffd700;
}

.restore-preview {
    font-size: 14px;
    line-height: 1.4;
    margin-bottom: 5px;
    opacity: 0.9;
    font-style: italic;
    max-height: 60px;
    overflow: hidden;
    text-overflow: ellipsis;
}

.restore-date {
    font-size: 12px;
    opacity: 0.8;
    margin: 0;
}

.restore-actions {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.restore-actions button {
    padding: 8px 12px;
    border: none;
    border-radius: 6px;
    font-size: 14px;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    gap: 6px;
    font-weight: 500;
}

.btn-restore {
    background: #27ae60;
    color: white;
}

.btn-restore:hover {
    background: #229954;
    transform: translateY(-1px);
}

.btn-copy {
    background: #3498db;
    color: white;
}

.btn-copy:hover {
    background: #2980b9;
    transform: translateY(-1px);
}

.btn-delete {
    background: #e74c3c;
    color: white;
}

.btn-delete:hover {
    background: #c0392b;
    transform: translateY(-1px);
}

.btn-dismiss {
    background: rgba(255,255,255,0.2);
    color: white;
    border: 1px solid rgba(255,255,255,0.3);
}

.btn-dismiss:hover {
    background: rgba(255,255,255,0.3);
    transform: translateY(-1px);
}

/* Responsive pour le bandeau de restauration */
@media (max-width: 768px) {
    .restore-content {
        flex-direction: column;
        align-items: stretch;
        text-align: center;
    }
    
    .restore-info {
        min-width: auto;
        margin-bottom: 10px;
    }
    
    .restore-actions {
        justify-content: center;
    }
    
    .restore-actions button {
        flex: 1;
        min-width: 80px;
    }
}

/* Animations pour les notifications */
@keyframes slideInRight {
    from {
        opacity: 0;
        transform: translateX(100%);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

@keyframes slideOutRight {
    from {
        opacity: 1;
        transform: translateX(0);
    }
    to {
        opacity: 0;
        transform: translateX(100%);
    }
}
