* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --primary-color: #2563eb;
    --primary-hover: #1d4ed8;
    --secondary-color: #64748b;
    --danger-color: #ef4444;
    --success-color: #10b981;
    --bg-color: #f8fafc;
    --card-bg: #ffffff;
    --text-primary: #0f172a;
    --text-secondary: #64748b;
    --border-color: #e2e8f0;
    --shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background-color: #f8fafc; /* Fallback for older TV browsers */
    background-color: var(--bg-color);
    color: #0f172a; /* Fallback for older TV browsers */
    color: var(--text-primary);
    line-height: 1.6;
}

body.locked {
    overflow: hidden;
}

/* Login Modal */
.login-modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(135deg, #2563eb 0%, #1d4ed8 100%);
    z-index: 9999;
    align-items: center;
    justify-content: center;
}

.login-modal.active {
    display: flex;
}

.login-content {
    background: white;
    border-radius: 16px;
    padding: 3rem;
    width: 90%;
    max-width: 420px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    animation: slideUp 0.4s ease;
}

.login-header {
    text-align: center;
    margin-bottom: 2rem;
}

.login-logo {
    height: 80px;
    width: auto;
    margin-bottom: 1rem;
}

.login-header h2 {
    margin: 0 0 0.5rem 0;
    color: #0f172a; /* Fallback for older TV browsers */
    color: var(--text-primary);
    font-size: 1.75rem;
}

.login-header p {
    color: #64748b; /* Fallback for older TV browsers */
    color: var(--text-secondary);
    margin: 0;
}

.login-form {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.form-group label {
    font-weight: 600;
    color: #0f172a; /* Fallback for older TV browsers */
    color: var(--text-primary);
}

.form-input {
    padding: 0.875rem;
    border: 2px solid #e2e8f0; /* Fallback for older TV browsers */
    border: 2px solid var(--border-color);
    border-radius: 8px;
    font-size: 1rem;
    transition: border-color 0.2s ease;
}

.form-input:focus {
    outline: none;
    border-color: #2563eb; /* Fallback for older TV browsers */
    border-color: var(--primary-color);
}

.btn-block {
    width: 100%;
}

.login-hint {
    text-align: center;
    color: #64748b; /* Fallback for older TV browsers */
    color: var(--text-secondary);
    font-size: 0.875rem;
    margin: 0;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px;
}

/* Header */
header {
    background: linear-gradient(135deg, #2563eb 0%, #1d4ed8 100%);
    color: white;
    padding: 2rem 0;
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1); /* Fallback for older TV browsers */
    box-shadow: var(--shadow-lg);
}

.header-container {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 2rem;
    position: relative;
}

/* Header User Section */
.header-user-section {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
    position: absolute;
    right: 0;
    top: 50%;
    transform: translateY(-50%);
}

.logo-menu-wrapper {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.clickable-logo {
    cursor: pointer;
    transition: transform 0.2s ease, filter 0.2s ease;
    height: 60px;
    width: auto;
    object-fit: contain;
    display: block;
}

.clickable-logo:hover {
    transform: scale(1.05);
    filter: brightness(1.1);
}

.current-user {
    color: rgba(255, 255, 255, 0.9);
    font-weight: 600;
    padding: 0.35rem 0.75rem;
    background: rgba(255, 255, 255, 0.15);
    border-radius: 12px;
    font-size: 0.75rem;
    text-align: center;
}

/* Dropdown Menu */
.user-dropdown-menu {
    position: absolute;
    top: calc(100% + 0.5rem);
    right: 0;
    background: white;
    border-radius: 12px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
    min-width: 200px;
    padding: 0.5rem;
    opacity: 0;
    visibility: hidden;
    transform: translateY(-10px);
    transition: all 0.2s ease;
    z-index: 1000;
}

.user-dropdown-menu.active {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.dropdown-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    width: 100%;
    padding: 0.75rem 1rem;
    border: none;
    background: transparent;
    color: var(--text-primary);
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    border-radius: 8px;
    transition: background 0.2s ease;
    text-align: left;
}

.dropdown-item:hover {
    background: var(--bg-color);
}

.dropdown-item svg {
    width: 18px;
    height: 18px;
    flex-shrink: 0;
}

.dropdown-item-danger {
    color: var(--danger-color);
}

.dropdown-item-danger:hover {
    background: #fef2f2;
}

.dropdown-divider {
    height: 1px;
    background: var(--border-color);
    margin: 0.5rem 0;
}

.header-content {
    flex: 1;
}

.header-logo {
    flex-shrink: 0;
}

.header-logo img {
    height: 80px;
    width: auto;
    object-fit: contain;
}

header h1 {
    font-size: 2.5rem;
    font-weight: 700;
    margin-bottom: 0.5rem;
}

.tagline {
    font-size: 1.1rem;
    opacity: 0.9;
}

/* Main Content */
main {
    padding: 2rem 0;
}

/* Main Layout - Two Column Design */
.main-layout {
    display: flex;
    gap: 1.5rem;
    align-items: flex-start;
}

section {
    background: var(--card-bg);
    border-radius: 12px;
    padding: 2rem;
    margin-bottom: 2rem;
    box-shadow: var(--shadow);
}

/* Upload Section - 20% width, left side */
.upload-section {
    flex: 0 0 20%;
    min-width: 250px;
    margin-bottom: 0;
}

/* Sticky Upload Section - Progressive Enhancement */
@supports (position: sticky) {
    .upload-section {
        position: sticky;
        top: 1rem;
        align-self: flex-start;
    }
}

/* Gallery Section - 80% width, right side */
.gallery-section {
    flex: 1;
    margin-bottom: 0;
}

h2 {
    font-size: 1.75rem;
    margin-bottom: 1.5rem;
    color: var(--text-primary);
}

/* Upload Section Adjustments for narrow layout */
.upload-section .upload-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.75rem;
}

.upload-section .upload-header h2 {
    font-size: 1.25rem;
}

.upload-section .upload-category-controls {
    flex-direction: column;
    width: 100%;
    gap: 0.5rem;
}

.upload-section .category-select {
    width: 100%;
}

.upload-section .btn-outline {
    width: 100%;
}

.upload-section .upload-area {
    padding: 2rem 1rem;
}

.upload-section .upload-icon {
    width: 48px;
    height: 48px;
}

.upload-section .upload-text {
    font-size: 1rem;
}

.upload-section .upload-hint {
    font-size: 0.75rem;
}

/* Upload Area */
.upload-area {
    border: 3px dashed var(--border-color);
    border-radius: 12px;
    padding: 3rem;
    text-align: center;
    cursor: pointer;
    transition: all 0.3s ease;
}

.upload-area:hover,
.upload-area.dragover {
    border-color: var(--primary-color);
    background-color: #eff6ff;
}

.upload-content {
    pointer-events: none;
}

.upload-icon {
    width: 64px;
    height: 64px;
    color: var(--primary-color);
    margin-bottom: 1rem;
}

.upload-text {
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 0.5rem;
}

.upload-hint {
    color: var(--text-secondary);
    font-size: 0.875rem;
}

/* Upload Header */
.upload-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
    flex-wrap: wrap;
    gap: 1rem;
}

.upload-header h2 {
    margin-bottom: 0;
}

.upload-category-controls {
    display: flex;
    gap: 0.75rem;
    align-items: center;
}

.category-select {
    min-width: 150px;
    padding: 0.75rem;
    border: 2px solid var(--border-color);
    border-radius: 8px;
    font-size: 1rem;
    background: white;
    cursor: pointer;
    transition: border-color 0.2s ease;
}

.category-select:focus {
    outline: none;
    border-color: var(--primary-color);
}

.btn-outline {
    background: white;
    color: var(--primary-color);
    border: 2px solid var(--primary-color);
    white-space: nowrap;
}

.btn-outline:hover {
    background: var(--primary-color);
    color: white;
}

/* Gallery */
.gallery-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
}

.gallery-controls {
    display: flex;
    gap: 0.75rem;
}

/* Filter Bar */
.filter-bar {
    margin-bottom: 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.search-box {
    position: relative;
    width: 100%;
}

.search-icon {
    position: absolute;
    left: 1rem;
    top: 50%;
    transform: translateY(-50%);
    width: 20px;
    height: 20px;
    color: var(--text-secondary);
    stroke-width: 2;
}

.search-input {
    width: 100%;
    padding: 0.75rem 1rem 0.75rem 3rem;
    border: 2px solid var(--border-color);
    border-radius: 8px;
    font-size: 1rem;
    transition: border-color 0.2s ease;
}

.search-input:focus {
    outline: none;
    border-color: var(--primary-color);
}

.category-filters {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.category-filter {
    padding: 0.5rem 1rem;
    border: 2px solid var(--border-color);
    background: white;
    border-radius: 20px;
    font-size: 0.875rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
}

.category-filter:hover {
    border-color: var(--primary-color);
    color: var(--primary-color);
}

.category-filter.active {
    background: var(--primary-color);
    border-color: var(--primary-color);
    color: white;
}

.gallery-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    gap: 1.5rem;
}

.empty-state {
    grid-column: 1 / -1;
    text-align: center;
    padding: 3rem;
    color: var(--text-secondary);
}

.media-item {
    position: relative;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: var(--shadow);
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    cursor: pointer;
    aspect-ratio: 16 / 9;
}

.media-item:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-lg);
}

.media-item img,
.media-item video {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.media-item-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(to bottom, rgba(0,0,0,0) 0%, rgba(0,0,0,0.7) 100%);
    opacity: 0;
    transition: opacity 0.3s ease;
    display: flex;
    align-items: flex-end;
    padding: 1rem;
}

.media-item:hover .media-item-overlay {
    opacity: 1;
}

.media-item-info {
    color: white;
    width: 100%;
}

.media-item-name {
    font-size: 0.875rem;
    font-weight: 600;
    margin-bottom: 0.25rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.media-item-category {
    display: inline-block;
    background: rgba(255, 255, 255, 0.3);
    /* Safari/iOS support */
    -webkit-backdrop-filter: blur(10px);
    backdrop-filter: blur(10px);
    padding: 0.25rem 0.75rem;
    border-radius: 12px;
    font-size: 0.75rem;
    font-weight: 600;
}

.media-item-actions {
    position: absolute;
    top: 0.75rem;
    right: 0.75rem;
    display: flex;
    gap: 0.5rem;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.media-item:hover .media-item-actions {
    opacity: 1;
}

.delete-btn {
    background: var(--danger-color);
    color: white;
    border: none;
    border-radius: 6px;
    padding: 0.5rem;
    cursor: pointer;
    transition: background 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.delete-btn:hover {
    background: #dc2626;
}

.delete-btn svg {
    width: 20px;
    height: 20px;
    stroke-width: 2;
}

/* Buttons */
.btn {
    padding: 0.75rem 1.5rem;
    border: none;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
}

.btn-primary {
    background: var(--primary-color);
    color: white;
}

.btn-primary:hover {
    background: var(--primary-hover);
}

.btn-secondary {
    background: var(--secondary-color);
    color: white;
}

.btn-secondary:hover {
    background: #475569;
}

/* Clear All Button - Red on hover */
#clearAllBtn:hover {
    background: var(--danger-color);
}

/* Slideshow Modal */
.slideshow-modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgb(0, 0, 0);
    z-index: 1000;
    animation: fadeIn 0.3s ease;
}

.slideshow-modal.active {
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.slideshow-content {
    flex: 1;
    position: relative;
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1;
    overflow: auto;
}

.slideshow-content .slideshow-media {
    position: absolute;
    width: calc(100% - 4rem);
    height: calc(100% - 4rem);
    object-fit: contain;
    border-radius: 8px;
    transition: opacity var(--transition-speed, 0.6s) ease-in-out, object-fit 0.3s ease;
    transform-origin: center center;
}

.slideshow-content img.slideshow-media {
    pointer-events: none;
}

.slideshow-content video.slideshow-media {
    pointer-events: auto;
}

/* Slideshow Top Controls */
.slideshow-top-controls {
    position: absolute;
    top: 1.5rem;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0, 0, 0, 0.5);
    /* Safari/iOS support */
    -webkit-backdrop-filter: blur(10px);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.2);
    padding: 0.4rem;
    border-radius: 20px;
    display: flex;
    gap: 0.3rem;
    opacity: 0;
    transition: opacity 0.3s ease;
    z-index: 30;
}

.slideshow-modal:hover .slideshow-top-controls,
.slideshow-modal.show-controls .slideshow-top-controls {
    opacity: 1;
}

.slideshow-close-btn,
.slideshow-settings-btn {
    width: 36px;
    height: 36px;
    background: transparent;
    border: none;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.3s ease;
    border-radius: 50%;
}

.slideshow-close-btn:hover,
.slideshow-settings-btn:hover {
    background: rgba(255, 255, 255, 0.2);
}

.slideshow-close-btn svg,
.slideshow-settings-btn svg {
    width: 18px;
    height: 18px;
    color: white;
    stroke-width: 2.5;
}

/* Bottom Info Section - Counter + Controls */
.slideshow-bottom-info {
    position: absolute;
    bottom: 2rem;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1rem;
    opacity: 0;
    transition: opacity 0.3s ease;
    z-index: 20;
    pointer-events: none;
}

.slideshow-modal:hover .slideshow-bottom-info,
.slideshow-modal.show-controls .slideshow-bottom-info {
    opacity: 1;
    pointer-events: all;
}

.slideshow-counter {
    background: rgba(0, 0, 0, 0.5);
    /* Safari/iOS support */
    -webkit-backdrop-filter: blur(10px);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: white;
    padding: 0.4rem 0.875rem;
    border-radius: 20px;
    font-size: 0.8rem;
    font-weight: 600;
}

.slideshow-controls {
    display: flex;
    gap: 0.75rem;
    align-items: center;
}

.control-btn {
    background: rgba(0, 0, 0, 0.5);
    /* Safari/iOS support */
    -webkit-backdrop-filter: blur(10px);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 50%;
    width: 48px;
    height: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.3s ease;
}

.control-btn:hover {
    background: rgba(0, 0, 0, 0.7);
    border-color: rgba(255, 255, 255, 0.4);
    transform: scale(1.1);
}

.control-btn svg {
    width: 20px;
    height: 20px;
    color: white;
}

.play-pause-btn {
    width: 56px;
    height: 56px;
}

.play-pause-btn svg {
    width: 24px;
    height: 24px;
}

#playPauseBtn {
    position: relative;
}

/* Slideshow Zoom Controls */
.slideshow-zoom-controls {
    position: absolute;
    bottom: 4rem;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0, 0, 0, 0.5);
    /* Safari/iOS support */
    -webkit-backdrop-filter: blur(10px);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.2);
    padding: 0.4rem;
    border-radius: 20px;
    display: flex;
    gap: 0.3rem;
    opacity: 0;
    transition: opacity 0.3s ease;
    z-index: 20;
}

.slideshow-modal:hover .slideshow-zoom-controls,
.slideshow-modal.show-controls .slideshow-zoom-controls {
    opacity: 1;
}

.slideshow-zoom-controls .control-btn {
    width: 36px;
    height: 36px;
    background: transparent;
    border: none;
}

.slideshow-zoom-controls .control-btn:hover {
    background: rgba(255, 255, 255, 0.2);
}

.slideshow-zoom-controls .control-btn svg {
    width: 18px;
    height: 18px;
}

/* Slideshow Settings Panel */
.slideshow-settings-panel {
    position: absolute;
    top: 4.5rem;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0, 0, 0, 0.85);
    /* Safari/iOS support */
    -webkit-backdrop-filter: blur(20px);
    backdrop-filter: blur(20px);
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 12px;
    width: 320px;
    max-width: calc(100vw - 2rem);
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s ease, opacity 0.3s ease;
    opacity: 0;
    z-index: 30;
}

.slideshow-settings-panel.active {
    max-height: calc(100vh - 8rem);
    opacity: 1;
    overflow-y: auto;
}

.settings-header {
    padding: 0.875rem 1.25rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.settings-header h4 {
    margin: 0;
    color: white;
    font-size: 1rem;
    font-weight: 600;
}

.settings-body {
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 1.75rem;
}

.setting-item {
    display: flex;
    flex-direction: column;
    gap: 0.625rem;
    padding: 0.5rem 0;
}

.setting-item label {
    color: rgba(255, 255, 255, 0.95);
    font-size: 0.9rem;
    font-weight: 600;
}

.setting-select {
    padding: 0.625rem 0.75rem;
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.1);
    color: white;
    font-size: 0.9rem;
    cursor: pointer;
    transition: all 0.2s ease;
}

.setting-select:focus {
    outline: none;
    border-color: var(--primary-color);
    background: rgba(255, 255, 255, 0.15);
}

.setting-select option {
    background: #1a1a1a;
    color: white;
}

.slider-container {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.setting-slider {
    flex: 1;
    height: 8px;
    border-radius: 4px;
    background: rgba(255, 255, 255, 0.2);
    outline: none;
    -webkit-appearance: none;
    appearance: none;
}

.setting-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: var(--primary-color);
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
}

.setting-slider::-webkit-slider-thumb:hover {
    transform: scale(1.15);
}

.setting-slider::-moz-range-thumb {
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: var(--primary-color);
    cursor: pointer;
    border: none;
    transition: all 0.2s ease;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
}

.setting-slider::-moz-range-thumb:hover {
    transform: scale(1.15);
}

.slider-value {
    min-width: 3rem;
    color: white;
    font-size: 0.875rem;
    font-weight: 600;
    text-align: right;
}

/* Video Loop Setting Styles */
#videoLoopSetting p {
    color: rgba(255, 255, 255, 0.7);
    font-size: 0.85em;
    margin-top: 5px;
}

#currentVideoLoopCount {
    width: 80px;
    padding: 8px;
    border: 1px solid rgba(255, 255, 255, 0.3);
    border-radius: 6px;
    background: rgba(255, 255, 255, 0.15);
    color: white;
    font-size: 0.9rem;
    font-weight: 600;
    text-align: center;
    transition: all 0.2s ease;
}

#currentVideoLoopCount:focus {
    outline: none;
    border-color: var(--primary-color);
    background: rgba(255, 255, 255, 0.2);
}

#saveVideoLoopBtn {
    margin-left: 10px;
    padding: 8px 16px;
    font-size: 0.85rem;
    background: var(--primary-color);
    border: none;
    border-radius: 6px;
    color: white;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
}

#saveVideoLoopBtn:hover {
    background: var(--primary-hover);
    transform: translateY(-1px);
}

/* Settings Sections */
.settings-section {
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    padding-bottom: 1.25rem;
    margin-bottom: 1.25rem;
}

.settings-section:last-child {
    border-bottom: none;
    padding-bottom: 0;
    margin-bottom: 0;
}

.settings-section-title {
    color: var(--primary-color);
    font-size: 0.85rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 1rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

/* Toggle Switch */
.toggle-switch {
    position: relative;
    display: inline-block;
    width: 48px;
    height: 26px;
}

.toggle-switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.toggle-slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(255, 255, 255, 0.2);
    transition: 0.3s;
    border-radius: 26px;
}

.toggle-slider:before {
    position: absolute;
    content: "";
    height: 20px;
    width: 20px;
    left: 3px;
    bottom: 3px;
    background-color: white;
    transition: 0.3s;
    border-radius: 50%;
}

.toggle-switch input:checked + .toggle-slider {
    background-color: var(--primary-color);
}

.toggle-switch input:checked + .toggle-slider:before {
    transform: translateX(22px);
}

/* Setting item with toggle */
.setting-item.toggle-item {
    flex-direction: row;
    justify-content: space-between;
    align-items: center;
    padding: 0.625rem 0;
}

/* Safari/iOS fallback - :has() not supported before Safari 15.4 */
@supports selector(:has(*)) {
    .setting-item:has(.toggle-switch) {
        flex-direction: row;
        justify-content: space-between;
        align-items: center;
        padding: 0.625rem 0;
    }
}

/* Color Picker */
.color-picker-container {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.color-picker {
    width: 48px;
    height: 36px;
    padding: 0;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-radius: 8px;
    cursor: pointer;
    background: transparent;
}

.color-picker::-webkit-color-swatch-wrapper {
    padding: 2px;
}

.color-picker::-webkit-color-swatch {
    border-radius: 4px;
    border: none;
}

.color-value {
    color: rgba(255, 255, 255, 0.8);
    font-size: 0.85rem;
    font-family: monospace;
}

/* Transition Effects */
.slideshow-content.transition-fade img,
.slideshow-content.transition-fade video {
    animation: fadeIn var(--transition-speed, 0.6s) ease-in-out;
}

.slideshow-content.transition-slide img,
.slideshow-content.transition-slide video {
    animation: slideIn var(--transition-speed, 0.6s) ease-in-out;
}

.slideshow-content.transition-zoom img,
.slideshow-content.transition-zoom video {
    animation: zoomIn var(--transition-speed, 0.6s) ease-in-out;
}

.slideshow-content.transition-flip img,
.slideshow-content.transition-flip video {
    animation: flipIn var(--transition-speed, 0.6s) ease-in-out;
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateX(100%);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

@keyframes zoomIn {
    from {
        opacity: 0;
        transform: scale(0.8);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

@keyframes flipIn {
    from {
        opacity: 0;
        transform: rotateY(90deg);
    }
    to {
        opacity: 1;
        transform: rotateY(0);
    }
}

.hidden {
    display: none !important;
}

/* Category Management Modal */
.category-modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 1000;
    align-items: center;
    justify-content: center;
}

.category-modal.active {
    display: flex;
}

.modal-content {
    background: white;
    border-radius: 16px;
    width: 90%;
    max-width: 500px;
    max-height: 80vh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    animation: slideUp 0.3s ease;
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1.5rem;
    border-bottom: 1px solid var(--border-color);
}

.modal-header h3 {
    margin: 0;
    font-size: 1.5rem;
}

.close-modal-btn {
    background: none;
    border: none;
    cursor: pointer;
    padding: 0.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
    transition: background 0.2s ease;
}

.close-modal-btn:hover {
    background: var(--bg-color);
}

.close-modal-btn svg {
    width: 24px;
    height: 24px;
    stroke-width: 2;
}

.modal-body {
    padding: 1.5rem;
    overflow-y: auto;
}

.add-category-form {
    display: flex;
    gap: 0.75rem;
    margin-bottom: 1.5rem;
}

.modal-input {
    flex: 1;
    padding: 0.75rem;
    border: 2px solid var(--border-color);
    border-radius: 8px;
    font-size: 1rem;
}

.modal-input:focus {
    outline: none;
    border-color: var(--primary-color);
}

.categories-list {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.category-list-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem;
    background: var(--bg-color);
    border-radius: 8px;
    transition: background 0.2s ease;
}

.category-list-item:hover {
    background: #e2e8f0;
}

.category-list-name {
    font-weight: 600;
    color: var(--text-primary);
}

.category-list-count {
    color: var(--text-secondary);
    font-size: 0.875rem;
    margin-left: 0.5rem;
}

.category-delete-btn {
    background: var(--danger-color);
    color: white;
    border: none;
    border-radius: 6px;
    padding: 0.5rem 0.75rem;
    cursor: pointer;
    font-size: 0.875rem;
    font-weight: 600;
    transition: background 0.2s ease;
}

.category-delete-btn:hover {
    background: #dc2626;
}

.category-delete-btn:disabled {
    background: var(--secondary-color);
    opacity: 0.5;
    cursor: not-allowed;
}

/* User Management Styles */
.modal-content-lg {
    max-width: 600px;
}

.add-user-form {
    display: flex;
    gap: 0.75rem;
    margin-bottom: 1.5rem;
    flex-wrap: wrap;
}

.add-user-form .modal-input {
    flex: 1;
    min-width: 120px;
}

.add-user-form select.modal-input {
    min-width: 140px;
    flex: 0;
}

.users-list {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.user-list-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem;
    background: var(--bg-color);
    border-radius: 8px;
    transition: background 0.2s ease;
}

.user-list-item:hover {
    background: #e2e8f0;
}

.user-info {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.user-name {
    font-weight: 600;
    color: var(--text-primary);
}

.user-role {
    font-size: 0.75rem;
    padding: 0.25rem 0.5rem;
    border-radius: 12px;
    display: inline-block;
    width: fit-content;
}

.user-role.admin {
    background: #dbeafe;
    color: #1d4ed8;
}

.user-role.user {
    background: #f0fdf4;
    color: #16a34a;
}

.user-actions {
    display: flex;
    gap: 0.5rem;
}

.user-edit-btn {
    background: var(--primary-color);
    color: white;
    border: none;
    border-radius: 6px;
    padding: 0.5rem 0.75rem;
    cursor: pointer;
    font-size: 0.875rem;
    font-weight: 600;
    transition: background 0.2s ease;
}

.user-edit-btn:hover {
    background: var(--primary-hover);
}

.user-delete-btn {
    background: var(--danger-color);
    color: white;
    border: none;
    border-radius: 6px;
    padding: 0.5rem 0.75rem;
    cursor: pointer;
    font-size: 0.875rem;
    font-weight: 600;
    transition: background 0.2s ease;
}

.user-delete-btn:hover {
    background: #dc2626;
}

.user-delete-btn:disabled,
.user-edit-btn:disabled {
    background: var(--secondary-color);
    opacity: 0.5;
    cursor: not-allowed;
}

/* Change Password Form */
.change-password-form,
.edit-user-form {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.change-password-form .form-group,
.edit-user-form .form-group {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.change-password-form label,
.edit-user-form label {
    font-weight: 600;
    color: var(--text-primary);
}

/* Share Link Styles */
.share-link-description {
    color: var(--text-secondary);
    margin-bottom: 1rem;
    font-size: 0.875rem;
}

.share-link-box {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1rem;
}

.share-link-box .modal-input {
    flex: 1;
    font-family: monospace;
    font-size: 0.8rem;
}

.share-link-options {
    margin-bottom: 1rem;
}

.share-link-options label {
    display: block;
    font-weight: 600;
    margin-bottom: 0.5rem;
    color: var(--text-primary);
}

.share-link-actions {
    display: flex;
    gap: 0.5rem;
    justify-content: flex-end;
}

/* Share TV Button */
#shareLinkBtn {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

#shareLinkBtn svg {
    flex-shrink: 0;
}

/* Responsive */
@media (max-width: 992px) {
    .main-layout {
        flex-direction: column;
    }

    .upload-section,
    .gallery-section {
        flex: none;
        width: 100%;
        margin-bottom: 2rem;
    }

    /* Disable sticky on mobile/tablet */
    .upload-section {
        position: static !important;
    }

    /* Reset upload section styles for mobile */
    .upload-section .upload-header {
        flex-direction: column;
        align-items: flex-start;
    }

    .upload-section .upload-header h2 {
        font-size: 1.75rem;
    }

    .upload-section .upload-category-controls {
        width: 100%;
    }

    .upload-section .upload-area {
        padding: 3rem;
    }

    .upload-section .upload-icon {
        width: 64px;
        height: 64px;
    }

    .upload-section .upload-text {
        font-size: 1.25rem;
    }

    .upload-section .upload-hint {
        font-size: 0.875rem;
    }
}

@media (max-width: 768px) {
    .header-container {
        gap: 1rem;
    }

    .header-logo img {
        height: 60px;
    }

    header h1 {
        font-size: 2rem;
    }

    .tagline {
        font-size: 1rem;
    }

    section {
        padding: 1.5rem;
    }

    .upload-header {
        flex-direction: column;
        align-items: flex-start;
    }

    .upload-category-controls {
        width: 100%;
    }

    .category-select {
        flex: 1;
    }

    .gallery-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 1rem;
    }

    .gallery-grid {
        grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
        gap: 1rem;
    }

    .control-btn {
        width: 44px;
        height: 44px;
    }

    .control-btn svg {
        width: 18px;
        height: 18px;
    }

    .slideshow-close-btn,
    .slideshow-settings-btn {
        width: 36px;
        height: 36px;
    }

    .slideshow-close-btn svg,
    .slideshow-settings-btn svg {
        width: 16px;
        height: 16px;
    }

    .slideshow-settings-panel {
        width: calc(100vw - 2rem);
        right: 1rem;
        left: 1rem;
        transform: translateX(0);
        max-width: none;
    }

    .slideshow-settings-panel.active {
        max-height: calc(100vh - 10rem);
    }

    .settings-header {
        padding: 0.75rem 1rem;
    }

    .settings-header h4 {
        font-size: 0.9rem;
    }

    .settings-body {
        padding: 1rem;
        gap: 1rem;
    }

    .settings-section {
        padding-bottom: 0.75rem;
        margin-bottom: 0.75rem;
    }

    .settings-section-title {
        font-size: 0.7rem;
    }

    .setting-item label {
        font-size: 0.8rem;
    }

    .setting-select {
        padding: 0.4rem;
        font-size: 0.8rem;
    }

    .slider-value {
        font-size: 0.8rem;
    }

    .slideshow-counter {
        font-size: 0.8rem;
        padding: 0.4rem 0.875rem;
    }

    /* Header responsive */
    .header-user-section {
        position: static;
        transform: none;
        margin-top: 1rem;
    }

    .header-logo img {
        height: 60px;
    }

    /* User form responsive */
    .add-user-form {
        flex-direction: column;
    }

    .add-user-form .modal-input,
    .add-user-form select.modal-input {
        width: 100%;
        flex: none;
    }

    .user-list-item {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.75rem;
    }

    .user-actions {
        width: 100%;
        justify-content: flex-end;
    }
}
