/* =========================================
   VARIABLES GLOBALES ET THEMES
   ========================================= */
:root { 
    --bg: #1a1a1a; 
    --card: #2a2a2a; 
    --text: #e0e0e0; 
    --border: #444; 
    --accent: #2196F3; 
    --hover: #333; 
}

body[data-theme="light"] { --bg: #f8f9fa; --card: #fff; --text: #333; --border: #e9ecef; --accent: #007bff; --hover: #f1f3f5; }
body[data-theme="midnight"] { --bg: #0f172a; --card: #1e293b; --text: #e2e8f0; --border: #334155; --accent: #38bdf8; --hover: #334155; }
body[data-theme="dracula"] { --bg: #282a36; --card: #44475a; --text: #f8f8f2; --border: #6272a4; --accent: #bd93f9; --hover: #6272a4; }
body[data-theme="cyberpunk"] { --bg: #000b1e; --card: #051532; --text: #00ff9f; --border: #003cff; --accent: #ff003c; --hover: #0b254a; }
body[data-theme="matrix"] { --bg: #000; --card: #0d0d0d; --text: #00ff00; --border: #003300; --accent: #00cc00; --hover: #001a00; }
body[data-theme="ocean"] { --bg: #e0f7fa; --card: #ffffff; --text: #006064; --border: #b2ebf2; --accent: #00bcd4; --hover: #e0f2f1; }
body[data-theme="retro"] { --bg: #fdf6e3; --card: #eee8d5; --text: #657b83; --border: #d33682; --accent: #268bd2; --hover: #fdf6e3; }

/* =========================================
   BASE
   ========================================= */
body { 
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif; 
    background: var(--bg); 
    color: var(--text); 
    margin: 0; 
    padding: 15px; 
    padding-bottom: 100px; 
    transition: background 0.3s, color 0.3s; 
    min-height: 100vh; 
}
* { box-sizing: border-box; }
a { text-decoration: none; color: inherit; }

/* =========================================
   HEADER & BOUTONS
   ========================================= */
header { 
    margin-bottom: 20px; 
    width: 100%; 
    position: sticky; 
    top: 0; 
    z-index: 800; 
    background: var(--bg);
    padding: 15px 0; 
    border-bottom: 1px solid var(--border);
}
.top-bar { display: flex; justify-content: space-between; align-items: center; margin-bottom: 15px; flex-wrap: wrap; gap: 10px; }
.toolbar { background: var(--card); padding: 12px; border-radius: 12px; box-shadow: 0 1px 4px rgba(0,0,0,0.1); display: flex; flex-wrap: wrap; gap: 10px; justify-content: space-between; align-items: center; }

.btn { 
    border: 1px solid var(--border); 
    background: var(--card); 
    padding: 8px 15px; 
    border-radius: 20px; 
    cursor: pointer; 
    color: var(--text); 
    font-weight: 600; 
    font-size: 0.9rem; 
    display: inline-flex; 
    align-items: center; 
    gap: 6px; 
    white-space: nowrap; 
    transition: 0.2s;
}
.btn:hover { background: var(--hover); border-color: var(--accent); } 
.btn-primary { background: var(--accent); color: #fff; border-color: var(--accent); }
.btn-danger { color: #ff4444; border-color: #ff4444; } 
.btn-purple { color: #e040fb; border-color: #e040fb; } 
.btn-success { color: #00C851; border-color: #00C851; }
.btn-sm { padding: 6px 12px; font-size: 0.8rem; }
.btn-group { display: flex; gap: 5px; flex-wrap: wrap; }
.btn.active { background: var(--accent); color: white; border-color: var(--accent); }

/* =========================================
   BREADCRUMB (Fil d'ariane)
   ========================================= */
.breadcrumb { 
    background: var(--card); 
    padding: 10px 15px; 
    border-radius: 12px; 
    margin-bottom: 15px; 
    display: flex; 
    align-items: center; 
    box-shadow: 0 1px 2px rgba(0,0,0,0.1); 
    font-size: 1rem; 
    flex-wrap: wrap; 
    gap: 8px; 
}
.bc-item { color: var(--accent); font-weight: bold; cursor: pointer; } 
.bc-item:hover { text-decoration: underline; }
.bc-sep { margin: 0 5px; color: var(--text); opacity: 0.5; }

/* =========================================
   VUE FICHIERS (GRILLE ET LISTE)
   ========================================= */
.view-grid { 
    display: grid; 
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); 
    gap: 15px; 
}
.view-list { 
    display: flex; 
    flex-direction: column; 
    gap: 5px; 
    background: var(--card);
    padding: 10px;
    border-radius: 12px;
}

/* Cartes (Vue Grille) */
.file-card { 
    background: var(--card); 
    border: 1px solid var(--border); 
    border-radius: 12px; 
    padding: 10px; 
    text-align: center; 
    cursor: pointer; 
    transition: transform 0.2s, box-shadow 0.2s;
    position: relative;
    height: 160px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}
.file-card:hover { 
    transform: translateY(-3px); 
    box-shadow: 0 8px 20px rgba(0,0,0,0.3); 
    border-color: var(--accent); 
}
.card-thumb { 
    height: 80px; 
    max-width: 100%; 
    object-fit: contain; 
    margin-bottom: 12px; 
}
.card-name { 
    font-size: 0.85rem; 
    width: 100%;
    overflow: hidden; 
    text-overflow: ellipsis; 
    white-space: nowrap; 
}

/* Lignes (Vue Liste) */
.file-row {
    display: flex;
    align-items: center;
    padding: 10px;
    border-bottom: 1px solid var(--border);
    cursor: pointer;
    transition: background 0.2s;
    border-radius: 6px;
}
.file-row:hover { background: var(--hover); }
.file-row:last-child { border-bottom: none; }

/* =========================================
   MODALES (FENETRES)
   ========================================= */
.modal-overlay { 
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.85); /* Fond sombre transparent */
    z-index: 9500; /* Toujours au-dessus du reste */
    display: none; /* Géré par le JS (flex) */
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(8px); 
}

.modal-box { 
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 12px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.9); 
    animation: popIn 0.2s ease-out forwards;
    max-height: 95vh;
    overflow-y: auto;
}

@keyframes popIn { 
    from { transform: scale(0.9); opacity: 0; } 
    to { transform: scale(1); opacity: 1; } 
}

.confirm-box, .prompt-box { 
    background: var(--card); 
    border: 1px solid var(--border); 
    border-top: 4px solid var(--accent); 
    padding: 25px; 
    border-radius: 12px; 
    width: 90%; 
    max-width: 400px; 
    text-align: center; 
    display: flex; 
    flex-direction: column; 
    gap: 20px; 
}
.prompt-input { 
    width: 100%; 
    padding: 12px; 
    background: var(--bg); 
    border: 1px solid var(--border); 
    color: var(--text); 
    border-radius: 6px; 
    font-size: 1rem; 
    outline: none; 
}
.prompt-input:focus { border-color: var(--accent); }

/* Menu Contextuel */
.ctx-item:hover { background: var(--hover); color: var(--accent); }

/* WIDGET RECHERCHE FLOTTANT */
#search-widget {
    position: fixed;
    top: 80px;
    left: 50%;
    transform: translateX(-50%);
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 50px;
    padding: 10px 25px;
    box-shadow: 0 5px 20px rgba(0,0,0,0.5);
    z-index: 9500;
    align-items: center;
    gap: 15px;
    font-weight: bold;
    animation: slideDown 0.3s ease-out;
}
@keyframes slideDown { 
    from { transform: translate(-50%, -20px); opacity: 0; } 
    to { transform: translate(-50%, 0); opacity: 1; } 
}

/* Animations Toasts */
@keyframes slideIn { 
    from { transform: translateX(100%); opacity: 0; } 
    to { transform: translateX(0); opacity: 1; } 
}

/* =========================================
   STYLE EDITEUR COMPLEXE V28
   ========================================= */
.editor-toolbar { padding:12px; background:var(--card); border-bottom:1px solid var(--border); display:flex; gap:10px; align-items:center; flex-wrap:wrap; }
.editor-toolbar-group { display:flex; gap:8px; border-right:1px solid var(--border); padding-right:12px; align-items:center; flex-wrap:wrap; }
.editor-toolbar-group:last-child { border:none; }
.editor-title { font-weight:bold; margin-right:10px; font-size:1rem; white-space:nowrap; overflow:hidden; text-overflow:ellipsis; max-width:200px; color:var(--accent); }
.pane { flex:1; height:100%; display:flex; flex-direction:column; min-width:0; }
.pane-header { background:#222; padding:5px 10px; font-size:0.8rem; color:#888; border-bottom:1px solid #333; display:flex; justify-content:space-between; align-items:center;}
#notes-content { background:#1e1e1e; color:#ddd; border:none; padding:15px; font-family:monospace; resize:none; flex:1; outline:none; font-size:15px; line-height:1.6; }
#editor-statusbar { background:var(--card); padding:5px 15px; font-size:0.8rem; color:#aaa; border-top:1px solid var(--border); display:flex; justify-content:space-between; }

@media (max-width: 768px) {
    .editor-toolbar { flex-direction: column; align-items: stretch; gap: 8px; padding: 10px; }
    .editor-toolbar-group { border-right: none; border-bottom: 1px solid var(--border); padding-bottom: 8px; justify-content: space-between; width: 100%; padding-right: 0; }
    .editor-toolbar-group:last-child { border-bottom: none; }
    .editor-toolbar .btn { flex: 1; justify-content: center; padding: 10px; font-size: 0.85rem; }
    .editor-title { text-align: center; width: 100%; margin: 0 0 5px 0; max-width: none; }
}