/* 1. Global Setup with a Background Image for the Blur Effect */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: 'Inter', system-ui, -apple-system, sans-serif;
    /* A subtle gradient background helps the glass effect pop */
    background: linear-gradient(135deg, #0f172a 0%, #1e293b 50%, #334155 100%);
    background-attachment: fixed;
    color: #ffffff;
    display: flex;
    flex-direction: column;
    align-items: center;
    min-height: 100vh;
    padding: 40px 20px 100px;
    line-height: 1.6;
}

/* App Header */
.app-header {
    text-align: center;
    margin-bottom: 40px;
}

.app-title {
    font-size: clamp(2rem, 8vw, 3.5rem);
    font-weight: 800;
    background: linear-gradient(135deg, #38bdf8 0%, #0ea5e9 50%, #0284c7 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin: 0 0 8px 0;
    text-shadow: 0 2px 10px rgba(56, 189, 248, 0.3);
}

.app-subtitle {
    font-size: 1.1rem;
    color: #94a3b8;
    margin: 0;
    font-weight: 400;
    opacity: 0.8;
}

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

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

.fade-in {
    animation: fadeIn 0.6s ease-out;
}

.spinner {
    display: inline-block;
    width: 16px;
    height: 16px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    border-top-color: #fff;
    animation: spin 1s ease-in-out infinite;
    margin-right: 8px;
}

/* Search Container for better alignment */
.search-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    width: 100%;
    max-width: 600px;
    margin: 0 auto 20px;
}

#movie {
    width: 100%;
    max-width: 400px;
    height: 56px;
    padding: 0 20px;
    /* Glass Effect */
    background: rgba(255, 255, 255, 0.08);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 16px;
    
    color: #fff;
    font-size: 1.1rem;
    outline: none;
    transition: all 0.3s ease;
    margin-bottom: 15px;
    font-family: inherit;
}

#movie:focus {
    background: rgba(255, 255, 255, 0.12);
    border-color: rgba(56, 189, 248, 0.5);
    box-shadow: 0 8px 32px 0 rgba(56, 189, 248, 0.2);
    transform: translateY(-2px);
}

#movie::placeholder {
    color: rgba(255, 255, 255, 0.6);
}

button {
    height: 56px;
    padding: 0 32px;
    border-radius: 16px;
    border: none;
    background: linear-gradient(135deg, #38bdf8 0%, #0ea5e9 100%);
    color: #0f172a;
    font-weight: 600;
    font-size: 1rem;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 4px 15px rgba(56, 189, 248, 0.3);
    width: 100%;
    max-width: 200px;
    position: relative;
    overflow: hidden;
}

button:hover:not(:disabled) {
    transform: translateY(-3px);
    box-shadow: 0 8px 25px rgba(56, 189, 248, 0.5);
    background: linear-gradient(135deg, #0ea5e9 0%, #0284c7 100%);
}

button:active:not(:disabled) {
    transform: translateY(-1px);
}

button:disabled {
    opacity: 0.7;
    cursor: not-allowed;
    transform: none;
}

/* Error Message */
.error-message {
    display: none;
    background: rgba(239, 68, 68, 0.1);
    border: 1px solid rgba(239, 68, 68, 0.3);
    border-radius: 12px;
    padding: 16px 20px;
    margin-bottom: 20px;
    color: #fca5a5;
    text-align: center;
    max-width: 500px;
    width: 100%;
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
}

/* 3. Movie Display Area - Responsive Glass Card */
.movie-info {
    display: none;
    flex-direction: column;
    align-items: center;
    width: 100%;
    max-width: 800px;
    margin-top: 20px;
}

.movie-header {
    text-align: center;
    margin-bottom: 30px;
}

#title {
    margin: 0 0 8px 0;
    font-size: clamp(1.8rem, 6vw, 3rem);
    font-weight: 700;
    background: linear-gradient(135deg, #fff 0%, #e2e8f0 50%, #94a3b8 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    line-height: 1.2;
}

#year {
    color: #38bdf8;
    margin: 0;
    font-weight: 500;
    letter-spacing: 1px;
    font-size: 1.1rem;
    opacity: 0.9;
}

.movie-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 30px;
    width: 100%;
    margin-bottom: 30px;
}

#poster {
    width: 100%;
    max-width: 320px;
    border-radius: 20px;
    /* Glass border for the image */
    border: 2px solid rgba(255, 255, 255, 0.1);
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.6);
    transition: all 0.4s ease;
    object-fit: cover;
}

#poster:hover {
    transform: scale(1.05) rotate(1deg);
    box-shadow: 0 35px 70px -12px rgba(0, 0, 0, 0.8);
}

#plot {
    max-width: 600px;
    line-height: 1.7;
    text-align: center;
    padding: 30px;
    /* The core Glassmorphism effect */
    background: rgba(255, 255, 255, 0.04);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border-radius: 24px;
    border: 1px solid rgba(255, 255, 255, 0.08);
    color: #e2e8f0;
    font-size: 1.1rem;
    margin: 0 0 20px 0;
}

.plot-and-details {
    display: flex;
    flex-direction: column;
    width: 100%;
    max-width: 600px;
}

/* Cast and Ratings Section */
.cast-ratings {
    display: flex;
    flex-direction: column;
    gap: 24px;
    width: 100%;
    margin-bottom: 20px;
}

.cast, .ratings {
    background: rgba(255, 255, 255, 0.05);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-radius: 20px;
    border: 1px solid rgba(255, 255, 255, 0.08);
    padding: 24px;
    color: #e2e8f0;
    transition: all 0.3s ease;
}

.cast:hover, .ratings:hover {
    background: rgba(255, 255, 255, 0.08);
    transform: translateY(-2px);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
}

.cast h4, .ratings h4 {
    margin: 0 0 16px 0;
    color: #38bdf8;
    font-size: 1.2rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 8px;
}

.cast p {
    margin: 0;
    line-height: 1.6;
    font-size: 1rem;
    color: #cbd5e1;
}

.ratings ul {
    list-style: none;
    padding: 0;
    margin: 0;
}

.ratings li {
    padding: 8px 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.95rem;
}

.ratings li:last-child {
    border-bottom: none;
}

.ratings li strong {
    color: #94a3b8;
    font-weight: 500;
}

/* Movie Details Section */
.movie-details {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 12px;
    width: 100%;
}

.detail-item {
    background: rgba(255, 255, 255, 0.05);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-radius: 12px;
    border: 1px solid rgba(255, 255, 255, 0.08);
    padding: 16px;
    color: #e2e8f0;
    transition: all 0.3s ease;
    text-align: center;
}

.detail-item:hover {
    background: rgba(255, 255, 255, 0.08);
    transform: translateY(-3px);
    box-shadow: 0 12px 35px rgba(0, 0, 0, 0.25);
}

.detail-item h4 {
    margin: 0 0 8px 0;
    color: #38bdf8;
    font-size: 0.9rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
}

.detail-item p {
    margin: 0;
    line-height: 1.4;
    font-size: 0.85rem;
    color: #cbd5e1;
    word-wrap: break-word;
}

/* 4. Mobile Responsiveness */
@media (max-width: 600px) {
    body {
        padding: 20px 15px 100px;
    }
    
    .app-header {
        margin-bottom: 30px;
    }
    
    .app-title {
        font-size: 2.5rem;
    }
    
    .app-subtitle {
        font-size: 1rem;
    }
    
    .search-container {
        max-width: 100%;
    }
    
    #movie {
        max-width: 100%;
        font-size: 1.1rem;
        height: 48px;
        padding: 0 16px;
    }
    
    button {
        max-width: 100%;
        height: 48px;
        padding: 0 20px;
    }
    
    #poster {
        max-width: 90%;
    }
    
    #plot {
        font-size: 0.95rem;
        padding: 15px;
        max-width: 100%;
    }
    
    .movie-content {
        gap: 20px;
        margin-bottom: 20px;
    }
    
    .plot-and-details {
        max-width: 100%;
    }
    
    .cast-ratings {
        max-width: 100%;
        gap: 15px;
        margin-bottom: 15px;
    }
    
    .cast, .ratings {
        padding: 15px;
    }
    
    .movie-details {
        grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
        gap: 10px;
    }
    
    .detail-item {
        padding: 12px;
    }
    
    .detail-item h4 {
        font-size: 0.8rem;
    }
    
    .detail-item p {
        font-size: 0.8rem;
    }
    
    .error-message {
        padding: 12px 16px;
        font-size: 0.9rem;
    }
}

/* Tablet and larger screens */
@media (min-width: 768px) {
    .movie-content {
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 40px;
        align-items: start;
    }
    
    #poster {
        max-width: 100%;
        justify-self: center;
    }
    
    .plot-and-details {
        justify-self: start;
    }
    
    #plot {
        text-align: left;
    }
}

/* Large screens */
@media (min-width: 1024px) {
    body {
        padding: 60px 40px 100px;
    }
    
    .search-container {
        flex-direction: row;
        gap: 15px;
        max-width: 600px;
        justify-content: center;
        align-items: center;
    }
    
    #movie {
        margin-bottom: 0;
        flex: 1;
    }
    
    button {
        flex-shrink: 0;
        width: auto;
        max-width: none;
    }
    
    .movie-info {
        max-width: 1200px;
    }
    
    .movie-content {
        gap: 60px;
    }
    
    #poster {
        max-width: 400px;
    }
}

/* Footer */
.site-footer {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    width: 100%;
    z-index: 50;
    padding: 14px 20px;
    text-align: center;
    color: #94a3b8;
    font-size: 0.95rem;
    border-top: 1px solid rgba(255, 255, 255, 0.04);
    backdrop-filter: blur(6px);
    background: linear-gradient(180deg, rgba(15,23,42,0.06), rgba(15,23,42,0.4));
}

.site-footer p {
    margin: 0;
    max-width: 1200px;
    margin-left: auto;
    margin-right: auto;
}