:root {
    --primary-color: #1a4d4e;
    --secondary-color: #4a5568;
    --accent-color: #c05621;
    --background-color: #1a202c;
    --text-color: #e2e8f0;
    --heading-color: #ffffff;
    --card-background: #2d3748;
    --shadow-light: 0 4px 6px rgba(0, 0, 0, 0.3);
    --shadow-medium: 0 10px 15px rgba(0, 0, 0, 0.3);
    --shadow-strong: 0 20px 25px rgba(0, 0, 0, 0.4);
}

body {
    font-family: sans-serif;
    margin: 0;
    padding: 20px;
    background-color: var(--background-color);
    color: var(--text-color);
}

.container {
    padding: 20px;
}

h1 {
    color: var(--heading-color);
    margin-bottom: 1.5rem;
}

.film-card {
    border: 1px solid var(--secondary-color);
    border-radius: 8px;
    padding: 20px;
    margin-bottom: 20px;
    background-color: var(--card-background, #fff) !important; /* Use card-background for dark mode */
    box-shadow: var(--shadow-light);
    transition: transform 0.2s ease-in-out, box-shadow 0.2s ease-in-out;
}

.film-card:hover {
    transform: translateY(-5px);
    box-shadow: var(--shadow-medium);
}

.card {
    background-color: var(--card-background) !important;
    border-color: var(--secondary-color);
}

.film-card h5 {
    color: var(--heading-color);
    font-weight: bold;
    margin-bottom: 10px;
}

.film-card p {
    margin-bottom: 8px;
    font-size: 0.95em;
}

.film-card .badge {
    margin-right: 5px;
}

.search-container {
    position: relative;
    margin-bottom: 15px;
}

.clear-search {
    position: absolute;
    right: 5px;
    top: 50%;
    transform: translateY(-50%);
    cursor: pointer;
    color: #aaa;
    font-size: 1.5em; /* Erhöht die Größe des 'x' */
    padding: 5px; /* Vergrößert die klickbare Fläche */
    display: none; /* Hidden by default */
}

.clear-search:hover {
    color: var(--text-color);
}



.notes-icon {
    cursor: pointer;
    margin-left: 8px;
    font-size: 1.3em; /* Etwas größer für bessere Sichtbarkeit */
    padding: 5px 12px; /* Große, unsichtbare Klickfläche für Touch */
    opacity: 0.7;
    transition: all 0.2s ease-in-out;
    display: inline-block;
    vertical-align: middle;
}

.notes-icon:hover {
    opacity: 1;
    transform: scale(1.1);
}

/* Shortlist Pin */
.shortlist-btn {
    cursor: pointer;
    margin-right: 10px;
    font-size: 1.1em;
    opacity: 0.3;
    transition: opacity 0.2s, transform 0.2s;
    display: inline-block;
}

.shortlist-btn:hover {
    opacity: 0.7;
    transform: scale(1.2);
}

.shortlist-btn.active {
    opacity: 1;
    filter: drop-shadow(0 0 2px gold);
}

.btn-outline-warning {
    color: #ffc107;
    border-color: #ffc107;
}

.btn-outline-warning:hover, .btn-outline-warning.active {
    background-color: #ffc107;
    color: #212529;
}

/* Table Sorting */
th.sortable {
    cursor: pointer;
    position: relative;
    padding-right: 20px; /* Space for the icon */
}

th.sortable .sort-icon {
    position: absolute;
    right: 5px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 0.8em;
    opacity: 0.4;
    transition: opacity 0.2s ease-in-out;
}

th.sortable:hover .sort-icon {
    opacity: 0.7;
}

th.sortable.sorted-asc .sort-icon::after {
    content: ' ▲'; /* Up arrow */
    opacity: 1;
}

th.sortable.sorted-desc .sort-icon::after {
    content: ' ▼'; /* Down arrow */
    opacity: 1;
}

/* Hide sort icon by default if not sorted */
th.sortable .sort-icon::after {
    content: '';
}

.text-success-available {
    color: #4CAF50 !important;
}

.text-info-available {
    color: #17a2b8 !important;
}

.text-warning-expiration {
    color: #ffc107 !important;
}

/* Overlays */
#notes-modal-body {
    max-height: 60vh; /* Adjust as needed */
    overflow-y: auto;
}

/* Table row spacing */
.table td, .table th {
    padding: .75rem;
    vertical-align: top;
    border-top: 1px solid var(--secondary-color);
    color: #ffffff;
}

.table th {
    color: #ffffff;
}

.text-danger {
    color: #ff6b6b;
}

/* Modal styling */
.modal-content {
    box-shadow: var(--shadow-strong);
    border-radius: 8px;
    background-color: var(--background-color);
    color: var(--text-color);
}

.modal-header, .modal-footer {
    border-color: var(--secondary-color);
}

.list-group-item {
    background-color: var(--card-background);
    border-color: var(--secondary-color);
    color: var(--text-color);
}

.list-group-item small.text-muted {
    color: #a0aec0 !important; /* Brighter muted text for dark mode */
}

.progress {
    background-color: var(--secondary-color);
}

.progress-bar {
    background-color: var(--primary-color);
}

/* Button styling */
.btn-primary {
    background-color: var(--primary-color);
    border-color: var(--primary-color);
    transition: background-color 0.2s ease-in-out, border-color 0.2s ease-in-out, box-shadow 0.2s ease-in-out;
}

.btn-outline-primary {
    color: #4CAF50;
    border-color: #4CAF50;
    transition: all 0.2s ease-in-out;
}

.btn-outline-primary:hover {
    background-color: #4CAF50;
    color: #fff;
}

.btn-tmdb {
    background-color: #f5c518;
    border-color: #f5c518;
    color: #000 !important;
    font-weight: bold;
}

.btn-tmdb:hover {
    background-color: #e2b616;
    border-color: #e2b616;
    color: #000 !important;
}

.form-control {
    background-color: #2d3748; /* Slightly lighter than background */
    color: var(--text-color);
    border: 1px solid #4a5568;
    border-radius: 6px;
    transition: all 0.2s ease-in-out;
}

.form-control:focus {
    background-color: #3a4454;
    border-color: #66bb6a;
    box-shadow: 0 0 0 0.2rem rgba(102, 187, 106, 0.25);
    color: #fff;
}

.form-control:disabled, 
.form-control[readonly] {
    background-color: #1a202c; /* Darker background for disabled */
    color: #a0a0a0; /* Grey text for disabled */
    opacity: 1; /* Bootstrap override */
    cursor: not-allowed;
}

/* Highlight for active filters */
.form-control.filter-active {
    border-color: #66bb6a;
    color: #66bb6a;
    font-weight: 600;
    background-color: rgba(102, 187, 106, 0.05);
}

.form-control::placeholder {
    color: #718096;
}

.btn-outline-danger {
    color: #EF5350;
    border-color: #EF5350;
}

.btn-outline-danger:hover {
    background-color: #EF5350;
    color: #fff;
}

/* Alternating row colors for tables */
.table tbody tr:nth-child(even) {
    background-color: rgba(255, 255, 255, 0.05);
}

/* Custom Badges for Table View */
.badge-custom {
    display: inline-block;
    padding: .35em .6em;
    font-size: 75%;
    font-weight: 700;
    line-height: 1;
    text-align: center;
    white-space: nowrap;
    vertical-align: baseline;
    border-radius: .5rem; /* Abgerundete Ecken */
    transition: color .15s ease-in-out, background-color .15s ease-in-out, border-color .15s ease-in-out, box-shadow .15s ease-in-out;
}

/* Neutral Badge (for Source, Category) */
.badge-neutral {
    color: #adb5bd;
    background-color: rgba(108, 117, 125, 0.2);
}

/* Priority Badges */
.badge-p1 {
    color: #ff6b6b;
    background-color: rgba(220, 53, 69, 0.2);
}

.badge-p2 {
    color: #ffdd77;
    background-color: rgba(255, 193, 7, 0.2);
}

.badge-p3 {
    color: #66bb6a;
    background-color: rgba(40, 167, 69, 0.2);
}

.text-muted-subtle {
    color: #a0a0a0;
}

/* Styles for the new sticky header on the stats page */
.stats-header {
    position: -webkit-sticky; /* For Safari */
    position: sticky;
    top: 0;
    background-color: var(--background-color);
    padding-top: 1rem;
    padding-bottom: 0.5rem;
    z-index: 1020; /* Ensures it stays above other content */
    border-bottom: 1px solid var(--secondary-color);
}

/* Quick Filter Button Badges */
.btn-group .btn {
    position: relative; /* Wichtig für die Positionierung des Badges */
    flex: 1;
    min-width: 0;
    font-size: 0.85rem;
    padding: 0.375rem 0.25rem;
}

.btn-group .btn .badge {
    position: absolute;
    top: -8px;
    right: -8px;
    padding: 5px 8px;
    border-radius: 50%;
    font-size: 0.7rem;
    font-weight: 700;
    display: none; /* Hidden by default */
    z-index: 10; /* Wichtig: Badge immer im Vordergrund */
}

/* Mobile: Buttons in zwei Reihen */
@media (max-width: 768px) {
    .btn-group {
        display: flex;
        flex-wrap: wrap;
        gap: 0.25rem;
    }
    
    .btn-group .btn {
        flex: 1 1 calc(50% - 0.125rem);
        font-size: 0.75rem;
        padding: 0.25rem 0.125rem;
    }
}

/* Desktop: Flexible Dropdown-Felder */
@media (min-width: 992px) {
    .col-lg-flex-grow {
        flex: 1 1 0; /* Equal width for growth */
        min-width: 120px;
        flex-shrink: 1;
    }
    
    .col-lg-auto {
        flex: 0 0 140px; /* Fixed width for priority */
        flex-shrink: 0;
    }
}

/* Film Title / Notes Trigger Styling */
.film-notes-trigger {
    color: var(--text-color) !important;
    text-decoration: none !important;
    cursor: pointer;
    transition: color 0.2s ease-in-out;
}

.film-notes-trigger:hover {
    color: var(--heading-color) !important;
    text-decoration: underline !important;
}

/* Edit Icon in Table View */
.edit-icon-table {
    color: var(--secondary-color);
    opacity: 0.8;
    cursor: pointer;
    transition: all 0.2s ease-in-out;
    font-size: 1.3em;
    font-weight: bold;
    text-shadow: 0 0 1px var(--secondary-color);
    padding: 0 5px;
    display: inline-block;
    vertical-align: middle;
}

.edit-icon-table:hover {
    opacity: 1;
    color: var(--primary-color);
    transform: scale(1.2);
    text-shadow: 0 0 1px var(--primary-color);
}

.badge-info {
    background-color: #17a2b8;
    color: #fff;
}

.badge-warning {
    background-color: #ffc107;
    color: #000;
}

.badge-danger {
    background-color: #dc3545;
    color: #fff;
}

/* Custom Audit Warning Alert for Dark Mode */
.alert-audit-warning {
    background-color: #3b3b3b; /* Dunkler Hintergrund */
    color: var(--text-color); /* Helle Schrift */
    border-color: #dc3545; /* Roter Rand */
}

/* Notes truncation for cards */
.notes-preview {
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
    word-break: break-word;
    max-height: 4.5em; /* Approximately 3 lines */
}

.notes-preview.expanded {
    -webkit-line-clamp: unset;
    max-height: none;
}

.notes-expand-btn {
    cursor: pointer;
    color: #4CAF50;
    font-weight: bold;
    font-size: 0.9em;
    margin-top: 0.5em;
    display: inline-block;
}

.notes-expand-btn:hover {
    text-decoration: underline;
}

/* Fix für Modal-Anzeige auf mobilen Geräten */
.modal.fade.show {
    display: block !important;
    z-index: 1050 !important;
}

.modal-backdrop {
    z-index: 1040 !important;
}

.modal-dialog {
    z-index: 1050 !important;
}

/* Stelle sicher, dass das Modal vollständig sichtbar ist */
.modal.show .modal-dialog {
    transform: none !important;
}

/* Badge-Highlight für Tabellendaten */
.badge-highlight {
    background-color: rgba(255, 255, 255, 0.15) !important;
    border-radius: 4px;
    padding: 2px 4px;
}

.btn-icon {
    width: 38px; /* Standardhöhe eines Bootstrap-Buttons */
    height: 38px; /* Gleiche Höhe für quadratische Form */
    padding: 0; /* Padding entfernen */
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 1.2em; /* Größe des Icons anpassen */
}

.btn-icon.btn-sm {
    width: 40px;
    height: 40px;
    font-size: 1.3rem;
}

/* Uniform height for all header buttons */
.d-flex.justify-content-between.align-items-center.mb-4 .btn {
    height: 40px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    white-space: nowrap;
}

#add-film-btn {
    /* Height inherited from rule above */
    padding-left: 1rem;
    padding-right: 1rem;
}

/* Series Grouping Styles */
tr.series-header {
    background-color: rgba(255, 255, 255, 0.1);
    font-weight: bold;
    cursor: pointer;
}

tr.series-header:hover {
    background-color: rgba(255, 255, 255, 0.15);
}

tr.series-child {
    background-color: rgba(0, 0, 0, 0.2);
    display: none; /* Hidden by default */
}

tr.series-child.show {
    display: table-row;
}

tr.series-child td:first-child {
    padding-left: 40px; /* Indentation for children */
    position: relative;
}

tr.series-child td:first-child::before {
    content: '↳';
    position: absolute;
    left: 15px;
    opacity: 0.5;
}

.series-toggle-btn {
    display: inline-block;
    width: 20px;
    text-align: center;
    margin-right: 5px;
    transition: transform 0.2s;
    cursor: pointer;
    user-select: none;
}

.series-toggle-btn.open {
    transform: rotate(90deg);
}

.series-count-badge {
    font-size: 0.8em;
    background: rgba(255,255,255,0.2);
    padding: 2px 6px;
    border-radius: 10px;
    margin-left: 8px;
    font-weight: normal;
}

/* Series Episode Item in Card View */
.series-episode-item {
    background-color: rgba(0, 0, 0, 0.2);
    border: 1px solid var(--secondary-color);
}

/* Floating Action Bar */
.floating-action-bar {
    position: fixed;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    background-color: #2d3748;
    border: 1px solid #4a5568;
    border-radius: 8px;
    padding: 15px 20px;
    box-shadow: 0 5px 20px rgba(0,0,0,0.5);
    z-index: 1000; /* High enough for content, but below Bootstrap Modal (1050) */
    width: 90%;
    max-width: 800px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    color: #fff;
    animation: slideUp 0.3s ease-out;
}

@keyframes slideUp {
    from { transform: translate(-50%, 100%); opacity: 0; }
    to { transform: translate(-50%, 0); opacity: 1; }
}

#selection-count {
    font-weight: bold;
    font-size: 1.1em;
}

.bulk-actions .btn {
    margin-left: 10px;
    padding: 0.5rem 1rem; /* Larger touch target */
    font-size: 0.9rem;
    border-radius: 6px !important; /* Ensure rounded corners even without btn-group */
}

/* Checkbox Column Styling */
.selection-checkbox-cell {
    width: 40px;
    text-align: center;
}

.selection-checkbox {
    transform: scale(1.5); /* Make checkboxes bigger */
    cursor: pointer;
}

/* Selection Mode Button Active State */
#selection-mode-btn.active {
    background-color: var(--primary-color);
    color: #fff;
    border-color: var(--primary-color);
}

/* Responsive Anpassung für den "Neuen Film hinzufügen"-Button auf kleinen Bildschirmen */
@media (max-width: 576px) {
  #add-film-btn {
    width: 40px; /* Match icon buttons */
    padding-left: 0;
    padding-right: 0;
    font-size: 0; /* Hide text */
    text-align: center;
  }
  
  #add-film-btn::before {
    content: "+";
    font-size: 1.8rem; /* Make the plus icon a bit larger */
    line-height: 1;
  }
}

/* Spinning Animation for Reset Button */
@keyframes spin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

.spinning {
    animation: spin 1s linear infinite;
    display: inline-block; /* Ensure it can rotate */
    pointer-events: none; /* Prevent clicking while spinning */
}

/* --- GRID VIEW STYLES --- */
.grid-view-card {
    position: relative;
    border-radius: 8px;
    overflow: hidden;
    background-color: var(--card-background);
    box-shadow: var(--shadow-light);
    transition: transform 0.2s, box-shadow 0.2s;
    cursor: pointer;
    height: 100%; /* Fill column */
}

.grid-view-card:hover {
    transform: translateY(-5px);
    box-shadow: var(--shadow-medium);
    z-index: 10;
}

/* Poster Container & Placeholder */
.grid-poster-container {
    width: 100%;
    aspect-ratio: 2/3;
    background-color: #1a202c; /* Fallback dark */
    position: relative;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
}

.grid-poster-image {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: opacity 0.3s;
}

.grid-poster-placeholder {
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #2d3748 0%, #1a202c 100%);
    color: #718096;
    padding: 10px;
    text-align: center;
}

.grid-poster-placeholder span {
    font-size: 2em;
    opacity: 0.5;
}

.grid-poster-placeholder .placeholder-title {
    font-size: 0.8em;
    margin-top: 5px;
    color: #a0aec0;
    font-weight: bold;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* Overlays */
.grid-overlay-top-right {
    position: absolute;
    top: 5px;
    right: 5px;
    display: flex;
    flex-direction: column;
    gap: 2px;
    align-items: flex-end;
    pointer-events: none; /* Let clicks pass through to card */
}

.grid-overlay-bottom-right {
    position: absolute;
    bottom: 5px;
    right: 5px;
    pointer-events: none;
}

.grid-play-button {
    background: rgba(0, 0, 0, 0.6);
    color: #fff;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1rem;
    backdrop-filter: blur(2px);
    border: 1px solid rgba(255, 255, 255, 0.2);
    opacity: 0.8;
    transition: all 0.2s ease-in-out;
    padding-left: 2px; /* Center the play triangle better visually (horizontally) */
    padding-top: 2px;  /* Center the play triangle better visually (vertically) */
}

.grid-play-button.broken {
    color: #ffc107;
    padding-left: 0;
    padding-top: 0;
    font-size: 0.9rem;
}

.grid-view-card:hover .grid-play-button {
    opacity: 1;
    background: rgba(0, 0, 0, 0.8);
    transform: scale(1.1);
}

.grid-badge {
    background: rgba(0,0,0,0.7);
    color: #fff;
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 0.8rem;
    backdrop-filter: blur(2px);
}

.grid-badge.shortlist {
    color: #ffd700;
    font-size: 1.5rem; /* Increased size */
    background: transparent;
    text-shadow: 0 0 3px rgba(0,0,0,0.8);
}

.grid-badge.warning {
    color: #ff6b6b;
    font-size: 1.5rem; /* Increased size */
    background: transparent;
    text-shadow: 0 0 3px rgba(0,0,0,0.8);
}

.grid-badge.watched {
    color: #4CAF50;
    font-size: 1.5rem;
    background: transparent;
    text-shadow: 0 0 3px rgba(0,0,0,0.8);
    font-weight: bold;
}

/* Info Section below image */
.grid-info {
    padding: 8px 10px;
    background: var(--card-background);
}

.grid-title {
    font-size: 0.95rem;
    font-weight: bold;
    color: var(--text-color);
    margin: 0 0 4px 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.grid-meta {
    display: flex;
    justify-content: space-between;
    font-size: 0.75rem;
    color: #a0aec0;
}

/* Series Stack Effect */
.grid-view-card.series-stack {
    box-shadow: 
        var(--shadow-light),
        4px 4px 0 var(--secondary-color),
        8px 8px 0 rgba(0,0,0,0.3);
    margin-bottom: 8px; /* Extra space for stack effect */
    margin-right: 8px;
}

.grid-view-card.series-stack::before {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    border: 2px solid rgba(255, 255, 255, 0.1);
    border-radius: 8px;
    pointer-events: none;
}
