:root {
    --bg-color: #ffffff;
    --text-color: #333333;
    --sidebar-bg: #f8f9fa;
    --accent-color: #2c3e50;
    --chord-color: #e74c3c;
    --border-color: #dddddd;
    --modal-overlay: rgba(0,0,0,0.5);
    --lyrics-font-size: 1.1rem;
    --chord-font-size: 0.9rem;
    --sidebar-left-width: 280px;
    --chord-panel-width: 220px;
}

[data-theme="dark"] {
    --bg-color: #1a1a1a;
    --text-color: #e0e0e0;
    --sidebar-bg: #252525;
    --accent-color: #3498db;
    --chord-color: #ff7675;
    --border-color: #444444;
}

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

body {
    font-family: 'Segoe UI', system-ui, sans-serif;
    background-color: var(--bg-color);
    color: var(--text-color);
    height: 100vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

body.is-resizing {
    cursor: col-resize;
    user-select: none;
}

/* Header */
.top-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.75rem 1.5rem;
    background-color: var(--accent-color);
    color: white;
    box-shadow: 0 2px 5px rgba(0,0,0,0.1);
    z-index: 100;
}

.header-left { display: flex; align-items: center; gap: 1rem; }

#menu-toggle, #options-toggle {
    background: none;
    border: none;
    color: white;
    font-size: 1.5rem;
    cursor: pointer;
    padding: 0 5px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
}

#menu-toggle:hover, #options-toggle:hover { background: rgba(255,255,255,0.1); }

.logo { font-size: 1.25rem; font-weight: bold; }

@media (max-width: 900px) {
    .logo { display: none; }
}

.transpose-controls {
    display: flex;
    align-items: center;
    background: rgba(255,255,255,0.1);
    padding: 0.25rem 0.5rem;
    border-radius: 20px;
    gap: 0.5rem;
}

.transpose-controls button {
    background: none;
    border: none;
    color: white;
    cursor: pointer;
    font-size: 1.2rem;
    padding: 0 5px;
}

#transpose-val {
    background: white;
    color: var(--accent-color);
    padding: 2px 10px;
    border-radius: 12px;
    font-size: 0.9rem;
    font-weight: bold;
    min-width: 80px;
    text-align: center;
}

.header-actions { display: flex; gap: 0.75rem; }
.header-actions button {
    background: rgba(255,255,255,0.2);
    border: 1px solid rgba(255,255,255,0.3);
    color: white;
    padding: 5px 12px;
    border-radius: 4px;
    cursor: pointer;
}

.header-actions button:hover { background: rgba(255,255,255,0.3); }

/* Layout Principal (4 colonnes) */
.main-container {
    display: grid;
    /* Sidebar L | Song View | Resizer | Chord Panel */
    grid-template-columns: var(--sidebar-left-width) 1fr 6px var(--chord-panel-width);
    flex-grow: 1;
	height: calc(100vh - 60px); /* Ajuste selon la hauteur de ta top-bar */
    min-height: 0;
    overflow: hidden;
    transition: grid-template-columns 0.3s ease;
}

.main-container.sidebar-hidden {
    grid-template-columns: 0px 1fr 6px var(--chord-panel-width);
}

body.is-resizing .main-container {
    transition: none;
}

/* On force les éléments dans leurs colonnes respectives */
.sidebar { grid-column: 1; }
.song-view { grid-column: 2; }
.resizer-v { grid-column: 3; }
.chord-panel { grid-column: 4; }

.sidebar, .chord-panel, .song-view {
    min-width: 0;
	-webkit-overflow-scrolling: touch; /* Essentiel pour Android / iOS anciens */
    overflow-y: auto;
}

.sidebar {
    background-color: var(--sidebar-bg);
    overflow-y: auto;
    padding: 1.5rem;
    border-right: 1px solid var(--border-color);
    transition: opacity 0.3s ease;
}

.main-container.sidebar-hidden .sidebar {
    padding: 0;
    opacity: 0;
    border: none;
    overflow: hidden;
}

/* Resizer */
.resizer-v {
    width: 6px;
    cursor: col-resize;
    background-color: var(--border-color);
    z-index: 10;
}

.resizer-v:hover, body.is-resizing .resizer-v {
    background-color: var(--accent-color);
}

.chord-panel {
    background-color: var(--sidebar-bg);
    overflow-y: auto;
    padding: 1.5rem;
    border-left: 1px solid var(--border-color);
    container-type: inline-size;
}

.chord-panel.is-collapsed {
    padding: 0;
    border: none;
}

/* Song View */
.song-view {
    padding: 2rem 3rem;
    overflow-y: auto;
    background-color: var(--bg-color);
    min-width: 0;
}

@media (max-width: 600px) {
    .song-view {
        padding: 2rem 1rem;
    }
    .chord-panel {
        padding: 1rem 0.5rem;
    }
}

#song-metadata {
    margin-bottom: 2rem;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 1rem;
}

#song-metadata h1 { font-size: 2rem; margin-bottom: 0.5rem; }
#song-metadata h2 { font-size: 1.25rem; opacity: 0.7; font-weight: normal; }

#song-content {
    font-family: 'Courier New', Courier, monospace;
    white-space: pre-wrap;
    font-size: var(--lyrics-font-size);
    line-height: 2.5;
    word-break: break-word;
}

.song-line {
    position: relative;
    display: block;
    min-height: 1.5em;
}

/* Accords */
.chord {
    color: var(--chord-color);
    font-weight: bold;
    cursor: pointer;
    position: relative;
    display: inline-block;
    font-family: sans-serif;
    font-size: var(--chord-font-size);
}

.chord:empty {
    position: absolute;
    width: 0;
    white-space: nowrap;
    transform: translateY(-1.2em);
}

.chord:empty::after { content: attr(data-chord); }
.chord:not(:empty) { margin-right: 0.3ch; }

/* Sidebar L Content */
.search-section {
    display: flex;
    margin-bottom: 1rem;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    background: var(--bg-color);
}

.search-section input {
    flex: 1;
    border: none;
    padding: 8px 10px;
    background: transparent;
    color: var(--text-color);
}

.search-section button {
    background: none;
    border: none;
    padding: 0 10px;
    cursor: pointer;
    color: var(--text-color);
}

#song-list {
    list-style: none;
    margin-bottom: 2rem;
}

#song-list li {
    padding: 10px;
    border-radius: 4px;
    cursor: pointer;
    margin-bottom: 2px;
}

#song-list li:hover { background: rgba(0,0,0,0.05); }
#song-list li.active { background: var(--accent-color); color: white; }

/* Side Panel (Options) */
.side-panel {
    position: fixed;
    top: 56px;
    right: -250px;
    width: 250px;
    height: calc(100vh - 56px);
    background-color: var(--sidebar-bg);
    border-left: 1px solid var(--border-color);
    box-shadow: -2px 0 10px rgba(0,0,0,0.1);
    z-index: 500;
    transition: right 0.3s ease;
    display: flex;
    flex-direction: column;
}

.side-panel.open {
    right: 0;
}

.panel-header {
    padding: 1rem 1.5rem;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.panel-header h3 { font-size: 1.1rem; }

#close-options {
    background: none;
    border: none;
    font-size: 1.2rem;
    cursor: pointer;
    color: var(--text-color);
    opacity: 0.5;
}

.panel-body {
    padding: 1.5rem;
    overflow-y: auto;
}

.setting-row { margin-bottom: 1.5rem; }
.setting-row label { display: block; font-size: 0.85rem; font-weight: bold; margin-bottom: 8px; opacity: 0.8; }

.btn-full {
    width: 100%;
    padding: 10px;
    border: 1px solid var(--border-color);
    background: var(--bg-color);
    color: var(--text-color);
    border-radius: 4px;
    cursor: pointer;
}

.btn-group {
    display: flex;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    overflow: hidden;
}

.btn-group button {
    flex: 1;
    padding: 8px;
    border: none;
    background: var(--bg-color);
    color: var(--text-color);
    cursor: pointer;
}

.btn-group span {
    flex: 2;
    text-align: center;
    font-size: 0.85rem;
    padding: 8px;
    background: var(--bg-color);
    border-left: 1px solid var(--border-color);
    border-right: 1px solid var(--border-color);
}

/* Chord Panel Content */
.instrument-box {
    margin-bottom: 1.5rem;
}

#instrument-select {
    width: 100%;
    padding: 8px;
    margin-bottom: 0.5rem;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    background: var(--bg-color);
    color: var(--text-color);
}

.zoom-controls {
    display: flex;
    gap: 5px;
}

.zoom-controls button {
    flex: 1;
    padding: 4px;
    font-size: 0.8rem;
    border: 1px solid var(--border-color);
    background: var(--bg-color);
    color: var(--text-color);
    cursor: pointer;
    border-radius: 4px;
}

.zoom-controls button:hover {
    background: rgba(0,0,0,0.05);
}
[data-theme="dark"] .zoom-controls button:hover { background: rgba(255,255,255,0.05); }

.chord-section {
    margin-bottom: 1.5rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid var(--border-color);
    text-align: center;
}

.chord-title-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
}

.chord-title-header button {
    background: none;
    border: none;
    cursor: pointer;
    color: var(--text-color);
}

uke-chord { display: block; width: 100%; max-width: 160px; margin: 0 auto; }

/* Mode nuit par défaut : on inverse les couleurs du diagramme */
			[data-theme="dark"] uke-chord {
				filter: invert(0.9) hue-rotate(180deg);
			}

@container (max-width: 150px) {
    .chord-title-header h4 { font-size: 0.8rem; }
    uke-chord { max-width: 80px; }
    .chord-panel { padding: 8px; }
}

@container (min-width: 300px) {
    .chord-title-header h4 { font-size: 1.4rem; }
    uke-chord { max-width: 250px; }
    .chord-panel { padding: 25px; }
}

/* Modal */
.modal {
    display: none;
    position: fixed;
    top: 0; left: 0; width: 100%; height: 100%;
    background: var(--modal-overlay);
    justify-content: center;
    align-items: center;
    z-index: 1000;
}

.modal-content {
    background: var(--bg-color);
    padding: 2rem;
    width: 90%;
    max-width: 600px;
    border-radius: 8px;
    box-shadow: 0 5px 20px rgba(0,0,0,0.2);
}

textarea {
    width: 100%;
    height: 300px;
    padding: 1rem;
    margin: 1rem 0;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    background: var(--bg-color);
    color: var(--text-color);
}

.modal-actions { display: flex; justify-content: flex-end; gap: 1rem; }
.modal-actions button { padding: 8px 16px; cursor: pointer; border-radius: 4px; border: 1px solid var(--border-color); }
#save-song { background: var(--accent-color); color: white; border: none; }

/* Bouton d'ajout dans la sidebar */
.btn-primary-add {
    width: calc(100% - 1rem);
    margin: 0.5rem;
    padding: 0.75rem;
    background-color: #2563eb;
    color: white;
    border: none;
    border-radius: 8px;
    font-weight: bold;
    cursor: pointer;
    font-size: 0.95rem;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
}

.btn-primary-add:active {
    transform: scale(0.98);
}
