/* ============= CSS VARIABLES (Dark Mode - Default) ============= */
:root {
    --bg-primary: #0f172a;
    --bg-secondary: #1e293b;
    --bg-tertiary: #334155;
    --bg-card: #1e293b;
    --text-primary: #e2e8f0;
    --text-secondary: #94a3b8;
    --text-muted: #64748b;
    --border-color: #334155;
    --border-light: #475569;
    --accent-primary: #3b82f6;
    --accent-secondary: #10b981;
    --shadow-color: rgba(0, 0, 0, 0.5);
    --input-bg: #334155;
    --modal-bg: #1e293b;
    --card-hover: #2d3a4f;
}

/* Light Mode Variables */
body.light-mode {
    --bg-primary: #f1f5f9;
    --bg-secondary: #ffffff;
    --bg-tertiary: #e2e8f0;
    --bg-card: #ffffff;
    --text-primary: #1e293b;
    --text-secondary: #475569;
    --text-muted: #64748b;
    --border-color: #e2e8f0;
    --border-light: #cbd5e1;
    --accent-primary: #2563eb;
    --accent-secondary: #059669;
    --shadow-color: rgba(0, 0, 0, 0.1);
    --input-bg: #f8fafc;
    --modal-bg: #ffffff;
    --card-hover: #f8fafc;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    background: var(--bg-primary);
    min-height: 100vh;
    padding: 20px;
    color: var(--text-primary);
    transition: background-color 0.3s ease, color 0.3s ease;
}

.container {
    max-width: 1400px;
    margin: 0 auto;
    background: var(--bg-secondary);
    border-radius: 12px;
    box-shadow: 0 10px 40px var(--shadow-color);
    padding: 30px;
    transition: background-color 0.3s ease, box-shadow 0.3s ease;
    position: relative;
    z-index: 1;
}

header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 25px;
    padding-bottom: 20px;
    border-bottom: 1px solid #334155;
}

h1 {
    font-size: 2.25rem;
    margin: 0;
    display: flex;
    align-items: center;
    gap: 10px;
    font-weight: bold;
    background: linear-gradient(to right, #60a5fa, #a78bfa);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.subtitle {
    display: none;
}

.header-buttons {
    display: flex;
    gap: 10px;
}

/* Mobile menu button - hidden on desktop */
.mobile-menu-btn {
    display: none;
}

/* Mobile Menu Overlay */
.mobile-menu-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.8);
    z-index: 1000;
    opacity: 0;
    transition: opacity 0.2s ease;
}

.mobile-menu-overlay.show {
    display: flex;
    justify-content: center;
    align-items: flex-start;
    padding-top: 60px;
    opacity: 1;
}

.mobile-menu-content {
    background: #1e293b;
    border-radius: 12px;
    padding: 20px;
    width: 90%;
    max-width: 320px;
    position: relative;
}

.mobile-menu-close {
    position: absolute;
    top: 10px;
    right: 10px;
    background: none;
    border: none;
    color: #94a3b8;
    font-size: 20px;
    cursor: pointer;
    padding: 5px 10px;
}

.mobile-menu-close:hover {
    color: #fff;
}

.mobile-menu-nav {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-top: 10px;
}

.mobile-menu-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 14px 16px;
    background: #334155;
    border: none;
    border-radius: 8px;
    color: #f1f5f9;
    font-size: 16px;
    cursor: pointer;
    text-align: left;
    width: 100%;
    transition: background 0.2s ease;
}

.mobile-menu-item:hover {
    background: #475569;
}

/* Mobile styles for header */
@media (max-width: 600px) {
    .header-hide-mobile {
        display: none !important;
    }

    .mobile-menu-btn {
        display: inline-flex;
    }
}

.tab-switcher {
    display: flex;
    gap: 10px;
    justify-content: center;
    margin-bottom: 20px;
    margin-top: 10px;
    position: relative;
}

.tab-switcher-bottom {
    margin-top: 20px;
    margin-bottom: 10px;
    justify-content: center;
}

.tab-btn {
    padding: 10px 20px;
    border: none;
    background: #334155;
    color: #94a3b8;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
}

.tab-btn:hover {
    background: #475569;
    color: #e2e8f0;
}

.tab-btn.active {
    background: #10b981;
    color: white;
    box-shadow: 0 4px 15px rgba(16, 185, 129, 0.3);
}

.filters-bar {
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 12px;
    margin-bottom: 25px;
    padding: 12px 16px;
    background: #1e293b;
    border-radius: 10px;
    border: 1px solid #334155;
}

/* New Filter Button Style */
.btn-filter {
    background: linear-gradient(135deg, #3b82f6, #2563eb);
    color: white;
    padding: 12px 20px;
    border-radius: 8px;
    font-weight: 600;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    white-space: nowrap;
    border: none;
    flex-shrink: 0;
    cursor: pointer;
}

.btn-filter:hover {
    background: linear-gradient(135deg, #2563eb, #1d4ed8);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(59, 130, 246, 0.4);
}

.btn-filter .filter-count {
    background: #ef4444;
    color: white;
    font-size: 11px;
    font-weight: bold;
    padding: 2px 6px;
    border-radius: 10px;
    margin-left: 4px;
}

#searchInput {
    flex: 1;
    width: 100%;
    padding: 12px 16px;
    border: 2px solid #475569;
    border-radius: 8px;
    font-size: 14px;
    min-width: 0;
    background: #334155;
    color: #e2e8f0;
    transition: border-color 0.2s ease;
    box-sizing: border-box;
}

#searchInput:focus {
    outline: none;
    border-color: #3b82f6;
}

/* Add Movie Button in filters bar */
.btn-add {
    flex-shrink: 0;
    white-space: nowrap;
    padding: 12px 20px;
    height: 44px;
    box-sizing: border-box;
}

/* View Toggle Button (in header) */
.btn-view-toggle {
    padding: 10px 14px;
    font-size: 16px;
}

.btn-view-toggle .view-icon {
    display: inline-block;
}

/* View modes controlled by body class */
body.card-view .table-container {
    display: none !important;
}

body.card-view .movies-grid {
    display: grid !important;
}

body.list-view .table-container {
    display: block !important;
}

body.list-view .movies-grid {
    display: none !important;
}

#searchInput::placeholder {
    color: #64748b;
}

#filterOwned {
    padding: 10px 15px;
    border: 1px solid #475569;
    border-radius: 6px;
    font-size: 14px;
    background: #334155;
    color: #e2e8f0;
    cursor: pointer;
}

.btn {
    padding: 10px 20px;
    border: none;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    text-align: center;
    justify-content: center;
    align-items: center;
}

.btn-primary {
    background: #10b981;
    color: white;
}

.btn-primary:hover {
    background: #059669;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(16, 185, 129, 0.4);
}

.btn-secondary {
    background: #475569;
    color: #e2e8f0;
}

.btn-secondary:hover {
    background: #64748b;
}

/* Admin login button when logged in */
.btn-secondary.admin-active {
    background: linear-gradient(135deg, #10b981, #059669);
    color: white;
}

.btn-secondary.admin-active:hover {
    background: linear-gradient(135deg, #059669, #047857);
}

.btn-success {
    background: #10b981;
    color: white;
}

.btn-success:hover {
    background: #059669;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(16, 185, 129, 0.4);
}

.btn-danger {
    background: #ff4757;
    color: white;
}

.btn-danger:hover {
    background: #ee3344;
}

.btn-edit {
    background: #667eea;
    color: white;
    padding: 6px 12px;
    font-size: 12px;
}

.btn-edit:hover {
    background: #5568d3;
}

.stats {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 15px;
    margin-bottom: 25px;
}

/* Compact 2-column on very small screens */
@media (max-width: 380px) {
    .stats {
        grid-template-columns: repeat(2, 1fr);
        gap: 4px;
        margin-bottom: 8px;
    }

    .stat-card {
        padding: 4px 3px;
    }

    .stat-number {
        font-size: 0.85rem;
        margin-bottom: 1px;
    }

    .stat-label {
        font-size: 0.45rem;
    }

    .stat-card-wide {
        grid-column: span 2;
    }
}

@media (min-width: 768px) {
    .stats {
        grid-template-columns: repeat(6, 1fr);
    }
}

.stat-card-wide {
    grid-column: span 2;
}

.stat-card {
    background: #374151;
    color: #e2e8f0;
    padding: 12px;
    border-radius: 8px;
    text-align: center;
    border: 1px solid #4b5563;
}

.stat-number {
    font-size: 1.5rem;
    font-weight: bold;
    margin-bottom: 4px;
}

.stat-label {
    font-size: 0.75rem;
    color: #9ca3af;
}

/* Individual stat colors */
#watchedCount {
    color: #34d399;
}

#toWatchCount {
    color: #60a5fa;
}

#avgRating {
    color: #fbbf24;
}

#ownedMovies {
    color: #a78bfa;
}

#totalRuntime {
    color: #f87171;
}

.loading {
    text-align: center;
    padding: 40px;
    color: #94a3b8;
    display: none;
}

.loading.show {
    display: block;
}

.error-message {
    background: #dc2626;
    color: white;
    padding: 15px;
    border-radius: 6px;
    margin-bottom: 20px;
    display: none;
    border: 1px solid #991b1b;
}

.error-message.show {
    display: block;
}

.table-container {
    overflow-x: auto;
}

table {
    width: 100%;
    border-collapse: collapse;
}

thead {
    background: #334155;
    position: sticky;
    top: 0;
}

th {
    padding: 15px 10px;
    text-align: left;
    font-weight: 600;
    color: #94a3b8;
    border-bottom: 2px solid #475569;
    white-space: nowrap;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

td {
    padding: 12px 10px;
    border-bottom: 1px solid #334155;
    color: #e2e8f0;
}

tbody tr:hover {
    background: #334155;
}

.movie-row {
    cursor: pointer;
    transition: all 0.2s ease;
}

.movie-row:hover {
    background: #334155;
    transform: scale(1.01);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

.owned-badge {
    display: inline-block;
    padding: 4px 10px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 600;
}

.watch-count-badge {
    display: inline-block;
    margin-left: 8px;
    padding: 2px 8px;
    background: linear-gradient(135deg, #3b82f6, #2563eb);
    color: white;
    border-radius: 10px;
    font-size: 11px;
    font-weight: 700;
    vertical-align: middle;
    box-shadow: 0 2px 4px rgba(59, 130, 246, 0.3);
}

.owned-yes {
    background: #065f46;
    color: #6ee7b7;
}

.owned-no {
    background: #7c2d12;
    color: #fca5a5;
}

.actions {
    display: flex;
    gap: 8px;
}

/* Keyboard shortcut styling */
kbd {
    display: inline-block;
    padding: 4px 8px;
    font-family: monospace;
    font-size: 13px;
    font-weight: 600;
    color: #e2e8f0;
    background: #334155;
    border: 1px solid #475569;
    border-radius: 4px;
    box-shadow: 0 2px 0 #1e293b;
    min-width: 24px;
    text-align: center;
    margin-right: 8px;
}

/* Modal Styles */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    inset: 0; /* Shorthand for top/right/bottom/left: 0 */
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    animation: fadeIn 0.3s ease;
    overflow: hidden; /* Prevent scroll bleed */
}

.modal.show {
    display: flex;
    align-items: center;
    justify-content: center;
}

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

.modal-content {
    position: relative;
    background: #1e293b;
    border-radius: 12px;
    width: 90%;
    max-width: 700px;
    max-height: 90vh;
    overflow-y: auto;
    animation: slideIn 0.3s ease;
    border: 1px solid #475569;
}

@keyframes slideIn {
    from {
        transform: translateY(-50px);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 25px 30px;
    border-bottom: 1px solid #475569;
}

.modal-header h2 {
    color: #e2e8f0;
    font-size: 1.5rem;
}

.close {
    position: absolute;
    top: 20px;
    right: 25px;
    font-size: 2rem;
    color: #64748b;
    cursor: pointer;
    transition: color 0.2s;
    z-index: 10;
    background: none;
    border: none;
    padding: 0;
    line-height: 1;
}

.close:hover {
    color: #e2e8f0;
}

#movieForm {
    padding: 30px;
}

.form-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 20px;
    margin-bottom: 25px;
}

.form-group {
    display: flex;
    flex-direction: column;
}

.form-group label {
    margin-bottom: 8px;
    color: #94a3b8;
    font-weight: 600;
    font-size: 14px;
}

.form-group input,
.form-group select {
    width: 100%;
    box-sizing: border-box;
    padding: 10px 12px;
    border: 1px solid #475569;
    border-radius: 6px;
    font-size: 14px;
    transition: border-color 0.2s;
    background: #334155;
    color: #e2e8f0;
    height: 42px;
}

.form-group input:focus,
.form-group select:focus {
    outline: none;
    border-color: #10b981;
}

/* Title Suggestions Dropdown */
.title-input-container {
    position: relative;
    width: 100%;
}

/* Title field TMDB lookup indicator */
.title-indicator {
    position: absolute;
    right: 10px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 12px;
    color: #94a3b8;
    pointer-events: none;
    z-index: 1;
}

.title-indicator.waiting .waiting-text,
.title-indicator.loading .loading-text {
    color: #60a5fa;
    animation: fadeInOut 1.5s infinite;
}

.title-indicator.loading {
    display: flex;
    align-items: center;
    gap: 6px;
}

.title-indicator .spinner {
    width: 14px;
    height: 14px;
    border: 2px solid #475569;
    border-top-color: #60a5fa;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes fadeInOut {
    0%, 100% { opacity: 0.5; }
    50% { opacity: 1; }
}

/* Adjust title input padding to make room for indicator */
.title-input-container input {
    padding-right: 100px;
}

.title-suggestions {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: #1e293b;
    border: 1px solid #475569;
    border-top: none;
    border-radius: 0 0 6px 6px;
    max-height: 250px;
    overflow-y: auto;
    z-index: 1000;
    display: none;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

.title-suggestions.show {
    display: block;
}

.title-suggestion-item {
    padding: 10px 12px;
    cursor: pointer;
    border-bottom: 1px solid #334155;
    display: flex;
    align-items: center;
    gap: 10px;
}

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

.title-suggestion-item:hover {
    background: #334155;
}

.title-suggestion-poster {
    width: 35px;
    height: 52px;
    object-fit: cover;
    border-radius: 4px;
    background: #475569;
    margin-right: 12px;
    flex-shrink: 0;
}

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

.title-suggestion-title {
    color: #e2e8f0;
    font-weight: 600;
    font-size: 14px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.title-suggestion-year {
    color: #94a3b8;
    font-size: 12px;
}

/* Genre Multi-Select Dropdown */
.genre-select-container {
    position: relative;
}

.genre-select-wrapper {
    min-height: 42px;
    padding: 6px 10px;
    border: 1px solid #475569;
    border-radius: 6px;
    background: #334155;
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    align-items: center;
    box-sizing: border-box;
}

.genre-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    flex: 1;
}

.genre-tag {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 10px;
    background: #10b981;
    color: white;
    border-radius: 4px;
    font-size: 13px;
    font-weight: 500;
}

.genre-tag-remove {
    background: none;
    border: none;
    color: white;
    cursor: pointer;
    font-size: 16px;
    padding: 0;
    line-height: 1;
    opacity: 0.8;
    transition: opacity 0.2s;
}

.genre-tag-remove:hover {
    opacity: 1;
}

.genre-select-btn {
    padding: 6px 12px;
    background: #475569;
    color: #e2e8f0;
    border: none;
    border-radius: 4px;
    font-size: 13px;
    cursor: pointer;
    transition: background 0.2s;
    white-space: nowrap;
}

.genre-select-btn:hover {
    background: #64748b;
}

.genre-dropdown {
    display: none;
    position: absolute;
    top: calc(100% + 5px);
    left: 0;
    right: 0;
    background: #1e293b;
    border: 1px solid #475569;
    border-radius: 6px;
    max-height: 300px;
    overflow-y: auto;
    z-index: 1000;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.5);
}

.genre-dropdown.show {
    display: block;
}

.genre-dropdown-search {
    padding: 10px;
    border-bottom: 1px solid #334155;
    position: sticky;
    top: 0;
    background: #1e293b;
    z-index: 1;
}

.genre-dropdown-search input {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid #475569;
    border-radius: 4px;
    background: #334155;
    color: #e2e8f0;
    font-size: 13px;
}

.genre-dropdown-search input:focus {
    outline: none;
    border-color: #10b981;
}

.genre-options {
    padding: 5px 0;
}

.genre-option {
    padding: 10px 15px;
    cursor: pointer;
    transition: background 0.2s;
    font-size: 14px;
    color: #e2e8f0;
    display: flex;
    align-items: center;
    gap: 10px;
}

.genre-option:hover {
    background: #334155;
}

.genre-option.selected {
    background: #10b98120;
    color: #10b981;
    font-weight: 600;
}

.genre-option-checkbox {
    width: 16px;
    height: 16px;
    border: 2px solid #64748b;
    border-radius: 3px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
}

.genre-option.selected .genre-option-checkbox {
    background: #10b981;
    border-color: #10b981;
    color: white;
}

.form-actions {
    display: flex;
    gap: 15px;
    justify-content: flex-end;
}

/* Bottom Actions */
.bottom-actions {
    text-align: center;
    margin: 30px 0;
    padding: 20px 0;
}

.btn-large {
    padding: 15px 40px;
    font-size: 16px;
}

/* Floating Scroll Buttons */
.scroll-buttons {
    position: fixed;
    right: 30px;
    bottom: 30px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    z-index: 1000;
    pointer-events: auto; /* Ensure buttons are clickable */
}

.scroll-btn {
    padding: 12px 20px;
    border: none;
    border-radius: 8px;
    background: #475569;
    color: white;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3);
    transition: all 0.3s ease;
    min-width: 100px;
    border: 1px solid #64748b;
}

.scroll-btn:hover {
    transform: translateY(-3px);
    background: #64748b;
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.5);
}

.scroll-btn:active {
    transform: translateY(-1px);
}

/* Toast Notifications */
.toast-container {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 2000;
    display: flex;
    flex-direction: column;
    gap: 10px;
    max-width: 350px;
}

.toast {
    background: #1e293b;
    border-left: 4px solid;
    border-radius: 8px;
    padding: 16px 20px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    gap: 12px;
    animation: slideInRight 0.3s ease;
    color: #e2e8f0;
}

.toast.success {
    border-left-color: #10b981;
}

.toast.error {
    border-left-color: #ef4444;
}

.toast.warning {
    border-left-color: #f59e0b;
}

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

.toast-icon {
    font-size: 20px;
    flex-shrink: 0;
}

.toast-content {
    flex: 1;
}

.toast-message {
    font-size: 14px;
    font-weight: 500;
}

.toast-close {
    background: none;
    border: none;
    color: #64748b;
    cursor: pointer;
    font-size: 20px;
    padding: 0;
    width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: color 0.2s;
}

.toast-close:hover {
    color: #e2e8f0;
}

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

/* Sortable Table Headers */
th.sortable {
    cursor: pointer;
    user-select: none;
    position: relative;
    padding-right: 25px;
}

th.sortable:hover {
    background: #475569;
}

th.sortable::after {
    content: '⇅';
    position: absolute;
    right: 8px;
    opacity: 0.3;
}

th.sortable.asc::after {
    content: '↑';
    opacity: 1;
}

th.sortable.desc::after {
    content: '↓';
    opacity: 1;
}

/* Filter Sections */
.filter-section {
    display: flex;
    gap: 10px;
    align-items: center;
}

.filter-section label {
    font-size: 14px;
    color: #94a3b8;
    font-weight: 600;
}

#filterGenre, #filterFormat, #filterYear {
    padding: 10px 15px;
    border: 1px solid #475569;
    border-radius: 6px;
    font-size: 14px;
    background: #334155;
    color: #e2e8f0;
    cursor: pointer;
}

/* Undo Toast */
.undo-btn {
    background: #10b981;
    border: none;
    color: white;
    padding: 6px 12px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 12px;
    font-weight: 600;
    margin-left: 10px;
    transition: background 0.2s;
}

.undo-btn:hover {
    background: #059669;
}

/* Import Button */
.btn-import {
    background: #3b82f6;
    color: white;
}

.btn-import:hover {
    background: #2563eb;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(59, 130, 246, 0.4);
}

/* Validation Errors */
.form-group.error input,
.form-group.error select {
    border-color: #ef4444;
}

.form-error {
    color: #ef4444;
    font-size: 12px;
    margin-top: 4px;
    display: none;
}

.form-group.error .form-error {
    display: block;
}

/* Auto-fill Indicators */
.input-with-indicator {
    position: relative;
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
}

.input-with-indicator input {
    flex: 1;
    min-width: 0;
}

.autofill-indicator {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 24px;
    height: 24px;
    font-size: 14px;
    transition: all 0.3s ease;
}

.autofill-indicator.idle {
    opacity: 0;
}

.autofill-indicator.loading .spinner {
    width: 16px;
    height: 16px;
    border: 2px solid #475569;
    border-top-color: #3b82f6;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

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

.autofill-indicator.success .success-icon {
    color: #10b981;
    font-weight: bold;
    font-size: 16px;
}

.autofill-indicator.not-found .not-found-icon {
    color: #94a3b8;
    font-size: 14px;
}

.autofill-indicator.error .error-icon {
    color: #ef4444;
    font-size: 16px;
}

.autofill-indicator.edited .edited-icon {
    color: #f59e0b;
    font-size: 14px;
}

/* Auto-filled and manually edited field states */
input.tmdb-auto-filled {
    border-color: #10b981;
    background-color: rgba(16, 185, 129, 0.05);
}

input.manually-edited {
    border-color: #f59e0b;
    background-color: rgba(245, 158, 11, 0.05);
}

/* Duplicate Warning Modal */
.duplicate-modal .modal-content {
    max-width: 600px;
}

.duplicate-warning-content {
    padding: 0;
}

.duplicate-header {
    background: linear-gradient(135deg, #f59e0b, #d97706);
    color: white;
    padding: 24px;
    display: flex;
    align-items: center;
    gap: 16px;
    border-radius: 12px 12px 0 0;
}

.duplicate-header .warning-icon {
    font-size: 32px;
    animation: pulse 2s infinite;
}

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

.duplicate-header h3 {
    margin: 0;
    font-size: 20px;
    font-weight: 600;
}

.duplicate-section {
    padding: 20px 24px;
    border-bottom: 1px solid #334155;
}

.duplicate-section:last-of-type {
    border-bottom: none;
}

.duplicate-section.exact-match {
    background-color: rgba(239, 68, 68, 0.1);
    border-left: 4px solid #ef4444;
}

.duplicate-section.similar-match {
    background-color: rgba(245, 158, 11, 0.1);
    border-left: 4px solid #f59e0b;
}

.duplicate-section h4 {
    margin: 0 0 12px 0;
    font-size: 16px;
    font-weight: 600;
    color: #f1f5f9;
}

.duplicate-section ul {
    margin: 0 0 12px 0;
    padding-left: 24px;
}

.duplicate-section li {
    margin: 8px 0;
    color: #cbd5e1;
    font-size: 14px;
}

.duplicate-message {
    margin: 0;
    font-size: 14px;
    color: #94a3b8;
    font-style: italic;
}

.duplicate-actions {
    padding: 20px 24px;
    display: flex;
    justify-content: flex-end;
    gap: 12px;
    background: #1e293b;
    border-radius: 0 0 12px 12px;
}

.duplicate-actions .btn {
    min-width: 120px;
}

/* Bulk Delete Confirmation Modal */
.bulk-delete-modal .modal-content {
    max-width: 450px;
}

.bulk-delete-content {
    padding: 0;
}

.bulk-delete-header {
    background: linear-gradient(135deg, #ef4444, #dc2626);
    color: white;
    padding: 20px 24px;
    display: flex;
    align-items: center;
    gap: 12px;
    border-radius: 12px 12px 0 0;
}

.bulk-delete-header .warning-icon {
    font-size: 28px;
}

.bulk-delete-header h3 {
    margin: 0;
    font-size: 18px;
    font-weight: 600;
}

.bulk-delete-body {
    padding: 20px 24px;
}

.bulk-delete-body p {
    margin: 0 0 12px 0;
    color: #cbd5e1;
    font-size: 14px;
}

.bulk-delete-list {
    margin: 0 0 16px 0;
    padding-left: 24px;
    max-height: 200px;
    overflow-y: auto;
}

.bulk-delete-list li {
    margin: 6px 0;
    color: #f1f5f9;
    font-size: 14px;
}

.bulk-delete-list li.more-items {
    color: #94a3b8;
    font-style: italic;
}

.bulk-delete-warning {
    color: #ef4444 !important;
    font-weight: 600;
    margin-top: 16px !important;
}

.bulk-delete-actions {
    padding: 16px 24px;
    display: flex;
    justify-content: flex-end;
    gap: 12px;
    background: #1e293b;
    border-radius: 0 0 12px 12px;
}

.bulk-delete-actions .btn {
    min-width: 100px;
}

.btn-danger {
    background: linear-gradient(135deg, #ef4444, #dc2626);
    color: white;
    border: none;
}

.btn-danger:hover {
    background: linear-gradient(135deg, #dc2626, #b91c1c);
}

/* Card Layout for Mobile */
.movies-grid {
    display: none;
    gap: 15px;
    grid-template-columns: 1fr;
}

/* ============= POSTER GRID VIEW (Desktop Card Mode) ============= */
.movies-grid.poster-grid {
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 20px;
}

.poster-card {
    position: relative;
    aspect-ratio: 2/3;
    border-radius: 12px;
    overflow: hidden;
    cursor: pointer;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3);
}

.poster-card:hover {
    transform: translateY(-8px) scale(1.02);
    box-shadow: 0 12px 30px rgba(0, 0, 0, 0.5);
}

.poster-image {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
}

.poster-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    position: absolute;
    top: 0;
    left: 0;
    transition: opacity 0.3s ease;
    z-index: 1;
}

.poster-placeholder {
    font-size: 48px;
    font-weight: bold;
    color: rgba(255, 255, 255, 0.3);
    text-transform: uppercase;
    position: absolute;
    z-index: 0;
}

/* Blur-up placeholder image - tiny version that loads fast */
.poster-blur {
    width: 100%;
    height: 100%;
    object-fit: cover;
    position: absolute;
    top: 0;
    left: 0;
    z-index: 0;
    filter: blur(10px);
    transform: scale(1.1); /* Hide blur edges */
    transition: opacity 0.3s ease;
}

/* Hide placeholders when full image loads */
.poster-img.loaded + .poster-blur,
.poster-img.loaded ~ .poster-placeholder {
    opacity: 0;
}

/* Shimmer loading animation for posters */
@keyframes poster-shimmer {
    0% { background-position: -200% 0; }
    100% { background-position: 200% 0; }
}

.poster-card:not(.poster-loaded) .poster-image::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(90deg, transparent 0%, rgba(255,255,255,0.1) 50%, transparent 100%);
    background-size: 200% 100%;
    animation: poster-shimmer 1.5s infinite;
    z-index: 0;
}

.poster-overlay {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    background: linear-gradient(to top, rgba(0, 0, 0, 0.95) 0%, rgba(0, 0, 0, 0.7) 60%, transparent 100%);
    padding: 60px 12px 12px 12px;
    opacity: 0;
    transition: opacity 0.3s ease;
    z-index: 2;
}

.poster-card:hover .poster-overlay {
    opacity: 1;
}

.poster-title {
    font-size: 14px;
    font-weight: 700;
    color: #fff;
    margin: 0 0 6px 0;
    line-height: 1.3;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.poster-meta {
    display: flex;
    gap: 10px;
    align-items: center;
    margin-bottom: 4px;
}

.poster-year {
    color: #94a3b8;
    font-size: 12px;
}

.poster-rating {
    font-weight: 700;
    font-size: 13px;
}

.poster-genre {
    font-size: 11px;
    color: #64748b;
    display: -webkit-box;
    -webkit-line-clamp: 1;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.poster-director {
    font-size: 11px;
    color: #94a3b8;
    margin-top: 4px;
    display: -webkit-box;
    -webkit-line-clamp: 1;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* Light mode poster cards */
body.light-mode .poster-card {
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.15);
}

body.light-mode .poster-card:hover {
    box-shadow: 0 12px 30px rgba(0, 0, 0, 0.25);
}

/* Mobile: Poster grid with 2-3 columns */
@media (max-width: 768px) {
    /* Hide certain columns on mobile for better layout */
    .hide-on-mobile {
        display: none !important;
    }

    /* Fix wishlist card title overlapping with priority badge on mobile */
    .wishlist-card .movie-card-header {
        margin-top: 55px;
    }

    .movies-grid.poster-grid {
        grid-template-columns: repeat(3, 1fr);
        gap: 10px;
    }

    .poster-overlay {
        opacity: 1;
        background: linear-gradient(to top, rgba(0, 0, 0, 0.9) 0%, rgba(0, 0, 0, 0.5) 80%, transparent 100%);
        padding: 30px 8px 8px 8px;
        /* Allow clicks through the gradient to reach the poster card */
        pointer-events: none;
    }

    /* But make buttons inside the overlay clickable */
    .poster-overlay .poster-actions,
    .poster-overlay button,
    .poster-overlay .btn,
    .poster-overlay .poster-title,
    .poster-overlay .poster-meta {
        pointer-events: auto;
    }

    .poster-title {
        font-size: 11px;
        -webkit-line-clamp: 2;
    }

    .poster-meta {
        font-size: 10px;
    }

    .poster-genre,
    .poster-director {
        display: none; /* Hide on mobile to keep it clean */
    }
}

/* Very small phones: 2 columns */
@media (max-width: 400px) {
    .movies-grid.poster-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 8px;
    }
}

.movie-card {
    background: #334155;
    border-radius: 8px;
    padding: 15px;
    border: 1px solid #475569;
    cursor: pointer;
    transition: all 0.2s ease;
}

.movie-card:hover {
    background: #3d4a61;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

/* FORTNITE LEGENDARY - MAXIMUM INTENSITY */
@keyframes legendaryPulse {
    0%, 100% {
        box-shadow:
            0 0 10px #fff,
            0 0 20px #fbbf24,
            0 0 40px #fbbf24,
            0 0 60px rgba(251, 191, 36, 0.8),
            0 0 100px rgba(251, 191, 36, 0.6),
            inset 0 0 15px rgba(251, 191, 36, 0.3);
        filter: brightness(1);
    }
    50% {
        box-shadow:
            0 0 20px #fff,
            0 0 40px #fbbf24,
            0 0 80px #f59e0b,
            0 0 120px rgba(251, 191, 36, 0.9),
            0 0 160px rgba(245, 158, 11, 0.7),
            inset 0 0 30px rgba(251, 191, 36, 0.5);
        filter: brightness(1.1);
    }
}

@keyframes borderShimmer {
    0% { background-position: 200% center; }
    100% { background-position: -200% center; }
}

@keyframes colorShift {
    0%, 100% { border-color: #fbbf24; }
    25% { border-color: #fff7a1; }
    50% { border-color: #f59e0b; }
    75% { border-color: #fcd34d; }
}

.gold-border {
    border: 4px solid #fbbf24 !important;
    background:
        linear-gradient(#334155, #334155) padding-box,
        linear-gradient(90deg, #fbbf24, #fff, #f59e0b, #fbbf24, #fff, #fbbf24) border-box !important;
    background-size: 300% auto;
    animation:
        legendaryPulse 1s ease-in-out infinite,
        borderShimmer 2s linear infinite,
        colorShift 2s ease-in-out infinite;
    position: relative;
}

/* Extra glow layer using pseudo-element (exclude table rows) */
.gold-border:not(tr)::before {
    content: '';
    position: absolute;
    inset: -4px;
    border-radius: inherit;
    background: linear-gradient(90deg, #fbbf24, #fff, #f59e0b, #fbbf24);
    background-size: 300% auto;
    animation: borderShimmer 2s linear infinite;
    z-index: -1;
    filter: blur(8px);
    opacity: 0.8;
}

.gold-border:hover {
    animation:
        legendaryPulse 0.8s ease-in-out infinite,
        borderShimmer 1.5s linear infinite,
        colorShift 1.5s ease-in-out infinite;
}

/* Gold border for list view rows - MAXIMUM legendary */
tr.gold-border {
    background: linear-gradient(90deg, rgba(251, 191, 36, 0.25) 0%, rgba(251, 191, 36, 0.1) 30%, transparent 70%) !important;
    border-left: 5px solid #fbbf24 !important;
    animation: legendaryPulse 1s ease-in-out infinite;
}

tr.gold-border:hover {
    background: linear-gradient(90deg, rgba(251, 191, 36, 0.35) 0%, rgba(251, 191, 36, 0.15) 30%, transparent 70%) !important;
}

.movie-card-header {
    display: flex;
    justify-content: space-between;
    align-items: start;
    margin-bottom: 12px;
}

.movie-card-title {
    font-size: 16px;
    font-weight: 600;
    color: #e2e8f0;
    margin: 0;
}

.movie-card-rating {
    font-size: 14px;
    font-weight: 600;
    color: #fbbf24;
}

.movie-card-info {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
    margin-top: 10px;
}

.movie-card-detail {
    font-size: 12px;
}

.movie-card-label {
    color: #94a3b8;
    font-weight: 600;
}

.movie-card-value {
    color: #e2e8f0;
}

/* Wishlist Card Styles */
.wishlist-card {
    position: relative;
}

.wishlist-card.reserved {
    border-color: #f59e0b;
    background: linear-gradient(135deg, #334155, #423d15);
}

.reserved-badge {
    position: absolute;
    top: -8px;
    right: -8px;
    background: linear-gradient(135deg, #f59e0b, #d97706);
    color: white;
    padding: 4px 12px;
    border-radius: 12px;
    font-size: 11px;
    font-weight: 600;
    box-shadow: 0 2px 8px rgba(245, 158, 11, 0.4);
}

.boxset-badge {
    position: absolute;
    top: 28px;
    right: -8px;
    background: linear-gradient(135deg, #8b5cf6, #6d28d9);
    color: white;
    padding: 4px 10px;
    border-radius: 12px;
    font-size: 11px;
    font-weight: 600;
    box-shadow: 0 2px 8px rgba(139, 92, 246, 0.4);
}

/* When no reserved badge, move boxset badge to top position */
.boxset-badge.no-reserved {
    top: -8px;
}

.btn-reserve {
    width: 100%;
    margin-top: 12px;
    padding: 10px 16px;
    background: linear-gradient(135deg, #10b981, #059669);
    color: white;
    border: none;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-reserve:hover {
    background: linear-gradient(135deg, #059669, #047857);
    transform: scale(1.02);
}

.btn-unreserve {
    width: 100%;
    margin-top: 12px;
    padding: 8px 12px;
    background: #64748b;
    color: white;
    border: none;
    border-radius: 6px;
    font-size: 12px;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-unreserve:hover {
    background: #475569;
}

/* Share button */
.btn-share {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 10px 20px;
    background: linear-gradient(135deg, #6366f1, #4f46e5);
    color: white;
    border: none;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    position: absolute;
    right: 20px;
}

.btn-share:hover {
    background: linear-gradient(135deg, #4f46e5, #4338ca);
    transform: scale(1.02);
}

/* Wishlist Table/List View Styles */
.reserved-row {
    background: linear-gradient(135deg, #334155, #423d15) !important;
}

.reserved-badge-inline {
    display: inline-block;
    background: linear-gradient(135deg, #f59e0b, #d97706);
    color: white;
    padding: 2px 8px;
    border-radius: 10px;
    font-size: 10px;
    font-weight: 600;
    margin-left: 8px;
    vertical-align: middle;
}

/* Priority System Styles */

/* Priority Header */
.priority-header {
    width: 60px;
    min-width: 60px;
    max-width: 60px;
    text-align: center;
    padding: 8px 4px !important;
}

/* List View Priority Cell */
.priority-cell {
    width: 60px;
    min-width: 60px;
    max-width: 60px;
    text-align: center;
    padding: 8px 4px !important;
    white-space: nowrap;
}

.priority-cell .drag-handle {
    display: inline-block;
    margin-left: 6px;
    vertical-align: middle;
    cursor: grab;
    padding: 4px 6px;
    border-radius: 4px;
    background: rgba(255, 255, 255, 0.05);
}

.priority-cell .drag-handle:hover {
    background: rgba(255, 255, 255, 0.15);
    color: #f1f5f9;
}

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

.priority-number {
    font-weight: 700;
    font-size: 14px;
    vertical-align: middle;
    color: #94a3b8;
    min-width: 30px;
    cursor: pointer;
    transition: color 0.2s;
    /* Mobile touch target - minimum 44px recommended */
    padding: 8px 4px;
    margin: -8px -4px;
    display: inline-block;
    -webkit-tap-highlight-color: rgba(96, 165, 250, 0.3);
    touch-action: manipulation;
}

.priority-number:hover,
.priority-number:active {
    color: #60a5fa;
    text-decoration: underline;
}

.priority-number.priority-top,
.priority-cell.priority-top .priority-number,
.priority-badge.priority-top .priority-number,
.priority-overlay.priority-top .priority-number {
    color: #fbbf24;
    text-shadow: 0 0 8px rgba(251, 191, 36, 0.4);
}

.priority-number.priority-top:hover,
.priority-cell.priority-top .priority-number:hover,
.priority-badge.priority-top .priority-number:hover,
.priority-overlay.priority-top .priority-number:hover {
    color: #fcd34d;
    text-decoration: underline;
}

/* Drag Handle */
.drag-handle {
    cursor: grab;
    color: #64748b;
    font-size: 14px;
    padding: 2px 4px;
    border-radius: 4px;
    transition: all 0.2s;
    user-select: none;
    touch-action: none;
    margin-left: 4px;
    vertical-align: middle;
}

.drag-handle:hover {
    color: #f1f5f9;
    background: rgba(255, 255, 255, 0.1);
}

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

/* Card View Priority Badge */
.priority-badge {
    position: absolute;
    top: 8px;
    left: 8px;
    display: flex;
    align-items: center;
    gap: 6px;
    background: rgba(15, 23, 42, 0.85);
    padding: 6px 12px;
    border-radius: 20px;
    backdrop-filter: blur(4px);
    z-index: 5;
}

.priority-badge .priority-number {
    font-size: 13px;
}

.priority-badge .drag-handle {
    font-size: 14px;
    padding: 2px 4px;
}

/* Poster View Priority Overlay */
.priority-overlay {
    position: absolute;
    top: 8px;
    left: 8px;
    display: flex;
    align-items: center;
    gap: 6px;
    background: rgba(15, 23, 42, 0.9);
    padding: 8px 14px;
    border-radius: 24px;
    backdrop-filter: blur(8px);
    z-index: 10;
}

.priority-overlay .priority-number {
    font-size: 16px;
    font-weight: 800;
}

.priority-overlay .drag-handle {
    font-size: 18px;
    padding: 4px 8px;
}

/* Rename poster-overlay to poster-overlay-info for Wishlist to avoid conflict */
.wishlist-poster .poster-overlay-info {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    background: linear-gradient(transparent, rgba(0, 0, 0, 0.9));
    padding: 60px 12px 12px;
    opacity: 0;
    transition: opacity 0.3s;
}

.wishlist-poster:hover .poster-overlay-info {
    opacity: 1;
}

/* SortableJS Drag States */
.sortable-ghost {
    opacity: 0.4;
    background: #334155 !important;
}

.sortable-chosen {
    box-shadow: 0 0 20px rgba(99, 102, 241, 0.5);
}

.sortable-drag {
    opacity: 1;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.4);
}

/* Mobile-friendly touch targets */
@media (max-width: 768px) {
    .priority-cell {
        min-width: 70px;
        padding: 6px 8px;
    }

    .drag-handle {
        font-size: 20px;
        padding: 8px 12px;
        min-height: 44px;
        min-width: 44px;
        display: flex;
        align-items: center;
        justify-content: center;
    }

    .priority-overlay {
        top: 6px;
        left: 6px;
        padding: 6px 12px;
    }

    .priority-overlay .drag-handle {
        font-size: 22px;
        min-height: 44px;
        min-width: 44px;
    }

    .priority-badge {
        padding: 8px 14px;
    }

    .priority-badge .drag-handle {
        font-size: 18px;
        min-height: 44px;
        min-width: 44px;
    }
}

/* Boxset Section Styles */
.boxset-section {
    margin-top: 20px;
    padding: 16px;
    background: linear-gradient(135deg, #312e81, #3730a3);
    border-radius: 12px;
    border: 1px solid #4f46e5;
}

.boxset-section h4 {
    color: #a5b4fc;
    margin: 0 0 12px 0;
    font-size: 14px;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 8px;
}

.boxset-section h4::before {
    content: '📦';
}

.boxset-item {
    background: rgba(0, 0, 0, 0.2);
    border-radius: 8px;
    padding: 12px;
    margin-bottom: 12px;
}

.boxset-item:last-child {
    margin-bottom: 0;
}

/* Boxset type label for modal (NOT positioned absolutely) */
.boxset-type-label {
    display: inline-block;
    background: linear-gradient(135deg, #fbbf24, #f59e0b);
    color: #1e1b4b;
    padding: 4px 10px;
    border-radius: 6px;
    font-size: 11px;
    font-weight: 700;
    margin-bottom: 8px;
}

.boxset-name {
    color: #f1f5f9;
    font-size: 16px;
    font-weight: 600;
    margin: 0 0 4px 0;
}

.boxset-label {
    color: #94a3b8;
    font-size: 12px;
    margin: 0 0 12px 0;
}

.boxset-movies {
    margin-bottom: 12px;
}

.boxset-movies strong {
    color: #a5b4fc;
    font-size: 12px;
}

.boxset-movies ul {
    margin: 8px 0 0 0;
    padding-left: 20px;
    color: #e2e8f0;
    font-size: 13px;
}

.boxset-movies li {
    margin-bottom: 4px;
}

.boxset-retailers {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.btn-boxset-buy {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 14px;
    background: linear-gradient(135deg, #10b981, #059669);
    color: white;
    border: none;
    border-radius: 6px;
    font-size: 13px;
    font-weight: 600;
    text-decoration: none;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-boxset-buy:hover {
    background: linear-gradient(135deg, #059669, #047857);
    transform: scale(1.02);
}

.boxset-source {
    color: #64748b;
    font-size: 11px;
    margin: 4px 0 12px 0;
    font-style: italic;
}

.boxset-loading {
    color: #94a3b8;
    font-size: 13px;
    padding: 12px;
    text-align: center;
    font-style: italic;
}

.days-remaining {
    color: #f59e0b;
    font-size: 12px;
    font-weight: 500;
}

.btn-reserve-small {
    padding: 4px 10px;
    background: linear-gradient(135deg, #10b981, #059669);
    color: white;
    border: none;
    border-radius: 4px;
    font-size: 11px;
    font-weight: 600;
    cursor: pointer;
}

.btn-reserve-small:hover {
    background: linear-gradient(135deg, #059669, #047857);
}

.btn-unreserve-small {
    padding: 4px 10px;
    background: #64748b;
    color: white;
    border: none;
    border-radius: 4px;
    font-size: 11px;
    cursor: pointer;
}

.btn-unreserve-small:hover {
    background: #475569;
}

/* Wishlist Poster View Styles */
.wishlist-poster.reserved {
    box-shadow: 0 0 0 3px #f59e0b;
}

.poster-reserved-badge {
    position: absolute;
    top: 8px;
    right: 8px;
    background: linear-gradient(135deg, #f59e0b, #d97706);
    color: white;
    padding: 4px 10px;
    border-radius: 12px;
    font-size: 11px;
    font-weight: 600;
    z-index: 10;
    box-shadow: 0 2px 8px rgba(0,0,0,0.3);
}

.poster-boxset-badge {
    position: absolute;
    top: 38px;
    right: 8px;
    background: linear-gradient(135deg, #8b5cf6, #6d28d9);
    color: white;
    padding: 4px 10px;
    border-radius: 12px;
    font-size: 11px;
    font-weight: 600;
    z-index: 10;
    box-shadow: 0 2px 8px rgba(139, 92, 246, 0.4);
}

/* When no reserved badge, move boxset badge to top position */
.poster-boxset-badge.no-reserved {
    top: 8px;
}

.poster-format {
    background: #475569;
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 10px;
}

.btn-reserve-poster {
    margin-top: 8px;
    padding: 6px 12px;
    background: linear-gradient(135deg, #10b981, #059669);
    color: white;
    border: none;
    border-radius: 4px;
    font-size: 11px;
    font-weight: 600;
    cursor: pointer;
    width: 100%;
}

.btn-reserve-poster:hover {
    background: linear-gradient(135deg, #059669, #047857);
}

.btn-unreserve-poster {
    margin-top: 4px;
    padding: 4px 8px;
    background: #64748b;
    color: white;
    border: none;
    border-radius: 4px;
    font-size: 10px;
    font-weight: 600;
    cursor: pointer;
    width: 100%;
}

.btn-unreserve-poster:hover {
    background: #475569;
}

.poster-days-left {
    margin-top: 8px;
    color: #f59e0b;
    font-size: 11px;
    font-weight: 500;
    text-align: center;
}

/* Responsive Design */

/* iPad landscape (768-1024px) */
@media (min-width: 768px) and (max-width: 1024px) and (orientation: landscape) {
    .container {
        max-width: 100%;
        padding: 15px 20px;
    }

    .movies-grid {
        grid-template-columns: repeat(3, 1fr);
    }

    body.card-view .movies-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .modal-content {
        max-width: 80%;
        max-height: 90vh;
    }
}

@media (max-width: 768px) {
    body {
        padding: 10px;
    }

    .container {
        padding: 15px;
    }

    header {
        flex-direction: column;
        gap: 15px;
        align-items: flex-start;
    }

    h1 {
        font-size: 1.5rem;
    }

    .header-buttons {
        width: 100%;
        justify-content: space-between;
    }

    .header-buttons .btn {
        padding: 8px 12px;
        font-size: 12px;
    }

    .stats {
        grid-template-columns: repeat(2, 1fr);
        gap: 8px;
        margin-bottom: 12px;
    }

    .stat-card {
        padding: 8px;
    }

    .stat-number {
        font-size: 1.1rem;
    }

    .stat-label {
        font-size: 0.6rem;
    }

    .stat-card-wide {
        grid-column: span 2;
    }

    .tab-switcher {
        width: 100%;
        margin-bottom: 15px;
        flex-wrap: wrap;
        position: relative;
    }

    .tab-switcher-bottom {
        margin-top: 15px;
        margin-bottom: 15px;
    }

    .tab-btn {
        flex: 1;
        padding: 8px 12px;
        font-size: 12px;
    }

    .btn-share {
        position: static;
        width: 100%;
        margin-top: 10px;
        padding: 8px 12px;
        font-size: 12px;
    }

    .filters-bar {
        flex-direction: column;
        align-items: stretch;
        gap: 10px;
    }

    .filters-bar .btn-filter {
        width: 100%;
        justify-content: center;
    }

    .filters-bar #searchInput {
        width: 100%;
        min-width: 0;
    }

    .filters-bar .btn-add {
        width: 100%;
    }

    .filters-left {
        width: 100%;
        flex-direction: column;
        gap: 10px;
    }

    .filters-right {
        width: 100%;
        margin-left: 0;
        flex-direction: column;
        gap: 10px;
    }

    #searchInput, #filterOwned {
        width: 100%;
        min-width: auto;
    }

    .filter-section {
        width: 100%;
        flex-direction: column;
        align-items: flex-start;
        gap: 5px;
    }

    #filterGenre, #filterFormat, #filterYear {
        width: 100%;
    }

    .table-container {
        display: none; /* Hide table on mobile, show cards instead */
    }

    .movies-grid {
        display: grid;
    }

    .toast-container {
        right: 10px;
        left: 10px;
        max-width: none;
    }

    th, td {
        padding: 6px 4px;
        font-size: 11px;
    }

    th {
        font-size: 10px;
    }

    .movie-row:hover {
        transform: none;
    }

    .owned-badge {
        font-size: 10px;
        padding: 3px 6px;
    }

    .bottom-actions {
        margin: 20px 0;
    }

    .btn-large {
        padding: 12px 30px;
        font-size: 14px;
    }

    .scroll-buttons {
        right: 10px;
        bottom: 10px;
    }

    .scroll-btn {
        padding: 8px 12px;
        min-width: 70px;
        font-size: 11px;
    }

    .modal-content {
        width: 95%;
        max-width: none;
        margin: 10px;
    }

    .modal-header {
        padding: 20px;
    }

    .modal-header h2 {
        font-size: 1.25rem;
    }

    #movieForm {
        padding: 20px;
    }

    .form-grid {
        grid-template-columns: 1fr;
        gap: 15px;
    }

    .form-group input,
    .form-group select {
        font-size: 16px; /* Prevents zoom on iOS */
    }

    .form-actions {
        flex-direction: column;
    }

    .form-actions .btn {
        width: 100%;
    }

    .error-message {
        font-size: 13px;
        padding: 12px;
    }

    .loading {
        padding: 30px;
        font-size: 14px;
    }
}

/* ================ RATING SYSTEM STYLES ================ */

/* Rating help button */
.rating-help-btn {
    background: #3b82f6;
    color: white;
    border: none;
    border-radius: 50%;
    width: 20px;
    height: 20px;
    font-size: 12px;
    font-weight: bold;
    cursor: pointer;
    margin-left: 5px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.rating-help-btn:hover {
    background: #2563eb;
    transform: scale(1.1);
}

/* Rating Guide Modal */
.rating-guide-modal {
    max-width: 600px;
    max-height: 85vh;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
}

.rating-guide-modal h2 {
    margin-bottom: 8px;
    color: #60a5fa;
    text-align: center;
    font-size: 1.5rem;
}

.rating-guide-help {
    text-align: center;
    color: #94a3b8;
    font-size: 13px;
    margin-bottom: 12px;
    font-style: italic;
}

.rating-scale-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
    flex: 1;
    overflow-y: auto;
}

.rating-scale-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
    background: #1e293b;
    border-radius: 8px;
    border-left: 4px solid;
    transition: all 0.2s;
    cursor: default;
    min-height: 0; /* Allow shrinking */
}

.rating-scale-item:hover {
    transform: translateX(5px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

.rating-value {
    font-size: 22px;
    font-weight: bold;
    min-width: 45px;
    text-align: center;
}

.rating-info {
    flex: 1;
    min-width: 0; /* Allow text truncation */
}

.rating-label {
    font-size: 15px;
    font-weight: 600;
    margin-bottom: 2px;
}

.rating-description {
    font-size: 12px;
    color: #94a3b8;
    line-height: 1.3;
}

.rating-icon {
    font-size: 20px;
    opacity: 0.6;
}

/* Rating color classes */
.rating-10 {
    border-color: #c084fc;
}
.rating-10 .rating-value,
.rating-10 .rating-label {
    color: #c084fc;
}

.rating-9 {
    border-color: #4ade80;
}
.rating-9 .rating-value,
.rating-9 .rating-label {
    color: #4ade80;
}

.rating-8 {
    border-color: #60a5fa;
}
.rating-8 .rating-value,
.rating-8 .rating-label {
    color: #60a5fa;
}

.rating-7 {
    border-color: #22d3ee;
}
.rating-7 .rating-value,
.rating-7 .rating-label {
    color: #22d3ee;
}

.rating-6 {
    border-color: #facc15;
}
.rating-6 .rating-value,
.rating-6 .rating-label {
    color: #facc15;
}

.rating-5 {
    border-color: #fb923c;
}
.rating-5 .rating-value,
.rating-5 .rating-label {
    color: #fb923c;
}

.rating-4 {
    border-color: #f87171;
}
.rating-4 .rating-value,
.rating-4 .rating-label {
    color: #f87171;
}

.rating-3 {
    border-color: #ef4444;
}
.rating-3 .rating-value,
.rating-3 .rating-label {
    color: #ef4444;
}

.rating-2 {
    border-color: #dc2626;
}
.rating-2 .rating-value,
.rating-2 .rating-label {
    color: #dc2626;
}

.rating-1 {
    border-color: #b91c1c;
}
.rating-1 .rating-value,
.rating-1 .rating-label {
    color: #b91c1c;
}

/* Standalone rating color classes for use in tables/cards */
.rating-color-10 { color: #c084fc !important; }
.rating-color-9 { color: #4ade80 !important; }
.rating-color-8 { color: #60a5fa !important; }
.rating-color-7 { color: #22d3ee !important; }
.rating-color-6 { color: #facc15 !important; }
.rating-color-5 { color: #fb923c !important; }
.rating-color-4 { color: #f87171 !important; }
.rating-color-3 { color: #ef4444 !important; }
.rating-color-2 { color: #dc2626 !important; }
.rating-color-1 { color: #b91c1c !important; }

/* Rating display in tables and cards */
.movie-rating-display {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 2px;
}

.movie-rating-value {
    font-size: 18px;
    font-weight: bold;
}

.movie-rating-label {
    font-size: 11px;
    opacity: 0.8;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* Movie Detail Modal */
.movie-detail-modal {
    max-width: 1400px;
    width: 95%;
    max-height: 90vh;
    overflow-y: auto;
    padding: 0;
}

.movie-detail-content {
    display: grid;
    grid-template-columns: 350px 1fr;
    gap: 40px;
    padding: 40px;
}

.movie-detail-left {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.movie-detail-poster-container {
    width: 100%;
    position: relative;
}

.movie-detail-poster {
    width: 100%;
    border-radius: 12px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
    display: block;
}

.poster-placeholder {
    width: 100%;
    aspect-ratio: 2/3;
    background: #1e293b;
    border: 2px dashed #475569;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #64748b;
    font-size: 14px;
    text-align: center;
}

.poster-placeholder p {
    margin: 0;
    padding: 20px;
}

.movie-detail-trailer {
    width: 100%;
    aspect-ratio: 16/9;
    background: #0f172a;
    border-radius: 8px;
    overflow: hidden;
}

.movie-detail-trailer iframe {
    width: 100%;
    height: 100%;
    border: none;
}

.movie-detail-trailer.no-trailer {
    display: flex;
    align-items: center;
    justify-content: center;
    color: #64748b;
    font-size: 14px;
}

.no-trailer-content {
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
}

.no-trailer-content p {
    margin: 0;
    color: #64748b;
}

.btn-youtube-search {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    background: #cc0000;
    color: white;
    padding: 8px 16px;
    border-radius: 6px;
    text-decoration: none;
    font-size: 13px;
    font-weight: 500;
    transition: background 0.2s, transform 0.2s;
}

.btn-youtube-search:hover {
    background: #990000;
    transform: scale(1.02);
}

.btn-youtube-search svg {
    flex-shrink: 0;
}

.movie-detail-right {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.movie-detail-title {
    font-size: 36px;
    margin: 0;
    color: #e2e8f0;
    font-weight: bold;
    line-height: 1.2;
}

.movie-detail-tagline {
    font-size: 17px;
    font-style: italic;
    color: #94a3b8;
    margin: -5px 0 0 0;
    line-height: 1.4;
}

.movie-detail-meta {
    display: flex;
    gap: 15px;
    flex-wrap: wrap;
    align-items: center;
}

.movie-detail-rating {
    padding: 6px 12px;
    border-radius: 6px;
    font-weight: 600;
    font-size: 14px;
}

.movie-detail-year,
.movie-detail-runtime {
    color: #94a3b8;
    font-size: 14px;
}

.movie-detail-section {
    margin-top: 10px;
}

.movie-detail-section h3 {
    color: #60a5fa;
    font-size: 18px;
    margin-bottom: 10px;
}

.movie-detail-overview {
    color: #cbd5e1;
    line-height: 1.8;
    font-size: 16px;
}

.movie-detail-recap {
    color: #cbd5e1;
    line-height: 1.8;
    font-size: 15px;
    background: #0f172a;
    padding: 15px 20px;
    border-radius: 8px;
    border-left: 4px solid #60a5fa;
    font-style: italic;
}

.previous-movie-link {
    color: #60a5fa;
    text-decoration: none;
    border-bottom: 1px solid transparent;
    transition: all 0.2s ease;
}

.previous-movie-link:hover {
    color: #93c5fd;
    border-bottom-color: #93c5fd;
}

#movieDetailRecapSection h3 {
    color: #60a5fa;
}

#movieDetailRecapTitle {
    color: #10b981;
    font-weight: bold;
}

.movie-detail-info-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 15px;
    padding: 20px;
    background: #0f172a;
    border-radius: 8px;
}

.movie-detail-info-item {
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.movie-detail-info-item strong {
    color: #94a3b8;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.movie-detail-info-item span {
    color: #e2e8f0;
    font-size: 14px;
}

.imdb-button-container {
    margin-top: 15px;
    margin-bottom: 10px;
}

.imdb-button-container .btn {
    width: 100%;
    display: block;
}

/* Purchase Links Section */
.purchase-links-section {
    margin-top: 16px;
    padding: 16px;
    background: linear-gradient(135deg, #1e293b 0%, #0f172a 100%);
    border-radius: 12px;
    border: 1px solid #334155;
}

.purchase-links-section h4 {
    margin: 0 0 12px 0;
    font-size: 14px;
    color: #94a3b8;
    font-weight: 600;
}

.purchase-links-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
}

.purchase-link-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 14px;
    border: none;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    text-decoration: none;
    color: white;
}

.purchase-link-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

.purchase-link-btn.amazon {
    background: linear-gradient(135deg, #ff9900, #e88b00);
}

.purchase-link-btn.zavvi {
    background: linear-gradient(135deg, #00a651, #008c44);
}

.purchase-link-btn.hmv {
    background: linear-gradient(135deg, #e91e8c, #c4187a);
}

.purchase-link-btn.ebay {
    background: linear-gradient(135deg, #0064d2, #0050a8);
}

/* Similar Movies Recommendations */
.similar-movies-section {
    margin-top: 16px;
    padding: 16px;
    background: linear-gradient(135deg, #f8fafc 0%, #f1f5f9 100%);
    border-radius: 12px;
    border: 1px solid #e2e8f0;
}

.similar-movies-section h4 {
    margin: 0 0 12px 0;
    color: #334155;
    font-size: 14px;
    font-weight: 600;
}

.similar-movies-list {
    display: flex;
    gap: 12px;
    overflow-x: auto;
    padding-bottom: 8px;
    scrollbar-width: thin;
    scrollbar-color: #cbd5e1 transparent;
}

.similar-movies-list::-webkit-scrollbar {
    height: 6px;
}

.similar-movies-list::-webkit-scrollbar-track {
    background: transparent;
}

.similar-movies-list::-webkit-scrollbar-thumb {
    background-color: #cbd5e1;
    border-radius: 3px;
}

.similar-movie-card {
    flex: 0 0 auto;
    width: 100px;
    cursor: pointer;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    border-radius: 8px;
    overflow: hidden;
    background: white;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

.similar-movie-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 8px 16px rgba(0,0,0,0.15);
}

.similar-movie-card .poster {
    width: 100%;
    aspect-ratio: 2/3;
    object-fit: cover;
    display: block;
    background: #e2e8f0;
}

.similar-movie-card .poster-placeholder {
    width: 100%;
    aspect-ratio: 2/3;
    background: linear-gradient(135deg, #e2e8f0 0%, #cbd5e1 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
}

.similar-movie-card .info {
    padding: 8px;
}

.similar-movie-card .title {
    font-size: 11px;
    font-weight: 600;
    color: #334155;
    line-height: 1.3;
    overflow: hidden;
    text-overflow: ellipsis;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    margin-bottom: 4px;
}

.similar-movie-card .meta {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 10px;
}

.similar-movie-card .year {
    color: #64748b;
}

.similar-movie-card .rating {
    font-weight: 600;
    padding: 2px 6px;
    border-radius: 4px;
    color: white;
}

.similar-movie-card .genre-match {
    font-size: 9px;
    color: #10b981;
    margin-top: 4px;
    font-weight: 500;
}

/* Dark mode support for similar movies */
body.dark-mode .similar-movies-section {
    background: linear-gradient(135deg, #1e293b 0%, #0f172a 100%);
    border-color: #334155;
}

body.dark-mode .similar-movies-section h4 {
    color: #e2e8f0;
}

body.dark-mode .similar-movie-card {
    background: #1e293b;
    box-shadow: 0 2px 8px rgba(0,0,0,0.3);
}

body.dark-mode .similar-movie-card .title {
    color: #e2e8f0;
}

body.dark-mode .similar-movie-card .year {
    color: #94a3b8;
}

body.dark-mode .similar-movie-card .poster-placeholder {
    background: linear-gradient(135deg, #334155 0%, #1e293b 100%);
}

.movie-detail-actions {
    display: flex !important;
    gap: 10px;
    margin-top: 0;
    margin-bottom: 0;
    padding: 0;
    width: 100%;
    box-sizing: border-box;
}

.movie-detail-actions .btn {
    flex: 1;
    box-sizing: border-box;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.movie-detail-loading {
    display: none;
    text-align: center;
    padding: 60px 30px;
}

.movie-detail-loading.show {
    display: block;
}

.movie-detail-loading + .movie-detail-content {
    display: grid;
}

.movie-detail-loading.show + .movie-detail-content {
    display: none;
}

.spinner {
    border: 4px solid #334155;
    border-top: 4px solid #10b981;
    border-radius: 50%;
    width: 50px;
    height: 50px;
    animation: spin 1s linear infinite;
    margin: 0 auto 20px;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.movie-detail-loading p {
    color: #94a3b8;
    font-size: 14px;
}

/* Mobile Responsive */
@media (max-width: 1024px) {
    .movie-detail-modal {
        width: 98%;
        max-height: 95vh;
    }

    .movie-detail-content {
        grid-template-columns: 1fr;
        gap: 25px;
        padding: 25px;
    }

    .movie-detail-left {
        max-width: 350px;
        margin: 0 auto;
    }

    .movie-detail-title {
        font-size: 28px;
    }

    .movie-detail-info-grid {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 768px) {
    /* Ensure no horizontal scroll */
    body, .container {
        overflow-x: hidden;
        max-width: 100vw;
    }

    /* Header buttons - ensure wrap and proper touch targets */
    .header-buttons {
        flex-wrap: wrap;
        gap: 8px;
    }

    .header-buttons .btn {
        min-height: 44px; /* iOS minimum touch target */
        min-width: 44px;
        padding: 10px 14px;
    }

    /* Scroll buttons - position at bottom right, avoid overlap */
    .scroll-buttons {
        right: 10px;
        bottom: 80px; /* Above bottom actions */
    }

    .scroll-btn {
        min-height: 44px;
        min-width: 44px;
    }

    .movie-detail-content {
        padding: 20px;
    }

    .movie-detail-left {
        max-width: 300px;
    }

    .movie-detail-title {
        font-size: 24px;
    }
}

@media (max-width: 480px) {
    body {
        padding: 5px;
    }

    .container {
        padding: 10px;
    }

    /* Header */
    h1 {
        font-size: 1.3rem;
    }

    .header-buttons {
        width: 100%;
    }

    .header-buttons .btn {
        font-size: 11px;
        padding: 8px;
    }

    /* Tab switcher */
    .tab-switcher {
        flex-wrap: wrap;
        gap: 6px;
    }

    .tab-btn {
        padding: 10px;
        font-size: 11px;
    }

    /* Filter sections */
    .filter-section label {
        font-size: 13px;
    }

    #filterGenre, #filterFormat, #filterYear {
        font-size: 14px;
        padding: 10px;
    }

    #searchInput, #filterOwned {
        font-size: 14px;
        padding: 10px;
    }

    /* Scroll buttons - smaller on very small screens */
    .scroll-buttons {
        right: 5px;
        bottom: 70px;
        gap: 6px;
    }

    .scroll-btn {
        padding: 8px 10px;
        font-size: 10px;
        min-width: 60px;
    }

    /* Movie cards */
    .movie-card {
        padding: 12px;
    }

    .movie-card:active {
        background: #3d4a61;
    }

    .movie-card-title {
        font-size: 14px;
    }

    /* Modal adjustments */
    .modal-content {
        width: 98%;
        margin: 5px;
    }

    .modal-header {
        padding: 15px;
    }

    .modal-header h2 {
        font-size: 1.1rem;
    }

    #movieForm {
        padding: 15px;
    }

    /* Form buttons */
    .form-actions .btn {
        min-height: 44px;
        font-size: 14px;
    }

    /* Bottom actions */
    .bottom-actions {
        margin: 15px 0;
    }

    .btn-large {
        width: 100%;
        min-height: 50px;
    }

    /* Movie detail modal */
    #movieDetailModal.modal.show {
        align-items: flex-start; /* Start from top on mobile to prevent cutoff */
        padding: 5px; /* Smaller padding on mobile */
    }

    .movie-detail-modal {
        width: 100% !important;
        max-width: 100% !important;
        max-height: 100vh;
        margin: 0 !important;
        border-radius: 8px;
    }

    .movie-detail-modal .modal-content {
        width: 100% !important;
        max-width: calc(100vw - 10px) !important;
        margin: 0;
        border-radius: 8px;
        max-height: calc(100vh - 10px); /* Account for top/bottom padding */
        overflow: hidden;
    }

    .movie-detail-content {
        flex-direction: column;
        display: flex !important;
        grid-template-columns: 1fr !important;
        padding: 12px;
        padding-top: 55px; /* Add space for sticky close button */
        padding-bottom: 30px; /* Extra padding at bottom for easier scrolling */
        overflow-y: auto;
        overflow-x: hidden;
        -webkit-overflow-scrolling: touch; /* Smooth scrolling on iOS */
        max-height: calc(100vh - 30px);
    }

    .movie-detail-left {
        width: 100%;
        max-width: 100%;
    }

    .movie-detail-poster-container {
        max-width: 200px;
        margin: 0 auto;
    }

    .movie-detail-title {
        font-size: 20px;
    }

    /* IMDb button container on mobile */
    .imdb-button-container {
        margin-top: 15px;
        margin-bottom: 10px;
    }

    .imdb-button-container .btn {
        width: 100% !important;
        min-height: 48px;
        font-size: 14px;
        padding: 12px 16px;
    }

    .movie-detail-actions {
        grid-template-columns: 1fr !important; /* Single column on mobile */
        gap: 10px;
        padding-bottom: 0;
    }

    .movie-detail-actions .btn {
        width: 100% !important;
        min-height: 48px; /* Larger touch target */
        font-size: 14px;
        padding: 12px 16px;
    }

    /* Make close button sticky on mobile so it's always visible */
    .movie-detail-modal .close {
        position: absolute;
        top: 15px;
        right: 15px;
        z-index: 1001;
        background: rgba(15, 23, 42, 0.9);
        border-radius: 50%;
        width: 44px;
        height: 44px;
        display: flex;
        align-items: center;
        justify-content: center;
        font-size: 1.8rem;
        backdrop-filter: blur(4px);
    }
}

/* Statistics Modal */
.stats-modal-content {
    width: 90%;
    max-width: 1200px;
    max-height: 90vh;
}

.stats-modal-body {
    padding: 20px;
    overflow-y: auto;
}

/* Stats Sheet Tabs */
.stats-sheet-tabs {
    display: flex;
    gap: 8px;
    margin-bottom: 15px;
    flex-wrap: wrap;
    padding-bottom: 15px;
    border-bottom: 1px solid var(--border-color);
}

.stats-sheet-btn {
    padding: 10px 16px;
    border: none;
    background: var(--bg-secondary);
    color: var(--text-secondary);
    border-radius: 8px;
    cursor: pointer;
    font-weight: 500;
    font-size: 14px;
    transition: all 0.2s ease;
}

.stats-sheet-btn:hover {
    background: var(--bg-primary);
    color: var(--text-primary);
}

.stats-sheet-btn.active {
    background: linear-gradient(135deg, #3b82f6, #2563eb);
    color: white;
}

.stats-filters {
    display: flex;
    gap: 10px;
    margin-bottom: 20px;
    flex-wrap: wrap;
}

.stats-filter-btn {
    padding: 8px 16px;
    border: 2px solid #475569;
    background: transparent;
    color: #e2e8f0;
    border-radius: 6px;
    cursor: pointer;
    font-weight: 600;
    transition: all 0.3s ease;
}

.stats-filter-btn.active {
    background: #3b82f6;
    border-color: #3b82f6;
    color: white;
}

.stats-overview {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 15px;
    margin-bottom: 30px;
}

.stats-card {
    background: linear-gradient(135deg, #334155, #475569);
    padding: 20px;
    border-radius: 8px;
    text-align: center;
}

.stat-value {
    font-size: 36px;
    font-weight: 700;
    color: #3b82f6;
    margin-bottom: 8px;
}

.stat-label {
    font-size: 14px;
    color: #94a3b8;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.stats-charts {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(400px, 1fr));
    gap: 20px;
    margin-bottom: 30px;
}

.chart-container {
    background: #1e293b;
    padding: 20px;
    border-radius: 8px;
    height: 300px;
}

.chart-container h3 {
    margin: 0 0 15px 0;
    color: #e2e8f0;
}

.chart-container canvas {
    max-height: 250px;
}

.stats-top-lists {
    display: grid;
    grid-template-columns: 1fr;
    gap: 20px;
}

.top-list {
    background: #1e293b;
    padding: 20px;
    border-radius: 8px;
}

.top-list h3 {
    margin: 0 0 15px 0;
    color: #e2e8f0;
}

.top-list ol {
    margin: 0;
    padding-left: 25px;
    color: #cbd5e1;
}

.top-list li {
    margin: 8px 0;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

/* Stats grid for multiple lists */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 20px;
}

/* Badges for stats */
.rating-badge {
    background: linear-gradient(135deg, #10b981, #059669);
    color: white;
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 600;
}

.count-badge {
    background: #334155;
    color: #94a3b8;
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 12px;
}

/* Format breakdown */
.format-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.format-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 12px;
    background: #334155;
    border-radius: 6px;
}

.format-name {
    color: #e2e8f0;
    font-weight: 500;
}

.format-count {
    background: #3b82f6;
    color: white;
    padding: 2px 10px;
    border-radius: 12px;
    font-size: 13px;
    font-weight: 600;
}

/* Total runtime display */
.total-runtime {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    margin-top: 24px;
    padding: 16px;
    background: linear-gradient(135deg, #1e293b, #334155);
    border-radius: 12px;
    border: 1px solid #475569;
}

.runtime-icon {
    font-size: 24px;
}

.runtime-label {
    color: #94a3b8;
    font-size: 14px;
}

.runtime-value {
    color: #10b981;
    font-size: 20px;
    font-weight: 700;
}

.runtime-days {
    color: #64748b;
    font-size: 13px;
}

/* Compact years grid */
.years-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(80px, 1fr));
    gap: 6px;
    max-height: 300px;
    overflow-y: auto;
}

.year-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 6px 10px;
    background: #334155;
    border-radius: 4px;
    font-size: 13px;
}

.year-item .year-name {
    color: #e2e8f0;
    font-weight: 500;
}

.year-item .year-count {
    color: #3b82f6;
    font-weight: 600;
}

/* Light mode stats */
body.light-mode .rating-badge {
    background: linear-gradient(135deg, #059669, #047857);
}

body.light-mode .count-badge {
    background: #e2e8f0;
    color: #475569;
}

body.light-mode .format-item {
    background: #e2e8f0;
}

body.light-mode .format-name {
    color: #1e293b;
}

body.light-mode .total-runtime {
    background: linear-gradient(135deg, #f1f5f9, #e2e8f0);
    border-color: #cbd5e1;
}

body.light-mode .runtime-label {
    color: #475569;
}

body.light-mode .runtime-days {
    color: #64748b;
}

body.light-mode .stats-sheet-btn {
    background: #e2e8f0;
    color: #475569;
}

body.light-mode .stats-sheet-btn:hover {
    background: #cbd5e1;
    color: #1e293b;
}

body.light-mode .stats-sheet-btn.active {
    background: linear-gradient(135deg, #3b82f6, #2563eb);
    color: white;
}

body.light-mode .year-item {
    background: #e2e8f0;
}

body.light-mode .year-item .year-name {
    color: #1e293b;
}

body.light-mode .year-item .year-count {
    color: #2563eb;
}

@media (max-width: 768px) {
    .stats-sheet-tabs {
        display: grid;
        grid-template-columns: repeat(2, 1fr);
        gap: 6px;
    }

    .stats-sheet-btn {
        padding: 8px 10px;
        font-size: 12px;
    }

    .stats-filters {
        flex-wrap: wrap;
    }

    .stats-filter-btn {
        padding: 6px 12px;
        font-size: 12px;
    }

    .stats-charts {
        grid-template-columns: 1fr;
    }

    .stats-grid {
        grid-template-columns: 1fr;
    }

    .chart-container {
        height: 250px;
    }

    .stats-overview {
        grid-template-columns: repeat(2, 1fr);
    }

    .years-grid {
        grid-template-columns: repeat(auto-fill, minmax(70px, 1fr));
        gap: 4px;
    }

    .year-item {
        padding: 4px 8px;
        font-size: 12px;
    }
}

/* Barcode Scanner Styles */
.barcode-scanner-content {
    max-width: 600px;
    width: 90%;
}

.barcode-scanner-content .modal-body {
    padding: 20px;
    max-height: 80vh;
    overflow-y: auto;
}

.barcode-reader {
    width: 100%;
    min-height: 300px;
    background: #1e293b;
    border-radius: 8px;
    margin: 20px 0;
    position: relative;
    overflow: visible;
}

.scanner-message {
    text-align: center;
    padding: 15px;
    background: #334155;
    border-radius: 8px;
    margin-bottom: 10px;
    color: #e2e8f0;
    font-size: 14px;
    position: relative;
    z-index: 10;
    line-height: 1.6;
}

.scanner-message.success {
    background: #10b981;
    color: white;
    font-weight: 600;
}

.scanner-message.error {
    background: #ef4444;
    color: white;
    padding: 20px;
    font-size: 15px;
    line-height: 1.8;
}

.scanner-controls {
    display: flex;
    justify-content: center;
    gap: 10px;
    margin-top: 15px;
}

/* Override html5-qrcode styles */
#barcodeScannerReader video {
    width: 100% !important;
    height: auto !important;
    border-radius: 8px;
}

#barcodeScannerReader canvas {
    position: absolute !important;
    top: 0 !important;
    left: 0 !important;
}

@media (max-width: 768px) {
    .barcode-scanner-content {
        width: 95%;
        max-width: none;
    }

    .barcode-reader {
        min-height: 250px;
    }
}

/* ============= NEW FULLSCREEN BARCODE SCANNER ============= */

/* Header Scan Button - matches .btn-add height */
.btn-scan-barcode {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 12px 20px;
    background: linear-gradient(135deg, #8b5cf6, #6d28d9);
    color: white;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-weight: 600;
    font-size: 14px;
    transition: all 0.2s ease;
    box-shadow: 0 2px 8px rgba(139, 92, 246, 0.3);
    flex-shrink: 0;
    white-space: nowrap;
    height: 44px; /* Match Add Movie button height */
    box-sizing: border-box;
}

/* Boutique Release styling in scanned movie modal */
.scanned-movie-edition.boutique-release {
    background: linear-gradient(135deg, rgba(168, 85, 247, 0.15), rgba(139, 92, 246, 0.1));
    border: 1px solid rgba(168, 85, 247, 0.3);
    border-radius: 12px;
    padding: 16px;
    margin-bottom: 16px;
}

.scanned-movie-edition.boutique-release h4 {
    color: #a855f7;
    font-size: 16px;
    margin-bottom: 12px;
}

.edition-tag.label.boutique {
    background: linear-gradient(135deg, #a855f7, #7c3aed);
    color: white;
    font-weight: 700;
    padding: 8px 16px;
    font-size: 14px;
    border-radius: 20px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* Product Images Section (from UPC database) */
.product-images-section {
    background: rgba(30, 41, 59, 0.6);
    border: 1px solid rgba(148, 163, 184, 0.2);
    border-radius: 12px;
    padding: 16px;
    margin-bottom: 16px;
}

.product-images-section h4 {
    color: #94a3b8;
    font-size: 14px;
    font-weight: 600;
    margin-bottom: 12px;
}

.product-images-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(80px, 1fr));
    gap: 10px;
    max-width: 100%;
}

.product-image-thumb {
    width: 100%;
    height: 80px;
    object-fit: contain;
    background: rgba(15, 23, 42, 0.5);
    border-radius: 8px;
    cursor: pointer;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    border: 1px solid rgba(148, 163, 184, 0.1);
}

.product-image-thumb:hover {
    transform: scale(1.05);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    border-color: rgba(139, 92, 246, 0.5);
}

.btn-scan-barcode:hover {
    background: linear-gradient(135deg, #7c3aed, #5b21b6);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(139, 92, 246, 0.4);
}

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

.btn-scan-barcode .barcode-icon {
    width: 28px;
    height: 18px;
}

.btn-scan-barcode .scan-text {
    font-size: 14px;
}

/* Fullscreen Scanner Overlay */
.scanner-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: #000;
    z-index: 10000;
    display: none;
    flex-direction: column;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.scanner-overlay.active {
    display: flex;
    opacity: 1;
}

.scanner-overlay-header {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px 20px;
    background: rgba(0, 0, 0, 0.8);
    position: relative;
    z-index: 10;
}

.scanner-close-btn {
    position: absolute;
    left: 16px;
    width: 44px;
    height: 44px;
    background: rgba(255, 255, 255, 0.1);
    border: none;
    border-radius: 50%;
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

.scanner-close-btn:hover {
    background: rgba(255, 255, 255, 0.2);
}

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

.scanner-title {
    display: flex;
    align-items: center;
    gap: 12px;
    color: white;
    font-size: 18px;
    font-weight: 600;
}

.scanner-title-icon {
    width: 32px;
    height: 20px;
    fill: #a78bfa;
}

/* Scanner Viewport */
.scanner-viewport-container {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    overflow: hidden;
}

.scanner-viewport {
    width: 100%;
    height: 100%;
    position: absolute;
    top: 0;
    left: 0;
}

.scanner-viewport video {
    width: 100% !important;
    height: 100% !important;
    object-fit: cover;
}

/* Scanner Frame with Corners */
.scanner-frame {
    position: absolute;
    width: 280px;
    height: 180px;
    pointer-events: none;
}

.scanner-corner {
    position: absolute;
    width: 30px;
    height: 30px;
    border: 3px solid #a78bfa;
}

.scanner-corner.top-left {
    top: 0;
    left: 0;
    border-right: none;
    border-bottom: none;
    border-radius: 8px 0 0 0;
}

.scanner-corner.top-right {
    top: 0;
    right: 0;
    border-left: none;
    border-bottom: none;
    border-radius: 0 8px 0 0;
}

.scanner-corner.bottom-left {
    bottom: 0;
    left: 0;
    border-right: none;
    border-top: none;
    border-radius: 0 0 0 8px;
}

.scanner-corner.bottom-right {
    bottom: 0;
    right: 0;
    border-left: none;
    border-top: none;
    border-radius: 0 0 8px 0;
}

/* Animated Laser Line */
.scanner-laser {
    position: absolute;
    left: 10px;
    right: 10px;
    height: 2px;
    background: linear-gradient(90deg, transparent, #a78bfa, #8b5cf6, #a78bfa, transparent);
    box-shadow: 0 0 8px #a78bfa, 0 0 16px #8b5cf6;
    animation: scanLaser 2s ease-in-out infinite;
}

@keyframes scanLaser {
    0%, 100% {
        top: 20%;
        opacity: 0.8;
    }
    50% {
        top: 80%;
        opacity: 1;
    }
}

/* Scanner Status */
.scanner-status {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    padding: 16px 20px;
    background: rgba(0, 0, 0, 0.8);
}

.scanner-status-icon {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: #4ade80;
    animation: statusPulse 1.5s ease-in-out infinite;
}

@keyframes statusPulse {
    0%, 100% {
        opacity: 1;
        transform: scale(1);
    }
    50% {
        opacity: 0.5;
        transform: scale(0.8);
    }
}

.scanner-status-text {
    color: #e2e8f0;
    font-size: 15px;
    font-weight: 500;
}

.scanner-status.loading .scanner-status-icon {
    background: #fbbf24;
}

.scanner-status.success .scanner-status-icon {
    background: #4ade80;
    animation: none;
}

.scanner-status.error .scanner-status-icon {
    background: #ef4444;
    animation: none;
}

/* Scanner Footer */
.scanner-footer {
    padding: 16px 20px;
    background: rgba(0, 0, 0, 0.8);
    text-align: center;
}

.scanner-hint {
    color: #94a3b8;
    font-size: 13px;
    margin: 0;
}

/* Scanned Movie Modal */
.scanned-movie-modal {
    max-width: 600px;
    width: 95%;
}

.scanned-movie-content {
    padding: 24px;
}

.scanned-movie-header {
    display: flex;
    gap: 20px;
    margin-bottom: 24px;
}

.scanned-movie-poster {
    width: 140px;
    height: 210px;
    object-fit: cover;
    border-radius: 8px;
    background: #334155;
    flex-shrink: 0;
}

.scanned-movie-info {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.scanned-movie-title {
    font-size: 22px;
    font-weight: 700;
    color: #f1f5f9;
    margin: 0;
    line-height: 1.3;
}

.scanned-movie-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    color: #94a3b8;
    font-size: 14px;
}

.scanned-movie-meta span {
    display: flex;
    align-items: center;
    gap: 4px;
}

.scanned-movie-overview {
    color: #cbd5e1;
    font-size: 14px;
    line-height: 1.6;
    margin: 0;
}

.scanned-movie-edition {
    margin-top: 16px;
    padding: 16px;
    background: #1e293b;
    border-radius: 8px;
    border-left: 4px solid #8b5cf6;
}

.scanned-movie-edition h4 {
    color: #a78bfa;
    font-size: 13px;
    font-weight: 600;
    margin: 0 0 8px 0;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.edition-info {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.edition-tag {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px 10px;
    background: #334155;
    border-radius: 4px;
    font-size: 13px;
    color: #e2e8f0;
}

.edition-tag.label {
    background: linear-gradient(135deg, #8b5cf6, #6d28d9);
    color: white;
}

.edition-tag.edition {
    background: linear-gradient(135deg, #3b82f6, #2563eb);
    color: white;
}

/* Edit Edition Button */
.edit-edition-btn {
    background: transparent;
    border: 1px dashed #64748b;
    color: #94a3b8;
    padding: 4px 10px;
    border-radius: 4px;
    font-size: 13px;
    cursor: pointer;
    transition: all 0.2s;
}

.edit-edition-btn:hover {
    border-color: #8b5cf6;
    color: #a78bfa;
}

/* Scanned Movie Actions */
.scanned-movie-actions {
    display: flex;
    gap: 12px;
    margin-top: 24px;
}

.scanned-movie-actions .btn {
    flex: 1;
    padding: 14px 20px;
    font-size: 15px;
    font-weight: 600;
}

.btn-add-collection {
    background: linear-gradient(135deg, #10b981, #059669);
    color: white;
    border: none;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.btn-add-collection:hover {
    background: linear-gradient(135deg, #059669, #047857);
}

.btn-scan-again {
    background: #334155;
    color: #e2e8f0;
    border: 2px solid #475569;
}

.btn-scan-again:hover {
    background: #475569;
}

/* Loading state for scan */
.scan-loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 60px 20px;
    gap: 20px;
}

.scan-loading .spinner {
    width: 48px;
    height: 48px;
    border: 4px solid #334155;
    border-top-color: #8b5cf6;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

.scan-loading-text {
    color: #94a3b8;
    font-size: 15px;
}

/* Mobile Responsiveness */
@media (max-width: 480px) {
    .btn-scan-barcode {
        padding: 6px 12px;
    }

    .btn-scan-barcode .barcode-icon {
        width: 24px;
        height: 16px;
    }

    .btn-scan-barcode .scan-text {
        display: none;
    }

    .scanner-frame {
        width: 250px;
        height: 160px;
    }

    .scanned-movie-header {
        flex-direction: column;
        align-items: center;
        text-align: center;
    }

    .scanned-movie-meta {
        justify-content: center;
    }

    .scanned-movie-actions {
        flex-direction: column;
    }
}

/* ============= SORT MODAL (Mobile) ============= */

/* Hide sort button on desktop, show on mobile */
.mobile-only {
    display: none !important;
}

/* Force show on desktop when in card/poster view */
.mobile-only.show-desktop {
    display: inline-flex !important;
    align-items: center;
    justify-content: center;
}

@media (max-width: 768px) {
    .mobile-only {
        display: inline-flex !important;
        align-items: center;
        justify-content: center;
    }
}

/* Sort Modal Styles */
.sort-modal {
    max-width: 400px;
    padding: 20px;
}

.sort-modal h2 {
    margin: 0 0 20px 0;
    color: #e2e8f0;
    font-size: 20px;
    text-align: center;
}

.sort-options {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.sort-option {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 16px;
    background: #334155;
    border: 2px solid #475569;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
    width: 100%;
    text-align: left;
}

.sort-option:hover {
    background: #3b82f6;
    border-color: #3b82f6;
}

.sort-option:active {
    transform: scale(0.98);
}

.sort-option.active {
    background: #3b82f6;
    border-color: #3b82f6;
}

.sort-icon {
    font-size: 20px;
    width: 28px;
    text-align: center;
}

.sort-label {
    color: #e2e8f0;
    font-size: 15px;
    font-weight: 500;
}

/* ============= FILTER MODAL STYLES ============= */
.filter-modal {
    max-width: 500px;
    padding: 24px;
}

.filter-modal h2 {
    margin: 0 0 20px 0;
    color: #e2e8f0;
    font-size: 22px;
    text-align: center;
}

.filter-modal-content {
    display: flex;
    flex-direction: column;
    gap: 16px;
    max-height: 60vh;
    overflow-y: auto;
    padding-right: 8px;
}

.filter-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.filter-group label {
    color: #94a3b8;
    font-size: 13px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.filter-group input,
.filter-group select {
    padding: 12px 14px;
    background: #334155;
    border: 2px solid #475569;
    border-radius: 8px;
    color: #e2e8f0;
    font-size: 15px;
    transition: border-color 0.2s ease;
}

.filter-group input:focus,
.filter-group select:focus {
    outline: none;
    border-color: #3b82f6;
}

.filter-group input::placeholder {
    color: #64748b;
}

.range-inputs {
    display: flex;
    align-items: center;
    gap: 10px;
}

.range-inputs input {
    flex: 1;
    min-width: 0;
}

.range-separator {
    color: #64748b;
    font-size: 14px;
}

.filter-modal-actions {
    display: flex;
    gap: 12px;
    margin-top: 20px;
    padding-top: 16px;
    border-top: 1px solid #334155;
}

.filter-modal-actions .btn {
    flex: 1;
    padding: 14px;
    font-size: 15px;
    font-weight: 600;
}

/* Filter modal mobile optimizations */
@media (max-width: 600px) {
    .filter-modal {
        max-width: 100%;
        margin: 10px;
        padding: 16px;
    }

    .filter-modal h2 {
        font-size: 18px;
        margin-bottom: 16px;
    }

    .filter-modal-content {
        gap: 12px;
        max-height: 55vh;
    }

    .filter-group {
        gap: 4px;
    }

    .filter-group label {
        font-size: 11px;
    }

    .filter-group input,
    .filter-group select {
        padding: 10px 12px;
        font-size: 14px;
    }

    .range-inputs {
        gap: 6px;
    }

    .range-separator {
        font-size: 12px;
    }

    .filter-modal-actions {
        margin-top: 16px;
        padding-top: 12px;
        gap: 8px;
    }

    .filter-modal-actions .btn {
        padding: 12px;
        font-size: 14px;
    }
}

/* Filter count badge on button */
.filter-count {
    background: #ef4444;
    color: white;
    font-size: 11px;
    font-weight: bold;
    padding: 2px 6px;
    border-radius: 10px;
    margin-left: 4px;
}

/* Filter bar mobile adjustments */
@media (max-width: 768px) {
    .filters-bar {
        flex-direction: column;
        gap: 10px;
    }

    .filters-bar .btn-filter {
        width: 100%;
        justify-content: center;
    }

    .filters-bar #searchInput {
        width: 100%;
        min-width: unset;
    }
}

/* Very small screens (320px) - prevent overflow */
@media (max-width: 400px) {
    .filters-bar {
        padding: 10px 12px;
        gap: 8px;
    }

    .filters-bar .btn-filter {
        padding: 10px 14px;
        font-size: 13px;
    }

    .filters-bar #searchInput {
        padding: 10px 12px;
        font-size: 14px;
    }

    .filters-bar .btn-add {
        padding: 10px 14px;
        font-size: 13px;
    }

    /* Card grid for very small screens */
    body.card-view .movies-grid {
        grid-template-columns: 1fr;
        gap: 12px;
    }

    /* Movie cards on very small screens */
    .movie-card {
        padding: 12px;
    }

    .movie-card-header h3 {
        font-size: 15px;
    }
}

/* Light mode filter bar */
body.light-mode .filters-bar {
    background: var(--bg-tertiary);
    border-color: var(--border-color);
}

body.light-mode .btn-filter {
    background: linear-gradient(135deg, #2563eb, #1d4ed8);
}

body.light-mode #searchInput {
    background: var(--bg-secondary);
    border-color: var(--border-light);
    color: var(--text-primary);
}

/* ============= PWA INSTALL BANNER ============= */
.install-banner {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    background: linear-gradient(135deg, #10b981, #059669);
    padding: 12px 16px;
    z-index: 9999;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.3);
}

.install-banner-content {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    max-width: 600px;
    margin: 0 auto;
    flex-wrap: wrap;
}

.install-icon {
    font-size: 24px;
}

.install-text {
    color: white;
    font-size: 14px;
    font-weight: 500;
}

.install-banner .btn-sm {
    padding: 8px 16px;
    font-size: 13px;
    background: white;
    color: #10b981;
    border: none;
}

.install-banner .btn-sm:hover {
    background: #f1f5f9;
}

.install-dismiss {
    background: none;
    border: none;
    color: white;
    font-size: 24px;
    cursor: pointer;
    padding: 0 8px;
    opacity: 0.8;
    line-height: 1;
}

.install-dismiss:hover {
    opacity: 1;
}

@media (max-width: 480px) {
    .install-banner-content {
        gap: 8px;
    }

    .install-text {
        flex: 1;
        font-size: 13px;
    }
}

/* ============= OFFLINE INDICATOR ============= */
.offline-indicator {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: linear-gradient(135deg, #ef4444, #dc2626);
    padding: 6px 12px;
    border-radius: 20px;
    margin-left: 12px;
    animation: pulse-offline 2s ease-in-out infinite;
}

.offline-indicator.syncing {
    background: linear-gradient(135deg, #f59e0b, #d97706);
    animation: none;
}

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

.offline-icon {
    font-size: 14px;
}

.offline-text {
    color: white;
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.pending-sync-badge {
    background: white;
    color: #ef4444;
    font-size: 11px;
    font-weight: 700;
    padding: 2px 6px;
    border-radius: 10px;
    min-width: 18px;
    text-align: center;
}

/* Syncing state */
.offline-indicator.syncing .pending-sync-badge {
    color: #f59e0b;
}

@media (max-width: 480px) {
    .offline-indicator {
        padding: 4px 8px;
        margin-left: 8px;
    }

    .offline-text {
        font-size: 10px;
    }
}

/* ============= BULK SELECTION MODE ============= */
.bulk-action-bar {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: linear-gradient(135deg, #1e293b 0%, #0f172a 100%);
    border-top: 2px solid #3b82f6;
    padding: 15px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    z-index: 1000;
    box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.3);
}

.bulk-action-info {
    font-size: 16px;
    font-weight: 600;
    color: #3b82f6;
}

.bulk-action-buttons {
    display: flex;
    gap: 10px;
}

.bulk-action-buttons .btn {
    padding: 10px 16px;
}

/* Selection mode checkbox on cards */
.movie-card.selectable {
    position: relative;
}

.movie-card .select-checkbox {
    display: none;
    position: absolute;
    top: 10px;
    left: 10px;
    width: 24px;
    height: 24px;
    z-index: 10;
    cursor: pointer;
    accent-color: #3b82f6;
}

body.selection-mode .movie-card .select-checkbox {
    display: block;
}

body.selection-mode .movie-card {
    padding-left: 45px;
}

.movie-card.selected {
    border-color: #3b82f6 !important;
    box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.5), 0 4px 12px rgba(0, 0, 0, 0.3);
}

/* Poster card selection */
.poster-card .select-checkbox {
    display: none;
    position: absolute;
    top: 8px;
    left: 8px;
    width: 24px;
    height: 24px;
    z-index: 10;
    cursor: pointer;
    accent-color: #3b82f6;
}

body.selection-mode .poster-card .select-checkbox {
    display: block;
}

.poster-card.selected {
    outline: 3px solid #3b82f6;
    outline-offset: -3px;
}

/* Table row selection */
.movies-table tbody tr .select-checkbox {
    display: none;
}

body.selection-mode .movies-table tbody tr .select-checkbox {
    display: inline-block;
}

body.selection-mode .movies-table tbody tr.selected {
    background: rgba(59, 130, 246, 0.2) !important;
}

/* Selection mode button active state */
#selectModeBtn.active {
    background: #3b82f6;
    color: white;
}

/* Mobile styles */
@media (max-width: 480px) {
    .bulk-action-bar {
        flex-direction: column;
        gap: 10px;
        padding: 12px 15px;
    }

    .bulk-action-buttons {
        width: 100%;
        justify-content: center;
    }

    .bulk-action-buttons .btn {
        padding: 8px 12px;
        font-size: 13px;
    }
}

/* ============= SETTINGS MODAL ============= */
.settings-modal {
    max-width: 750px;
    width: 90%;
    padding: 32px 40px;
    border-radius: 16px;
    max-height: 85vh;
    overflow-y: auto;
}

.settings-modal h2 {
    margin-bottom: 12px;
    font-size: 20px;
}

.settings-description {
    color: #94a3b8;
    font-size: 14px;
    margin-bottom: 24px;
    line-height: 1.5;
}

.settings-options {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 14px;
    margin-bottom: 28px;
}

.settings-checkbox {
    display: flex;
    align-items: center;
    gap: 12px;
    cursor: pointer;
    padding: 14px 16px;
    background: #1e293b;
    border-radius: 10px;
    border: 1px solid #334155;
    transition: all 0.2s ease;
}

.settings-checkbox:hover {
    background: #334155;
    border-color: #475569;
}

.settings-checkbox input[type="checkbox"] {
    width: 20px;
    height: 20px;
    cursor: pointer;
    accent-color: #3b82f6;
    flex-shrink: 0;
}

.settings-checkbox span {
    font-size: 14px;
    color: #e2e8f0;
    line-height: 1.3;
}

.settings-section {
    margin-top: 24px;
    padding-top: 24px;
    border-top: 1px solid #334155;
}

.settings-section h3 {
    font-size: 15px;
    color: #94a3b8;
    margin-bottom: 16px;
    font-weight: 500;
}

.settings-section .settings-checkbox {
    width: 100%;
}

.settings-actions {
    display: flex;
    gap: 14px;
    margin-top: 28px;
    justify-content: flex-end;
}

.settings-actions .btn {
    padding: 12px 20px;
    font-size: 14px;
}

body.light-mode .settings-checkbox {
    background: #f8fafc;
    border-color: #e2e8f0;
}

body.light-mode .settings-checkbox:hover {
    background: #e2e8f0;
    border-color: #cbd5e1;
}

body.light-mode .settings-checkbox span {
    color: #334155;
}

body.light-mode .settings-section {
    border-top-color: #e2e8f0;
}

body.light-mode .settings-description {
    color: #64748b;
}

/* Appearance Options */
.appearance-options {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.appearance-option {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 16px;
    background: var(--bg-tertiary);
    border-radius: 8px;
    border: 1px solid var(--border-color);
}

.appearance-label {
    font-size: 14px;
    font-weight: 500;
    color: var(--text-primary);
}

.toggle-buttons {
    display: flex;
    gap: 4px;
    background: var(--bg-primary);
    padding: 4px;
    border-radius: 8px;
}

.toggle-btn {
    padding: 8px 12px;
    font-size: 13px;
    font-weight: 500;
    border: none;
    border-radius: 6px;
    background: transparent;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.2s ease;
    white-space: nowrap;
}

.toggle-btn:hover {
    color: var(--text-primary);
    background: var(--bg-tertiary);
}

.toggle-btn.active {
    background: var(--accent-primary);
    color: white;
}

body.light-mode .appearance-option {
    background: #f1f5f9;
    border-color: #e2e8f0;
}

body.light-mode .toggle-buttons {
    background: #e2e8f0;
}

body.light-mode .toggle-btn:hover {
    background: #cbd5e1;
}

@media (max-width: 480px) {
    .appearance-option {
        flex-direction: column;
        gap: 12px;
        align-items: flex-start;
    }

    .toggle-buttons {
        width: 100%;
        justify-content: center;
    }

    .toggle-btn {
        flex: 1;
        text-align: center;
        padding: 10px 8px;
    }
}

/* Keyboard Shortcuts Grid */
.shortcuts-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
}

.shortcut-item {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 13px;
    color: var(--text-secondary);
}

.shortcut-item kbd {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 28px;
    height: 26px;
    padding: 0 8px;
    font-family: inherit;
    font-size: 12px;
    font-weight: 600;
    color: var(--text-primary);
    background: var(--bg-tertiary);
    border: 1px solid var(--border-light);
    border-radius: 6px;
    box-shadow: 0 2px 0 var(--border-color);
}

.shortcut-item span {
    color: var(--text-secondary);
}

@media (max-width: 480px) {
    .shortcuts-grid {
        grid-template-columns: 1fr;
        gap: 8px;
    }
}

/* ============= ACHIEVEMENTS MODAL ============= */
.achievements-modal {
    max-width: 600px;
    padding: 28px 32px;
    max-height: 85vh;
    overflow-y: auto;
}

.achievements-modal h2 {
    margin-bottom: 20px;
    font-size: 22px;
}

.achievements-summary {
    display: flex;
    gap: 20px;
    margin-bottom: 28px;
    justify-content: center;
}

.achievement-stat {
    text-align: center;
    padding: 16px 24px;
    background: var(--bg-tertiary);
    border-radius: 12px;
    min-width: 100px;
}

.achievement-stat-value {
    display: block;
    font-size: 28px;
    font-weight: 700;
    color: var(--text-primary);
}

.achievement-stat-label {
    font-size: 12px;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.streak-stat {
    background: linear-gradient(135deg, #f97316, #ea580c);
}

.streak-stat .achievement-stat-value,
.streak-stat .achievement-stat-label {
    color: white;
}

.achievements-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 14px;
}

.achievement-card {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 16px;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    transition: all 0.2s ease;
}

.achievement-card.locked {
    opacity: 0.5;
    filter: grayscale(0.8);
}

.achievement-card.unlocked {
    background: linear-gradient(135deg, rgba(16, 185, 129, 0.1), rgba(59, 130, 246, 0.1));
    border-color: #10b981;
}

.achievement-icon {
    font-size: 32px;
    flex-shrink: 0;
    width: 48px;
    height: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-tertiary);
    border-radius: 10px;
}

.achievement-card.unlocked .achievement-icon {
    background: linear-gradient(135deg, #10b981, #3b82f6);
}

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

.achievement-name {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 4px;
}

.achievement-desc {
    font-size: 12px;
    color: var(--text-secondary);
    line-height: 1.4;
}

.achievement-card.unlocked .achievement-name {
    color: #10b981;
}

.achievement-progress {
    margin-top: 8px;
    height: 4px;
    background: var(--bg-tertiary);
    border-radius: 2px;
    overflow: hidden;
}

.achievement-progress-bar {
    height: 100%;
    background: linear-gradient(90deg, #10b981, #3b82f6);
    border-radius: 2px;
    transition: width 0.3s ease;
}

@media (max-width: 600px) {
    .achievements-modal {
        padding: 20px;
    }

    .achievements-grid {
        grid-template-columns: 1fr;
    }

    .achievements-summary {
        flex-wrap: wrap;
        gap: 12px;
    }

    .achievement-stat {
        flex: 1;
        min-width: 80px;
        padding: 12px 16px;
    }

    .achievement-stat-value {
        font-size: 24px;
    }
}

/* ============= LIGHT MODE OVERRIDES ============= */
body.light-mode header {
    border-bottom-color: var(--border-color);
}

body.light-mode h1 {
    background: linear-gradient(to right, #2563eb, #7c3aed);
    -webkit-background-clip: text;
    background-clip: text;
}

body.light-mode .stat-card {
    background: var(--bg-tertiary);
    border-color: var(--border-color);
}

body.light-mode .stat-number {
    color: var(--text-primary);
}

body.light-mode .stat-label {
    color: var(--text-secondary);
}

body.light-mode .tab-btn {
    background: var(--bg-tertiary);
    color: var(--text-secondary);
    border-color: var(--border-color);
}

body.light-mode .tab-btn.active {
    background: var(--accent-primary);
    color: white;
}

body.light-mode .filters-bar {
    background: var(--bg-tertiary);
    border-color: var(--border-color);
}

body.light-mode .filters-bar select,
body.light-mode .filters-bar input {
    background: var(--bg-secondary);
    border-color: var(--border-light);
    color: var(--text-primary);
}

body.light-mode .movie-card {
    background: var(--bg-card);
    border-color: var(--border-color);
    box-shadow: 0 2px 8px var(--shadow-color);
}

body.light-mode .movie-card:hover {
    background: var(--card-hover);
    border-color: var(--accent-primary);
}

body.light-mode .movie-card-title {
    color: var(--text-primary);
}

body.light-mode .movie-meta {
    color: var(--text-secondary);
}

body.light-mode .movie-meta-label {
    color: var(--text-muted);
}

body.light-mode .modal-content {
    background: var(--modal-bg);
    border-color: var(--border-color);
}

body.light-mode .form-group label {
    color: var(--text-secondary);
}

body.light-mode .form-group input,
body.light-mode .form-group select,
body.light-mode .form-group textarea {
    background: var(--input-bg);
    border-color: var(--border-light);
    color: var(--text-primary);
}

body.light-mode .btn-secondary {
    background: var(--bg-tertiary);
    border-color: var(--border-light);
    color: var(--text-primary);
}

body.light-mode .btn-secondary:hover {
    background: var(--border-light);
}

body.light-mode th {
    background: var(--bg-tertiary);
    color: var(--text-primary);
    border-color: var(--border-color);
}

body.light-mode td {
    border-color: var(--border-color);
    color: var(--text-primary);
}

body.light-mode tr:hover td {
    background: var(--card-hover);
}

body.light-mode .movie-detail-content {
    color: var(--text-primary);
}

body.light-mode .movie-detail-meta {
    color: var(--text-secondary);
}

body.light-mode .filter-group label {
    color: var(--text-secondary);
}

body.light-mode .filter-group input,
body.light-mode .filter-group select {
    background: var(--input-bg);
    border-color: var(--border-light);
    color: var(--text-primary);
}

body.light-mode .sort-option {
    background: var(--bg-tertiary);
    border-color: var(--border-light);
}

body.light-mode .sort-label {
    color: var(--text-primary);
}

body.light-mode .stats-modal-content {
    background: var(--modal-bg);
}

body.light-mode .stats-card {
    background: var(--bg-tertiary);
}

body.light-mode .chart-container {
    background: var(--bg-tertiary);
}

body.light-mode .close {
    color: var(--text-secondary);
}

body.light-mode .close:hover {
    color: var(--text-primary);
}

/* Toast in light mode */
body.light-mode .toast {
    background: var(--bg-secondary);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
    box-shadow: 0 4px 12px var(--shadow-color);
}

/* Rating guide in light mode */
body.light-mode .rating-guide-content {
    background: var(--modal-bg);
}

body.light-mode .rating-level {
    background: var(--bg-tertiary);
    border-color: var(--border-color);
}

body.light-mode .rating-description {
    color: var(--text-secondary);
}

/* ============= PAGINATION CONTROLS ============= */
.pagination-controls {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    padding: 20px;
    margin-top: 20px;
    background: var(--bg-secondary);
    border-radius: 12px;
    border: 1px solid var(--border-color);
}

.pagination-info {
    color: var(--text-secondary);
    font-size: 14px;
}

.pagination-buttons {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
    justify-content: center;
}

.pagination-buttons .btn {
    padding: 8px 12px;
    font-size: 13px;
    min-width: auto;
}

.pagination-buttons .btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.page-indicator {
    color: var(--text-primary);
    font-weight: 500;
    padding: 0 10px;
}

@media (max-width: 480px) {
    .pagination-controls {
        padding: 15px;
    }

    .pagination-buttons {
        gap: 6px;
    }

    .pagination-buttons .btn {
        padding: 6px 10px;
        font-size: 12px;
    }

    .page-indicator {
        padding: 0 5px;
        font-size: 13px;
    }
}

/* ==================== */
/* News Page Styles     */
/* ==================== */

/* Hide movie elements when news page is active */
body.news-active .filters-bar,
body.news-active .table-container,
body.news-active .movies-grid,
body.news-active .bottom-actions,
body.news-active .pagination-container {
    display: none !important;
}

.news-page {
    padding: 20px;
    display: none;
}

body.news-active .news-page {
    display: block !important;
}

.news-header {
    text-align: center;
    margin-bottom: 30px;
}

.news-header h2 {
    font-size: 28px;
    margin-bottom: 8px;
    color: var(--text-primary);
}

.news-subtitle {
    color: var(--text-secondary);
    font-size: 14px;
    margin-bottom: 15px;
}

.news-loading {
    text-align: center;
    padding: 60px 20px;
}

.news-loading p {
    color: var(--text-secondary);
    margin-top: 15px;
}

.news-grid {
    display: grid !important;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)) !important;
    gap: 20px;
}

.news-card {
    background: var(--bg-secondary);
    border-radius: 12px;
    overflow: hidden;
    border: 1px solid var(--border-color);
    transition: transform 0.2s, box-shadow 0.2s;
    cursor: pointer;
}

.news-card:hover {
    transform: translateY(-3px);
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.3);
}

.news-card-content {
    padding: 20px;
}

.news-card-source {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 10px;
}

.news-source-badge {
    background: var(--accent-primary);
    color: white;
    padding: 3px 8px;
    border-radius: 4px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
}

.news-card-date {
    color: var(--text-secondary);
    font-size: 12px;
}

.news-card-title {
    font-size: 16px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 10px;
    line-height: 1.4;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.news-card-description {
    color: var(--text-secondary);
    font-size: 13px;
    line-height: 1.5;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.news-card-movie {
    margin-top: 12px;
    padding-top: 12px;
    border-top: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    gap: 8px;
}

.news-card-movie-tag {
    background: var(--bg-tertiary);
    color: var(--text-secondary);
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 12px;
}

.no-news-message {
    text-align: center;
    padding: 60px 20px;
    color: var(--text-secondary);
}

.no-news-message p {
    font-size: 16px;
}

/* News page mobile */
@media (max-width: 768px) {
    .news-grid {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 480px) {
    .news-header h2 {
        font-size: 24px;
    }

    .news-card-title {
        font-size: 15px;
    }
}

/* ============= ACCESSIBILITY & PERFORMANCE ============= */

/* Respect user's motion preferences */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }
}

/* ============= ENHANCED MOBILE TOUCH TARGETS ============= */

/* Ensure minimum touch target size (44x44px) for interactive elements */
@media (max-width: 768px) {
    /* Settings checkboxes */
    .settings-checkbox input[type="checkbox"] {
        width: 24px;
        height: 24px;
        min-width: 24px;
        min-height: 24px;
    }

    /* Filter and sort buttons */
    .filter-btn,
    .sort-btn {
        min-height: 44px;
        padding: 10px 16px;
    }

    /* Form inputs */
    input[type="text"],
    input[type="password"],
    input[type="number"],
    input[type="email"],
    select,
    textarea {
        min-height: 44px;
        font-size: 16px; /* Prevents iOS zoom on focus */
    }

    /* Add active states for touch feedback */
    .btn:active,
    .tab-btn:active,
    .movie-card:active,
    .poster-card:active {
        opacity: 0.8;
        transform: scale(0.98);
    }
}

/* ============= SAFE AREA INSETS (NOTCHED DEVICES) ============= */

/* Support for notched devices (iPhone X+, etc.) */
@supports (padding: env(safe-area-inset-top)) {
    body {
        padding-left: env(safe-area-inset-left);
        padding-right: env(safe-area-inset-right);
        padding-bottom: env(safe-area-inset-bottom);
    }

    /* Fixed elements need safe area adjustments */
    .scroll-buttons {
        bottom: calc(80px + env(safe-area-inset-bottom));
    }

    .tab-switcher {
        padding-bottom: env(safe-area-inset-bottom);
    }

    /* Toast container */
    .toast-container {
        bottom: calc(20px + env(safe-area-inset-bottom));
    }
}

/* ============= IMPROVED FORM LAYOUT ON SMALL SCREENS ============= */

@media (max-width: 480px) {
    /* Single column form on very small screens */
    .form-grid {
        grid-template-columns: 1fr;
        gap: 12px;
    }

    /* More compact modal padding */
    .modal-content {
        padding: 16px;
    }

    /* Larger tap targets for select dropdowns */
    select {
        padding: 12px 16px;
        background-position: right 12px center;
    }
}
