/* Movie Recommendation Engine Styles */

/* Reset and Base Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Apple Color Emoji', 'Segoe UI Emoji', 'Noto Color Emoji', sans-serif;
    background: linear-gradient(135deg, #0f0f23 0%, #1a1a2e 50%, #16213e 100%);
    color: #ffffff;
    min-height: 100vh;
    line-height: 1.6;
    overflow-x: hidden;
    width: 100%;
    position: relative;
}

/* Global overflow prevention */
* {
    max-width: 100%;
    word-wrap: break-word;
    overflow-wrap: break-word;
}

html {
    overflow-x: hidden;
    width: 100%;
}

/* Prevent all sections and children from overflowing */
.user-profile-section,
.filter-section,
.recommendations-section,
.analytics-section,
.sql-showcase,
.schema-section {
    width: 100%;
    max-width: 100%;
    overflow-x: hidden;
    box-sizing: border-box;
}

.user-profile-section *,
.filter-section *,
.recommendations-section *,
.analytics-section *,
.sql-showcase *,
.schema-section * {
    max-width: 100%;
    word-wrap: break-word;
    overflow-wrap: break-word;
    box-sizing: border-box;
}

/* Container */
.recommendation-container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 20px;
    animation: fadeIn 0.6s ease-out;
    width: 100%;
    box-sizing: border-box;
    overflow-x: hidden;
}

@media (max-width: 768px) {
    .recommendation-container {
        padding: 15px;
        max-width: 100vw;
    }
}

@media (max-width: 480px) {
    .recommendation-container {
        padding: 10px;
        max-width: 100vw;
    }
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}

/* Header Styles */
.recommendation-header {
    background: linear-gradient(135deg, #353866 0%, #000dff 100%);
    border-radius: 20px;
    padding: 30px;
    margin-bottom: 30px;
    box-shadow: 0 20px 40px rgba(107, 115, 255, 0.3);
    position: relative;
    overflow: hidden;
}

.recommendation-header::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(45deg, transparent 30%, rgba(255,255,255,0.1) 50%, transparent 70%);
    animation: shimmer 3s infinite;
}

@keyframes shimmer {
    0% { transform: translateX(-100%); }
    100% { transform: translateX(100%); }
}

.header-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: relative;
    z-index: 1;
}

.header-left h1 {
    font-family: 'Montserrat', sans-serif;
    font-size: 2.5rem;
    font-weight: 700;
    margin-bottom: 10px;
    text-shadow: 2px 2px 4px rgba(0,0,0,0.3);
}

.header-left p {
    font-size: 1.2rem;
    opacity: 0.9;
    font-weight: 400;
}

.header-right {
    display: flex;
    gap: 15px;
    align-items: center;
}

/* Button Styles */
.btn-refresh,
.btn-export,
.btn-return,
.btn-generate {
    background: linear-gradient(135deg, #353866 0%, #23263a 100%);
    color: white;
    border: none;
    padding: 12px 24px;
    border-radius: 12px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    font-size: 14px;
    text-decoration: none;
    display: inline-block;
    text-align: center;
}

.btn-refresh:hover,
.btn-export:hover,
.btn-return:hover,
.btn-generate:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(255, 107, 107, 0.4);
    background: linear-gradient(135deg, #353866 0%, #23263a 100%);
}

.btn-generate {
    background: linear-gradient(135deg, #4CAF50 0%, #45a049 100%);
    padding: 15px 30px;
    font-size: 16px;
}

.btn-generate:hover {
    background: linear-gradient(135deg, #45a049 0%, #388e3c 100%);
    box-shadow: 0 8px 25px rgba(76, 175, 80, 0.4);
}

/* Emoji styling to preserve colors */
.emoji {
    background: none !important;
    -webkit-background-clip: initial !important;
    -webkit-text-fill-color: initial !important;
    background-clip: initial !important;
    color: inherit;
    font-family: 'Apple Color Emoji', 'Segoe UI Emoji', 'Noto Color Emoji', sans-serif !important;
    font-variant-emoji: unicode;
    margin-right: 0.5rem;
    display: inline-block;
}

/* Section Styles */
.user-profile-section,
.filters-section,
.recommendations-section,
.analytics-section,
.sql-showcase,
.schema-section {
    background: rgba(255, 255, 255, 0.05);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 20px;
    padding: 30px;
    margin-bottom: 30px;
    transition: all 0.3s ease;
    width: 100%;
    box-sizing: border-box;
    overflow: hidden;
}

.user-profile-section:hover,
.filters-section:hover,
.recommendations-section:hover,
.analytics-section:hover,
.sql-showcase:hover,
.schema-section:hover {
    transform: translateY(-5px);
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.2);
}

/* Profile Section */
.profile-header h2,
.filters-header h2,
.recommendations-header h2,
.analytics-header h2,
.sql-header h2,
.schema-header h2 {
    font-family: 'Montserrat', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Apple Color Emoji', 'Segoe UI Emoji', 'Noto Color Emoji', sans-serif;
    font-size: 1.8rem;
    margin-bottom: 25px;
    background: linear-gradient(135deg, #60BADB 0%, #b2becd 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    word-wrap: break-word;
    overflow-wrap: break-word;
    max-width: 100%;
    width: 100%;
    box-sizing: border-box;
    /* Ensure emojis are displayed properly */
    font-variant-emoji: unicode;
    text-rendering: optimizeQuality;
}

@media (max-width: 768px) {
    .profile-header h2,
    .filters-header h2,
    .recommendations-header h2,
    .analytics-header h2,
    .sql-header h2,
    .schema-header h2 {
        font-size: 1.4rem;
        line-height: 1.2;
        margin-bottom: 20px;
    }
}

@media (max-width: 480px) {
    .profile-header h2,
    .filters-header h2,
    .recommendations-header h2,
    .analytics-header h2,
    .sql-header h2,
    .schema-header h2 {
        font-size: 1.2rem;
        line-height: 1.1;
    }
}

.profile-grid {
    display: grid;
    grid-template-columns: 1fr 2fr;
    gap: 30px;
    align-items: center;
}

@media (max-width: 768px) {
    .profile-grid {
        grid-template-columns: 1fr;
        gap: 20px;
    }
}

.user-selector {
    display: flex;
    flex-direction: column;
    gap: 10px;
    width: 100%;
    box-sizing: border-box;
}

.user-selector label {
    font-weight: 600;
    color: #8892b0;
    font-size: 14px;
    word-wrap: break-word;
}

.user-selector select {
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 12px;
    padding: 12px 16px;
    color: #60BADB;
    font-size: 14px;
    outline: none;
    transition: all 0.3s ease;
    width: 100%;
    box-sizing: border-box;
    max-width: 100%;
}

.user-selector select:focus {
    border-color: #353866;
    box-shadow: 0 0 0 3px rgba(107, 115, 255, 0.2);
}

.user-stats {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 20px;
}

@media (max-width: 768px) {
    .user-stats {
        grid-template-columns: 1fr;
        gap: 15px;
    }
}

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

.stat-item {
    background: rgba(255, 255, 255, 0.05);
    padding: 20px;
    border-radius: 12px;
    text-align: center;
    border: 1px solid rgba(255, 255, 255, 0.1);
    transition: all 0.3s ease;
    width: 100%;
    box-sizing: border-box;
    overflow: hidden;
}

.stat-item:hover {
    background: rgba(255, 255, 255, 0.1);
    transform: translateY(-2px);
}

.stat-label {
    display: block;
    font-size: 12px;
    color: #8892b0;
    margin-bottom: 5px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    word-wrap: break-word;
    overflow-wrap: break-word;
}

.stat-value {
    display: block;
    font-size: 1.5rem;
    font-weight: 700;
    color: #60BADB;
    word-wrap: break-word;
}

@media (max-width: 768px) {
    .stat-item {
        padding: 15px 10px;
    }
    
    .stat-label {
        font-size: 11px;
    }
    
    .stat-value {
        font-size: 1.3rem;
    }
}

@media (max-width: 480px) {
    .stat-item {
        padding: 12px 8px;
    }
    
    .stat-label {
        font-size: 10px;
        letter-spacing: 0.3px;
    }
    
    .stat-value {
        font-size: 1.1rem;
    }
}

/* Filters Section */
.filters-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 20px;
    align-items: end;
}

@media (max-width: 768px) {
    .filters-grid {
        grid-template-columns: 1fr;
        gap: 15px;
    }
}

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

.filter-group label {
    font-weight: 600;
    color: #8892b0;
    font-size: 14px;
    word-wrap: break-word;
}

.filter-group select {
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 12px;
    padding: 12px 16px;
    color: #60BADB;
    font-size: 14px;
    outline: none;
    transition: all 0.3s ease;
    width: 100%;
    box-sizing: border-box;
    max-width: 100%;
}

.filter-group select:focus {
    border-color: #353866;
    box-shadow: 0 0 0 3px rgba(107, 115, 255, 0.2);
}

/* Recommendations Section */
.recommendations-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 30px;
    width: 100%;
    box-sizing: border-box;
    flex-wrap: wrap;
    gap: 15px;
}

.recommendation-type {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    box-sizing: border-box;
}

.recommendation-type label {
    font-weight: 600;
    color: #8892b0;
    white-space: nowrap;
    min-width: fit-content;
}

.recommendation-type select {
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 12px;
    padding: 8px 12px;
    color: #60BADB;
    font-size: 14px;
    outline: none;
    flex: 1;
    max-width: 100%;
    box-sizing: border-box;
}

@media (max-width: 768px) {
    .recommendations-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 15px;
    }
    
    .recommendation-type {
        width: 100%;
        justify-content: flex-start;
    }
}

.recommendations-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 20px;
    width: 100%;
    box-sizing: border-box;
}

@media (max-width: 768px) {
    .recommendations-grid {
        grid-template-columns: 1fr;
        gap: 15px;
    }
}

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

.movie-card {
    background: linear-gradient(135deg, rgba(255,255,255,0.1) 0%, rgba(255,255,255,0.05) 100%);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 16px;
    padding: 20px;
    transition: all 0.3s ease;
    cursor: pointer;
}

.movie-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 15px 35px rgba(0, 0, 0, 0.3);
    border-color: #353866;
}

.movie-poster {
    width: 100%;
    height: 200px;
    background: linear-gradient(135deg, #23263a 0%, #353866 100%);
    border-radius: 12px;
    margin-bottom: 15px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 48px;
    color: rgba(255, 255, 255, 0.8);
}

.movie-title {
    font-size: 1.2rem;
    font-weight: 700;
    margin-bottom: 8px;
    color: #ffffff;
}

.movie-info {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
}

.movie-genre {
    background: rgba(107, 115, 255, 0.2);
    padding: 4px 8px;
    border-radius: 6px;
    font-size: 12px;
    color: #ffffff;
}

.movie-year {
    color: #8892b0;
    font-size: 14px;
}

.movie-rating {
    display: flex;
    align-items: center;
    gap: 5px;
    margin-bottom: 10px;
}

.rating-score {
    font-weight: 700;
    color: #ffd700;
}

.movie-description {
    font-size: 14px;
    color: #8892b0;
    line-height: 1.5;
}

/* Analytics Section */
.analytics-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 20px;
    width: 100%;
    box-sizing: border-box;
}

@media (max-width: 1024px) {
    .analytics-grid {
        grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    }
}

@media (max-width: 768px) {
    .analytics-grid {
        grid-template-columns: 1fr;
        gap: 15px;
    }
}

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

.analytics-card {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 16px;
    padding: 20px;
    transition: all 0.3s ease;
    width: 100%;
    box-sizing: border-box;
    overflow: hidden;
}

.analytics-card:hover {
    background: rgba(255, 255, 255, 0.08);
    transform: translateY(-2px);
}

.analytics-card h3 {
    font-size: 1.1rem;
    margin-bottom: 15px;
    color: #ffffff;
    text-align: center;
    word-wrap: break-word;
    overflow-wrap: break-word;
    line-height: 1.3;
}

.analytics-card canvas {
    max-height: 250px;
    width: 100%;
    box-sizing: border-box;
}

@media (max-width: 768px) {
    .analytics-card {
        padding: 15px;
    }
    
    .analytics-card h3 {
        font-size: 1rem;
        margin-bottom: 12px;
        line-height: 1.2;
    }
    
    .analytics-card canvas {
        max-height: 200px;
    }
}

@media (max-width: 480px) {
    .analytics-card {
        padding: 12px;
    }
    
    .analytics-card h3 {
        font-size: 0.9rem;
        margin-bottom: 10px;
    }
    
    .analytics-card canvas {
        max-height: 180px;
    }
}

/* SQL Showcase */
.sql-tabs {
    display: flex;
    gap: 10px;
    margin-bottom: 20px;
    flex-wrap: wrap;
}

.sql-tab {
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: white;
    padding: 10px 20px;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s ease;
    font-size: 14px;
}

.sql-tab.active,
.sql-tab:hover {
    background: linear-gradient(135deg, #23263a 0%, #353866 100%);
    border-color: transparent;
}

.sql-content {
    background: rgba(0, 0, 0, 0.3);
    border-radius: 12px;
    padding: 20px;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.sql-query {
    display: none;
}

.sql-query.active {
    display: block;
}

.sql-query h3 {
    font-size: 1.2rem;
    margin-bottom: 15px;
    color: #60BADB;
}

.sql-query pre {
    background: rgba(0, 0, 0, 0.5);
    border-radius: 8px;
    padding: 20px;
    overflow-x: auto;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.sql-query code {
    font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', monospace;
    font-size: 13px;
    line-height: 1.6;
    color: #b2becd;
}

/* Schema Section */
.tables-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 20px;
}

.table-card {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 12px;
    padding: 20px;
    transition: all 0.3s ease;
}

.table-card:hover {
    background: rgba(255, 255, 255, 0.08);
    transform: translateY(-2px);
}

.table-card h4 {
    font-size: 1.1rem;
    margin-bottom: 15px;
    color: #60BADB;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    padding-bottom: 10px;
}

.table-card ul {
    list-style: none;
}

.table-card li {
    padding: 5px 0;
    color: #8892b0;
    font-size: 14px;
}

.table-card li:hover {
    color: #ffffff;
}

/* Responsive Design */
@media (max-width: 1024px) {
    .recommendation-container {
        padding: 15px;
        max-width: 100%;
    }

    .analytics-grid {
        grid-template-columns: repeat(auto-fit, minmax(350px, 1fr));
    }

    .sql-query pre {
        font-size: 12px;
        padding: 15px;
    }

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

@media (max-width: 768px) {
    .recommendation-container {
        padding: 10px;
        margin: 0;
    }

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

    .header-left h1 {
        font-size: 1.8rem;
        line-height: 1.2;
    }

    .header-left p {
        font-size: 1rem;
    }

    .header-right {
        flex-direction: column;
        width: 100%;
        gap: 10px;
    }

    .btn-refresh,
    .btn-export,
    .btn-return,
    .btn-generate {
        width: 100%;
        padding: 12px 20px;
        font-size: 14px;
    }

    .profile-grid {
        grid-template-columns: 1fr;
        gap: 20px;
    }

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

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

    .filter-group select {
        width: 100%;
    }

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

    .recommendations-header {
        flex-direction: column;
        gap: 15px;
        align-items: stretch;
    }

    .recommendation-type {
        justify-content: center;
    }

    .movie-card {
        padding: 15px;
    }

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

    .analytics-card canvas {
        max-height: 200px;
    }

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

    .sql-tabs {
        flex-direction: column;
        gap: 8px;
    }

    .sql-tab {
        text-align: center;
        padding: 12px 16px;
    }

    .sql-query pre {
        font-size: 11px;
        padding: 12px;
        overflow-x: auto;
    }

    .sql-query h3 {
        font-size: 1.1rem;
    }

    /* Sections padding adjustments */
    .user-profile-section,
    .filters-section,
    .recommendations-section,
    .analytics-section,
    .sql-showcase,
    .schema-section {
        padding: 20px 15px;
        margin-bottom: 20px;
    }

    .recommendation-header {
        padding: 20px 15px;
    }
}

@media (max-width: 480px) {
    .recommendation-container {
        padding: 8px;
    }

    .header-left h1 {
        font-size: 1.5rem;
    }

    .header-left p {
        font-size: 0.9rem;
    }

    .user-profile-section,
    .filters-section,
    .recommendations-section,
    .analytics-section,
    .sql-showcase,
    .schema-section {
        padding: 15px 10px;
        margin-bottom: 15px;
    }

    .recommendation-header {
        padding: 15px 10px;
    }

    .movie-card {
        padding: 12px;
    }

    .movie-title {
        font-size: 1.1rem;
    }

    .sql-query pre {
        font-size: 10px;
        padding: 10px;
    }

    .analytics-card {
        padding: 15px;
    }

    .analytics-card canvas {
        max-height: 180px;
    }

    .stat-item {
        padding: 15px;
    }

    .achievement-card {
        padding: 15px;
    }

    .table-card {
        padding: 15px;
    }

    /* Font size adjustments for very small screens */
    h2 {
        font-size: 1.4rem;
    }

    h3 {
        font-size: 1.1rem;
    }

    .movie-description,
    .sql-query code,
    .table-card li {
        font-size: 12px;
    }
}

/* Loading States */
.loading {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 40px;
    color: #8892b0;
}

.loading::after {
    content: '';
    width: 20px;
    height: 20px;
    border: 2px solid #353866;
    border-top: 2px solid transparent;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-left: 10px;
}

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

/* Scrollbar Styles */
::-webkit-scrollbar {
    width: 8px;
}

::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb {
    background: linear-gradient(135deg, #5a8dda 0%, #353866 100%);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: linear-gradient(135deg, #353866 0%, #5a8dda 100%);
}

/* Final mobile overflow prevention */
@media (max-width: 480px) {
    /* Ensure no element can exceed viewport width */
    * {
        max-width: 100vw !important;
        box-sizing: border-box !important;
    }
    
    /* Specific fixes for sections that were overflowing */
    .profile-header h2,
    .filters-header h2,
    .recommendations-header h2,
    .analytics-header h2 {
        font-size: 1.1rem !important;
        line-height: 1.1 !important;
        word-wrap: break-word !important;
        overflow-wrap: break-word !important;
        hyphens: auto !important;
        white-space: normal !important;
    }
    
    /* Force containers to respect viewport */
    .user-profile-section,
    .filter-section,
    .recommendations-section,
    .analytics-section {
        max-width: calc(100vw - 20px) !important;
        padding: 10px !important;
        margin: 10px auto !important;
        overflow: hidden !important;
    }
    
    /* Ensure text elements don't overflow */
    .user-selector,
    .filter-group,
    .analytics-card {
        width: 100% !important;
        max-width: 100% !important;
        overflow: hidden !important;
        word-wrap: break-word !important;
    }
}