"""
themes.py — Lyst og mørkt tema til PyQt6.
"""

DARK = """
QWidget {
    background-color: #1a1c1f;
    color: #e8eaf0;
    font-family: 'Barlow', 'Segoe UI', sans-serif;
    font-size: 13px;
}
QMainWindow, #root {
    background-color: #111214;
}

/* Knapper */
QPushButton {
    background-color: #30343c;
    color: #9aa0b0;
    border: 1px solid #4a5060;
    border-radius: 4px;
    padding: 6px 14px;
}
QPushButton:hover {
    background-color: #454a56;
    color: #e8eaf0;
    border-color: #e8a020;
}
QPushButton:pressed {
    background-color: #22252a;
}
QPushButton:checked {
    background-color: #e8a020;
    color: #111214;
    border-color: #c47a10;
}
QPushButton#btn_play {
    background-color: #e8a020;
    color: #111214;
    border-color: #c47a10;
    font-size: 22px;
    font-weight: bold;
}
QPushButton#btn_play:hover {
    background-color: #c47a10;
}
QPushButton#btn_play_small {
    background-color: #e8a020;
    color: #111214;
    border-color: #c47a10;
    font-size: 14px;
    font-weight: bold;
    padding: 0px 0px;
}
QPushButton#btn_play_small:hover {
    background-color: #c47a10;
}
QPushButton#btn_stop_small {
    color: #e74c3c;
    font-size: 12px;
    padding: 0px 0px;
}
QPushButton#btn_stop_small:hover {
    border-color: #e74c3c;
}
QPushButton#btn_stop {
    color: #e74c3c;
}
QPushButton#btn_stop:hover {
    border-color: #e74c3c;
}
QPushButton#btn_demo {
    color: #3b8fd4;
    border-color: #3b8fd4;
    font-size: 11px;
}
QPushButton#btn_demo:hover, QPushButton#btn_demo:checked {
    background-color: #3b8fd4;
    color: #111214;
    border-color: #3b8fd4;
}
QPushButton#btn_info_row {
    color: #3b8fd4;
    border-color: #3b8fd4;
    padding: 2px 6px;
}
QPushButton#btn_info_row:hover {
    background-color: rgba(59,143,212,0.15);
    border-color: #3b8fd4;
}
QPushButton#btn_rm_row {
    color: #e74c3c;
    border-color: #e74c3c;
    padding: 2px 6px;
}
QPushButton#btn_rm_row:hover {
    background-color: rgba(231,76,60,0.15);
    border-color: #e74c3c;
}

/* Slider */
QSlider::groove:horizontal {
    height: 4px;
    background: #2c3038;
    border-radius: 2px;
}
QSlider::sub-page:horizontal {
    background: #e8a020;
    border-radius: 2px;
}
QSlider::handle:horizontal {
    background: #e8a020;
    width: 12px;
    height: 12px;
    margin: -4px 0;
    border-radius: 6px;
}

/* Volume slider — stor og tydelig */
QSlider#vol_slider::groove:horizontal {
    height: 6px;
    background: #2c3038;
    border-radius: 3px;
}
QSlider#vol_slider::sub-page:horizontal {
    background: #e8a020;
    border-radius: 3px;
}
QSlider#vol_slider::handle:horizontal {
    background: #e8a020;
    border: 3px solid #f0c060;
    width: 22px;
    height: 22px;
    margin: -9px 0;
    border-radius: 12px;
}

/* Lister */
QListWidget {
    background-color: #1a1c1f;
    border: none;
    outline: none;
}
QListWidget::item {
    padding: 6px 10px;
    border-bottom: 1px solid #22252a;
}
QListWidget::item:selected {
    background-color: #2c3038;
    color: #e8eaf0;
    border-left: 2px solid #e8a020;
}
QListWidget::item:hover {
    background-color: #22252a;
}

/* Søgefelt */
QLineEdit {
    background-color: #111214;
    border: 1px solid #3a3e46;
    border-radius: 3px;
    padding: 5px 8px;
    color: #e8eaf0;
}
QLineEdit:focus {
    border-color: #e8a020;
}

/* Labels */
QLabel#track_title {
    font-size: 20px;
    font-weight: bold;
    color: #e8eaf0;
    font-family: 'Rajdhani', 'Segoe UI', sans-serif;
}
QLabel#track_meta {
    font-size: 11px;
    color: #9aa0b0;
    font-family: 'Courier New', monospace;
}
QLabel#section_title {
    font-size: 11px;
    font-weight: bold;
    color: #5a6070;
    letter-spacing: 2px;
    font-family: 'Courier New', monospace;
    padding: 6px 10px;
    background-color: #22252a;
    border-bottom: 1px solid #3a3e46;
}
QLabel#next_up_label {
    color: #e8a020;
    font-family: 'Courier New', monospace;
    font-size: 11px;
    letter-spacing: 2px;
}
QLabel#next_up_title {
    font-size: 17px;
    font-weight: bold;
    color: #e8eaf0;
}
QLabel#next_up_sub {
    font-size: 11px;
    color: #9aa0b0;
    font-family: 'Courier New', monospace;
}
QLabel#vol_label {
    font-size: 10px;
    color: #5a6070;
    font-family: 'Courier New', monospace;
    letter-spacing: 1px;
}
QLabel#vol_val {
    font-size: 11px;
    color: #9aa0b0;
    font-family: 'Courier New', monospace;
    min-width: 28px;
}
QLabel#result_count {
    font-size: 10px;
    color: #5a6070;
    font-family: 'Courier New', monospace;
    padding: 3px 10px;
}

/* Frames / paneler */
QFrame#panel {
    background-color: #1a1c1f;
    border: 1px solid #3a3e46;
    border-radius: 4px;
}
QFrame#now_playing_frame {
    background-color: #1a1c1f;
    border: 1px solid #3a3e46;
    border-radius: 4px 4px 0 0;
}
QFrame#track_display {
    background-color: #111214;
    border: 1px solid #3a3e46;
    border-radius: 3px;
    padding: 4px;
}
QFrame#transport_frame {
    background-color: #1a1c1f;
    border: 1px solid #3a3e46;
    border-top: none;
    border-radius: 0 0 4px 4px;
}
QFrame#next_up_frame {
    background-color: #22252a;
    border: 1px solid #e8a020;
    border-top: none;
    border-bottom: none;
}
QFrame#progress_frame {
    background-color: #1a1c1f;
    border: 1px solid #3a3e46;
    border-top: none;
    border-bottom: none;
}

/* Scrollbar */
QScrollBar:vertical {
    background: #1a1c1f;
    width: 6px;
    border-radius: 3px;
}
QScrollBar::handle:vertical {
    background: #4a5060;
    border-radius: 3px;
    min-height: 20px;
}
QScrollBar::add-line:vertical, QScrollBar::sub-line:vertical { height: 0; }

/* Højreklik-menu */
QMenu {
    background-color: #22252a;
    color: #e8eaf0;
    border: 1px solid #4a5060;
    padding: 4px 0;
    font-size: 14px;
}
QMenu::item {
    padding: 8px 24px;
    border-radius: 0;
}
QMenu::item:selected {
    background-color: #e8a020;
    color: #111214;
}
QMenu::separator {
    height: 1px;
    background: #3a3e46;
    margin: 4px 8px;
}

/* Topbar */
QFrame#topbar {
    background-color: #1a1c1f;
    border: 1px solid #3a3e46;
    border-radius: 4px;
}
QLabel#logo {
    font-size: 16px;
    font-weight: bold;
    letter-spacing: 3px;
    color: #e8a020;
    font-family: 'Rajdhani', 'Segoe UI', sans-serif;
}
QLabel#conn_label {
    font-size: 11px;
    color: #5a6070;
    font-family: 'Courier New', monospace;
    letter-spacing: 1px;
}
"""

LIGHT = DARK + """
QWidget {
    background-color: #d8dae0;
    color: #1a1c22;
}
QMainWindow, #root {
    background-color: #c8cad0;
}
QPushButton {
    background-color: #b0b4bc;
    color: #1a1c22;
    border-color: #8890a0;
}
QPushButton:hover {
    background-color: #c8ccd4;
    color: #1a1c22;
    border-color: #c07010;
}
QPushButton#btn_play {
    background-color: #c07010;
    color: #fff;
    border-color: #a05808;
}
QPushButton#btn_play_small {
    background-color: #c07010;
    color: #fff;
    border-color: #a05808;
}
QPushButton#btn_play_small:hover {
    background-color: #a05808;
}
QPushButton#btn_info_row {
    color: #1a6fb0;
    border-color: #1a6fb0;
    padding: 2px 6px;
}
QPushButton#btn_info_row:hover {
    background-color: rgba(26,111,176,0.12);
}
QPushButton#btn_rm_row {
    color: #c0392b;
    border-color: #c0392b;
    padding: 2px 6px;
}
QPushButton#btn_rm_row:hover {
    background-color: rgba(192,57,43,0.12);
}
QListWidget {
    background-color: #d8dae0;
    color: #1a1c22;
}
QListWidget::item {
    color: #1a1c22;
}
QListWidget::item:selected {
    background-color: #c07010;
    color: #ffffff;
    border-left: 2px solid #a05808;
}
QListWidget::item:hover {
    background-color: #c8ccd4;
    color: #1a1c22;
}
QLineEdit {
    background-color: #c8cad0;
    border-color: #aab0bc;
    color: #1a1c22;
}
QLineEdit:focus { border-color: #c07010; }
QFrame#panel, QFrame#now_playing_frame,
QFrame#transport_frame, QFrame#progress_frame {
    background-color: #d8dae0;
    border-color: #aab0bc;
}
QFrame#track_display { background-color: #c8cad0; border-color: #aab0bc; }
QFrame#topbar { background-color: #d8dae0; border-color: #aab0bc; }
QLabel#section_title { background-color: #e4e6ec; color: #1a1c22; border-color: #aab0bc; }
QLabel#track_title { color: #1a1c22; }
QLabel#track_meta { color: #4a5060; }
QLabel#result_count { color: #5a6070; }
QSlider::groove:horizontal { background: #b0b4bc; }
QScrollBar:vertical { background: #d8dae0; }
QScrollBar::handle:vertical { background: #8890a0; }
QMenu {
    background-color: #e4e6ec;
    color: #1a1c22;
    border: 1px solid #aab0bc;
}
QMenu::item:selected {
    background-color: #c07010;
    color: #ffffff;
}
"""


def apply_theme(app, dark: bool = True):
    app.setStyleSheet(DARK if dark else LIGHT)
