/* General Styles */
body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    max-width: 800px;
    margin: 0 auto;
    padding: 20px;
    background-color: #f5f5f5;
    color: #333;
}

h1 {
    color: #2c3e50;
    text-align: center;
    margin-bottom: 8px;
    font-size: 2.5em;
}

.tagline {
    text-align: center;
    color: #7f8c8d;
    font-size: 1.1em;
    margin: 0 0 24px 0;
}

.section-hint {
    color: #95a5a6;
    font-size: 0.9em;
    margin: -8px 0 12px 0;
}

.results-placeholder {
    color: #95a5a6;
    text-align: center;
    padding: 20px 0;
    font-size: 0.95em;
}

h3 {
    color: #34495e;
    margin-top: 0;
    margin-bottom: 15px;
    font-size: 1.3em;
    border-bottom: 2px solid #3498db;
    padding-bottom: 5px;
}

/* Section Container */
.section {
    background: white;
    padding: 20px;
    margin-bottom: 20px;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

/* Input Fields */
input[type="text"] {
    width: 100%;
    padding: 12px;
    font-size: 16px;
    border: 2px solid #ddd;
    border-radius: 5px;
    box-sizing: border-box;
    margin-bottom: 10px;
    transition: border-color 0.3s;
}

input[type="text"]:focus {
    outline: none;
    border-color: #3498db;
}

/* Tags Input Container */
.tags-input {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 4px;
    padding: 6px 8px;
    border: 2px solid #ddd;
    border-radius: 5px;
    background-color: white;
    cursor: text;
    margin-bottom: 10px;
    transition: border-color 0.3s;
    max-height: 72px;
    overflow: hidden;
}

.tags-input:focus-within {
    border-color: #3498db;
}

.tags-input #myInput {
    border: none;
    padding: 6px 4px;
    margin-bottom: 0;
    min-width: 80px;
    flex: 1;
    font-size: 16px;
    outline: none;
}

.tags-input #myInput:focus {
    border-color: transparent;
}

.input-clear {
    background: none;
    border: none;
    color: #bdc3c7;
    font-size: 16px;
    cursor: pointer;
    padding: 4px 8px;
    flex-shrink: 0;
    transition: color 0.2s;
    line-height: 1;
}

.input-clear:hover {
    color: #e74c3c;
}

#chipContainer {
    display: contents;
}

/* Selection Chips */
.selection-chip {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    background-color: #e8e8e8;
    border-radius: 12px;
    padding: 2px 4px 2px 8px;
    font-size: 13px;
    height: 26px;
    max-width: 180px;
    white-space: nowrap;
    flex-shrink: 0;
    transition: background-color 0.2s;
}

.selection-chip:hover {
    background-color: #d5d5d5;
}

.chip-badge {
    font-size: 8px;
    font-weight: bold;
    padding: 1px 4px;
    border-radius: 2px;
    color: white;
    letter-spacing: 0.5px;
    flex-shrink: 0;
}

.chip-badge-movie {
    background-color: #8e44ad;
}

.chip-badge-tv {
    background-color: #16a085;
}

.chip-badge-genre {
    background-color: #e67e22;
}

.chip-badge-actor {
    background-color: #2ecc71;
}

.chip-text {
    overflow: hidden;
    text-overflow: ellipsis;
    color: #333;
}

.chip-x {
    background: none;
    border: none;
    color: #888;
    font-size: 14px;
    line-height: 1;
    cursor: pointer;
    padding: 0 4px;
    border-radius: 50%;
    flex-shrink: 0;
    transition: all 0.2s;
}

.chip-x:hover {
    color: #e74c3c;
    background-color: rgba(0,0,0,0.1);
}

/* Chip Overflow Pill */
.chip-overflow {
    display: inline-flex;
    align-items: center;
    background-color: #bdc3c7;
    color: white;
    border-radius: 12px;
    padding: 2px 10px;
    font-size: 12px;
    font-weight: bold;
    height: 26px;
    flex-shrink: 0;
    cursor: pointer;
    transition: background-color 0.2s;
}

.chip-overflow:hover {
    background-color: #95a5a6;
}

/* Tabs */
.tabs {
    display: flex;
    border-bottom: 2px solid #eee;
    margin-bottom: 15px;
}

.tab {
    flex: 1;
    padding: 10px;
    text-align: center;
    font-size: 14px;
    font-weight: 600;
    color: #888;
    cursor: pointer;
    transition: all 0.2s;
    border-bottom: 3px solid transparent;
    margin-bottom: -2px;
}

.tab:hover {
    color: #555;
}

.tab.active {
    color: #3498db;
    border-bottom-color: #3498db;
}

/* Tab Content */
.tab-content {
    display: none;
}

.tab-content.active {
    display: block;
}

/* Language Filter Hint */
.lang-hint {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    background: #f0f0f0;
    border-radius: 5px;
    margin-bottom: 10px;
    font-size: 12px;
    color: #555;
    cursor: pointer;
    transition: background-color 0.2s;
}

.lang-hint:hover {
    background: #e0e0e0;
}

/* Media Type Badge */
.media-badge {
    display: inline-block;
    font-size: 10px;
    font-weight: bold;
    padding: 2px 6px;
    border-radius: 3px;
    color: white;
    letter-spacing: 0.5px;
    vertical-align: middle;
    flex-shrink: 0;
}

.media-badge-movie {
    background-color: #8e44ad;
}

.media-badge-tv {
    background-color: #16a085;
}

/* Output Type Selector (Movies / TV / Both) */
.output-type-selector {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 0 12px 0;
    flex-wrap: wrap;
}

.output-type-label {
    font-size: 13px;
    color: #34495e;
    font-weight: 600;
}

.output-type-pills {
    display: flex;
    gap: 6px;
}

.output-type-pill {
    padding: 6px 14px;
    font-size: 13px;
    border: 2px solid #ddd;
    border-radius: 20px;
    background-color: white;
    color: #555;
    cursor: pointer;
    transition: all 0.2s;
}

.output-type-pill:hover {
    border-color: #3498db;
    color: #3498db;
}

.output-type-pill.active {
    background-color: #3498db;
    border-color: #3498db;
    color: white;
}

/* Department Pills */
.dept-pills {
    display: flex;
    gap: 6px;
    margin-bottom: 10px;
}

.dept-pill {
    padding: 5px 12px;
    font-size: 13px;
    border: 2px solid #ddd;
    border-radius: 20px;
    background-color: white;
    color: #555;
    cursor: pointer;
    transition: all 0.2s;
}

.dept-pill:hover {
    border-color: #3498db;
    color: #3498db;
}

.dept-pill.active {
    background-color: #3498db;
    border-color: #3498db;
    color: white;
}

/* Search Result Items with Thumbnails */
.search-result-item {
    display: flex;
    align-items: center;
    gap: 10px;
    margin: 5px;
    padding: 6px 12px;
    background-color: #3498db;
    color: white;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    font-size: 14px;
    transition: background-color 0.3s;
    position: relative;
}

.search-result-item:hover {
    background-color: #2980b9;
}

.search-result-item:active {
    background-color: #1c5a85;
}

.search-result-thumb {
    width: 30px;
    height: 45px;
    object-fit: cover;
    border-radius: 3px;
    flex-shrink: 0;
}

.search-result-thumb-placeholder {
    width: 30px;
    height: 45px;
    background-color: rgba(255,255,255,0.2);
    border-radius: 3px;
    flex-shrink: 0;
}

/* Hover preview for thumbnails */
.search-result-thumb-wrap {
    position: relative;
    flex-shrink: 0;
}

/* Hover Detail Card (movies) */
.hover-detail-card {
    display: none;
    position: absolute;
    z-index: 100;
    left: 0;
    top: -10px;
    background: white;
    border-radius: 8px;
    box-shadow: 0 6px 24px rgba(0,0,0,0.3);
    padding: 12px;
    width: 340px;
    pointer-events: none;
    color: #333;
}

@media (hover: hover) {
    .search-result-thumb-wrap:hover .hover-detail-card {
        display: flex;
        gap: 12px;
    }
}

/* Touch devices: JS-toggled visibility */
.hover-detail-card.touch-visible {
    display: flex;
    gap: 12px;
    pointer-events: auto;
}

/* On touch devices, show the card as a centered overlay */
@media (hover: none) {
    .search-result-thumb-wrap {
        min-width: 44px;
        min-height: 44px;
        display: flex;
        align-items: center;
        justify-content: center;
    }

    .hover-detail-card.touch-visible {
        position: fixed;
        left: 50%;
        top: 50%;
        transform: translate(-50%, -50%);
        width: calc(100vw - 32px);
        max-width: 380px;
        z-index: 1001;
    }
}

/* Backdrop overlay behind touch detail card */
.touch-backdrop {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.4);
    z-index: 1000;
}
.touch-backdrop.active {
    display: block;
}

.hover-detail-poster {
    width: 100px;
    border-radius: 4px;
    flex-shrink: 0;
    align-self: flex-start;
}

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

.hover-detail-title {
    font-weight: bold;
    font-size: 14px;
    margin-bottom: 4px;
}

.hover-detail-date {
    font-size: 12px;
    color: #7f8c8d;
    margin-bottom: 4px;
}

.hover-detail-rating {
    display: inline-block;
    background-color: #f39c12;
    color: white;
    padding: 1px 8px;
    border-radius: 10px;
    font-size: 12px;
    font-weight: bold;
    margin-bottom: 6px;
}

.hover-detail-genres {
    font-size: 12px;
    color: #555;
    margin-bottom: 4px;
}

.hover-detail-director {
    font-size: 12px;
    color: #555;
    margin-bottom: 6px;
}

.hover-detail-overview {
    font-size: 11px;
    color: #666;
    line-height: 1.4;
}

.hover-detail-known-for {
    font-size: 12px;
    color: #555;
    font-weight: bold;
    margin-bottom: 4px;
}

.hover-detail-movies {
    margin: 0;
    padding-left: 16px;
    font-size: 12px;
    color: #555;
    line-height: 1.6;
}

/* Search Results Toolbar */
.search-results-toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
}

.search-results-toolbar .search-results-header {
    font-size: 13px;
    color: #7f8c8d;
    font-style: italic;
}

.search-results-header {
    font-size: 13px;
    color: #7f8c8d;
    font-style: italic;
    margin-bottom: 8px;
}

.view-toggle-btn {
    padding: 3px 10px;
    font-size: 12px;
    border: 1px solid #bdc3c7;
    border-radius: 4px;
    background-color: white;
    color: #555;
    cursor: pointer;
    transition: all 0.2s;
}

.view-toggle-btn:hover {
    border-color: #3498db;
    color: #3498db;
}

/* Movie Search Result Info */
.search-result-info {
    flex: 1;
    min-width: 0;
}

.search-result-title-row {
    display: flex;
    align-items: center;
    gap: 8px;
}

.search-result-title {
    flex: 1;
}

.search-result-rating {
    background-color: rgba(255,255,255,0.25);
    padding: 1px 6px;
    border-radius: 10px;
    font-size: 12px;
    font-weight: bold;
    flex-shrink: 0;
}

.search-result-genres {
    font-size: 11px;
    opacity: 0.8;
    margin-top: 2px;
}

.search-result-director {
    font-size: 12px;
    opacity: 0.85;
    margin-top: 4px;
}

.search-result-overview {
    font-size: 11px;
    opacity: 0.75;
    margin-top: 4px;
    line-height: 1.4;
}

/* Detailed view adjustments */
.search-result-item.detailed {
    align-items: flex-start;
    padding: 8px 12px;
}

.search-result-item.detailed .search-result-thumb {
    width: 45px;
    height: 67px;
}

.search-result-item.detailed .search-result-thumb-placeholder {
    width: 45px;
    height: 67px;
}

/* Search Results — Movie, Actor, Genre, and Language Areas */
#output, #actorOutput, #genreOutput, #languageOutput {
    margin: 10px 0;
    padding: 10px;
    background-color: #f8f9fa;
    border-radius: 5px;
    min-height: 50px;
}

#genreOutput input[type="button"] {
    display: inline-block;
    margin: 5px;
    padding: 8px 15px;
    background-color: #3498db;
    color: white;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    font-size: 14px;
    transition: background-color 0.3s;
    white-space: nowrap;
    min-width: 120px;
}

#genreOutput input[type="button"]:hover {
    background-color: #2980b9;
}

#genreOutput input[type="button"]:active {
    background-color: #1c5a85;
}

#genreOutput input[type="button"].selected {
    background-color: #27ae60;
}

/* Language Buttons */
.lang-btn {
    display: inline-block;
    margin: 5px;
    padding: 8px 15px;
    background-color: #3498db;
    color: white;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    font-size: 14px;
    transition: background-color 0.3s;
    white-space: nowrap;
}

.lang-btn:hover {
    background-color: #2980b9;
}

.lang-btn.selected {
    background-color: #27ae60;
}

/* No Results */
.no-results {
    color: #95a5a6;
    font-style: italic;
    text-align: center;
    padding: 10px;
}

/* Form and Submit Button */
.sticky-submit {
    position: sticky;
    bottom: 0;
    z-index: 50;
    padding: 10px 0;
    background: linear-gradient(transparent, #f5f5f5 30%);
}

form {
    margin: 0;
}

button[type="submit"] {
    width: 100%;
    padding: 15px;
    font-size: 18px;
    font-weight: bold;
    background-color: #27ae60;
    color: white;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    transition: all 0.3s;
    box-shadow: 0 -2px 8px rgba(0,0,0,0.1);
}

button[type="submit"].has-results {
    padding: 8px;
    font-size: 14px;
    background-color: #2980b9;
}

button[type="submit"]:hover {
    background-color: #229954;
}

button[type="submit"]:active {
    background-color: #1e7e45;
}

/* Results Section */
#results {
    padding: 10px 0;
    min-height: 100px;
}

#results:empty::before {
    content: "Add some movies and shows you love above, then click 'Get Recommendations'.";
    color: #95a5a6;
    font-style: italic;
    display: block;
    padding: 20px;
    background-color: white;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

/* Movie Cards */
.movie-card {
    background-color: white;
    padding: 20px;
    margin-bottom: 15px;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    transition: box-shadow 0.3s, transform 0.2s;
}

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

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

.movie-title {
    margin: 0;
    color: #2c3e50;
    font-size: 1.4em;
    flex: 1;
}

.movie-rating {
    background-color: #f39c12;
    color: white;
    padding: 4px 10px;
    border-radius: 15px;
    font-weight: bold;
    font-size: 14px;
    margin-left: 10px;
    flex-shrink: 0;
}

.movie-year {
    color: #7f8c8d;
    font-size: 14px;
    margin: 0 0 10px 0;
}

.movie-genres, .movie-cast {
    margin: 8px 0;
    font-size: 14px;
    color: #34495e;
}

.movie-genres strong, .movie-cast strong {
    color: #2c3e50;
}

.movie-overview {
    margin: 12px 0 0 0;
    line-height: 1.6;
    color: #555;
    font-size: 15px;
}

/* Search Spinner */
.search-spinner {
    display: flex;
    justify-content: center;
    padding: 20px;
}

/* Loading Spinner */
.loading-spinner {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 60px 20px;
    background-color: white;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.spinner {
    border: 4px solid #f3f3f3;
    border-top: 4px solid #3498db;
    border-radius: 50%;
    width: 50px;
    height: 50px;
    animation: spin 1s linear infinite;
}

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

.loading-spinner p {
    margin-top: 20px;
    color: #7f8c8d;
    font-size: 16px;
    font-style: italic;
}

/* Mini Spinner for Individual Movies */
.mini-spinner-container {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-top: 10px;
    padding: 10px;
    background-color: #f8f9fa;
    border-radius: 4px;
}

.mini-spinner {
    border: 3px solid #f3f3f3;
    border-top: 3px solid #3498db;
    border-radius: 50%;
    width: 20px;
    height: 20px;
    animation: spin 1s linear infinite;
    flex-shrink: 0;
}

.loading-text {
    color: #7f8c8d;
    font-size: 14px;
    font-style: italic;
    margin: 0;
}

/* Footer */
footer {
    margin-top: 20px;
}

.attribution {
    text-align: center;
    color: #95a5a6;
    font-size: 12px;
}

.attribution img {
    opacity: 0.6;
    transition: opacity 0.2s;
}

.attribution img:hover {
    opacity: 1;
}

.footer-links {
    margin: 8px 0;
}

.footer-links a {
    color: #7f8c8d;
    text-decoration: none;
}

.footer-links a:hover {
    color: #3498db;
    text-decoration: underline;
}

.version {
    font-size: 11px;
    color: #bdc3c7;
}

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

    h1 {
        font-size: 2em;
    }

    h3 {
        font-size: 1.1em;
    }

    .search-result-item {
        width: 100%;
        margin: 5px 0;
    }

    .dept-pills {
        flex-wrap: wrap;
    }
}
