/* MPV.Rocks Installer Web UI Styles */
body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

/*
 * Touch-friendly defaults. Text buttons keep their natural width, while
 * icon-only controls with an accessible name also receive a 44px width.
 * Radios/checkboxes are excluded because their surrounding labels/cards own
 * the actual hit area.
 */
button {
    min-height: 44px;
}

button[aria-label] {
    min-width: 44px;
}

input:not([type="radio"]):not([type="checkbox"]):not([type="hidden"]),
select,
textarea {
    min-height: 44px;
}

label:has(> input[type="radio"]),
label:has(> input[type="checkbox"]) {
    min-width: 44px;
    min-height: 44px;
}

/*
 * Surface-aware dark-theme text colors. These selectors intentionally target
 * text utilities rather than replacing Tailwind's palette tokens: gray-500,
 * for example, is also used as a button hover background and must remain dark.
 * Every value below provides at least 4.8:1 contrast on a gray-700 card.
 */
.text-gray-400 {
    color: oklch(82% .018 261.325);
}

.text-gray-500 {
    color: oklch(76% .02 264.364);
}

.text-purple-400 {
    color: oklch(80% .14 305.504);
}

.text-red-400 {
    color: oklch(78% .13 22.216);
}

.text-blue-400 {
    color: oklch(78% .12 254.624);
}

/* Persistent Config-page save action, offset from the desktop sidebar. */
.config-save-bar {
    position: fixed;
    right: 1rem;
    bottom: 1rem;
    left: 1rem;
    z-index: 35;
}

@media (min-width: 1024px) {
    .config-save-bar {
        right: 2rem;
        left: 19.5rem;
    }
}

/* Keep Hotkeys discovery controls reachable while the mobile catalog scrolls. */
@media (max-width: 767px) {
    .hotkeys-filter-bar {
        position: sticky;
        top: 0.75rem;
        z-index: 20;
        box-shadow: 0 12px 24px rgb(3 7 18 / 45%);
    }
}

/* Alpine.js: hide x-cloak elements until components initialize */
[x-cloak] {
    display: none !important;
}

/* Navigation styles */
.nav-item {
    transition: all 0.2s;
}
.nav-item:hover {
    background-color: rgba(124, 58, 237, 0.1);
}
.nav-item.active {
    background-color: rgba(124, 58, 237, 0.2);
    border-left: 3px solid #7c3aed;
}

/* Apple gradient text effect */
.apple-gradient {
    background: linear-gradient(45deg, #FF9500 0%, #BF5AF2 50%, #72C7E6 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    display: inline-block;
}

/* Accessibility: Skip to main content link */
.skip-link {
    position: absolute;
    top: -100px;
    left: 50%;
    transform: translateX(-50%);
    background: #7c3aed;
    color: white;
    padding: 12px 24px;
    border-radius: 0 0 8px 8px;
    font-weight: 600;
    text-decoration: none;
    z-index: 9999;
    transition: top 0.2s ease;
}
.skip-link:focus {
    top: 0;
    outline: 2px solid white;
    outline-offset: 2px;
}

/* Accessibility: Screen reader only content */
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* Accessibility: Focus indicators */
:focus-visible {
    outline: 2px solid #7c3aed;
    outline-offset: 2px;
}

/* Remove default focus for mouse users */
:focus:not(:focus-visible) {
    outline: none;
}

/* Button focus states */
button:focus-visible,
a:focus-visible {
    outline: 2px solid #7c3aed;
    outline-offset: 2px;
    box-shadow: 0 0 0 4px rgba(124, 58, 237, 0.3);
}

/* Input focus states */
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
    outline: 2px solid #7c3aed;
    outline-offset: 2px;
    border-color: #7c3aed;
    box-shadow: 0 0 0 4px rgba(124, 58, 237, 0.3);
}

/* Modal focus trap and animation */
.modal-overlay {
    opacity: 0;
    transition: opacity 0.2s ease;
}
.modal-overlay:not([style*="display: none"]) {
    opacity: 1;
}

.modal-container {
    transform: scale(0.95);
    transition: transform 0.2s ease;
}
.modal-overlay:not([style*="display: none"]) .modal-container {
    transform: scale(1);
}
.modal-container.modal-closing {
    transform: scale(0.95);
    opacity: 0;
}

/* Modal messages are plain text; preserve line breaks from \n */
.modal-message {
    white-space: pre-line;
}

/* Toast Container */
.toast-container {
    position: fixed;
    bottom: 1rem;
    right: 1rem;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    max-width: 400px;
}

/* Toast Card */
.toast {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    padding: 0.75rem 1rem;
    border-radius: 0.5rem;
    background-color: #1f2937; /* gray-800 */
    border: 1px solid #374151; /* gray-700 */
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.3), 0 4px 6px -2px rgba(0, 0, 0, 0.2);
    opacity: 0;
    transform: translateX(100%);
    transition: all 0.3s ease;
}

.toast.toast-visible {
    opacity: 1;
    transform: translateX(0);
}

.toast.toast-dismissing {
    opacity: 0;
    transform: translateX(100%);
}

.toast-content {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    flex: 1;
    min-width: 0;
}

.toast-icon {
    flex-shrink: 0;
    font-size: 1.25rem;
    line-height: 1;
}

.toast-message {
    font-size: 0.875rem;
    color: #f3f4f6; /* gray-100 */
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.toast-close {
    flex-shrink: 0;
    padding: 0.25rem;
    background: transparent;
    border: none;
    color: #9ca3af; /* gray-400 */
    cursor: pointer;
    border-radius: 0.25rem;
    transition: all 0.15s;
}

.toast-close:hover {
    color: #f3f4f6; /* gray-100 */
    background-color: rgba(255, 255, 255, 0.1);
}

.toast-close:focus-visible {
    outline: 2px solid #7c3aed;
    outline-offset: 2px;
}

.toast-details-btn {
    margin-left: 0.75rem;
    padding: 0.25rem 0.5rem;
    font-size: 0.75rem;
    background-color: rgba(255, 255, 255, 0.1);
    border: none;
    border-radius: 0.25rem;
    color: #a78bfa; /* purple-400 */
    cursor: pointer;
    transition: all 0.15s;
    white-space: nowrap;
}

.toast-details-btn:hover {
    background-color: rgba(255, 255, 255, 0.2);
    color: #c4b5fd; /* purple-300 */
}

.toast-progress-btn {
    margin-left: 0.75rem;
    padding: 0.25rem 0.5rem;
    font-size: 0.75rem;
    background-color: rgba(147, 197, 253, 0.2); /* blue-200 with opacity */
    border: none;
    border-radius: 0.25rem;
    color: #93c5fd; /* blue-300 */
    cursor: pointer;
    transition: all 0.15s;
    white-space: nowrap;
}

.toast-progress-btn:hover {
    background-color: rgba(147, 197, 253, 0.3);
    color: #bfdbfe; /* blue-200 */
}

/* Toast Type Variants */
.toast.toast-success {
    border-left: 4px solid #22c55e; /* green-500 */
}

.toast.toast-success .toast-icon {
    color: #22c55e;
}

.toast.toast-error {
    border-left: 4px solid #ef4444; /* red-500 */
}

.toast.toast-error .toast-icon {
    color: #ef4444;
}

.toast.toast-warning {
    border-left: 4px solid #f59e0b; /* amber-500 */
}

.toast.toast-warning .toast-icon {
    color: #f59e0b;
}

.toast.toast-info {
    border-left: 4px solid #3b82f6; /* blue-500 */
}

.toast.toast-info .toast-icon {
    color: #3b82f6;
}

/* Task badge in sidebar */
.task-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 1.25rem;
    height: 1.25rem;
    padding: 0 0.375rem;
    font-size: 0.75rem;
    font-weight: 600;
    border-radius: 9999px;
    background-color: #1d4ed8; /* blue-700: 6.7:1 with white */
    color: white;
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0%, 100% {
        opacity: 1;
    }
    50% {
        opacity: 0.7;
    }
}

/* Job progress bar in app cards */
.job-progress-bar {
    transition: width 0.3s ease;
}

/* Job output modal */
#job-output-modal {
    animation: fadeIn 0.2s ease;
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

/* Drag and drop styles for priority lists */
.priority-list-item {
    transition: opacity 0.15s ease, transform 0.15s ease, border-color 0.15s ease;
}

.priority-list-item.dragging {
    opacity: 0.5;
    transform: scale(0.95);
}

.priority-list-item.drag-over {
    border-top: 3px solid #7c3aed;
    margin-top: -3px;
    padding-top: calc(0.75rem + 3px);
}

.priority-list-item.drag-over-bottom {
    border-bottom: 3px solid #7c3aed;
    margin-bottom: -3px;
    padding-bottom: calc(0.75rem + 3px);
}

.drag-handle {
    cursor: grab;
    color: #9ca3af;
    transition: color 0.15s ease;
}

.drag-handle:hover {
    color: #d1d5db;
}

.drag-handle:active {
    cursor: grabbing;
}

/* Reduced motion preference */
@media (prefers-reduced-motion: reduce) {
    [role="dialog"],
    [role="dialog"] *,
    .modal-overlay,
    .modal-container {
        animation: none !important;
        transition: none !important;
    }

    .toast {
        transition: opacity 0.15s ease;
        transform: none !important;
    }
    
    .toast.toast-visible {
        transform: none !important;
    }
    
    .task-badge {
        animation: none;
    }
    
    .job-progress-bar {
        transition: none;
    }

    .priority-list-item {
        transition: none;
    }
    
    .priority-list-item.dragging {
        transform: none;
    }
}

/* =============================================================================
   Custom Scrollbar Styles
   Cross-browser support: Chrome, Safari, Edge (WebKit), Firefox
   ============================================================================= */

/* WebKit Scrollbar (Chrome, Safari, Edge) */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: #1f2937; /* gray-800 */
    border-radius: 4px;
}

::-webkit-scrollbar-thumb {
    background: #4b5563; /* gray-600 */
    border-radius: 4px;
    transition: background-color 0.15s ease;
}

::-webkit-scrollbar-thumb:hover {
    background: #a855f7; /* purple-500 */
}

::-webkit-scrollbar-thumb:active {
    background: #7c3aed; /* purple-600 */
}

/* Corner where horizontal and vertical scrollbars meet */
::-webkit-scrollbar-corner {
    background: #1f2937; /* gray-800 */
}

/* Firefox Scrollbar */
* {
    scrollbar-width: thin;
    scrollbar-color: #4b5563 #1f2937; /* thumb track - gray-600 on gray-800 */
}

/* Firefox doesn't support hover states for scrollbar-color, 
   but thin scrollbar provides a clean look */

/* =============================================================================
   Boxicons compatibility aliases
   ============================================================================= */

/* bx-loader-alt was renamed to bx-loader-lines in the bundled boxicons subset.
   Keep the old name rendering for scripts that still reference it. */
.bx-loader-alt:before {
    content: "\f519"; /* bx-loader-lines */
}
