# -*- coding: utf-8 -*-
"""主题与全局样式表。

深色主题，贴近专业素材库的观感（参考 Bridge / Finder）。
所有颜色集中在此，便于换肤。
"""
from __future__ import annotations

# 色板
BG = "#1B1D23"
BG_PANEL = "#23262E"
BG_CARD = "#2A2E37"
BG_HOVER = "#333845"
BG_SELECTED = "#3B5A8A"
BG_INPUT = "#16181D"

FG = "#E6E8EB"
FG_DIM = "#9AA0AB"
FG_FAINT = "#6B7280"

ACCENT = "#4A90D9"
ACCENT_HOVER = "#5BA0E9"
DANGER = "#E74C3C"
SUCCESS = "#27AE60"
WARN = "#F39C12"

BORDER = "#333845"
BORDER_LIGHT = "#3E4453"

RADIUS = 8

APP_QSS = f"""
* {{
    font-size: 13px;
    color: {FG};
}}

QMainWindow, QWidget#Root, QDialog {{ background: {BG}; }}
QMessageBox {{ background: {BG_PANEL}; }}
QFrame#Panel {{ background: {BG_PANEL}; border: 1px solid {BORDER}; border-radius: {RADIUS}px; }}
QFrame#Card {{ background: {BG_CARD}; border: 1px solid {BORDER}; border-radius: {RADIUS}px; }}
QToolTip {{ background: {BG_CARD}; color: {FG}; border: 1px solid {BORDER_LIGHT}; padding: 4px 8px; border-radius: 4px; }}

/* 菜单栏 */
QMenuBar {{ background: {BG_PANEL}; border-bottom: 1px solid {BORDER}; }}
QMenuBar::item {{ padding: 6px 12px; border-radius: 4px; }}
QMenuBar::item:selected {{ background: {BG_HOVER}; }}
QMenu {{ background: {BG_PANEL}; border: 1px solid {BORDER_LIGHT}; border-radius: 6px; padding: 4px; }}
QMenu::item {{ padding: 6px 20px; border-radius: 4px; }}
QMenu::item:selected {{ background: {BG_HOVER}; }}
QMenu::separator {{ height: 1px; background: {BORDER}; margin: 4px 8px; }}

/* 工具栏 */
QToolBar {{ background: {BG_PANEL}; border-bottom: 1px solid {BORDER}; spacing: 6px; padding: 4px; }}
QToolButton {{ background: transparent; border: 1px solid transparent; border-radius: 6px; padding: 6px 10px; }}
QToolButton:hover {{ background: {BG_HOVER}; }}
QToolButton:checked {{ background: {BG_SELECTED}; }}
QToolButton:pressed {{ background: {BG_CARD}; }}

/* 按钮 */
QPushButton {{
    background: {ACCENT}; color: white; border: none; border-radius: 6px;
    padding: 7px 16px; font-weight: 600;
}}
QPushButton:hover {{ background: {ACCENT_HOVER}; }}
QPushButton:pressed {{ background: {BG_SELECTED}; }}
QPushButton:disabled {{ background: {BG_CARD}; color: {FG_FAINT}; }}
QPushButton#Ghost {{ background: {BG_CARD}; color: {FG}; border: 1px solid {BORDER_LIGHT}; }}
QPushButton#Ghost:hover {{ background: {BG_HOVER}; }}
QPushButton#Danger {{ background: {DANGER}; }}
QPushButton#Danger:hover {{ background: #F25C4D; }}
QPushButton#IconOnly {{ padding: 6px; min-width: 30px; }}

/* 输入 */
QLineEdit, QPlainTextEdit, QSpinBox, QComboBox {{
    background: {BG_INPUT}; border: 1px solid {BORDER_LIGHT}; border-radius: 6px;
    padding: 6px 10px; selection-background-color: {ACCENT};
}}
QLineEdit:focus, QPlainTextEdit:focus, QSpinBox:focus, QComboBox:focus {{ border-color: {ACCENT}; }}
QLineEdit:disabled, QSpinBox:disabled, QComboBox:disabled {{ color: {FG_FAINT}; background: {BG_CARD}; }}
QComboBox::drop-down {{ border: none; width: 24px; }}
QComboBox QAbstractItemView {{
    background: {BG_PANEL}; border: 1px solid {BORDER_LIGHT}; border-radius: 6px;
    selection-background-color: {BG_SELECTED}; selection-color: {FG};
}}
QSpinBox::up-button, QSpinBox::down-button {{ width: 16px; background: transparent; border: none; }}

/* 滚动条 */
QScrollBar:vertical {{ background: transparent; width: 10px; margin: 0; }}
QScrollBar::handle:vertical {{ background: {BORDER_LIGHT}; border-radius: 5px; min-height: 30px; }}
QScrollBar::handle:vertical:hover {{ background: {FG_FAINT}; }}
QScrollBar::add-line:vertical, QScrollBar::sub-line:vertical {{ height: 0; }}
QScrollBar:horizontal {{ background: transparent; height: 10px; margin: 0; }}
QScrollBar::handle:horizontal {{ background: {BORDER_LIGHT}; border-radius: 5px; min-width: 30px; }}
QScrollBar::add-line:horizontal, QScrollBar::sub-line:horizontal {{ width: 0; }}

/* 分割器 */
QSplitter::handle {{ background: {BORDER}; }}
QSplitter::handle:hover {{ background: {BORDER_LIGHT}; }}
QSplitter::handle:horizontal {{ width: 1px; }}
QSplitter::handle:vertical {{ height: 1px; }}

/* 列表 */
QListWidget, QTableView {{ background: {BG}; border: none; outline: none; }}
QListWidget::item {{ border: none; padding: 2px; border-radius: {RADIUS}px; }}
QListWidget::item:selected {{ background: {BG_SELECTED}; }}
QHeaderView::section {{
    background: {BG_PANEL}; color: {FG_DIM}; border: none;
    border-bottom: 1px solid {BORDER}; padding: 6px 10px; font-weight: 600;
}}
QCheckBox {{ spacing: 6px; }}
QCheckBox::indicator {{ width: 14px; height: 14px; border: 1px solid {BORDER_LIGHT}; border-radius: 3px; background: {BG_INPUT}; }}
QCheckBox::indicator:checked {{ background: {ACCENT}; border-color: {ACCENT}; }}
QProgressBar {{ background: {BG_INPUT}; border-radius: 4px; height: 6px; text-align: center; }}
QProgressBar::chunk {{ background: {ACCENT}; border-radius: 4px; }}
"""


def qss() -> str:
    """返回应用级样式表。"""
    return APP_QSS
