/* ===== Status Badges ===== */
.status-badge {
    border-radius: 9px;
    padding: 3px 10px;
    min-height: 18px;
    font-size: 0.8em;
    font-weight: 600;
}

.status-badge.success {
    background: @success_bg_color;
    color: @success_fg_color;
}

.status-badge.warning {
    background: @warning_bg_color;
    color: @warning_fg_color;
}

.status-badge.error {
    background: @error_bg_color;
    color: @error_fg_color;
}

.status-badge.info {
    background: @accent_bg_color;
    color: @accent_fg_color;
}

.status-badge.neutral {
    background: @card_shade_color;
    color: @window_fg_color;
}

/* Badge with icon prefix */
.status-badge-with-icon {
    border-radius: 9px;
    padding: 3px 10px;
    min-height: 18px;
    font-size: 0.8em;
    font-weight: 600;
}

.status-badge-with-icon.success {
    background: @success_bg_color;
    color: @success_fg_color;
}

.status-badge-with-icon.warning {
    background: @warning_bg_color;
    color: @warning_fg_color;
}

.status-badge-with-icon.error {
    background: @error_bg_color;
    color: @error_fg_color;
}

.status-badge-with-icon.info {
    background: @accent_bg_color;
    color: @accent_fg_color;
}

.status-badge-with-icon.neutral {
    background: @card_shade_color;
    color: @window_fg_color;
}

/* ===== Drop Overlay ===== */
.drop-overlay-scrim {
    background: alpha(@window_bg_color, 0.75);
}

.drop-zone-card {
    background: @card_bg_color;
    border-radius: 16px;
    padding: 48px 40px;
    border: 2px dashed alpha(@accent_bg_color, 0.5);
    box-shadow: 0 8px 32px alpha(black, 0.15);
}

.drop-zone-icon {
    color: @accent_bg_color;
    opacity: 0.85;
}

/* ===== Card View (using libadwaita .card) ===== */
.card {
    padding: 24px 20px;
}

flowboxchild:focus-visible .card {
    outline: 3px solid @accent_bg_color;
    outline-offset: 3px;
}

/* ===== Selection Mode Highlight ===== */
flowboxchild.selected .card {
    outline: 3px solid @accent_bg_color;
    outline-offset: -3px;
    background: alpha(@accent_bg_color, 0.12);
}

row.selected {
    background: alpha(@accent_bg_color, 0.15);
    outline: 3px solid @accent_bg_color;
    outline-offset: -3px;
}

@media (prefers-contrast: more) {
    flowboxchild.selected .card {
        outline-width: 4px;
        background: alpha(@accent_bg_color, 0.2);
    }

    row.selected {
        outline-width: 4px;
        background: alpha(@accent_bg_color, 0.25);
    }
}

/* App card status indicators */
.status-ok {
    border: 1px solid alpha(@success_bg_color, 0.6);
}

.status-attention {
    border: 1px dashed alpha(@warning_bg_color, 0.6);
}

/* Rounded icon clipping for list view */
.icon-rounded {
    border-radius: 8px;
}

/* ===== WCAG AAA Focus Indicators (3px for enhanced visibility) ===== */
button:focus-visible,
togglebutton:focus-visible,
menubutton:focus-visible,
checkbutton:focus-visible,
switch:focus-visible,
entry:focus-visible,
searchentry:focus-visible,
spinbutton:focus-visible {
    outline: 3px solid @accent_bg_color;
    outline-offset: 2px;
}

row:focus-visible {
    outline: 3px solid @accent_bg_color;
    outline-offset: 2px;
}

/* Letter-circle fallback icon */
.letter-icon {
    border-radius: 50%;
    font-weight: 700;
    font-size: 1.4em;
}

/* Integration emblem on card icon */
.integration-emblem {
    background: @success_bg_color;
    color: @success_fg_color;
    border-radius: 50%;
    padding: 2px;
    min-width: 24px;
    min-height: 24px;
}

/* ===== Detail View Banner ===== */
.detail-banner {
    padding: 18px 0;
    background-image: linear-gradient(
        to bottom,
        alpha(@accent_bg_color, 0.08),
        transparent
    );
    border-radius: 12px;
    margin-bottom: 6px;
}

/* ===== Compatibility Warning Banner ===== */
.compat-warning-banner {
    background: alpha(@warning_bg_color, 0.22);
    border-radius: 12px;
    padding: 12px;
    border: 1px solid alpha(@warning_bg_color, 0.5);
}

/* ===== Reduced Motion (WCAG AAA 2.3.3) ===== */
/* Note: GTK CSS does not support prefers-reduced-motion or !important.
   Reduced motion is handled by the GTK toolkit settings instead
   (gtk-enable-animations). */

/* ===== Minimum Target Size (WCAG 2.5.5 AAA - 44x44px) ===== */
button.flat.circular,
button.flat:not(.pill):not(.suggested-action):not(.destructive-action) {
    min-width: 44px;
    min-height: 44px;
}

/* Accessible icon button minimum target size (WCAG 2.5.5 AAA) */
.accessible-icon-btn {
    min-width: 44px;
    min-height: 44px;
}

/* Header bar buttons: ensure icon-only buttons meet AAA 44px target */
headerbar button.flat,
headerbar button.image-button,
headerbar menubutton > button,
headerbar splitbutton > button,
headerbar splitbutton > menubutton > button {
    min-width: 44px;
    min-height: 44px;
}

/* ===== Category Filter Tiles ===== */
.category-tile {
    padding: 14px 18px;
    min-height: 48px;
    border-radius: 12px;
    border: none;
    font-weight: 600;
    font-size: 0.9em;
    color: white;
}

.category-tile image {
    color: white;
    opacity: 0.9;
}

/* Colored backgrounds per category - darkened for WCAG AAA 7:1 contrast with white text */
.cat-accent { background: color-mix(in srgb, @accent_bg_color 80%, black 20%); }
.cat-purple { background: color-mix(in srgb, @purple_3 75%, black 25%); }
.cat-red { background: color-mix(in srgb, @red_3 70%, black 30%); }
.cat-green { background: color-mix(in srgb, @success_bg_color 65%, black 35%); }
.cat-orange { background: color-mix(in srgb, @orange_3 75%, black 25%); }
.cat-blue { background: color-mix(in srgb, @blue_3 70%, black 30%); }
.cat-amber { background: color-mix(in srgb, @warning_bg_color 70%, black 30%); }
.cat-neutral { background: color-mix(in srgb, @window_fg_color 55%, @window_bg_color 45%); }
.cat-teal { background: color-mix(in srgb, color-mix(in srgb, @blue_3 50%, @success_bg_color 50%) 70%, black 30%); }
.cat-brown { background: color-mix(in srgb, color-mix(in srgb, @orange_3 60%, @red_3 40%) 60%, black 40%); }
.cat-lime { background: color-mix(in srgb, color-mix(in srgb, @success_bg_color 70%, @warning_bg_color 30%) 65%, black 35%); }
.cat-slate { background: color-mix(in srgb, color-mix(in srgb, @blue_3 30%, @window_fg_color 70%) 45%, black 55%); }
.cat-pink { background: color-mix(in srgb, color-mix(in srgb, @red_3 50%, @purple_3 50%) 75%, black 25%); }
.cat-emerald { background: color-mix(in srgb, color-mix(in srgb, @success_bg_color 80%, @blue_3 20%) 70%, black 30%); }
.cat-crimson { background: color-mix(in srgb, @red_3 60%, black 40%); }
.cat-indigo { background: color-mix(in srgb, color-mix(in srgb, @blue_3 70%, @purple_3 30%) 70%, black 30%); }
.cat-coral { background: color-mix(in srgb, color-mix(in srgb, @red_3 60%, @orange_3 40%) 75%, black 25%); }
.cat-violet { background: color-mix(in srgb, color-mix(in srgb, @purple_3 70%, @red_3 30%) 70%, black 30%); }
.cat-mint { background: color-mix(in srgb, color-mix(in srgb, @success_bg_color 60%, @blue_3 40%) 65%, black 35%); }

/* Hover: intensify the background */
.cat-accent:hover { background: color-mix(in srgb, @accent_bg_color 95%, black 5%); }
.cat-purple:hover { background: color-mix(in srgb, @purple_3 90%, black 10%); }
.cat-red:hover { background: color-mix(in srgb, @red_3 85%, black 15%); }
.cat-green:hover { background: color-mix(in srgb, @success_bg_color 80%, black 20%); }
.cat-orange:hover { background: color-mix(in srgb, @orange_3 90%, black 10%); }
.cat-blue:hover { background: color-mix(in srgb, @blue_3 85%, black 15%); }
.cat-amber:hover { background: color-mix(in srgb, @warning_bg_color 85%, black 15%); }
.cat-neutral:hover { background: color-mix(in srgb, @window_fg_color 65%, @window_bg_color 35%); }
.cat-teal:hover { background: color-mix(in srgb, color-mix(in srgb, @blue_3 50%, @success_bg_color 50%) 85%, black 15%); }
.cat-brown:hover { background: color-mix(in srgb, color-mix(in srgb, @orange_3 60%, @red_3 40%) 75%, black 25%); }
.cat-lime:hover { background: color-mix(in srgb, color-mix(in srgb, @success_bg_color 70%, @warning_bg_color 30%) 80%, black 20%); }
.cat-slate:hover { background: color-mix(in srgb, color-mix(in srgb, @blue_3 30%, @window_fg_color 70%) 60%, black 40%); }
.cat-pink:hover { background: color-mix(in srgb, color-mix(in srgb, @red_3 50%, @purple_3 50%) 90%, black 10%); }
.cat-emerald:hover { background: color-mix(in srgb, color-mix(in srgb, @success_bg_color 80%, @blue_3 20%) 85%, black 15%); }
.cat-crimson:hover { background: color-mix(in srgb, @red_3 75%, black 25%); }
.cat-indigo:hover { background: color-mix(in srgb, color-mix(in srgb, @blue_3 70%, @purple_3 30%) 85%, black 15%); }
.cat-coral:hover { background: color-mix(in srgb, color-mix(in srgb, @red_3 60%, @orange_3 40%) 90%, black 10%); }
.cat-violet:hover { background: color-mix(in srgb, color-mix(in srgb, @purple_3 70%, @red_3 30%) 85%, black 15%); }
.cat-mint:hover { background: color-mix(in srgb, color-mix(in srgb, @success_bg_color 60%, @blue_3 40%) 80%, black 20%); }

/* Checked: slightly darkened for WCAG AAA contrast with white text */
.cat-accent:checked { background: color-mix(in srgb, @accent_bg_color 85%, black 15%); }
.cat-purple:checked { background: color-mix(in srgb, @purple_3 85%, black 15%); }
.cat-red:checked { background: color-mix(in srgb, @red_3 85%, black 15%); }
.cat-green:checked { background: color-mix(in srgb, @success_bg_color 85%, black 15%); }
.cat-orange:checked { background: color-mix(in srgb, @orange_3 85%, black 15%); }
.cat-blue:checked { background: color-mix(in srgb, @blue_3 85%, black 15%); }
.cat-amber:checked { background: color-mix(in srgb, @warning_bg_color 85%, black 15%); }
.cat-neutral:checked { background: alpha(@window_fg_color, 0.45); }
.cat-teal:checked { background: color-mix(in srgb, color-mix(in srgb, @blue_3 50%, @success_bg_color 50%) 85%, black 15%); }
.cat-brown:checked { background: color-mix(in srgb, color-mix(in srgb, @orange_3 60%, @red_3 40%) 85%, black 15%); }
.cat-lime:checked { background: color-mix(in srgb, color-mix(in srgb, @success_bg_color 70%, @warning_bg_color 30%) 85%, black 15%); }
.cat-slate:checked { background: color-mix(in srgb, color-mix(in srgb, @blue_3 30%, @window_fg_color 70%) 85%, black 15%); }
.cat-pink:checked { background: color-mix(in srgb, color-mix(in srgb, @red_3 50%, @purple_3 50%) 85%, black 15%); }
.cat-emerald:checked { background: color-mix(in srgb, color-mix(in srgb, @success_bg_color 80%, @blue_3 20%) 85%, black 15%); }
.cat-crimson:checked { background: color-mix(in srgb, @red_3 75%, black 25%); }
.cat-indigo:checked { background: color-mix(in srgb, color-mix(in srgb, @blue_3 70%, @purple_3 30%) 85%, black 15%); }
.cat-coral:checked { background: color-mix(in srgb, color-mix(in srgb, @red_3 60%, @orange_3 40%) 85%, black 15%); }
.cat-violet:checked { background: color-mix(in srgb, color-mix(in srgb, @purple_3 70%, @red_3 30%) 85%, black 15%); }
.cat-mint:checked { background: color-mix(in srgb, color-mix(in srgb, @success_bg_color 60%, @blue_3 40%) 85%, black 15%); }

/* Focus indicator on the tile itself */
flowboxchild:focus-visible .category-tile {
    outline: 3px solid @accent_bg_color;
    outline-offset: 2px;
}

/* Focus indicators for catalog items */
.catalog-tile:focus-visible,
.catalog-featured-card:focus-visible {
    outline: 3px solid @accent_bg_color;
    outline-offset: 2px;
}

.destructive-context-item:focus-visible {
    outline: 3px solid @accent_bg_color;
    outline-offset: 2px;
}

/* ===== Catalog Tile Cards ===== */
.catalog-tile {
    border: 1px solid alpha(@window_fg_color, 0.12);
    border-radius: 12px;
}

.catalog-tile:hover {
    border-color: alpha(@accent_bg_color, 0.5);
}

/* ===== Featured Banner Cards ===== */
.catalog-featured-card {
    border-radius: 12px;
    border: 1px solid alpha(@window_fg_color, 0.15);
    padding: 0;
}

.catalog-featured-card:hover {
    border-color: alpha(@accent_bg_color, 0.5);
}

/* Screenshot area inside featured card */
.catalog-featured-screenshot {
    border-radius: 11px 11px 0 0;
    border: none;
    background: alpha(@window_fg_color, 0.04);
}

.catalog-featured-screenshot picture {
    border-radius: 11px 11px 0 0;
}

/* ===== Destructive Context Menu Item ===== */
.destructive-context-item {
    color: @error_fg_color;
    background: alpha(@error_bg_color, 0.85);
    border: none;
    box-shadow: none;
    padding: 6px 12px;
    border-radius: 6px;
    min-height: 28px;
}

.destructive-context-item:hover {
    background: @error_bg_color;
}

/* ===== Screenshot Lightbox ===== */
window.lightbox {
    background-color: rgba(0, 0, 0, 0.92);
    border-radius: 12px;
}

window.lightbox .lightbox-counter {
    background: rgba(0, 0, 0, 0.78);
    color: white;
    border-radius: 12px;
    padding: 4px 12px;
    font-size: 0.85em;
}

window.lightbox .lightbox-nav {
    min-width: 48px;
    min-height: 48px;
}

/* ===== Catalog Tile Stats Row ===== */
.catalog-stats-row {
    font-size: 0.8em;
    color: alpha(@window_fg_color, 0.87);
}

.catalog-stats-row image {
    opacity: 0.85;
}

/* ===== Detail Page Stat Cards ===== */
.stat-card {
    background: alpha(@window_fg_color, 0.06);
    border-radius: 12px;
    padding: 14px 16px;
    border: 1px solid alpha(@window_fg_color, 0.08);
}

.stat-card.stat-stars {
    background: alpha(@warning_bg_color, 0.12);
    border-color: alpha(@warning_bg_color, 0.2);
}

.stat-card.stat-stars image {
    color: @warning_bg_color;
    opacity: 0.85;
}

.stat-card.stat-version {
    background: alpha(@accent_bg_color, 0.1);
    border-color: alpha(@accent_bg_color, 0.18);
}

.stat-card.stat-version image {
    color: @accent_bg_color;
    opacity: 0.85;
}

.stat-card.stat-downloads {
    background: alpha(@success_bg_color, 0.1);
    border-color: alpha(@success_bg_color, 0.18);
}

.stat-card.stat-downloads image {
    color: @success_bg_color;
    opacity: 0.85;
}

.stat-card.stat-released {
    background: alpha(@purple_3, 0.12);
    border-color: alpha(@purple_3, 0.2);
}

.stat-card.stat-released image {
    color: @purple_3;
    opacity: 0.85;
}

.stat-card .stat-value {
    font-weight: 700;
    font-size: 1.15em;
}

.stat-card .stat-label {
    font-size: 0.8em;
    color: alpha(@window_fg_color, 0.87);
}

.stat-card image {
    opacity: 0.78;
}

/* ===== Catalog Row (compact list view) ===== */
.catalog-row {
    border: 1px solid alpha(@window_fg_color, 0.08);
    border-radius: 8px;
    padding: 0;
}

.catalog-row:hover {
    border-color: alpha(@accent_bg_color, 0.4);
}

/* ===== Skeleton Loading Placeholder ===== */
.skeleton-card {
    background: alpha(@card_bg_color, 0.5);
    border-radius: 12px;
    min-height: 180px;
    min-width: 140px;
    animation: skeleton-pulse 1.5s ease-in-out infinite;
}

@keyframes skeleton-pulse {
    0%, 100% { opacity: 0.4; }
    50% { opacity: 0.7; }
}

/* ===== Reduced Motion (WCAG AAA 2.3.3) ===== */
@media (prefers-reduced-motion: reduce) {
    .skeleton-card {
        animation: none;
        opacity: 0.5;
    }
}

/* ===== High Contrast Mode (WCAG AAA) ===== */
@media (prefers-contrast: more) {
    .catalog-tile,
    .catalog-featured-card,
    .catalog-row {
        border-width: 2px;
    }

    .stat-card {
        border-width: 2px;
        background: alpha(@window_fg_color, 0.1);
    }

    .status-badge,
    .status-badge-with-icon {
        border: 1px solid currentColor;
    }

    .drop-zone-card {
        border-width: 3px;
    }

    .status-ok,
    .status-attention {
        border-width: 2px;
    }

    .category-tile {
        border: 2px solid white;
    }

    .stat-card .stat-label {
        color: @window_fg_color;
    }

    .stat-card image {
        opacity: 1.0;
    }

    .compat-warning-banner {
        border-width: 2px;
    }

    window.lightbox .lightbox-counter {
        background: rgba(0, 0, 0, 0.9);
    }

    .catalog-stats-row image {
        opacity: 1.0;
    }

    .category-tile image {
        opacity: 1.0;
    }
}
