/* =========================================
   OpenList Web - Modern Light Theme CSS
   Compatible with Chrome 106+
   ========================================= */

:root {
    /* Colors - Light Theme */
    --bg-primary: #f5f5f7;
    --bg-secondary: #ffffff;
    --bg-tertiary: #f0f0f2;
    --bg-card: rgba(255, 255, 255, 0.95);
    --bg-hover: rgba(0, 0, 0, 0.03);

    --text-primary: #1d1d1f;
    --text-secondary: #6e6e73;
    --text-tertiary: #8e8e93;

    --accent-primary: #007aff;
    --accent-secondary: #5ac8fa;
    --accent-gradient: linear-gradient(135deg, #007aff, #5ac8fa);

    --border-color: rgba(0, 0, 0, 0.08);
    --border-focus: rgba(0, 122, 255, 0.4);

    --success: #34c759;
    --warning: #ff9500;
    --error: #ff3b30;

    /* Spacing */
    --spacing-xs: 4px;
    --spacing-sm: 8px;
    --spacing-md: 16px;
    --spacing-lg: 24px;
    --spacing-xl: 32px;

    /* Border Radius */
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --radius-xl: 24px;

    /* Shadows */
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.08);
    --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.12);
    --shadow-card: 0 2px 8px rgba(0, 0, 0, 0.06);

    /* Transitions */
    --transition-fast: 150ms ease;
    --transition-normal: 250ms ease;
    --transition-slow: 350ms ease;

    /* Typography */
    --font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

/* Reset & Base */
*,
*::before,
*::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    font-size: 16px;
    -webkit-tap-highlight-color: transparent;
}

body {
    font-family: var(--font-family);
    background: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.5;
    min-height: 100vh;
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
}

/* Screen System */
.screen {
    min-height: 100vh;
    width: 100%;
}

.screen.hidden {
    display: none;
}

/* =========================================
   Login Screen
   ========================================= */
.login-container {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: var(--spacing-lg);
    background: var(--bg-primary);
}

.login-card {
    width: 100%;
    max-width: 400px;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-xl);
    padding: var(--spacing-xl);
    box-shadow: var(--shadow-lg);
    animation: fadeInUp 0.5s ease;
}

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.login-header {
    text-align: center;
    margin-bottom: var(--spacing-xl);
}

.logo {
    width: 64px;
    height: 64px;
    margin: 0 auto var(--spacing-md);
    background: var(--accent-gradient);
    border-radius: var(--radius-lg);
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: var(--shadow-md);
}

.logo svg {
    width: 32px;
    height: 32px;
    color: white;
}

.login-header h1 {
    font-size: 1.75rem;
    font-weight: 700;
    margin-bottom: var(--spacing-xs);
    color: var(--text-primary);
}

.subtitle {
    color: var(--text-secondary);
    font-size: 0.875rem;
}

/* Form Styles */
.login-form {
    display: flex;
    flex-direction: column;
    gap: var(--spacing-md);
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: var(--spacing-xs);
}

.form-group label {
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text-secondary);
}

.form-group input {
    width: 100%;
    padding: 14px 16px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    font-size: 1rem;
    font-family: inherit;
    transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}

.form-group input:focus {
    outline: none;
    border-color: var(--accent-primary);
    box-shadow: 0 0 0 3px var(--border-focus);
    background: var(--bg-secondary);
}

.form-group input::placeholder {
    color: var(--text-tertiary);
}

/* Button Styles */
.btn-primary {
    width: 100%;
    padding: 14px 24px;
    background: var(--accent-primary);
    border: none;
    border-radius: var(--radius-md);
    color: white;
    font-size: 1rem;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    transition: transform var(--transition-fast), box-shadow var(--transition-fast), background var(--transition-fast);
    position: relative;
    overflow: hidden;
}

.btn-primary:hover {
    background: #0066d6;
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
}

.btn-primary:active {
    transform: translateY(0);
}

.btn-primary.loading .btn-text {
    visibility: hidden;
}

.btn-primary.loading .btn-loader {
    display: block;
}

.btn-loader {
    display: none;
    position: absolute;
    top: 50%;
    left: 50%;
    width: 20px;
    height: 20px;
    margin: -10px 0 0 -10px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-top-color: white;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

.error-message {
    color: var(--error);
    font-size: 0.875rem;
    text-align: center;
    min-height: 20px;
}

/* =========================================
   Browser Screen
   ========================================= */
.header {
    position: sticky;
    top: 0;
    z-index: 100;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--spacing-md);
    background: rgba(245, 245, 247, 0.9);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-bottom: 1px solid var(--border-color);
}

.header-left,
.header-right {
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
}

.header-center {
    flex: 1;
    text-align: center;
    overflow: hidden;
}

.path-title {
    font-size: 1rem;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    padding: 0 var(--spacing-sm);
    color: var(--text-primary);
}

.icon-btn {
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: none;
    border-radius: var(--radius-sm);
    color: var(--accent-primary);
    cursor: pointer;
    transition: background var(--transition-fast);
}

.icon-btn:hover {
    background: var(--bg-hover);
}

.icon-btn svg {
    width: 20px;
    height: 20px;
}

/* Breadcrumb */
.breadcrumb {
    display: flex;
    align-items: center;
    gap: var(--spacing-xs);
    padding: var(--spacing-sm) var(--spacing-md);
    background: var(--bg-primary);
    overflow-x: auto;
    white-space: nowrap;
    scrollbar-width: none;
    -ms-overflow-style: none;
}

.breadcrumb::-webkit-scrollbar {
    display: none;
}

.breadcrumb-item {
    font-size: 0.875rem;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 6px 12px;
    border-radius: var(--radius-sm);
    transition: color var(--transition-fast), background var(--transition-fast);
}

.breadcrumb-item:hover {
    color: var(--text-primary);
    background: var(--bg-hover);
}

.breadcrumb-item:last-child {
    color: var(--accent-primary);
    font-weight: 500;
}

.breadcrumb-separator {
    color: var(--text-tertiary);
    font-size: 0.75rem;
}

/* File List */
.file-list {
    padding: var(--spacing-md);
    min-height: calc(100vh - 120px);
}

.file-list-card {
    background: var(--bg-secondary);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-card);
    overflow: hidden;
}

.file-item {
    display: flex;
    align-items: center;
    gap: var(--spacing-md);
    padding: var(--spacing-md) var(--spacing-lg);
    background: var(--bg-secondary);
    cursor: pointer;
    transition: background var(--transition-fast);
    border-bottom: 1px solid var(--border-color);
}

.file-item:last-child {
    border-bottom: none;
}

.file-item:hover {
    background: var(--bg-tertiary);
}

.file-item:active {
    background: rgba(0, 0, 0, 0.05);
}

.file-icon {
    width: 44px;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-sm);
    flex-shrink: 0;
}

.file-icon svg {
    width: 28px;
    height: 28px;
}

.file-icon.folder {
    background: transparent;
    color: #007aff;
}

.file-icon.folder svg {
    width: 36px;
    height: 36px;
}

.file-icon.video {
    background: rgba(255, 59, 48, 0.1);
    color: #ff3b30;
}

.file-icon.audio {
    background: rgba(52, 199, 89, 0.1);
    color: #34c759;
}

.file-icon.image {
    background: rgba(175, 82, 222, 0.1);
    color: #af52de;
}

.file-icon.text {
    background: rgba(0, 122, 255, 0.1);
    color: #007aff;
}

.file-icon.unknown {
    background: rgba(142, 142, 147, 0.1);
    color: #8e8e93;
}

.file-info {
    flex: 1;
    min-width: 0;
}

.file-name {
    font-size: 1rem;
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    color: var(--text-primary);
}

.file-meta {
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
    margin-top: 2px;
    font-size: 0.8125rem;
    color: var(--text-tertiary);
}

.file-arrow {
    color: var(--text-tertiary);
    flex-shrink: 0;
}

.file-arrow svg {
    width: 16px;
    height: 16px;
}

/* Empty State */
.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: var(--spacing-xl);
    color: var(--text-tertiary);
    text-align: center;
    min-height: 300px;
}

.empty-state svg {
    width: 64px;
    height: 64px;
    margin-bottom: var(--spacing-md);
    opacity: 0.5;
}

/* Loading Overlay */
.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(245, 245, 247, 0.9);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 200;
}

.loading-overlay.hidden {
    display: none;
}

.spinner {
    width: 48px;
    height: 48px;
    border: 3px solid var(--border-color);
    border-top-color: var(--accent-primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

/* =========================================
   Video Player Screen
   ========================================= */
#playerScreen {
    background: #000;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 1000;
}

.player-container {
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    position: relative;
}

.player-header {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    z-index: 10;
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
    padding: var(--spacing-md);
    background: linear-gradient(to bottom, rgba(0, 0, 0, 0.8) 0%, transparent 100%);
    transition: opacity var(--transition-normal);
}

.player-header.hidden {
    opacity: 0;
    pointer-events: none;
}

.player-header .icon-btn {
    color: white;
}

.video-title {
    flex: 1;
    font-size: 1rem;
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    color: white;
}

.video-wrapper {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    overflow: hidden;
}

#videoPlayer {
    width: 100%;
    height: 100%;
    max-height: 100vh;
    object-fit: contain;
    background: #000;
}

/* Seek Indicator */
.seek-indicator {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(0, 0, 0, 0.8);
    padding: 16px 24px;
    border-radius: var(--radius-md);
    font-size: 1.5rem;
    font-weight: 600;
    color: white;
    z-index: 20;
    transition: opacity var(--transition-fast);
}

.seek-indicator.hidden {
    opacity: 0;
    pointer-events: none;
}

/* Center Play Button */
.center-play-btn {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 80px;
    height: 80px;
    background: rgba(255, 255, 255, 0.2);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: transform var(--transition-fast), background var(--transition-fast);
    color: white;
}

.center-play-btn:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: translate(-50%, -50%) scale(1.1);
}

.center-play-btn svg {
    width: 32px;
    height: 32px;
    margin-left: 4px;
}

.center-play-btn.hidden {
    display: none;
}

/* Player Controls */
.player-controls {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 10;
    padding: var(--spacing-md);
    background: linear-gradient(to top, rgba(0, 0, 0, 0.8) 0%, transparent 100%);
    transition: opacity var(--transition-normal);
}

.player-controls.hidden {
    opacity: 0;
    pointer-events: none;
}

.progress-container {
    padding: var(--spacing-md) 0;
    margin-bottom: var(--spacing-sm);
    cursor: pointer;
}

.progress-bar {
    height: 4px;
    background: rgba(255, 255, 255, 0.3);
    border-radius: 2px;
    position: relative;
    cursor: pointer;
    /* Increase clickable area */
    padding: 8px 0;
    margin: -8px 0;
    user-select: none;
    -webkit-user-select: none;
}

.progress-bar:hover {
    height: 6px;
}

.progress-bar:active {
    height: 8px;
    cursor: grabbing;
}

.progress-played {
    height: 100%;
    background: var(--accent-primary);
    border-radius: 2px;
    width: 0%;
    pointer-events: none;
}

.progress-handle {
    position: absolute;
    left: 0;
    top: 50%;
    transform: translate(-50%, -50%);
    width: 14px;
    height: 14px;
    background: white;
    border-radius: 50%;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
    opacity: 1;
    transition: width 0.1s ease, height 0.1s ease, box-shadow 0.1s ease;
    pointer-events: none;
    z-index: 2;
}

.progress-bar:hover .progress-handle {
    width: 16px;
    height: 16px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.4);
}

.progress-bar:active .progress-handle {
    width: 18px;
    height: 18px;
}

.controls-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.controls-left,
.controls-right {
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
}

.control-btn {
    width: 44px;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: none;
    border-radius: var(--radius-sm);
    color: white;
    cursor: pointer;
    transition: background var(--transition-fast);
}

.control-btn:hover {
    background: rgba(255, 255, 255, 0.1);
}

.control-btn svg {
    width: 24px;
    height: 24px;
}

.control-btn svg.hidden {
    display: none;
}

.control-btn.active {
    color: var(--accent-primary);
}

.time-display {
    font-size: 0.875rem;
    color: rgba(255, 255, 255, 0.9);
    font-variant-numeric: tabular-nums;
}

/* Subtitle Display */
.subtitle-display {
    position: absolute;
    bottom: 60px;
    left: 50%;
    transform: translateX(-50%);
    text-align: center;
    max-width: 90%;
    z-index: 15;
    pointer-events: none;
}

.subtitle-text {
    display: inline-block;
    padding: 4px 8px;
    border-radius: var(--radius-sm);
    font-size: 1.75rem;
    line-height: 1.4;
    color: white;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.9),
                 -1px -1px 2px rgba(0, 0, 0, 0.9),
                 1px -1px 2px rgba(0, 0, 0, 0.9),
                 -1px 1px 2px rgba(0, 0, 0, 0.9);
    font-weight: 600;
}

/* =========================================
   Toast Notification
   ========================================= */
.toast {
    position: fixed;
    bottom: 80px;
    left: 50%;
    transform: translateX(-50%);
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    padding: 12px 24px;
    border-radius: var(--radius-md);
    font-size: 0.875rem;
    color: var(--text-primary);
    z-index: 2000;
    box-shadow: var(--shadow-lg);
    animation: toastIn 0.3s ease;
}

.toast.hidden {
    display: none;
}

@keyframes toastIn {
    from {
        opacity: 0;
        transform: translate(-50%, 20px);
    }

    to {
        opacity: 1;
        transform: translate(-50%, 0);
    }
}

/* =========================================
   Responsive Adjustments
   ========================================= */
@media (max-width: 480px) {
    .login-card {
        padding: var(--spacing-lg);
    }

    .file-item {
        padding: var(--spacing-sm) var(--spacing-md);
    }

    .file-icon {
        width: 40px;
        height: 40px;
    }

    .file-icon svg {
        width: 24px;
        height: 24px;
    }

    .file-icon.folder svg {
        width: 32px;
        height: 32px;
    }

    .subtitle-display {
        bottom: 50px;
    }

    .subtitle-text {
        font-size: 1.5rem;
    }
    
    /* Larger touch target for progress bar on mobile */
    .progress-container {
        padding: var(--spacing-lg) 0;
    }
    
    .progress-bar {
        height: 6px;
        padding: 12px 0;
        margin: -12px 0;
    }
    
    .progress-bar:hover,
    .progress-bar:active {
        height: 6px;
    }
    
    .progress-handle {
        width: 16px;
        height: 16px;
    }
    
    .progress-bar:hover .progress-handle,
    .progress-bar:active .progress-handle {
        width: 20px;
        height: 20px;
    }
}

/* Landscape mode for video player */
@media (orientation: landscape) and (max-height: 500px) {
    .player-header {
        padding: var(--spacing-sm) var(--spacing-md);
    }

    .player-controls {
        padding: var(--spacing-sm) var(--spacing-md);
    }

    .subtitle-display {
        bottom: 40px;
    }
    
    .subtitle-text {
        font-size: 1.25rem;
    }
}