/* GrabZilla 2.1 - Exact Figma Design System */

/* Import component styles */
@import url('./components/header.css');

:root {
    /* Primary Colors - Exact from Figma */
    --primary-blue: #155dfc;
    --success-green: #00a63e;
    --error-red: #e7000b;
    
    /* Backgrounds - Exact from Figma */
    --bg-dark: #1d293d;
    --header-dark: #0f172b;
    --card-bg: #314158;
    --border-color: #45556c;
    
    /* Text Colors - Exact from Figma */
    --text-primary: #ffffff;
    --text-secondary: #cad5e2;
    --text-muted: #90a1b9;
    --text-disabled: #62748e;
    
    /* Status Colors */
    --status-ready: #00a63e;
    --status-downloading: #00a63e;
    --status-converting: #155dfc;
    --status-completed: #4a5565;
    --status-error: #e7000b;
    
    /* macOS Traffic Light Colors */
    --macos-red: #ff5f57;
    --macos-red-hover: #ff4136;
    --macos-yellow: #ffbd2e;
    --macos-yellow-hover: #ff9500;
    --macos-green: #28ca42;
    --macos-green-hover: #00d084;
}

/* Base Styles */
* {
    box-sizing: border-box;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background-color: var(--bg-dark);
    color: var(--text-primary);
    margin: 0;
    padding: 0;
    min-height: 100vh;
}

/* Scrollbar Styling */
::-webkit-scrollbar {
    width: 8px;
}

::-webkit-scrollbar-track {
    background: var(--bg-dark);
}

::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--text-muted);
}

/* Button Hover Effects */
button:hover {
    transition: all 0.2s ease;
}

button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Input Focus Styles */
input:focus,
textarea:focus,
select:focus {
    outline: none;
    border-color: var(--primary-blue);
    box-shadow: 0 0 0 2px rgba(21, 93, 252, 0.2);
}

/* Enhanced Focus Indicators for Accessibility */
button:focus-visible,
input:focus-visible,
textarea:focus-visible,
select:focus-visible,
[tabindex]:focus-visible {
    outline: 3px solid var(--primary-blue) !important;
    outline-offset: 2px !important;
    box-shadow: 0 0 0 1px rgba(21, 93, 252, 0.3) !important;
    position: relative;
    z-index: 10;
}

/* Video item focus management */
.video-item {
    position: relative;
}

.video-item:focus-within {
    outline: 2px solid var(--primary-blue) !important;
    outline-offset: 1px !important;
    background-color: rgba(21, 93, 252, 0.1) !important;
    z-index: 5;
}

.video-item:focus {
    outline: 3px solid var(--primary-blue) !important;
    outline-offset: 2px !important;
    background-color: rgba(21, 93, 252, 0.15) !important;
}

/* Keyboard navigation indicators */
.video-item.keyboard-focused {
    background-color: rgba(21, 93, 252, 0.1) !important;
    border: 1px solid var(--primary-blue);
}

/* Selection states with accessibility */
.video-item.selected {
    background-color: rgba(21, 93, 252, 0.2) !important;
    border: 2px solid var(--primary-blue);
    box-shadow: 0 0 0 1px rgba(21, 93, 252, 0.3);
}

.video-item.selected:focus {
    outline: 3px solid var(--success-green) !important;
    outline-offset: 2px !important;
}

/* Screen Reader Only Utility */
.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;
}

/* High Contrast Mode Support */
@media (prefers-contrast: high) {
    :root {
        --border-color: #ffffff;
        --text-muted: #ffffff;
    }
}

/* Reduced Motion Support */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* Loading Spinner Animation */
@keyframes spin {
    from {
        transform: rotate(0deg);
    }
    to {
        transform: rotate(360deg);
    }
}

.animate-spin {
    animation: spin 1s linear infinite;
}

/* Control Panel Button Styles */
#clearListBtn:hover:not(:disabled) {
    background-color: var(--border-color);
    border-color: var(--text-muted);
}

#updateDepsBtn:hover:not(:disabled) {
    background-color: var(--border-color);
    border-color: var(--text-muted);
}

#cancelDownloadsBtn:hover:not(:disabled) {
    background-color: #c53030;
}

#downloadVideosBtn:hover:not(:disabled) {
    background-color: #38a169;
}

/* Disabled button styles */
button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

button:disabled:hover {
    transform: none;
    box-shadow: none;
}

/* Utility Classes */
.text-truncate {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Thumbnail Preview Hover Effect */
.video-thumbnail-container {
    position: relative;
    overflow: visible;
    z-index: 1;
}

.video-thumbnail-container:hover {
    z-index: 50;
}

.video-thumbnail-container img {
    transition: all 200ms ease-out;
}

.video-thumbnail-container:hover img {
    transform: scale(2.5);
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.5);
    border-radius: 6px;
    position: relative;
    z-index: 50;
}

/* Settings Modal Tabs */
.settings-tab.active {
    color: white;
    border-bottom-color: #155dfc;
}

/* Toast Notifications */
.toast {
    pointer-events: auto;
    min-width: 300px;
    max-width: 400px;
    animation: slideIn 0.3s ease-out;
}

.toast.removing {
    animation: slideOut 0.3s ease-out forwards;
}

@keyframes slideIn {
    from {
        transform: translateX(400px);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

@keyframes slideOut {
    from {
        transform: translateX(0);
        opacity: 1;
    }
    to {
        transform: translateX(400px);
        opacity: 0;
    }
}

/* Responsive Design */
@media (max-width: 1024px) {
    .grid-cols-\[40px_40px_1fr_120px_100px_120px_100px\] {
        grid-template-columns: 40px 1fr 80px 80px 80px;
    }
    
    /* Hide drag handle and checkbox on smaller screens */
    .grid-cols-\[40px_40px_1fr_120px_100px_120px_100px\] > :nth-child(1),
    .grid-cols-\[40px_40px_1fr_120px_100px_120px_100px\] > :nth-child(2) {
        display: none;
    }
}

@media (max-width: 768px) {
    .grid-cols-\[40px_40px_1fr_120px_100px_120px_100px\] {
        grid-template-columns: 1fr 60px;
        gap: 8px;
    }
    
    /* Hide some columns on mobile */
    .grid-cols-\[40px_40px_1fr_120px_100px_120px_100px\] > :nth-child(4),
    .grid-cols-\[40px_40px_1fr_120px_100px_120px_100px\] > :nth-child(5),
    .grid-cols-\[40px_40px_1fr_120px_100px_120px_100px\] > :nth-child(6) {
        display: none;
    }
}
/*
 Video List Styles - Exact Figma Implementation */
.video-item {
    border-radius: 4px;
    cursor: pointer;
}

.video-item:hover {
    background-color: #3a4a68 !important;
}

/* Video Item Checkbox Styling */
.video-item button svg rect {
    transition: all 0.2s ease;
}

.video-item button:hover svg rect {
    stroke: var(--primary-blue);
}

/* Video Item Drag Handle Styling */
.video-item svg circle {
    transition: fill 0.2s ease;
}

/* Video Thumbnail Styling */
.video-item .w-16.h-12 {
    background: linear-gradient(135deg, #4a5568 0%, #2d3748 100%);
    border: 1px solid var(--border-color);
}

/* Video Dropdown Styling */
.video-item select {
    transition: all 0.2s ease;
    appearance: none;
    background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 20 20'%3e%3cpath stroke='%236b7280' stroke-linecap='round' stroke-linejoin='round' stroke-width='1.5' d='m6 8 4 4 4-4'/%3e%3c/svg%3e");
    background-position: right 8px center;
    background-repeat: no-repeat;
    background-size: 16px;
    padding-right: 32px;
}

.video-item select:hover {
    border-color: var(--primary-blue);
    background-color: #3a4a68;
}

.video-item select:focus {
    outline: none;
    border-color: var(--primary-blue);
    box-shadow: 0 0 0 2px rgba(21, 93, 252, 0.2);
}

/* Progress Bar Styling */
.video-item .bg-\[\#45556c\] {
    background-color: var(--border-color);
    border-radius: 6px;
}

.video-item .bg-\[\#00a63e\] {
    background-color: var(--success-green);
    border-radius: 6px;
}

.video-item .bg-\[\#155dfc\] {
    background-color: var(--primary-blue);
    border-radius: 6px;
}

/* Status Badge Component - Integrated Progress Design - Exact Figma Implementation */
.status-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 4px 12px;
    border-radius: 4px;
    font-size: 12px;
    font-weight: 500;
    line-height: 16px;
    letter-spacing: -0.1504px;
    min-width: 80px;
    max-width: 140px; /* Increased from 100px to accommodate "Downloading 99%" */
    text-align: center;
    transition: all 0.2s ease;
    position: relative;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
}

/* Ready State - Green Badge */
.status-badge.ready {
    background-color: var(--status-ready); /* #00a63e */
    color: #ffffff;
    font-weight: 500;
}

/* Downloading State - Green Badge with Integrated Progress */
.status-badge.downloading {
    background-color: var(--status-downloading); /* #00a63e */
    color: #ffffff;
    font-weight: 500;
    position: relative;
}

/* Converting State - Blue Badge with Integrated Progress */
.status-badge.converting {
    background-color: var(--status-converting); /* #155dfc */
    color: #ffffff;
    font-weight: 500;
    position: relative;
}

/* Paused State - Muted Gray Badge */
.status-badge.paused {
    background-color: var(--text-muted); /* #90a1b9 */
    color: #ffffff;
    font-weight: 500;
}

/* Completed State - Gray Badge */
.status-badge.completed {
    background-color: var(--status-completed); /* #4a5565 */
    color: #ffffff;
    font-weight: 500;
}

/* Error State - Red Badge */
.status-badge.error {
    background-color: var(--status-error); /* #e7000b */
    color: #ffffff;
    font-weight: 500;
}

/* Progress Animation for Status Badges - Enhanced Figma-Compliant Design */
.status-badge.downloading::before,
.status-badge.converting::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(
        90deg,
        transparent,
        rgba(255, 255, 255, 0.15),
        transparent
    );
    animation: progress-shimmer 2.5s infinite;
    z-index: 1;
}

@keyframes progress-shimmer {
    0% {
        left: -100%;
    }
    100% {
        left: 100%;
    }
}

/* Subtle pulsing effect for active status badges */
.status-badge.downloading,
.status-badge.converting {
    animation: status-pulse 3s ease-in-out infinite;
}

@keyframes status-pulse {
    0%, 100% {
        opacity: 1;
        transform: scale(1);
    }
    50% {
        opacity: 0.9;
        transform: scale(1.02);
    }
}

/* Progress Indicator Overlay for Integrated Progress Display */
.status-badge[data-progress]::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    height: 2px;
    background-color: rgba(255, 255, 255, 0.3);
    border-radius: 0 0 4px 4px;
    transition: width 0.3s ease;
    z-index: 2;
}

/* Dynamic progress indicator - will be set via JavaScript */
.status-badge.has-progress::after {
    width: var(--progress-width, 0%);
}

/* Legacy Progress Bar Styles - Kept for backward compatibility */
.progress-container {
    display: flex;
    flex-direction: column;
    gap: 4px;
    width: 100%;
}

.progress-bar {
    width: 100%;
    height: 16px;
    background-color: var(--border-color);
    border-radius: 6px;
    overflow: hidden;
    position: relative;
}

.progress-fill {
    height: 100%;
    border-radius: 6px;
    transition: width 0.3s ease;
    position: relative;
}

.progress-fill.downloading {
    background-color: var(--status-downloading);
}

.progress-fill.converting {
    background-color: var(--status-converting);
}

.progress-text {
    font-size: 12px;
    font-weight: 500;
    line-height: 16px;
    letter-spacing: -0.1504px;
    color: var(--text-secondary);
    text-align: center;
}

/* Progress Bar with Status Text Combined */
.progress-status {
    display: flex;
    flex-direction: column;
    gap: 2px;
    align-items: center;
    justify-content: center;
    width: 100%;
}

.progress-status .progress-bar {
    height: 16px;
    margin-bottom: 2px;
}

.progress-status .progress-text {
    font-size: 12px;
    color: var(--text-secondary);
}

/* Status Badge Hover Effects */
.status-badge:hover {
    transform: translateY(-1px);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

/* Accessibility Improvements for Status Components */
.status-badge[aria-live="polite"] {
    /* Ensure status changes are announced to screen readers */
}

.progress-container[role="progressbar"] {
    /* Ensure progress is accessible */
}

/* High Contrast Mode Support for Status Components */
@media (prefers-contrast: high) {
    .status-badge {
        border: 1px solid var(--text-primary);
        font-weight: 600;
    }
    
    .progress-bar {
        border: 1px solid var(--text-primary);
    }
}

/* Responsive Video List */
@media (max-width: 1024px) {
    .video-item {
        grid-template-columns: 40px 1fr 80px 80px 80px;
    }
    
    /* Hide drag handle on smaller screens */
    .video-item > :nth-child(2) {
        display: none;
    }
}

@media (max-width: 768px) {
    .video-item {
        grid-template-columns: 1fr 60px;
        gap: 8px;
        padding: 12px;
    }
    
    /* Hide checkbox, duration, quality, format on mobile */
    .video-item > :nth-child(1),
    .video-item > :nth-child(4),
    .video-item > :nth-child(5),
    .video-item > :nth-child(6) {
        display: none;
    }
    
    /* Stack video info vertically on mobile */
    .video-item .flex.items-center.gap-3 {
        flex-direction: column;
        align-items: flex-start;
        gap: 8px;
    }
    
    .video-item .w-16.h-12 {
        width: 48px;
        height: 36px;
    }
}

/* Video Selection States */
.video-item.selected {
    background-color: rgba(21, 93, 252, 0.15) !important;
    border: 1px solid var(--primary-blue);
    box-shadow: 0 0 0 1px rgba(21, 93, 252, 0.3);
}

.video-item.selected:hover {
    background-color: rgba(21, 93, 252, 0.2) !important;
}

/* Enhanced Checkbox States for Accessibility */
.video-checkbox {
    position: relative;
    cursor: pointer;
    border-radius: 4px;
    transition: all 0.2s ease;
}

.video-checkbox:focus-visible {
    outline: 2px solid var(--primary-blue) !important;
    outline-offset: 2px !important;
}

.video-checkbox svg rect {
    transition: all 0.2s ease;
}

.video-checkbox:hover svg rect {
    stroke: var(--primary-blue);
    stroke-width: 2;
}

.video-checkbox.checked svg rect {
    fill: var(--primary-blue);
    stroke: var(--primary-blue);
}

.video-checkbox.checked svg {
    position: relative;
}

.video-checkbox.checked svg::after {
    content: '✓';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    color: white;
    font-size: 12px;
    font-weight: bold;
}

/* Keyboard navigation helpers */
.keyboard-navigation-active .video-item:focus {
    background-color: rgba(21, 93, 252, 0.15) !important;
}

.keyboard-navigation-active button:focus,
.keyboard-navigation-active select:focus,
.keyboard-navigation-active input:focus,
.keyboard-navigation-active textarea:focus {
    box-shadow: 0 0 0 3px rgba(21, 93, 252, 0.3) !important;
}

/* Drag and Drop States */
.video-item.dragging {
    opacity: 0.6;
    transform: rotate(3deg) scale(1.02);
    z-index: 1000;
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.3);
    border: 2px solid var(--primary-blue);
}

.video-item.drop-target {
    background-color: rgba(21, 93, 252, 0.1) !important;
    border: 2px dashed var(--primary-blue);
    transform: scale(1.02);
}

.video-item.drop-target::before {
    content: '';
    position: absolute;
    top: -2px;
    left: 0;
    right: 0;
    height: 4px;
    background-color: var(--primary-blue);
    border-radius: 2px;
    z-index: 10;
}

/* Drag handle cursor */
.video-item [data-drag-handle] {
    cursor: grab;
}

.video-item [data-drag-handle]:active {
    cursor: grabbing;
}

/* Selection counter in status */
.selection-status {
    color: var(--primary-blue);
    font-weight: 500;
}

/* Loading States */
.video-item .loading-spinner {
    width: 16px;
    height: 16px;
    border: 2px solid var(--border-color);
    border-top: 2px solid var(--primary-blue);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

/* Accessibility Improvements */
.video-item:focus-within {
    outline: 2px solid var(--primary-blue);
    outline-offset: 2px;
}

.video-item button:focus-visible,
.video-item select:focus-visible {
    outline: 2px solid var(--primary-blue);
    outline-offset: 2px;
}

/* Text Truncation for Long Titles */
.video-item .truncate {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Smooth Transitions */
.video-item * {
    transition: all 0.2s ease;
}

/* High Contrast Mode Support for Video List */
@media (prefers-contrast: high) {
    .video-item {
        border: 1px solid var(--text-primary);
    }
    
    .video-item select {
        border-color: var(--text-primary);
    }
}
/* macOS 
Title Bar Styling */
header {
    -webkit-app-region: drag;
    -webkit-user-select: none;
    user-select: none;
}

/* Traffic Light Buttons */
.traffic-light {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    transition: all 0.2s ease;
    cursor: pointer;
    -webkit-app-region: no-drag;
    border: none;
    outline: none;
}

.traffic-light:focus-visible {
    outline: 2px solid var(--primary-blue);
    outline-offset: 2px;
}

.traffic-light:active {
    transform: scale(0.95);
}

.traffic-light:hover {
    transform: scale(1.1);
}

/* Fix Row Selection Cut-off Issue */
#videoList {
    padding-top: 8px; /* Add top padding to prevent cut-off */
}

.video-item {
    margin-top: 2px; /* Ensure proper spacing */
    margin-bottom: 2px;
}

.video-item:first-child {
    margin-top: 0; /* Remove extra margin from first item */
}

/* Improve Video Item Hover Effect */
.video-item:hover {
    background-color: #3a4a68 !important;
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

/* Ensure proper spacing in video list container */
.video-item + .video-item {
    margin-top: 8px;
}

/* Fix any potential overflow issues */
main {
    overflow: hidden;
}

#videoList {
    overflow-y: auto;
    overflow-x: hidden;
}

/* Improve scrollbar in video list */
#videoList::-webkit-scrollbar {
    width: 6px;
}

#videoList::-webkit-scrollbar-track {
    background: transparent;
}

#videoList::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 3px;
}

#videoList::-webkit-scrollbar-thumb:hover {
    background: var(--text-muted);
}

/* Ensure proper title bar height and centering */
header {
    min-height: 41px;
    height: 41px;
    -webkit-app-region: drag;
    -webkit-user-select: none;
    user-select: none;
}

/* Make sure the logo and title are properly centered */
header > div {
    -webkit-app-region: no-drag;
}

/* Responsive title bar */
@media (max-width: 768px) {
    header {
        height: 41px;
        min-height: 41px;
    }
}
/* Binary Version Statusline */
.update-badge {
    color: var(--primary-blue);
    font-size: 16px;
    line-height: 1;
    animation: pulse-badge 2s ease-in-out infinite;
}

@keyframes pulse-badge {
    0%, 100% {
        opacity: 1;
    }
    50% {
        opacity: 0.4;
    }
}

#binaryVersions {
    font-family: ui-monospace, "SF Mono", Monaco, "Cascadia Code", "Roboto Mono", Menlo, Consolas, "Courier New", monospace;
}

#lastUpdateCheck {
    font-style: italic;
}
