/* Main App Structure */
body {
    background-color: var(--bg-primary, #F9F7F2);
    color: var(--text-primary, #1A252F);
    font-family: var(--font-family-sans, sans-serif);
    margin: 0;
    padding: 0;
    -webkit-font-smoothing: antialiased;
}

#app {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

/* Header & Nav */
.app-header {
    background: #fff;
    padding: 15px 20px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.05);
    position: sticky;
    top: 0;
    z-index: 100;
}

.logo {
    text-align: center;
    margin-bottom: 10px;
}

.logo-img {
    height: 40px;
    /* Fix huge logo issue */
    width: auto;
    display: block;
    margin: 0 auto;
}

.main-nav {
    display: flex;
    justify-content: center;
    gap: 10px;
    overflow-x: auto;
    white-space: nowrap;
    padding-bottom: 5px;
    /* for scrollbar */
}

.nav-btn {
    border: none;
    background: none;
    padding: 8px 16px;
    font-size: 0.95rem;
    color: var(--text-muted, #999);
    cursor: pointer;
    border-radius: 20px;
    transition: all 0.2s;
}

.nav-btn.active {
    background: var(--color-terra-400, #C19A6B);
    color: #fff;
    font-weight: 600;
}

.menu-toggle {
    display: none;
}

.menu-toggle:focus-visible,
.nav-btn:focus-visible {
    outline: 3px solid var(--color-terra-400, #C19A6B);
    outline-offset: 3px;
}

@media (max-width: 767px) {
    .app-header {
        display: flex;
        flex-wrap: wrap;
        align-items: center;
        justify-content: space-between;
        gap: 10px;
    }

    .app-header .logo {
        margin-bottom: 0;
    }

    .menu-toggle {
        display: flex;
        align-items: center;
        justify-content: center;
        width: 44px;
        height: 44px;
        border: 1px solid #ddd;
        border-radius: 10px;
        background: #fff;
        color: var(--text-primary, #1A252F);
        font-size: 1.5rem;
        cursor: pointer;
    }

    .main-nav {
        display: none;
        flex-direction: column;
        flex-basis: 100%;
        gap: 4px;
        overflow: visible;
        padding: 8px 0 0;
        border-top: 1px solid #eee;
    }

    .main-nav.is-open {
        display: flex;
    }

    .main-nav .nav-btn {
        display: flex;
        align-items: center;
        min-height: 44px;
        box-sizing: border-box;
        padding: 10px 16px;
        border-radius: 10px;
        text-align: left;
    }
}

/* Main Content */
#main-content {
    flex: 1;
    padding: 20px;
    max-width: 600px;
    margin: 0 auto;
    width: 100%;
    box-sizing: border-box;
}

/* Hero Section */
.hero-section {
    text-align: center;
    padding: 40px 20px;
    background: var(--color-sand-200, #E6E0D4);
    border-radius: 12px;
    margin-bottom: 20px;
}

.hero-content h2 {
    font-size: 1.5rem;
    color: var(--color-terra-600, #8B5E3C);
    margin-bottom: 10px;
}

/* Daily Card */
.daily-card {
    background: #fff;
    border-radius: 16px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.08);
    overflow: hidden;
    padding: 0;
}

.card-header {
    background: var(--color-terra-600, #8B5E3C);
    color: #fff;
    padding: 15px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.date-badge {
    font-weight: 600;
}

.day-badge {
    background: rgba(255, 255, 255, 0.2);
    padding: 4px 10px;
    border-radius: 12px;
    font-size: 0.85rem;
}

.card-body {
    padding: 25px 20px;
    text-align: center;
}

.card-body h3 {
    font-size: 1.4rem;
    margin-bottom: 10px;
    color: var(--color-night-900, #1A252F);
}

.subtitle {
    font-size: 1rem;
    color: var(--color-terra-500, #A67B5B);
    margin-bottom: 20px;
    line-height: 1.5;
}

.btn-primary {
    background: var(--color-terra-500, #A67B5B);
    color: white;
    border: none;
    padding: 12px 24px;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    width: 100%;
    box-sizing: border-box;
    /* Fix width overflow */
    transition: background 0.2s;
}

.btn-primary:active {
    transform: scale(0.98);
}

.btn-primary.completed {
    background: var(--color-olive-500, #6B8E23);
}

/* Yearly Schedule Layout Fix (Preserved) */
.schedule-card-year {
    display: flex;
    align-items: flex-start;
    gap: 20px;
    /* Wider gap between Month and List */
    padding: 15px 0;
    border-bottom: 1px solid var(--border-color, #e0e0e0);
}

.schedule-card-year strong {
    flex: 0 0 60px;
    /* Fixed width to prevent wrapping for "12월" */
    white-space: nowrap;
    text-align: center;
    color: var(--color-terra-600, #8B5E3C);
    font-weight: 700;
    margin-top: 3px;
    /* visual alignment with text */
}

.schedule-card-year p {
    margin: 0 !important;
    flex: 1;
    line-height: 1.6;
    color: var(--text-primary, #333);
}

.year-list {
    display: flex;
    flex-direction: column;
    gap: 5px;
}

/* Footer */
.app-footer {
    text-align: center;
    padding: 20px;
    color: var(--text-muted, #999);
    font-size: 0.8rem;
    margin-top: auto;
}

/* Responsive */
@media (max-width: 480px) {
    .app-header {
        padding: 10px 15px;
    }

    .logo-img {
        height: 32px;
    }

    .nav-btn {
        padding: 6px 12px;
        font-size: 0.85rem;
    }

    .hero-content h2 {
        font-size: 1.3rem;
    }
}

/* Sticker Map / Puzzle Styles */
.view-container {
    padding: 10px 0;
}

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

.month-nav-btn {
    background: none;
    border: 1px solid var(--border-color, #ccc);
    width: 36px;
    height: 36px;
    border-radius: 50%;
    font-size: 1.1rem;
    cursor: pointer;
    color: var(--text-secondary, #666);
}

.puzzle-board {
    position: relative;
    width: 100%;
    max-width: 400px;
    aspect-ratio: 1 / 1;
    /* Keep it square-ish */
    margin: 0 auto;
    background-size: cover;
    background-position: center;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    background-color: #eee;
    /* Fallback if image missing */
}

/* 
 * Grid System for Puzzle
 * Using a flexible grid that adapts to roughly 30-31 items
 * A 6x6 grid = 36 slots, enough for 31 days 
 */
.puzzle-grid {
    display: grid;
    grid-template-columns: repeat(6, 1fr);
    grid-template-rows: repeat(6, 1fr);
    width: 100%;
    height: 100%;
}

.puzzle-piece {
    background-color: rgba(255, 255, 255, 0.92);
    /* Opaque cover */
    border: 1px solid rgba(0, 0, 0, 0.05);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.85rem;
    font-weight: 500;
    color: #999;
    transition: all 0.5s ease;
}

/* When revealed, become transparent to show background */
.puzzle-piece.revealed {
    background-color: transparent !important;
    border-color: transparent;
    color: transparent;
    /* Hide number */
}

.map-text {
    text-align: center;
    margin-top: 20px;
    font-size: 0.95rem;
    color: var(--text-secondary, #555);
    line-height: 1.5;
}

/* Comment Section (Community) */
.community-feed {
    margin-top: 20px;
}

.comment-input-area textarea {
    width: 100%;
    height: 80px;
    padding: 12px;
    border: 1px solid #ddd;
    border-radius: 8px;
    resize: none;
    font-family: inherit;
}

.comment-list {
    margin-top: 20px;
}

.comment-card {
    background: #fff;
    padding: 15px;
    border-radius: 12px;
    margin-bottom: 15px;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.03);
    border: 1px solid #eee;
}

.comment-header {
    display: flex;
    justify-content: space-between;
    font-size: 0.85rem;
    margin-bottom: 8px;
}

.user-name {
    font-weight: bold;
    color: var(--color-navy, #03234B);
}

.time {
    color: #999;
}

.comment-body {
    margin: 0;
    font-size: 0.95rem;
    line-height: 1.5;
    color: #333;
}

.like-btn {
    background: none;
    border: none;
    font-size: 0.8rem;
    color: #888;
    margin-top: 10px;
    cursor: pointer;
}

/* Guide View Tabs & Styling Improvements */

/* Top-level Tabs (Purpose vs Schedule) */
.guide-tabs {
    display: flex;
    width: 100%;
    border-bottom: 2px solid var(--color-terra-400, #C19A6B);
    margin-bottom: 25px;
}

.tab-btn {
    flex: 1;
    /* Equal width for mobile */
    padding: 14px 10px;
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-secondary, #666);
    background: #f4f4f4;
    border: none;
    border-radius: 8px 8px 0 0;
    cursor: pointer;
    transition: all 0.2s ease;
    text-align: center;
}

.tab-btn.active {
    background: #fff;
    color: var(--color-terra-600, #8B5E3C);
    border: 2px solid var(--color-terra-400, #C19A6B);
    border-bottom: none;
    /* Blend with content */
    margin-bottom: -2px;
    /* Overlap border */
    position: relative;
    z-index: 2;
    box-shadow: 0 -2px 5px rgba(0, 0, 0, 0.03);
}

/* Info Section Styling (Purpose) */
.info-section {
    background: #fff;
    padding: 20px;
    border-radius: 12px;
    margin-bottom: 20px;
    box-shadow: var(--shadow-sm);
    line-height: 1.7;
}

/* Reward Cards */
.reward-card {
    display: flex;
    align-items: center;
    gap: 15px;
    background: var(--bg-primary, #F9F7F2);
    padding: 15px;
    border-radius: 10px;
    margin-bottom: 12px;
    border: 1px solid var(--border-color);
}

.reward-icon {
    font-size: 2rem;
}

.reward-text strong {
    display: block;
    margin-bottom: 4px;
    color: var(--color-navy);
}

.reward-text p {
    margin: 0;
    font-size: 0.85rem;
    color: #666;
}

/* Sub-level Tabs (Schedule View: Year/Month/Week) */
.schedule-controls {
    display: flex;
    justify-content: center;
    gap: 10px;
    margin-bottom: 20px;
    padding: 5px;
    background: #f8f9fa;
    border-radius: 30px;
    display: inline-flex;
    /* Shrink to fit content, centered */
    width: 100%;
    /* Full width on mobile? -> Maybe flex wrap */
}

/* Override for better mobile fit */
@media (max-width: 480px) {
    .schedule-controls {
        display: flex;
        width: 100%;
        background: transparent;
        /* Remove container bg on mobile */
        padding: 0;
        justify-content: space-between;
    }
}

.pill-btn {
    padding: 8px 16px;
    border-radius: 20px;
    border: 1px solid transparent;
    background: transparent;
    color: #666;
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    flex: 1;
    /* Stretch on mobile */
    text-align: center;
}

.pill-btn.active {
    background: var(--color-terra-500, #A67B5B);
    color: #fff;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.15);
    font-weight: 600;
}

/* Clear hierarchy separator */
.guide-content {
    animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(5px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Signup / Login Screen Styles */
.signup-container {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 60vh;
    /* Ensure it takes up space */
    padding: 20px;
}

.signup-card {
    background: #fff;
    padding: 30px 25px;
    border-radius: 20px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.08);
    /* Soft premium shadow */
    width: 100%;
    max-width: 340px;
    text-align: center;
    border: 1px solid rgba(0, 0, 0, 0.03);
}

.signup-card h2 {
    color: var(--color-terra-600, #8B5E3C);
    margin-bottom: 15px;
    font-size: 1.6rem;
}

.signup-card p {
    color: #666;
    margin-bottom: 25px;
    line-height: 1.5;
    font-size: 0.95rem;
}

.input-group input {
    width: 100%;
    box-sizing: border-box;
    /* Important for padding */
}

/* Ensure global buttons look good */
.btn-primary {
    display: block;
    width: 100%;
    padding: 14px;
    font-size: 1.1rem;
    margin-top: 10px;
    /* other styles already in base */
}

/* Q&A Section Styling */
.qna-input-box {
    background: #fff;
    padding: 15px;
    border-radius: 12px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.05);
    margin-bottom: 20px;
}

.qna-input-box textarea {
    width: 100%;
    height: 120px;
    /* Increased height */
    padding: 15px;
    border: 1px solid #ddd;
    border-radius: 8px;
    resize: vertical;
    /* Allow manual resizing */
    font-family: inherit;
    font-size: 1rem;
    box-sizing: border-box;
    /* Critical for 100% width */
    margin-bottom: 10px;
}

/* Ensure the button matches */
.qna-input-box .btn-primary {
    width: 100%;
    /* Explicitly full width */
    margin-top: 5px;
}

.qna-card {
    background: #fff;
    padding: 20px;
    border-radius: 12px;
    margin-bottom: 15px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
    border: 1px solid #eee;
}

.qna-header {
    display: flex;
    justify-content: space-between;
    margin-bottom: 10px;
    font-size: 0.9rem;
    color: #666;
    border-bottom: 1px dashed #eee;
    padding-bottom: 8px;
}

.qna-content {
    font-size: 1rem;
    line-height: 1.6;
    color: #333;
    margin-bottom: 15px;
    white-space: pre-line;
    /* Preserve line breaks */
}

.qna-replies {
    background: #f8f9fa;
    padding: 15px;
    border-radius: 8px;
    margin-top: 10px;
}

/* Replies */
.reply-item p {
    margin: 5px 0;
    line-height: 1.5;
    white-space: pre-line;
    /* Fix line breaks */
}

.reply-item {
    border-bottom: 1px solid #eee;
    padding-bottom: 10px;
    margin-bottom: 10px;
}

.reply-item:last-child {
    border-bottom: none;
    margin-bottom: 0;
    padding-bottom: 0;
}

.reply-author {
    font-weight: bold;
    color: var(--color-terra-600, #8B5E3C);
    margin-bottom: 4px;
    font-size: 0.9rem;
}

/* Certificate Styling */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.8);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 2000;
    padding: 20px;
    animation: fadeIn 0.3s ease;
}

.certificate-modal {
    /* Combine Gold Frame + Logo Watermark */
    background:
        url('../assets/images/church_logo.png') no-repeat center,
        url('../images/cert_bg.png') no-repeat center;
    background-size: 150px, 100% 100%;
    /* Check actual image ratio */
    background-blend-mode: overlay, normal;
    background-color: #fff;

    width: 100%;
    max-width: 500px;
    aspect-ratio: 1/1;
    padding: 60px 40px;
    border-radius: 4px;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.5);
    text-align: center;
    position: relative;
    box-sizing: border-box;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

/* Remove CSS Borders */
.cert-border {
    border: none;
    padding: 0;
    position: relative;
}

.cert-header {
    font-family: 'Merriweather', serif;
    font-size: 1.8rem;
    color: #1A252F;
    margin-bottom: 20px;
    font-weight: 700;
    letter-spacing: -0.5px;
}

.cert-title {
    font-size: 1.2rem;
    color: #C19A6B;
    text-transform: uppercase;
    letter-spacing: 2px;
    margin-bottom: 10px;
}

.cert-body {
    font-family: 'Inter', sans-serif;
    color: #333;
    line-height: 1.8;
    margin-bottom: 30px;
}

.cert-name {
    font-size: 1.8rem;
    font-weight: bold;
    color: #000;
    border-bottom: 2px solid #C19A6B;
    display: inline-block;
    padding: 0 20px 5px 20px;
    margin: 15px 0 25px 0;
}

.cert-badge {
    font-size: 4rem;
    margin: 10px 0;
    text-shadow: 0 5px 10px rgba(0, 0, 0, 0.2);
}

.cert-footer {
    margin-top: 30px;
    font-family: 'Merriweather', serif;
    font-weight: bold;
    color: #555;
}
