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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    line-height: 1.6;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    color: #333;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
}

header {
    text-align: center;
    margin-bottom: 40px;
    color: white;
}

.header-content {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 20px;
    flex-wrap: wrap;
}

.site-logo {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    background: white;
    padding: 10px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.3);
    flex-shrink: 0;
}

.header-text {
    text-align: center;
}

header h1 {
    font-size: 3rem;
    font-weight: 700;
    margin-bottom: 10px;
    text-shadow: 2px 2px 4px rgba(0,0,0,0.3);
}

header p {
    font-size: 1.2rem;
    opacity: 0.9;
}

.search-section {
    background: white;
    border-radius: 12px;
    padding: 30px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.2);
    margin-bottom: 30px;
}

.form-group {
    display: flex;
    gap: 15px;
    margin-bottom: 20px;
}

#actorName {
    flex: 1;
    padding: 15px;
    border: 2px solid #e1e5e9;
    border-radius: 8px;
    font-size: 16px;
    transition: border-color 0.3s ease;
}

#actorName:focus {
    outline: none;
    border-color: #667eea;
}

#findCoStars,
#findEnsembles,
#findDirectors,
#findFranchises {
    padding: 15px 30px;
    background: linear-gradient(135deg, #667eea, #764ba2);
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: transform 0.2s ease;
}

#findCoStars:hover,
#findEnsembles:hover,
#findDirectors:hover,
#findFranchises:hover {
    transform: translateY(-2px);
}

#findEnsembles {
    background: linear-gradient(135deg, #764ba2, #667eea);
}

#findDirectors {
    background: linear-gradient(135deg, #e67e22, #d35400);
}

#findFranchises {
    background: linear-gradient(135deg, #8e44ad, #9b59b6);
}

.filters {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 15px;
}

.filters select,
.filters input {
    padding: 12px;
    border: 2px solid #e1e5e9;
    border-radius: 8px;
    font-size: 14px;
}

.cache-control {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 8px;
}

.cache-control label {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 14px;
    color: #666;
    cursor: pointer;
    user-select: none;
}

.cache-control input[type="checkbox"] {
    width: auto;
    padding: 0;
    margin: 0;
    cursor: pointer;
}

.basic-filters {
    justify-content: center;
}

.advanced-toggle {
    text-align: center;
    margin: 20px 0 10px 0;
}

.toggle-button {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 16px;
    background: transparent;
    color: #667eea;
    border: 2px solid #667eea;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s ease;
}

.toggle-button:hover {
    background: #667eea;
    color: white;
    transform: translateY(-1px);
}

.toggle-button .chevron {
    transition: transform 0.3s ease;
}

.toggle-button.expanded .chevron {
    transform: rotate(180deg);
}

.clickable-header {
    cursor: pointer;
    transition: opacity 0.2s ease;
}

.clickable-header:hover {
    opacity: 0.9;
}

.reset-button {
    background: #e74c3c;
    color: white;
    border: none;
    padding: 8px 16px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.9rem;
    display: flex;
    align-items: center;
    gap: 6px;
    transition: background-color 0.2s ease;
    margin-left: 10px;
}

.reset-button:hover {
    background: #c0392b;
}

.reset-button svg {
    width: 14px;
    height: 14px;
}

.advanced-toggle {
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 20px 0 10px;
}

.advanced-filters {
    max-height: 500px;
    overflow: hidden;
    transition: max-height 0.4s ease-in-out, opacity 0.3s ease-in-out;
    opacity: 1;
}

.advanced-filters.hidden {
    max-height: 0;
    opacity: 0;
    margin: 0;
}

.loading {
    text-align: center;
    padding: 40px;
    background: white;
    border-radius: 12px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.2);
}

.loading p {
    transition: opacity 0.3s ease-in-out;
}

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

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

.results,
.ensembles,
.directors,
.franchises {
    background: white;
    border-radius: 12px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.2);
    overflow: hidden;
}

.results-header {
    padding: 30px;
    background: linear-gradient(135deg, #667eea, #764ba2);
    color: white;
}

.results-header h2 {
    font-size: 2rem;
    margin-bottom: 10px;
}

.actor-header-content {
    display: flex;
    align-items: center;
    gap: 20px;
    flex-wrap: wrap;
}

.actor-header-profile {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
}

.header-profile-image {
    width: 80px;
    height: 120px;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 4px 12px rgba(0,0,0,0.3);
    background: rgba(255,255,255,0.1);
    display: flex;
    align-items: center;
    justify-content: center;
}

.header-profile-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.header-profile-image .no-profile-image {
    width: 100%;
    height: 100%;
    background: rgba(255,255,255,0.2);
    color: rgba(255,255,255,0.7);
    font-size: 28px;
    font-weight: bold;
    margin: 0;
}

.header-external-links {
    display: flex;
    gap: 6px;
}

.header-external-links .external-link {
    padding: 4px 8px;
    font-size: 0.75rem;
    border-radius: 4px;
    text-decoration: none;
    font-weight: 500;
    transition: opacity 0.2s ease;
}

.header-external-links .external-link:hover {
    opacity: 0.8;
}

.actor-header-text {
    flex: 1;
    min-width: 0;
}

.actor-header-text h2 {
    margin-bottom: 10px;
}

.actor-header-text p {
    margin: 0;
    opacity: 0.9;
}

.title-with-share {
    display: flex;
    align-items: center;
    gap: 15px;
    flex-wrap: wrap;
}

.share-button {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 12px;
    background: rgba(255, 255, 255, 0.2);
    color: white;
    border: 1px solid rgba(255, 255, 255, 0.3);
    border-radius: 6px;
    font-size: 0.85rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    flex-shrink: 0;
}

.share-button:hover {
    background: rgba(255, 255, 255, 0.3);
    border-color: rgba(255, 255, 255, 0.5);
    transform: translateY(-1px);
}

.share-button svg {
    flex-shrink: 0;
}

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

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

thead {
    background: #f8f9fa;
}

th {
    padding: 15px;
    text-align: left;
    font-weight: 600;
    border-bottom: 2px solid #e1e5e9;
}

td {
    padding: 15px;
    border-bottom: 1px solid #e1e5e9;
}

.rank {
    width: 80px;
    text-align: center;
    font-weight: 600;
    color: #667eea;
}

.name {
    font-weight: 500;
}

.costar-link {
    color: #667eea;
    text-decoration: none;
    font-weight: 500;
    transition: color 0.2s ease;
}

.costar-link:hover {
    color: #764ba2;
    text-decoration: underline;
    cursor: pointer;
}

.count {
    width: 120px;
    text-align: center;
    font-weight: 600;
    background: #f8f9fa;
}

.examples {
    font-size: 0.9rem;
    color: #666;
    max-width: 300px;
}

.profile {
    width: 80px;
    text-align: center;
}

.profile-image {
    width: 60px;
    height: 90px;
    border-radius: 8px;
    object-fit: cover;
    box-shadow: 0 2px 8px rgba(0,0,0,0.2);
}

.no-profile-image {
    width: 60px;
    height: 90px;
    background: #f0f0f0;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    color: #999;
    font-weight: bold;
    margin: 0 auto;
}

.external-links {
    margin-top: 5px;
    display: flex;
    gap: 8px;
}

.external-link {
    padding: 2px 6px;
    background: #667eea;
    color: white;
    text-decoration: none;
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: 500;
    transition: background-color 0.2s ease;
}

.external-link:hover {
    background: #764ba2;
    text-decoration: none;
}

.tmdb-link {
    background: #01b4e4;
}

.tmdb-link:hover {
    background: #0099cc;
}

.wiki-link {
    background: #666;
}

.wiki-link:hover {
    background: #444;
}

.department {
    font-size: 0.75rem;
    color: #999;
    margin-top: 2px;
    font-style: italic;
}

.no-results {
    text-align: center;
    padding: 40px;
    color: #666;
    font-style: italic;
}

.error {
    background: #fee;
    border: 2px solid #fcc;
    border-radius: 12px;
    padding: 30px;
    text-align: center;
    color: #c33;
}

.error h3 {
    margin-bottom: 10px;
}

.ensemble-list {
    padding: 20px;
}

.ensemble-card {
    background: #f8f9fa;
    border-radius: 8px;
    padding: 20px;
    margin-bottom: 20px;
    border-left: 4px solid #667eea;
}

.ensemble-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
}

.ensemble-header h3 {
    margin: 0;
    color: #333;
    font-size: 1.2rem;
}

.ensemble-stats {
    display: flex;
    gap: 15px;
}

.stat {
    background: white;
    padding: 5px 12px;
    border-radius: 20px;
    font-size: 0.9rem;
    color: #666;
    border: 1px solid #e1e5e9;
}

.score {
    background: #667eea;
    color: white;
    padding: 5px 12px;
    border-radius: 20px;
    font-size: 0.9rem;
    font-weight: 600;
}

.ensemble-actors {
    margin-bottom: 15px;
    font-size: 1.1rem;
    line-height: 1.6;
}

.ensemble-examples {
    font-size: 0.9rem;
    color: #666;
    line-height: 1.5;
}

.no-ensembles,
.no-directors {
    text-align: center;
    padding: 40px;
    color: #666;
    font-style: italic;
}

.director-list {
    padding: 20px;
}

.director-card {
    background: #f8f9fa;
    border-radius: 8px;
    padding: 20px;
    margin-bottom: 20px;
    border-left: 4px solid #e67e22;
}

.director-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
}

.director-header h3 {
    margin: 0;
    color: #333;
    font-size: 1.3rem;
}

.director-stats {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.director-projects {
    margin-bottom: 15px;
    font-size: 0.9rem;
    color: #666;
    line-height: 1.5;
}

.recurring-cast {
    font-size: 0.95rem;
    line-height: 1.6;
}

.cast-list {
    margin-top: 8px;
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.cast-member {
    background: white;
    padding: 4px 8px;
    border-radius: 15px;
    border: 1px solid #e1e5e9;
    font-size: 0.85rem;
}

.cast-count {
    color: #e67e22;
    font-weight: 600;
    margin-left: 2px;
}

.franchise-list {
    padding: 20px;
}

.franchise-card {
    background: #f8f9fa;
    border-radius: 8px;
    padding: 20px;
    margin-bottom: 20px;
    border-left: 4px solid #8e44ad;
}

.franchise-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
}

.franchise-header h3 {
    margin: 0;
    color: #333;
    font-size: 1.3rem;
    flex: 1;
    margin-right: 15px;
    word-break: break-word;
    min-width: 0;
}

.franchise-stats {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.franchise-timeline {
    margin-bottom: 15px;
    font-size: 0.9rem;
    color: #666;
    line-height: 1.5;
}

.franchise-cast {
    font-size: 0.95rem;
    line-height: 1.6;
}

.franchise-cast-list {
    margin-top: 8px;
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.franchise-cast-member {
    background: white;
    padding: 4px 8px;
    border-radius: 15px;
    border: 1px solid #e1e5e9;
    font-size: 0.85rem;
}

.franchise-percentage {
    color: #8e44ad;
    font-weight: 600;
    margin-left: 2px;
}

.no-franchises {
    text-align: center;
    padding: 40px;
    color: #666;
    font-style: italic;
}

.attribution {
    margin-top: 60px;
    padding: 30px 20px;
    background: #f8f9fa;
    border-top: 1px solid #e1e5e9;
}

.attribution-content {
    max-width: 1200px;
    margin: 0 auto;
    display: flex;
    align-items: center;
    gap: 20px;
    flex-wrap: wrap;
    justify-content: center;
}

.tmdb-logo {
    height: 40px;
    width: auto;
}

.attribution-text {
    color: #666;
    font-size: 0.9rem;
    margin: 0;
    text-align: center;
    max-width: 600px;
}

.hidden {
    display: none;
}

/* Responsive design */
@media (max-width: 768px) {
    .container {
        padding: 15px;
    }

    header h1 {
        font-size: 2rem;
    }

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

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

    .results-header {
        padding: 20px;
    }

    .actor-header-content {
        flex-direction: column;
        align-items: center;
        text-align: center;
        gap: 15px;
    }

    .header-profile-image {
        width: 60px;
        height: 90px;
    }

    .header-profile-image .no-profile-image {
        font-size: 24px;
    }

    .header-external-links .external-link {
        padding: 3px 6px;
        font-size: 0.7rem;
    }

    .title-with-share {
        flex-direction: column;
        align-items: center;
        gap: 10px;
    }

    .share-button {
        padding: 6px 10px;
        font-size: 0.8rem;
    }

    .toggle-button {
        padding: 8px 12px;
        font-size: 0.9rem;
    }

    .results-header h2 {
        font-size: 1.5rem;
    }

    th, td {
        padding: 10px 8px;
        font-size: 0.9rem;
    }

    .examples {
        max-width: 200px;
        font-size: 0.8rem;
    }

    .attribution {
        margin-top: 40px;
        padding: 20px 15px;
    }

    .attribution-content {
        flex-direction: column;
        gap: 15px;
    }

    .tmdb-logo {
        height: 32px;
    }

    .attribution-text {
        font-size: 0.8rem;
    }
}

.show-more-examples {
    color: #667eea;
    cursor: pointer;
    font-weight: 500;
    text-decoration: underline;
    margin-left: 4px;
    font-size: 0.9em;
}

.show-more-examples:hover {
    color: #5a67d8;
}

.examples-hint {
    font-size: 0.8em;
    color: #888;
    font-style: italic;
    margin-top: 4px;
}

.theme-filter-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
    width: 100%;
}

.theme-filter-label {
    font-weight: 600;
    color: #333;
    font-size: 0.9rem;
    margin-bottom: 4px;
}

.theme-checkboxes {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 8px;
}

.theme-checkbox {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.85rem;
    cursor: pointer;
    padding: 4px 8px;
    border-radius: 4px;
    transition: background-color 0.2s ease;
}

.theme-checkbox:hover {
    background-color: #f8f9fa;
}

.theme-checkbox input[type="checkbox"] {
    margin: 0;
    cursor: pointer;
}

.theme-checkbox span {
    user-select: none;
}