/* reset */
*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }

:root {
    --bg:         #0f0f0f;
    --bg2:        #181818;
    --bg3:        #212121;
    --bg4:        #2a2a2a;
    --border:     #333;
    --text:       #fff;
    --muted:      #888;
    --faint:      #555;
    --red:        #ff0000;
    --red-dark:   #cc0000;
    --red-dim:    #3d0000;
    --blue-dim:   #1a2d3d;
    --blue-light: #7ecfff;
    --green-dim:  #1a3d1a;
    --green-light:#99ff99;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
    padding: 20px;
}

a { color: inherit; text-decoration: none; }

.container { max-width: 1400px; margin: 0 auto; }

/* header */
.header { text-align: center; margin-bottom: 20px; }
.logo { font-size: 1.5rem; color: var(--red); font-weight: 700; }
a.logo:hover { color: var(--red-dark); }

/* input url */
.input-section {
    background: var(--bg3);
    padding: 15px 20px;
    border-radius: 12px;
    margin-bottom: 20px;
}

.input-group { display: flex; gap: 10px; flex-wrap: wrap; }

.url-input {
    flex: 1;
    min-width: 300px;
    padding: 12px 16px;
    border: 2px solid var(--border);
    border-radius: 8px;
    background: var(--bg);
    color: var(--text);
    font-size: 1rem;
}

.url-input:focus { outline: none; border-color: var(--red); }

.load-btn {
    padding: 12px 24px;
    background: var(--red);
    color: #fff;
    border: none;
    border-radius: 8px;
    font-size: 1rem;
    cursor: pointer;
    transition: background 0.2s;
    white-space: nowrap;
}

.load-btn:hover { background: var(--red-dark); }
.load-btn:disabled { background: #666; cursor: not-allowed; }

/* instructions */
.instructions { margin-bottom: 20px; }

.instructions-toggle {
    background: #1a1a1a;
    border: 1px solid var(--border);
    color: var(--muted);
    padding: 10px 16px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 0.9rem;
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
    text-align: left;
}

.instructions-toggle:hover { background: #222; }
.instructions-toggle .arrow { margin-left: auto; transition: transform 0.2s; }
.instructions-toggle.open .arrow { transform: rotate(180deg); }

.instructions-body {
    display: none;
    background: #1a1a1a;
    border: 1px solid var(--border);
    border-top: none;
    border-radius: 0 0 8px 8px;
    padding: 15px 20px;
}

.instructions-body ul { color: #ccc; padding-left: 20px; }
.instructions-body li { margin-bottom: 5px; font-size: 0.9rem; }

/* layout */
.main-layout { display: flex; gap: 20px; align-items: flex-start; }
.player-section { flex: 1; min-width: 0; }

/* sidebar playlist */
.playlists-tabs {
    background: #1a1a1a;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 10px;
    flex-shrink: 0;
}

.playlist-select {
    flex: 1;
    background: var(--bg);
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 6px 10px;
    font-size: 0.85rem;
    cursor: pointer;
    outline: none;
}

.playlist-select:focus {
    border-color: var(--red);
}
.tab-add{
    background: var(--border);
    color: #ccc;
    border:1px var(--faint) solid;
    padding:3px 6px;
    border-radius: 2px;
    cursor: pointer;
}
.tab-add:hover{
    color: #fff;
    border-color:#fff;
}


/* header playlist */
.playlist-header {
    padding: 10px 12px;
    background: var(--bg4);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    flex-shrink: 0;
}

.playlist-name-input {
    background: none;
    border: none;
    color: #fff;
    font-size: 0.95rem;
    font-weight: 600;
    flex: 1;
    min-width: 0;
    padding: 2px 4px;
    border-radius: 4px;
}

.playlist-name-input:focus {
    outline: 1px solid var(--red);
    background: #1a1a1a;
}

.playlist-actions { display: flex; gap: 5px; flex-shrink: 0; }

.btn-small {
    padding: 5px 9px;
    border-radius: 6px;
    border: none;
    font-size: 0.75rem;
    cursor: pointer;
    transition: background 0.2s;
    white-space: nowrap;
}

.btn-export { background: var(--border); color: #ccc; }
.btn-export:hover { background: #444; }

.btn-share { background: var(--blue-dim); color: var(--blue-light); }
.btn-share:hover { background: #1e3a52; }

.btn-save { background: var(--green-dim); color: var(--green-light); }
.btn-save:hover { background: #245a24; }
.btn-save.saving { opacity: 0.6; cursor: not-allowed; }

.btn-clear { background: #3d1a1a; color: #ff9999; }
.btn-clear:hover { background: #5a2020; }

/* drop zone */
.drop-zone {
    margin: 8px 10px;
    padding: 8px 12px;
    border: 2px dashed var(--border);
    border-radius: 8px;
    text-align: center;
    color: var(--faint);
    font-size: 0.8rem;
    cursor: pointer;
    transition: border-color 0.2s, color 0.2s, background 0.2s;
    flex-shrink: 0;
}

.drop-zone:hover, .drop-zone.drag-over {
    border-color: var(--red);
    color: #ff9999;
    background: #1a0000;
}

.drop-zone input[type="file"] { display: none; }
.drop-zone label { cursor: pointer; }

/* liste */
.playlist-list { overflow-y: auto; flex: 1; padding: 8px; }

.playlist-empty {
    text-align: center;
    color: var(--faint);
    padding: 30px 10px;
    font-size: 0.9rem;
}

.playlist-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 8px;
    border-radius: 8px;
    cursor: pointer;
    transition: background 0.2s;
    margin-bottom: 4px;
    border: 1px solid transparent;
}

.playlist-item:hover { background: var(--bg4); }

.playlist-item.active {
    background: var(--red-dim);
    border-color: var(--red);
}

.playlist-item-num {
    font-size: 0.72rem;
    color: var(--faint);
    width: 16px;
    text-align: right;
    flex-shrink: 0;
}

.playlist-thumb {
    width: 54px;
    height: 30px;
    object-fit: cover;
    border-radius: 4px;
    flex-shrink: 0;
    background: var(--border);
}

.playlist-item-info { flex: 1; min-width: 0; }

.playlist-item-title {
    font-size: 0.8rem;
    color: #fff;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.playlist-item-author {
    font-size: 0.72rem;
    color: var(--muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.playlist-item-remove {
    background: none;
    border: none;
    color: var(--faint);
    cursor: pointer;
    font-size: 1rem;
    padding: 2px 4px;
    border-radius: 4px;
    flex-shrink: 0;
}

.playlist-item-remove:hover { color: #ff4444; background: #2a0000; }

/* player */
.video-container {
    width: 100%;
    background: #000;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 8px 32px rgba(0,0,0,0.3);
}

.video-placeholder {
    aspect-ratio: 16/9;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg2);
    border: 2px dashed var(--border);
}

.placeholder-text { color: var(--faint); font-size: 1.1rem; }

.video-iframe { width: 100%; aspect-ratio: 16/9; border: none; display: block; }

.video-info {
    margin-top: 15px;
    background: var(--bg3);
    padding: 15px 20px;
    border-radius: 12px;
    display: none;
}

.video-title { font-size: 1.1rem; margin-bottom: 5px; }
.video-description { color: var(--muted); font-size: 0.9rem; }

/* section playlists en ligne */
.online-section {
    margin-top: 40px;
    padding-top: 30px;
    border-top: 1px solid var(--border);
}

.section-title {
    font-size: 1.2rem;
    margin-bottom: 20px;
    color: #fff;
}

.online-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 16px;
}

.online-empty {
    color: var(--faint);
    font-size: 0.9rem;
    grid-column: 1/-1;
}

.online-card {
    background: var(--bg3);
    border-radius: 10px;
    overflow: hidden;
    transition: transform 0.2s, box-shadow 0.2s;
    border: 1px solid transparent;
    display: block;
}

.online-card:hover {
    transform: translateY(-3px);
    box-shadow: 0 8px 24px rgba(0,0,0,0.4);
    border-color: var(--border);
}

.online-card-thumb {
    width: 100%;
    aspect-ratio: 16/9;
    background-color: var(--bg4);
    background-size: cover;
    background-position: center;
    display: flex;
    align-items: center;
    justify-content: center;
}

.thumb-placeholder { font-size: 2rem; }

.online-card-info { padding: 10px 12px; }

.online-card-name {
    font-size: 0.9rem;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-bottom: 4px;
}

.online-card-meta { font-size: 0.75rem; color: var(--muted); }

/* badge sync */
.sync-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 0.72rem;
    padding: 2px 7px;
    border-radius: 10px;
    margin-left: 6px;
    vertical-align: middle;
}

.sync-badge.synced { background: var(--green-dim); color: var(--green-light); }
.sync-badge.local { background: #2a2a00; color: #ffff99; }

/* erreur */
.error-page { text-align: center; padding: 60px 20px; }
.error-msg { font-size: 1.1rem; color: #ff9999; margin-bottom: 20px; }
.btn-back {
    display: inline-block;
    padding: 10px 20px;
    background: var(--bg3);
    border-radius: 8px;
    color: #ccc;
    transition: background 0.2s;
}
.btn-back:hover { background: var(--bg4); }

/* toast */
.toast {
    position: fixed;
    bottom: 30px;
    left: 50%;
    transform: translateX(-50%) translateY(20px);
    background: #222;
    color: #fff;
    padding: 12px 24px;
    border-radius: 8px;
    font-size: 0.9rem;
    border: 1px solid #444;
    opacity: 0;
    transition: opacity 0.3s, transform 0.3s;
    pointer-events: none;
    z-index: 1000;
    white-space: nowrap;
}

.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* modal */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.75);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2000;
}

.modal {
    background: var(--bg3);
    border: 1px solid #444;
    border-radius: 12px;
    padding: 24px;
    max-width: 420px;
    width: 90%;
}

.modal h3 { margin-bottom: 12px; font-size: 1.1rem; }

.modal p {
    color: var(--muted);
    font-size: 0.9rem;
    margin-bottom: 20px;
    line-height: 1.5;
}

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

.modal-btn {
    flex: 1;
    padding: 10px;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-size: 0.9rem;
    transition: background 0.2s;
}

.modal-btn-replace { background: var(--red); color: #fff; }
.modal-btn-replace:hover { background: var(--red-dark); }
.modal-btn-merge { background: var(--border); color: #fff; }
.modal-btn-merge:hover { background: #444; }
.modal-btn-new { background: var(--green-dim); color: var(--green-light); }
.modal-btn-new:hover { background: #245a24; }
.modal-btn-cancel { background: #1a1a1a; color: var(--muted); }
.modal-btn-cancel:hover { background: #222; }

/* mode public (playlist.php) */
.public-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 20px;
    flex-wrap: wrap;
    gap: 10px;
}

.public-playlist-name { font-size: 1.3rem; font-weight: 700; }
.public-meta { color: var(--muted); font-size: 0.9rem; }

.public-layout { display: flex; gap: 20px; align-items: flex-start; }

.public-playlist-panel {
    width: 300px;
    flex-shrink: 0;
    background: var(--bg3);
    border-radius: 12px;
    overflow: hidden;
    max-height: 600px;
    display: flex;
    flex-direction: column;
}

.public-panel-header {
    padding: 12px 15px;
    background: var(--bg4);
    font-weight: 600;
    font-size: 0.9rem;
    flex-shrink: 0;
}

/* mobile */
@media (max-width: 1000px) {
    .main-layout { flex-direction: column; }
    .public-layout { flex-direction: column; }
    .playlist-section { width: 100%; max-height: 350px; }
    .public-playlist-panel { width: 100%; max-height: 280px; }
    .input-group { flex-direction: column; }
    .url-input { min-width: auto; font-size: 16px; }
    .load-btn { width: 100%; }
    .logo { font-size: 1.2rem; }
    .online-grid { grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); }
}
