/**
 * addTitle.css - Styles for Add Title Modal
 */

/* Modal size */
#addTitleModal .modal-dialog {
    max-width: 900px;
}

#addTitleModal .modal-body {
    max-height: 70vh;
    overflow-y: auto;
}

/* Search results container */
#addTitleResults {
    min-height: 200px;
}

/* ============================================
   LIST VIEW
   ============================================ */

.add-title-list {
    display: flex;
    flex-direction: column;
}

.add-title-list-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 8px 10px;
    cursor: pointer;
    border-bottom: 1px solid #f0f0f0;
    transition: background 0.15s ease;
}

.add-title-list-item:last-child {
    border-bottom: none;
}

.add-title-list-item:hover {
    background: #f8f9fa;
}

.add-title-list-item.selected {
    background: #e7f1ff;
    border-left: 3px solid #0d6efd;
}

.add-title-list-poster {
    width: 40px;
    height: 60px;
    object-fit: cover;
    border-radius: 4px;
    flex-shrink: 0;
    background: #e9ecef;
}

.add-title-list-info {
    flex: 1;
    min-width: 0;
}

.add-title-list-title {
    font-weight: 600;
    font-size: 0.9rem;
    line-height: 1.3;
    color: #212529;
}

.add-title-list-title .bi-tv,
.add-title-list-title .bi-film {
    font-size: 0.8em;
    margin-right: 2px;
}

.add-title-list-synopsis {
    font-size: 0.78rem;
    color: #6c757d;
    line-height: 1.3;
    margin-top: 2px;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.add-title-list-item.selected .add-title-list-synopsis {
    -webkit-line-clamp: unset;
    display: block;
    overflow: visible;
}

.add-title-list-action {
    flex-shrink: 0;
}

/* "Add" pill - shown on items NOT in library */
.add-pill {
    font-size: 0.75rem;
    padding: 0.3em 0.7em;
    border-radius: 12px;
}

/* ============================================
   CARD/POSTER VIEW
   ============================================ */

/* Result card */
.add-title-result {
    cursor: pointer;
    border: 2px solid transparent;
    border-radius: 8px;
    transition: all 0.2s ease;
    background: #fff;
}

.add-title-result:hover {
    border-color: #0d6efd;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    transform: translateY(-2px);
}

.add-title-result.selected {
    border: 3px solid #0d6efd;
    background: #e7f1ff;
    box-shadow: 0 0 0 3px rgba(13, 110, 253, 0.3), 0 4px 12px rgba(13, 110, 253, 0.25);
}

/* Desktop: close button on right side of description */
.result-details-accordion {
    position: relative;
}

.result-details-close {
    position: absolute;
    top: 0.25rem;
    right: 0.25rem;
    background: none;
    border: none;
    font-size: 1rem;
    color: #6c757d;
    cursor: pointer;
    padding: 0.25rem;
    line-height: 1;
    z-index: 10;
}

.result-details-close:hover {
    color: #000;
}

/* Poster wrapper */
.add-title-result .poster-wrapper {
    aspect-ratio: 2/3;
    overflow: hidden;
    border-radius: 6px 6px 0 0;
    background: #e9ecef;
}

.add-title-result .poster-wrapper img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* Result info */
.add-title-result .result-info {
    background: #f8f9fa;
    border-radius: 0 0 6px 6px;
}

.add-title-result .result-title {
    font-size: 0.9rem;
    line-height: 1.2;
}

.add-title-result .result-year {
    font-size: 0.8rem;
}

/* Selected title info panel */
#selectedTitleInfo {
    background: #f8f9fa;
    border-radius: 8px;
    border: 1px solid var(--mv-border-color);
}

#selectedTitleOverview {
    max-height: 60px;
    overflow-y: auto;
    font-size: 0.9rem;
}

/* Search input group */
.add-title-search-group {
    margin-bottom: 1rem;
}

.add-title-search-group .form-control,
.add-title-search-group .form-select {
    border-color: #ced4da;
}

.add-title-search-group .form-control:focus,
.add-title-search-group .form-select:focus {
    border-color: #86b7fe;
    box-shadow: 0 0 0 0.25rem rgba(13, 110, 253, 0.25);
}

/* Add button in header */
#addTitleBtn {
    padding: 0.25rem 0.5rem;
    font-size: 0.875rem;
}

#addTitleBtn:hover {
    transform: scale(1.05);
}

/* Badges on posters (card view) */
.add-title-result .badge {
    font-size: 0.65rem;
    padding: 0.2em 0.4em;
}

/* Loading spinner in results */
#addTitleResults .spinner-border {
    width: 2rem;
    height: 2rem;
}

/* Responsive adjustments */
@media (max-width: 768px) {
    #addTitleModal .modal-dialog {
        margin: 0.5rem;
    }

    #addTitleModal .modal-body {
        max-height: 60vh;
    }

    .add-title-result .result-title {
        font-size: 0.8rem;
    }

    .add-title-result .result-year {
        font-size: 0.7rem;
    }
}

/* Mobile: card view - 3 columns */
@media (max-width: 576px) {
    /* Search form layout */
    #addTitleModal .add-title-search-group .row {
        flex-wrap: nowrap;
    }

    /* Search input - slightly smaller to give others room */
    #addTitleModal #addTitleSearch {
        font-size: 0.9rem;
    }

    /* Year input - slightly bigger */
    #addTitleModal #addTitleYear {
        width: 60px !important;
    }

    /* Type select - slightly bigger */
    #addTitleModal #addTitleType {
        width: 60px !important;
    }

    /* Force 3 columns on mobile (card view) */
    #addTitleResults .result-col:not(.add-title-list-item) {
        flex: 0 0 33.333% !important;
        max-width: 33.333% !important;
        padding: 0.25rem !important;
    }

    /* Card styling on mobile */
    #addTitleResults .add-title-result {
        border-radius: 6px;
        border: 1px solid rgba(0, 0, 0, 0.125);
        background: #fff;
        overflow: visible;
        position: relative;
    }

    .add-title-result .poster-wrapper {
        position: relative;
        width: 100%;
        padding-top: 150%; /* 2:3 aspect ratio */
        background-color: #1a1a2e;
        border-radius: 0;
    }

    .add-title-result .poster-wrapper img {
        position: absolute;
        top: 0;
        left: 0;
        width: 100%;
        height: 100%;
        object-fit: cover;
    }

    /* Card body - tight padding */
    .add-title-result .result-info {
        padding: 0.35rem !important;
        background: #fff;
    }

    /* Title - no min-height, no margin */
    .add-title-result .result-title {
        font-size: 0.8rem;
        line-height: 1.2;
        margin: 0 !important;
        min-height: 0 !important;
    }

    /* Year - no margin, directly under title */
    .add-title-result .result-year {
        font-size: 0.7rem;
        margin: 0 !important;
    }

    /* Description - full width, covers next row on mobile */
    #addTitleResults .result-details-accordion:not(.d-none) {
        position: fixed;
        bottom: 220px;
        left: 0;
        right: 0;
        width: 100%;
        background: #fff;
        border-top: 2px solid #0d6efd;
        box-shadow: 0 -4px 12px rgba(0,0,0,0.15);
        z-index: 1000;
        padding: 0.75rem 1rem;
    }

    #addTitleResults .result-details-accordion .result-details {
        font-size: 0.9rem;
        max-height: none;
        overflow-y: visible;
        padding: 0 !important;
    }

    /* Close button for description panel */
    #addTitleResults .result-details-close {
        position: absolute;
        top: 0.5rem;
        right: 0.5rem;
        background: none;
        border: none;
        font-size: 1.25rem;
        color: #6c757d;
        cursor: pointer;
        padding: 0.25rem;
        line-height: 1;
    }

    #addTitleResults .result-details-close:hover {
        color: var(--mv-text-primary);
    }

    .add-title-result .badge {
        font-size: 0.55rem;
        padding: 0.15em 0.3em;
    }

    /* List view on mobile - slightly smaller poster */
    .add-title-list-poster {
        width: 35px;
        height: 52px;
    }

    .add-title-list-item {
        padding: 6px 8px;
        gap: 8px;
    }

    .add-title-list-title {
        font-size: 0.85rem;
    }
}

/* Year input styling */
#addTitleYear {
    max-width: 100px;
}

/* Type select styling */
#addTitleType {
    max-width: 120px;
}

/* ========================================
   DARK MODE OVERRIDES
   ======================================== */

/* List view */
[data-bs-theme="dark"] .add-title-list-item {
    border-bottom-color: var(--mv-border-color);
}
[data-bs-theme="dark"] .add-title-list-item:hover {
    background: var(--mv-bg-hover);
}
[data-bs-theme="dark"] .add-title-list-item.selected {
    background: rgba(13, 110, 253, 0.15);
}
[data-bs-theme="dark"] .add-title-list-poster {
    background: var(--mv-bg-surface);
}
[data-bs-theme="dark"] .add-title-list-title {
    color: var(--mv-text-primary);
}
[data-bs-theme="dark"] .add-title-list-synopsis {
    color: var(--mv-text-muted);
}

/* Card view */
[data-bs-theme="dark"] .add-title-result {
    background: var(--mv-bg-card);
}
[data-bs-theme="dark"] .add-title-result.selected {
    background: rgba(13, 110, 253, 0.15);
}
[data-bs-theme="dark"] .add-title-result .poster-wrapper {
    background: var(--mv-bg-surface);
}
[data-bs-theme="dark"] .add-title-result .result-info {
    background: var(--mv-bg-surface);
}
[data-bs-theme="dark"] .result-details-close {
    color: var(--mv-text-muted);
}
[data-bs-theme="dark"] .result-details-close:hover {
    color: var(--mv-text-primary);
}

/* Selected title info panel */
[data-bs-theme="dark"] #selectedTitleInfo {
    background: var(--mv-bg-surface);
    border-color: var(--mv-border-color);
}

/* Mobile description panel */
@media (max-width: 576px) {
    [data-bs-theme="dark"] #addTitleResults .result-details-accordion:not(.d-none) {
        background: var(--mv-bg-card);
        box-shadow: 0 -4px 12px rgba(0, 0, 0, 0.4);
    }
    [data-bs-theme="dark"] #addTitleResults .add-title-result {
        background: var(--mv-bg-card);
        border-color: var(--mv-border-color);
    }
    [data-bs-theme="dark"] .add-title-result .result-info {
        background: var(--mv-bg-card);
    }
}
