/* NexusOS — Segment 10: polish pass.
   Catches widgets not covered by earlier segments (combobox, toolbar,
   searchbar, actionbar, statusbar, paned, expander, calendar, iconview,
   shortcuts-window, OSD overlays, etc.) and tightens focus/disabled rules. */

/* ── Comboboxes / dropdowns ──────────────────────────────── */

combobox,
combobox.combo,
combobox button {
    background-color: @surface_bg;
    color: @text_primary;
}

combobox button.combo {
    padding: 2px 8px;
    border: 1px solid @border_strong;
    border-radius: 6px;
}

combobox button.combo:hover {
    border-color: @brand_green_dark;
    background-color: @hover_bg;
}

combobox button.combo:focus {
    border-color: @brand_green;
    box-shadow: inset 0 0 0 1px @brand_green;
}

combobox button.combo:active,
combobox button.combo:checked {
    background-color: @overlay_bg;
}

combobox arrow {
    color: @text_secondary;
    min-width: 12px;
    min-height: 12px;
    margin-left: 6px;
    -gtk-icon-source: -gtk-icontheme("pan-down-symbolic");
}

combobox button.combo:hover arrow {
    color: @brand_green;
}

/* The popup list for a combobox */
combobox > window.popup,
combobox window.combo {
    background-color: @overlay_bg;
    border: 1px solid @border_strong;
    border-radius: 6px;
    box-shadow: 0 6px 18px rgba(0, 0, 0, 0.45);
}

combobox treeview.view {
    background-color: @overlay_bg;
}

combobox treeview.view:selected,
combobox treeview.view:hover {
    background-color: @hover_bg;
    color: @text_primary;
}

/* ── Toolbars ────────────────────────────────────────────── */

toolbar {
    background-color: @surface_bg_alt;
    border-color: @border;
    padding: 4px 6px;
    color: @text_primary;
}

toolbar.horizontal {
    border-bottom: 1px solid @border;
}

toolbar.vertical {
    border-right: 1px solid @border;
}

toolbar > button,
toolbar button.flat {
    background-color: transparent;
    border-color: transparent;
    color: @text_primary;
}

toolbar > button:hover,
toolbar button.flat:hover {
    background-color: @hover_bg;
}

toolbar > button:active,
toolbar > button:checked,
toolbar button.flat:checked {
    background-color: @active_bg;
    color: @active_fg;
}

toolbar separator {
    background-color: @border;
    margin: 4px 4px;
}

/* Inline toolbar — sits inside content, lower contrast */
toolbar.inline-toolbar {
    background-color: @surface_bg;
    border: 1px solid @border;
    border-radius: 0 0 6px 6px;
    border-top: none;
}

/* OSD-style toolbar (overlay) */
toolbar.osd {
    background-color: alpha(@overlay_bg, 0.92);
    border: 1px solid @border_strong;
    border-radius: 8px;
    box-shadow: 0 6px 18px rgba(0, 0, 0, 0.55);
    color: @text_primary;
    padding: 4px;
}

/* ── Searchbars, actionbars, statusbars ──────────────────── */

searchbar {
    background-color: @surface_bg_alt;
    border-bottom: 1px solid @border;
    padding: 6px;
}

searchbar > revealer > box {
    padding: 0 6px;
}

actionbar {
    background-color: @surface_bg;
    border-top: 1px solid @border;
    padding: 6px 10px;
    color: @text_primary;
}

statusbar {
    background-color: @surface_bg;
    border-top: 1px solid @border;
    padding: 4px 10px;
    color: @text_secondary;
    font-size: smaller;
}

/* ── Paned (resizable split-view divider) ────────────────── */

paned > separator {
    background-color: @border;
    background-image: none;
    min-width: 1px;
    min-height: 1px;
}

paned > separator:hover,
paned > separator:active {
    background-color: @brand_green;
}

paned.wide > separator {
    min-width: 4px;
    min-height: 4px;
    background-color: @border;
}

paned.wide > separator:hover {
    background-color: alpha(@brand_green, 0.6);
}

/* ── Expander (disclosure triangle + label) ──────────────── */

expander {
    color: @text_primary;
}

expander title > arrow {
    color: @text_secondary;
    min-width: 12px;
    min-height: 12px;
    -gtk-icon-source: -gtk-icontheme("pan-end-symbolic");
}

expander title:hover > arrow {
    color: @brand_green;
}

expander title > arrow:checked {
    -gtk-icon-source: -gtk-icontheme("pan-down-symbolic");
    color: @brand_green;
}

expander title:hover {
    color: @brand_green;
}

/* ── Calendar ────────────────────────────────────────────── */

calendar {
    background-color: @base_bg;
    color: @text_primary;
    border: 1px solid @border;
    border-radius: 6px;
    padding: 4px;
}

calendar:selected {
    background-color: @selected_bg;
    color: @selected_fg;
    border-radius: 4px;
}

calendar.header {
    background-color: @surface_bg_alt;
    border-bottom: 1px solid @border;
    color: @text_primary;
    font-weight: 600;
}

calendar.button {
    color: @text_secondary;
    background-color: transparent;
    border-color: transparent;
}

calendar.button:hover {
    color: @brand_green;
    background-color: @hover_bg;
}

calendar.button:disabled {
    color: @text_disabled;
}

calendar.highlight {
    color: @brand_green;
    font-weight: 600;
}

calendar:indeterminate {
    color: @text_disabled;
}

/* ── Icon view (e.g. file manager grid view) ─────────────── */

iconview {
    background-color: @base_bg;
    color: @text_primary;
}

iconview:hover,
iconview .cell:hover {
    background-color: @hover_bg;
}

iconview:selected,
iconview .cell:selected {
    background-color: @selected_bg;
    color: @selected_fg;
    border-radius: 6px;
}

iconview:selected:focus,
iconview .cell:selected:focus {
    background-color: shade(@selected_bg, 1.10);
}

iconview.dnd {
    box-shadow: inset 0 0 0 1px @brand_green;
}

iconview > rubberband,
.view > rubberband {
    background-color: alpha(@brand_green, 0.18);
    border: 1px solid @brand_green;
}

/* ── Generic .view (CellRenderer-based widgets) ──────────── */

.view {
    background-color: @base_bg;
    color: @text_primary;
}

.view:selected {
    background-color: @selected_bg;
    color: @selected_fg;
}

.view:hover {
    background-color: @hover_bg;
}

.view:disabled {
    color: @text_disabled;
}

/* ── Shortcuts window (Ctrl+? help) ──────────────────────── */

shortcuts-section,
shortcut {
    background-color: @base_bg;
    color: @text_primary;
}

shortcut > .keycap {
    background-color: @surface_bg_alt;
    border: 1px solid @border_strong;
    border-radius: 4px;
    color: @text_primary;
    min-width: 16px;
    padding: 1px 6px;
    font-family: monospace;
    box-shadow: 0 1px 0 0 @border;
}

/* ── Selection-mode helpers (matches headerbar selection-mode) ── */

.selection-mode {
    background-color: @brand_purple_dark;
    color: @selected_fg;
}

.selection-mode button:hover {
    background-color: alpha(@selected_fg, 0.15);
}

/* ── OSD overlay class (generic) ─────────────────────────── */

.osd {
    background-color: alpha(@overlay_bg, 0.92);
    color: @text_primary;
    border: 1px solid @border_strong;
    border-radius: 8px;
    box-shadow: 0 6px 18px rgba(0, 0, 0, 0.55);
}

.osd button {
    background-color: transparent;
    border-color: transparent;
    color: @text_primary;
}

.osd button:hover {
    background-color: alpha(@text_primary, 0.10);
}

.osd entry {
    background-color: alpha(#000000, 0.40);
    border-color: @border_strong;
    color: @text_primary;
}

.osd entry:focus {
    border-color: @brand_green;
    box-shadow: inset 0 0 0 1px @brand_green;
}

/* ── Globally consistent focus ring on common widgets ─────── */

*:focus-visible {
    outline: 2px solid @focus_ring;
    outline-offset: 1px;
}

/* Some widgets are better off without an outline ring */
button:focus-visible,
entry:focus-visible,
notebook > header > tabs > tab:focus-visible,
treeview.view:focus-visible,
columnview.view:focus-visible {
    /* These have their own focus treatment from earlier segments; the
       universal rule above is fine, but keep an explicit empty block to
       document the intent rather than chasing override specificity. */
}

/* ── Universal insensitive (disabled) handling ───────────── */

:disabled,
*:disabled {
    -gtk-icon-effect: dim;
}

/* ── Labels: dim-label, error-label, etc. ────────────────── */

label.error,
label.error-message {
    color: @error_color;
}

label.warning {
    color: @warning_color;
}

label.success {
    color: @success_color;
}

label.heading,
.heading {
    font-weight: 600;
    color: @text_primary;
}

/* ── Drag-and-drop highlight surfaces ────────────────────── */

box:drop(active),
grid:drop(active),
flowbox:drop(active) {
    box-shadow: inset 0 0 0 2px @brand_green;
    background-color: alpha(@brand_green, 0.08);
}

/* ── Selection rubberband (drag-select) ──────────────────── */

rubberband,
.rubberband {
    background-color: alpha(@brand_green, 0.18);
    border: 1px solid @brand_green;
}

/* ── Color & font choosers — small surface touches ───────── */

colorswatch,
colorswatch.color-active-badge {
    border-radius: 4px;
    border: 1px solid @border_strong;
}

colorswatch:hover {
    border-color: @brand_green;
}

colorswatch.color-light {
    color: @text_on_accent;
}

colorswatch.color-dark {
    color: @text_primary;
}

colorchooser .popover {
    background-color: @overlay_bg;
}

fontchooser .dim-label {
    color: @text_secondary;
}

/* ── Emoji chooser ───────────────────────────────────────── */

emoji-chooser,
emoji-chooser .emoji {
    background-color: @overlay_bg;
    color: @text_primary;
    border-radius: 6px;
    padding: 2px;
}

emoji-chooser .emoji:hover {
    background-color: @hover_bg;
}

emoji-chooser .emoji:focus,
emoji-chooser .emoji:checked {
    background-color: @selected_bg;
}

emoji-chooser .emoji-section {
    border-top: 1px solid @border;
    padding-top: 4px;
}

/* ── Placeholder text in entries ─────────────────────────── */

entry placeholder,
.entry placeholder {
    color: @text_disabled;
    opacity: 1.0;
}

/* ── Scaling fonts / image effects in disabled state ─────── */

image:disabled,
icon:disabled {
    -gtk-icon-effect: dim;
    opacity: 0.5;
}

/* ── Nemo file manager ───────────────────────────────────── */
/* Compact the top toolbar and the bottom status bar. */
.nemo-window .primary-toolbar,
.nemo-window statusbar {
    padding-top: 0;
    padding-bottom: 0;
    min-height: 0;
}

/* Slimmer buttons across the toolbar/statusbar chrome. */
.nemo-window .primary-toolbar button,
.nemo-window statusbar button,
.nemo-window statusbar radiobutton {
    min-height: 0;
    padding-top: 3px;
    padding-bottom: 3px;
}

/* The zoom slider's tall padding inflates the bottom bar. */
.nemo-window statusbar scale {
    min-height: 0;
    padding-top: 2px;
    padding-bottom: 2px;
}

/* The item/size readout sits in a plain GtkFrame — give it tight,
   symmetric padding (the group-frame rule's asymmetric padding is
   wrong for it and shoves the text off-centre) and a larger font. */
.nemo-window statusbar frame > border {
    padding: 1px 8px;
}

.nemo-window statusbar label {
    font-size: 11pt;
}

/* ── Desktop icon labels (xfdesktop 4.20) ──────────────────
   xfdesktop ships its own built-in CSS for the desktop icon
   view. Its label rule is:
       XfdesktopIconView.view.label { color: @theme_selected_fg_color; }
   In our palette theme_selected_fg_color resolves to #0a0a00
   (text_on_accent — meant to sit on lime-green), so unselected
   desktop labels render near-black and vanish on the dark
   wallpaper. Override with the exact selectors xfdesktop uses
   (CSS node name is the GType name "XfdesktopIconView", the
   label is a ".view.label" sub-node) so the cascade wins. */
XfdesktopIconView.view.label {
    color: @text_primary;
    background-color: transparent;
    border-radius: 3px;
    text-shadow: 1px 1px 3px rgba(0, 0, 0, 0.9);
}

/* Selected icon: purple chip behind the (white) label. */
XfdesktopIconView.view.label:selected {
    color: @selected_fg;
    background-color: @selected_bg;
    text-shadow: none;
}

XfdesktopIconView.view.label:selected:backdrop {
    background-color: alpha(@selected_bg, 0.5);
}

/* Keyboard-cursor / active item tint. */
XfdesktopIconView.view:active {
    color: @selected_bg;
}

/* Rubber-band marquee when drag-selecting icons. */
XfdesktopIconView.rubberband {
    border: 1px solid @selected_bg;
    background-color: alpha(@selected_bg, 0.2);
}
