:root {
    --primary-color: #2C5282;
    --secondary-color: #E2E8F0;
    --accent-color: #2C5282;
    --text-light: #FFFFFF;
    --text-dark: #2D3748;
    --shadow-sm: 0 2px 4px rgba(0, 0, 0, 0.05);
    --shadow-md: 0 6px 12px rgba(0, 0, 0, 0.08);
    --transition-fast: 0.2s ease;
    --navbar-height-desktop: 72px;
    --navbar-height-mobile: 60px;
}

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

/* Performance optimizations */
html {
    scroll-behavior: smooth;
    scroll-padding-top: var(--navbar-height-desktop);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    text-rendering: optimizeLegibility;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
    line-height: 1.6;
    color: var(--text-dark);
    background-color: var(--secondary-color);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* Navigation Bar */
.navbar {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    background-color: #F7FAFC;
    padding: 1rem;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.06);
    z-index: 1000;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.nav-brand {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-left: 2rem;
}

.nav-brand a {
    display: flex;
    align-items: center;
    gap: 1rem;
    text-decoration: none;
    color: inherit;
}

.logo {
    height: 50px;
    width: auto;
}

.church-title {
    display: flex;
    flex-direction: column;
}

.church-title h1 {
    font-size: 1.2rem;
    margin: 0;
    color: #2D3748;
}

.church-title h2 {
    font-size: 0.9rem;
    margin: 0;
    color: #666;
}

.auth-container {
    margin-right: 1rem;
    display: flex;
    align-items: center;
}

#loginButton {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    border: none;
    border-radius: 4px;
    background-color: #2C5282;
    color: white;
    cursor: pointer;
    transition: background-color 0.3s ease;
}

#loginButton:hover {
    background-color: #2A4365;
}

#loginButton i {
    font-size: 1rem;
}

#userInfo {
    display: none;
    align-items: center;
    gap: 1rem;
}

.user-name {
    color: var(--text-color);
    font-weight: 500;
}

.logout-btn {
    padding: 0.5rem 1rem;
    border: none;
    border-radius: 4px;
    background-color: #E53E3E;
    color: white;
    cursor: pointer;
    transition: background-color 0.3s ease;
}

.logout-btn:hover {
    background-color: #C53030;
}

/* Main Content */
.container {
    max-width: 1200px;
    width: 100%;
    margin: var(--navbar-height-desktop) auto 0;
    padding: 1.5rem;
    flex: 1;
}

/* Choir Banner */
.choir-banner {
    width: 100%;
    background: linear-gradient(rgba(44, 82, 130, 0.9), rgba(44, 82, 130, 0.9)), url('../images/choir-banner.jpg');
    background-size: cover;
    background-position: center;
    color: white;
    padding: 3rem 2rem;
    margin-bottom: 2rem;
    border-radius: 12px;
    text-align: center;
    box-shadow: var(--shadow-md);
}

.choir-banner h1 {
    color: white;
    font-size: 2.5rem;
    margin-bottom: 1rem;
    font-weight: 700;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.choir-banner p {
    font-size: 1.2rem;
    max-width: 800px;
    margin: 0 auto;
    line-height: 1.6;
    opacity: 0.9;
}

@media (max-width: 768px) {
    .choir-banner {
        padding: 2rem 1.5rem;
        margin-bottom: 1.5rem;
    }

    .choir-banner h1 {
        font-size: 2rem;
    }

    .choir-banner p {
        font-size: 1.1rem;
    }
}

@media (max-width: 480px) {
    .choir-banner {
        padding: 1.5rem 1rem;
        margin-bottom: 1rem;
    }

    .choir-banner h1 {
        font-size: 1.75rem;
    }

    .choir-banner p {
        font-size: 1rem;
    }
}

.page-header {
    text-align: center;
    margin-bottom: 2rem;
    padding: 0;
    background-color: transparent;
    border-radius: 8px;
    box-shadow: none;
}

h1 {
    font-size: 2rem;
    font-weight: 600;
    color: var(--primary-color);
    margin-bottom: 0.5rem;
}

.subtitle {
    font-size: 1.1rem;
    color: var(--text-dark);
    opacity: 0.8;
}

.banner-image {
    width: 100%;
    height: auto;
    max-height: 200px;
    object-fit: cover;
    border-radius: 8px;
    margin-bottom: 2rem;
}

/* Content Layout */
.content-wrapper {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 1rem;
}

.player-section {
    margin-bottom: 3rem;
    background: #FFFFFF;
    border-radius: 12px;
    padding: 1.5rem;
    box-shadow: var(--shadow-md);
}

.video-player {
    position: relative;
    padding-bottom: 56.25%;
    height: 0;
    overflow: hidden;
    max-width: 100%;
    background: #000;
    margin-bottom: 1.5rem;
    border-radius: 8px;
    box-shadow: var(--shadow-sm);
}

.video-player iframe {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    border: none;
}

/* Player Controls */
.player-controls {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 1rem;
    margin: 1.5rem 0;
    flex-wrap: wrap;
    padding: 0.5rem;
}

.control-btn {
    padding: 1rem 1.5rem;
    border: 1px solid #E2E8F0;
    border-radius: 8px;
    background: #FFFFFF;
    color: var(--text-dark);
    cursor: pointer;
    transition: all var(--transition-fast);
    font-size: 1rem;
    min-width: 120px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    box-shadow: var(--shadow-sm);
    font-weight: 500;
}

.control-btn:hover {
    background: #F7FAFC;
    border-color: #CBD5E0;
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.control-btn:active {
    transform: translateY(0);
}

.control-btn-primary {
    background: var(--accent-color);
    color: white;
    font-size: 1.1rem;
    min-width: 140px;
    border: none;
    font-weight: 600;
}

.control-btn-primary:hover {
    background: #2A4365;
}

.control-btn i {
    font-size: 1.1rem;
    line-height: 1;
}

.video-info {
    text-align: center;
    padding: 1rem;
    border-radius: 8px;
    background-color: var(--secondary-color);
}

.video-title {
    font-size: 1.2rem;
    margin-bottom: 0.5rem;
    color: var(--text-dark);
}

.video-date {
    color: var(--text-dark);
    opacity: 0.8;
    font-size: 0.9rem;
}

/* Playlist Section */
.playlist-section {
    background: #FFFFFF;
    border-radius: 8px;
    padding: 1.5rem;
    margin-top: 2rem;
    box-shadow: var(--shadow-sm);
}

.playlist-header {
    margin-bottom: 1.5rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.playlist-header h2 {
    font-size: 1.4rem;
    color: #2C5282;
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.view-all-btn {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    background-color: #2C5282;
    color: white;
    border: none;
    border-radius: 6px;
    font-size: 1rem;
    text-decoration: none;
    transition: background-color 0.2s ease, transform 0.2s ease;
}

.view-all-btn:hover {
    background-color: #1a365d;
    transform: translateY(-2px);
}

.view-all-btn i {
    font-size: 1rem;
}

/* Video Grid Layout */
.video-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 1rem;
    max-height: 500px;
    overflow-y: auto;
    padding: 0.25rem;
    scrollbar-width: thin;
    scrollbar-color: #A0AEC0 var(--secondary-color);
}

.video-grid-item {
    position: relative;
    cursor: pointer;
    background: #fff;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

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

.video-grid-item.active {
    border: 2px solid #3498db;
}

.video-grid-item img {
    width: 100%;
    aspect-ratio: 16/9;
    object-fit: cover;
    display: block;
}

.video-info {
    padding: 12px;
}

.video-title {
    font-weight: 600;
    margin-bottom: 8px;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.video-meta {
    font-size: 0.9em;
    color: #666;
    display: flex;
    gap: 8px;
}

.video-duration {
    background: rgba(0,0,0,0.7);
    color: white;
    padding: 2px 4px;
    border-radius: 3px;
    font-size: 0.8em;
}

/* Video Grid Scrollbar */
.video-grid::-webkit-scrollbar {
    width: 8px;
}

.video-grid::-webkit-scrollbar-track {
    background: var(--secondary-color);
    border-radius: 4px;
}

.video-grid::-webkit-scrollbar-thumb {
    background: #A0AEC0;
    border-radius: 4px;
    border: 2px solid var(--secondary-color);
}

.video-grid::-webkit-scrollbar-thumb:hover {
    background: #718096;
}

/* Responsive Grid Layout */
@media (max-width: 1024px) {
    .container {
        padding: 1rem;
    }
    
    .video-grid {
        grid-template-columns: repeat(2, 1fr);
        max-height: calc((220px * 9/16 + 1rem) * 2 + 1rem); /* Height of 2 videos + gap */
        gap: 1rem;
    }
}

@media (max-width: 768px) {
    html {
        scroll-padding-top: var(--navbar-height-mobile);
    }

    .navbar {
        padding: 0.75rem;
    }

    .nav-brand {
        margin-left: 1rem;
        flex: 1;
    }

    .auth-container {
        margin-right: 0.75rem;
    }

    .logo {
        height: 40px;
    }

    .church-title h1 {
        font-size: 1rem;
    }

    .church-title h2 {
        font-size: 0.8rem;
    }

    .container {
        margin-top: var(--navbar-height-mobile);
        padding: 0.75rem;
    }

    .player-section {
        padding: 1rem;
        margin-bottom: 2rem;
    }

    .player-controls {
        gap: 0.75rem;
    }

    .control-btn {
        padding: 0.75rem 1rem;
        min-width: 100px;
        font-size: 0.9rem;
    }

    .control-btn-primary {
        min-width: 120px;
    }

    .playlist-section {
        padding: 1rem;
    }

    .playlist-header {
        margin-bottom: 1rem;
    }

    .playlist-header h2 {
        font-size: 1.2rem;
    }

    .view-all-btn {
        padding: 0.4rem 0.8rem;
        font-size: 0.9rem;
    }

    .view-all-btn span {
        display: none;
    }
    .view-all-btn i {
        margin: 0 auto;
        font-size: 1.1rem;
    }

    .video-grid {
        grid-template-columns: repeat(2, 1fr);
        max-height: calc((180px * 9/16 + 0.75rem) * 2 + 0.75rem);
        gap: 0.75rem;
    }
}

@media (max-width: 480px) {
    html {
        font-size: 15px;
    }

    .container {
        padding: 0.5rem;
    }

    .navbar {
        padding: 0.5rem;
    }
    .nav-brand {
        margin-left: 0.5rem;
    }
    .logo {
        height: 35px;
    }

    .player-section {
        padding: 0.75rem;
        margin-bottom: 1.5rem;
        border-radius: 8px;
    }

    .player-controls {
        gap: 0.5rem;
        margin: 1rem 0;
    }

    .control-btn {
        padding: 0.6rem 0.8rem;
        min-width: 90px;
        font-size: 0.85rem;
    }
    .control-btn i {
        font-size: 1.1rem;
    }

    .control-btn-primary {
        min-width: 110px;
    }

    .playlist-section {
        padding: 0.75rem;
    }

    .playlist-header h2 {
        font-size: 1.1rem;
    }

    .view-all-btn {
        padding: 0.3rem 0.6rem;
    }
    .view-all-btn i {
        font-size: 1rem;
    }

    .video-grid {
        grid-template-columns: repeat(2, 1fr);
        max-height: calc((140px * 9/16 + 0.5rem) * 2 + 0.5rem);
        gap: 0.5rem;
    }
}

/* Ensure the page is scrollable on mobile */
@media (max-width: 768px) {
    body {
        min-height: 100vh;
        display: flex;
        flex-direction: column;
    }

    main {
        flex: 1;
    }

    .footer {
        margin-top: auto;
        padding: 2rem 1rem 0;
    }

    .footer-row {
        flex-direction: column;
        align-items: center;
        text-align: center;
        gap: 1.5rem;
    }

    .footer-logo img {
        height: 60px;
    }

    .footer-info {
        gap: 1rem;
    }

    .footer-line {
        flex-direction: column;
        gap: 0.75rem;
        text-align: center;
    }

    .korean-name {
        font-size: 1.3rem;
    }

    .church-name {
        font-size: 1.1rem;
    }

    .contact-info {
        font-size: 0.9rem;
        white-space: normal;
    }

    .external-links {
        gap: 1.5rem;
        justify-content: center;
    }

    .external-links a {
        font-size: 0.9rem;
    }

    .copyright {
        font-size: 0.8rem;
        padding: 1rem 0;
    }
}

/* Footer Styles */
.footer {
    background-color: #2C5282;
    padding: 3rem 2rem 0;
    border-top: none;
    margin-top: 2rem;
    color: #FFFFFF;
    flex-shrink: 0;
}

.footer-container {
    max-width: 1300px;
    margin: 0 auto;
    margin-bottom: 1rem;
}

.footer-row {
    display: flex;
    align-items: flex-start;
    gap: 3rem;
}

.footer-logo {
    flex-shrink: 0;
}

.footer-logo img {
    height: 80px;
    width: auto;
    transition: transform var(--transition-fast), box-shadow var(--transition-fast);
}

.footer-info {
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
}

.footer-line {
    display: flex;
    align-items: center;
    gap: 2rem;
    line-height: 1.6;
}

.korean-name {
    font-size: 1.5rem;
    font-weight: 500;
    min-width: max-content;
}

.church-name {
    font-size: 1.3rem;
    font-weight: 500;
    min-width: max-content;
}

.contact-info {
    color: #E2E8F0;
    font-size: 1.2rem;
    white-space: nowrap;
}

.external-links {
    display: flex;
    align-items: center;
    gap: 2rem;
}

.external-links a {
    color: #EDF2F7;
    text-decoration: none;
    transition: color 0.3s ease;
    font-size: 1.2rem;
}

.external-links a:hover {
    color: #FFFFFF;
    text-decoration: underline;
}

.copyright {
    background-color: #2C5282;
    color: white;
    display: block;
    font-family: Merriweather, "Helvetica Neue", Arial, sans-serif;
    font-size: 14px;
    line-height: 20px;
    padding: 20px 0;
    text-align: center;
    width: 100%;
    margin: 0;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
}

/* Responsive Footer */
@media (max-width: 1200px) {
    .footer-line {
        gap: 1.5rem;
    }

    .korean-name {
        font-size: 1.4rem;
    }

    .church-name {
        font-size: 1.2rem;
    }

    .contact-info,
    .external-links a {
        font-size: 1.1rem;
    }
}

@media (max-width: 768px) {
    .navbar {
        padding: 0.75rem;
    }

    .nav-brand {
        margin-left: 1rem;
    }

    .logo {
        height: 40px;
    }

    .church-title h1 {
        font-size: clamp(0.9rem, 2vw, 1.2rem);
    }

    .church-title h2 {
        font-size: 0.8rem;
    }

    .container {
        margin-top: 90px;
    }

    .footer {
        padding: 2rem 1.5rem 0;
    }

    .footer-row {
        flex-direction: column;
        align-items: center;
        text-align: center;
        gap: 2rem;
    }

    .footer-logo img {
        height: 70px;
    }

    .footer-info {
        gap: 1rem;
        align-items: center;
    }

    .footer-line {
        flex-direction: column;
        align-items: center;
        gap: 1rem;
    }

    .korean-name {
        font-size: 1.3rem;
    }

    .church-name {
        font-size: 1.2rem;
    }

    .contact-info,
    .external-links a {
        font-size: 1.1rem;
    }

    .external-links {
        gap: 1.5rem;
    }
}

@media (max-width: 480px) {
    .logo {
        height: 35px;
    }

    .church-title h1 {
        font-size: 0.9rem;
    }

    .church-title h2 {
        font-size: 0.7rem;
    }

    .footer {
        padding: 1.5rem 1rem 0;
    }

    .footer-logo img {
        height: 60px;
    }

    .footer-line {
        gap: 0.75rem;
    }

    .korean-name {
        font-size: 1.2rem;
    }

    .church-name {
        font-size: 1.1rem;
    }

    .contact-info,
    .external-links a {
        font-size: 1rem;
    }

    .external-links {
        flex-direction: column;
        gap: 0.75rem;
    }

    .copyright {
        font-size: 12px;
        line-height: 18px;
        padding: 16px 0;
    }
}

/* Banner Carousel */
.banner-carousel {
    position: relative;
    width: 100%;
    margin-bottom: 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    align-items: center;
}

.carousel-container {
    position: relative;
    width: 100%;
    padding-bottom: 20%;
    overflow: hidden;
    border-radius: 8px;
    background-color: var(--secondary-color);
    box-shadow: var(--shadow-sm);
}

.carousel-track {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
}

.carousel-slide {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.5s ease-in-out, visibility 0.5s ease-in-out;
}

.carousel-slide.active {
    opacity: 1;
    visibility: visible;
}

.carousel-slide img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.carousel-navigation {
    position: static;
    transform: none;
    display: flex;
    gap: 0.5rem;
    padding: 0.5rem 0;
}

.carousel-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: rgba(44, 82, 130, 0.3);
    border: none;
    padding: 0;
    cursor: pointer;
    transition: background-color 0.3s ease;
}

.carousel-dot.active {
    background: #2C5282;
}

@media (max-width: 1024px) {
    .carousel-container {
        padding-bottom: 35%;
    }
}

@media (max-width: 768px) {
    .banner-carousel {
        gap: 0.75rem;
        margin-bottom: 1.5rem;
    }

    .carousel-container {
        padding-bottom: 25%;
    }

    .carousel-navigation {
        gap: 0.5rem;
    }
    .carousel-dot {
        width: 10px;
        height: 10px;
    }
}

@media (max-width: 480px) {
    .banner-carousel {
        gap: 0.5rem;
        margin-bottom: 1rem;
    }
    
    .carousel-dot {
        width: 10px;
        height: 10px;
    }

    .carousel-container {
        padding-bottom: 30%;
    }
}

/* Loading and Error States */
.loading-placeholder {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
    padding: 2rem 1rem;
    text-align: center;
    color: #718096;
    min-height: 150px;
    font-size: 0.9rem;
}

.loading-placeholder i {
    font-size: 1.8rem;
    color: var(--accent-color);
    margin-bottom: 0.5rem;
}

@media (max-width: 480px) {
    .loading-placeholder {
        padding: 1rem 0.5rem;
        min-height: 100px;
    }

    .loading-placeholder i {
        font-size: 1.5rem;
    }
}

/* Scrollbar Styles */
.video-grid::-webkit-scrollbar {
    width: 6px;
}

.video-grid::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 3px;
}

.video-grid::-webkit-scrollbar-thumb {
    background: #888;
    border-radius: 3px;
}

.video-grid::-webkit-scrollbar-thumb:hover {
    background: #555;
}

@media (max-width: 480px) {
    .video-grid::-webkit-scrollbar {
        width: 4px;
    }
}

.error-message {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 1rem;
    background: #FEF2F2;
    color: #991B1B;
    border-radius: 6px;
    font-size: 0.9rem;
}

.error-message i {
    font-size: 1.2rem;
}