*,
*::before,
*::after {
    box-sizing: border-box;
}

:root {
    --primary-bg: #0f172a;
    --card-bg: rgba(30, 41, 59, 0.7);
    --accent-blue: #1e40af;
    --accent-gold: #fbbf24;
    --accent-bible: #166534;
    --text-main: #f8fafc;
    --text-muted: #94a3b8;
    --glass-border: rgba(255, 255, 255, 0.1);
    --accent-viber: #73348f;
    --section-bg: rgba(15, 23, 42, 0.3);
    --modal-overlay: rgba(0, 0, 0, 0.8);
}

:root.light-mode {
    --primary-bg: #f8fafc;
    --card-bg: rgba(255, 255, 255, 0.8);
    --text-main: #0f172a;
    --text-muted: #475569;
    --glass-border: rgba(0, 0, 0, 0.1);
    --section-bg: rgba(241, 245, 249, 0.8);
    --modal-overlay: rgba(255, 255, 255, 0.4);
}

body {
    background-color: var(--primary-bg);
    color: var(--text-main);
    font-family: 'Inter', sans-serif;
    margin: 0;
    line-height: 1.6;
    transition: background-color 0.3s ease, color 0.3s ease;
    overflow-x: hidden;
    overflow-wrap: break-word;
}

.container {
    max-width: 100%;
    margin: 0 auto;
    padding: 1.25rem;
    position: relative;
}

@media (min-width: 768px) {
    .container {
        max-width: 98%;
        padding: 2rem;
    }
}

/* Glassmorphism Cards */
.glass-card {
    background: var(--card-bg);
    backdrop-filter: blur(12px);
    border: 1px solid var(--glass-border);
    border-radius: 1rem;
    padding: 1.25rem;
    box-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.37);
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

@media (min-width: 768px) {
    .glass-card {
        padding: 1.5rem;
    }
}

.glass-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 12px 40px 0 rgba(0, 0, 0, 0.45);
}

.top-row-flex {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
    margin-bottom: 2rem;
    width: 100%;
    max-width: 100%;
}

.top-row-flex>div {
    min-width: 0;
    /* Prevents children from pushing parent width */
}

@media (min-width: 768px) and (max-width: 1023px) {
    .top-row-flex {
        display: flex;
        flex-wrap: wrap;
        gap: 1.5rem;
    }

    .recommended-section {
        flex: 1 1 calc(50% - 0.75rem);
        order: 1;
        margin-bottom: 0 !important;
    }

    .section-wrapper.viber {
        flex: 1 1 calc(50% - 0.75rem);
        order: 2;
        margin-bottom: 0 !important;
    }

    .section-wrapper.bible {
        flex: 1 1 100%;
        order: 3;
        margin-bottom: 0 !important;
    }
}

@media (min-width: 1024px) {
    .top-row-flex {
        flex-direction: row;
        display: flex;
        align-items: stretch;
        gap: 1.5rem;
    }

    .recommended-section {
        flex: 1;
        /* 25% */
        margin-bottom: 0 !important;
    }

    .section-wrapper.bible {
        flex: 2;
        /* 50% */
        margin-bottom: 0 !important;
    }

    .section-wrapper.viber {
        flex: 1;
        /* 25% */
        margin-bottom: 0 !important;
    }
}

/* Hero Section */
.hero-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 1rem;
}

.hero-card {
    padding: 1.25rem;
    border-top: 3px solid var(--accent-bible);
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
    align-items: stretch;
}

@media (min-width: 768px) {
    .hero-card {
        flex-direction: row;
        align-items: flex-start;
    }
}

.hero-card .media-container {
    flex: 0 0 auto;
    width: 100%;
    margin-bottom: 1rem;
}

@media (min-width: 768px) {
    .hero-card .media-container {
        flex: 0 0 240px;
        margin-bottom: 0;
    }
}

.hero-card .content-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
    width: 100%;
    overflow: hidden;
}

.hero-card h3 {
    font-size: 1rem;
    margin: 0.25rem 0 0.5rem 0;
    line-height: 1.3;
}

@media (max-width: 768px) {
    .hero-grid {
        grid-template-columns: 1fr;
    }
}

.bible-plan-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.5rem;
}

.hero-card .media-wrapper {
    position: relative;
    padding-bottom: 56.25%;
    height: 0;
}

.hero-card .media-wrapper iframe {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    border-radius: 0.5rem;
}

/* Cleaning up old media query as it's now handled above */
/* Removed @media (max-width: 640px) block for hero-card */

.accent-green {
    color: var(--accent-bible);
    font-weight: 600;
}

/* Category Tabs */
.tabs {
    display: flex;
    flex-wrap: wrap;
    gap: 0.8rem;
    row-gap: 1rem;
    margin-bottom: 2rem;
}

.tab-btn {
    background: transparent;
    border: 2px solid var(--glass-border);
    color: var(--text-muted);
    padding: 0.5rem 1.5rem;
    border-radius: 2rem;
    cursor: pointer;
    white-space: nowrap;
    transition: all 0.3s ease;
    font-weight: 600;
}

.tab-btn:hover {
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-main);
}

.light-mode .tab-btn:hover {
    background: rgba(0, 0, 0, 0.05);
}

.tab-btn.active {
    background: var(--active-bg, var(--accent-bible));
    color: white;
    border-color: var(--active-bg, var(--accent-bible)) !important;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

/* Search Filter */
.search-container {
    position: relative;
    flex-grow: 1;
    max-width: 300px;
    margin-left: auto;
}

.search-input {
    width: 100%;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--glass-border);
    border-radius: 2rem;
    padding: 0.6rem 1rem 0.6rem 2.5rem;
    color: var(--text-main);
    font-size: 0.9rem;
    outline: none;
    transition: all 0.3s ease;
}

.search-input:focus {
    border-color: var(--accent-bible);
    background: rgba(255, 255, 255, 0.1);
    box-shadow: 0 0 10px rgba(22, 101, 52, 0.2);
}

.search-icon {
    position: absolute;
    left: 1rem;
    top: 50%;
    transform: translateY(-50%);
    font-size: 0.9rem;
    opacity: 0.5;
    pointer-events: none;
}

@media (max-width: 768px) {
    .search-container {
        max-width: 100%;
        margin-left: 0;
        margin-top: 0.5rem;
    }
}

/* Church Grid */
.church-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
    gap: 1.5rem;
}

.church-card {
    display: flex;
    flex-direction: column;
    height: 100%;
    padding: 0;
    overflow: hidden;
    border-top: none; /* Removed the heavy top border */
    background: var(--card-bg);
    border: 1px solid var(--glass-border);
    transition: all 0.3s ease;
}

.church-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.4);
    border-color: rgba(255, 255, 255, 0.15);
}

.church-thumb {
    width: 100%;
    aspect-ratio: 16 / 9;
    object-fit: cover;
    border-bottom: 1px solid var(--glass-border);
}

.church-thumb {
    width: 100%;
    aspect-ratio: 16 / 9;
    object-fit: cover;
    border-bottom: 1px solid var(--glass-border);
}

.church-info {
    padding: 1.25rem;
    display: flex;
    flex-direction: column;
    flex-grow: 1;
    position: relative;
    gap: 0.5rem;
}

.church-indicator {
    position: absolute;
    left: 0;
    top: 1.25rem;
    bottom: 1.25rem;
    width: 3px;
    background: var(--accent-gold);
    border-radius: 0 2px 2px 0;
}

.church-title-wrapper {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.25rem;
    padding-left: 0.75rem; /* Space for the indicator */
}

.church-title {
    font-size: 1.05rem;
    font-weight: 700;
    color: var(--text-main);
    margin: 0;
    line-height: 1.2;
}

.message-title {
    font-size: 0.95rem; /* Slightly larger as requested */
    color: var(--text-muted);
    margin: 0 0 1rem 0;
    flex-grow: 1;
    padding-left: 0.75rem;
    line-height: 1.5;
}

.btn-watch {
    display: flex;
    align-items: center;
    justify-content: center;
    background: #d97706; /* Solid Professional Amber */
    color: white;
    text-align: center;
    padding: 0.75rem 1rem;
    border-radius: 0.75rem;
    text-decoration: none;
    font-weight: 700;
    border: none;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    transition: all 0.3s ease;
    font-size: 0.9rem;
    text-transform: none; /* Keep it readable */
    width: 100%;
}

.btn-watch:hover {
    background: #f59e0b;
    transform: translateY(-2px);
    box-shadow: 0 6px 15px rgba(217, 119, 6, 0.3);
}

/* Modal Styling */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: var(--modal-overlay);
    backdrop-filter: blur(5px);
}

.modal-content {
    background-color: var(--primary-bg);
    margin: 10% auto;
    padding: 2rem;
    border: 1px solid var(--glass-border);
    border-radius: 1rem;
    width: 80%;
    max-width: 600px;
    max-height: 70vh;
    overflow-y: auto;
}

.close-btn {
    color: var(--text-muted);
    float: right;
    font-size: 2rem;
    cursor: pointer;
}

.history-item {
    border-bottom: 1px solid var(--glass-border);
    padding: 1rem 0;
}

.history-item:last-child {
    border-bottom: none;
}

/* Month Navigation Strip */
.month-nav {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
    row-gap: 0.6rem;
    margin-top: 0.75rem;
    width: 100%;
}

.month-nav::-webkit-scrollbar {
    display: none;
}

.month-link {
    font-size: 0.7rem;
    color: var(--text-muted);
    text-decoration: none;
    background: rgba(255, 255, 255, 0.05);
    padding: 0.2rem 0.5rem;
    border-radius: 1rem;
    white-space: nowrap;
    transition: all 0.3s ease;
    border: 1px solid transparent;
}

.month-link:hover {
    background: rgba(22, 101, 52, 0.1);
    color: var(--accent-bible);
}

.month-link.active {
    background: var(--accent-bible);
    color: white;
    font-weight: 700;
}

/* Calendar Modal & Grid */
.calendar-modal-content {
    max-width: 500px;
    width: 95%;
}

.calendar-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 0.5rem;
    margin-top: 1rem;
}

.calendar-day-header {
    text-align: center;
    font-size: 0.75rem;
    font-weight: 700;
    color: var(--accent-bible);
    padding-bottom: 0.5rem;
}

.calendar-cell {
    aspect-ratio: 1/1;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 0.4rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    font-size: 0.8rem;
    position: relative;
    border: 1px solid var(--glass-border);
    transition: all 0.2s ease;
    cursor: pointer;
}

.calendar-cell:hover {
    transform: scale(1.05);
    background: rgba(22, 101, 52, 0.15);
    border-color: var(--accent-bible);
}

.calendar-cell.today {
    border-color: var(--accent-bible);
    box-shadow: 0 0 10px rgba(22, 101, 52, 0.3);
}

.calendar-day-num {
    font-weight: 700;
    margin-bottom: 0.2rem;
}

.calendar-links {
    display: flex;
    gap: 0.3rem;
}

.calendar-mini-link {
    font-size: 0.6rem;
    text-decoration: underline;
    color: inherit;
    padding: 0 0.2rem;
}

/* Section Wrappers */
.section-wrapper {
    border: 2px solid var(--glass-border);
    border-radius: 1.5rem;
    padding: 1.5rem 1.25rem 1.25rem 1.25rem;
    margin-bottom: 2rem;
    position: relative;
    background: var(--section-bg);
    width: 100%;
    max-width: 100%;
}

.section-wrapper.bible {
    border-color: var(--accent-bible);
}

.section-wrapper.churches {
    border-color: var(--accent-blue);
}

.section-wrapper.viber {
    border-color: var(--accent-viber);
}

.section-label {
    position: absolute;
    top: -11px;
    left: 1.5rem;
    background: var(--primary-bg);
    padding: 0 0.75rem;
    font-size: 0.75rem;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 1.5px;
    transition: background-color 0.3s ease;
}

.section-label.gold {
    color: var(--accent-bible);
}

.section-label.dark-gold {
    color: #d97706;
}

.section-label.purple {
    color: var(--accent-viber);
}

.section-label.blue {
    color: var(--accent-blue);
}

/* Recommended Card Top - Matching User Image */
.recommended-section {
    margin-bottom: 2rem;
    padding: 1.5rem 1.25rem 1.25rem 1.25rem;
    border: 2px solid #d97706;
    border-radius: 1.5rem;
    display: none;
    position: relative;
    background: var(--section-bg);
}

.recommended-section .accent-text {
    font-size: 0.75rem;
    letter-spacing: 0.5px;
    opacity: 0.9;
}

.btn-clear {
    background: transparent;
    border: 1px solid var(--glass-border);
    color: var(--text-muted);
    font-size: 0.65rem;
    padding: 0.25rem 0.5rem;
    border-radius: 0.5rem;
    cursor: pointer;
    transition: all 0.3s ease;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.btn-clear:hover {
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-main);
    border-color: var(--text-muted);
}

/* Video Player Styling */
.video-modal-content {
    max-width: 900px;
    width: 90%;
    padding: 1rem;
}

.video-modal-content .close-btn {
    position: absolute;
    right: 1.5rem;
    top: 1rem;
    z-index: 10;
}

.video-container {
    position: relative;
    padding-bottom: 56.25%;
    /* 16:9 ratio */
    height: 0;
    overflow: hidden;
    background: #000;
    border-radius: 0.5rem;
    margin-top: 1rem;
}

.video-container iframe {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
}

/* Recommended Section Redesign */
.rec-list {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.rec-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.75rem 1rem;
    background: rgba(255, 255, 255, 0.03);
    border-radius: 0.75rem;
    border: 1px solid var(--glass-border);
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
    text-decoration: none;
    color: inherit;
    cursor: pointer;
}

.light-mode .rec-item {
    background: rgba(0, 0, 0, 0.02);
}

.rec-item:hover {
    background: rgba(255, 255, 255, 0.05);
    transform: translateX(4px);
    border-color: rgba(251, 191, 36, 0.3);
}

.light-mode .rec-item:hover {
    background: rgba(0, 0, 0, 0.04);
}

.rec-indicator {
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 4px;
    background: var(--accent-gold);
}

.rec-content {
    flex: 1;
    min-width: 0;
    padding-right: 1rem;
}

.rec-church-name {
    margin: 0;
    font-size: 0.95rem;
    font-weight: 700;
    color: var(--text-main);
    line-height: 1.2;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.rec-lang-pill {
    font-size: 0.65rem;
    font-weight: 600;
    text-transform: uppercase;
    padding: 0.1rem 0.4rem;
    border-radius: 0.25rem;
    background: rgba(255, 255, 255, 0.1);
    color: var(--text-muted);
}

.light-mode .rec-lang-pill {
    background: rgba(0, 0, 0, 0.05);
}

.rec-message-title {
    margin: 0.25rem 0 0 0;
    font-size: 0.8rem;
    color: var(--text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.rec-btn-watch {
    width: auto;
    display: inline-flex;
    flex-shrink: 0;
    padding: 0.4rem 0.8rem;
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}
