/* 기본 설정 초기화 */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: 'Malgun Gothic', 'Dotum', sans-serif;
    line-height: 1.6;
    color: #333;
    background-color: #f4f4f4;
}

header, main, footer {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px;
}

/* 헤더 스타일 */
header {
    background: #fff;
    padding: 15px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 3px solid #0056b3;
}

header .site-logo a {
    color: #0056b3;
    text-decoration: none;
    font-size: 1.5em;
    font-weight: bold;
}

nav ul {
    list-style: none;
    display: flex;
}

nav ul li a {
    text-decoration: none;
    color: #333;
    padding: 10px 15px;
    display: block;
    font-weight: bold;
}

nav ul li a:hover, nav ul li.active a {
    color: #ff9900;
}

.donate-btn {
    background-color: #ff9900;
    color: white;
    padding: 10px 20px;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    font-weight: bold;
    text-decoration: none;
    transition: background-color 0.3s;
}

.donate-btn:hover {
    background-color: #e58700;
}

/* Auth 버튼 스타일 */
.auth-btn {
    padding: 6px 12px;
    border-radius: 4px;
    font-size: 0.85em;
    font-weight: 600;
    text-decoration: none;
    transition: background-color 0.2s;
    border: 1px solid transparent;
}
.login-btn {
    background-color: #f0f0f0;
    color: #333;
}
.login-btn:hover { background-color: #e0e0e0; }
.logout-btn {
    background-color: #e91e63;
    color: white;
}
.logout-btn:hover { background-color: #c2185b; }

/* 섹션 공통 스타일 */
section {
    padding: 60px 0;
    margin-bottom: 20px;
    background-color: #fff;
    border-radius: 8px;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
    text-align: center;
}

section h2 {
    color: #0056b3;
    margin-bottom: 30px;
    font-size: 2em;
}

/* CTA 버튼 스타일 */
.button {
    display: inline-block;
    padding: 12px 25px;
    margin: 10px;
    border-radius: 5px;
    text-decoration: none;
    font-weight: bold;
    transition: background-color 0.3s;
}

.primary {
    background-color: #0056b3;
    color: white;
}

.secondary {
    background-color: #ccc;
    color: #333;
}

.primary:hover { background-color: #003366; }
.secondary:hover { background-color: #b3b3b3; }


/* --- index.html 전용 스타일 --- */
.hero { 
    background-color: #e6f0ff; 
    padding: 80px 20px; 
    margin-top: 0; 
}
.hero h2 { font-size: 2.5em; color: #003366; }
.program-list { display: flex; justify-content: space-around; gap: 20px; padding: 0 40px; }
.program-list article { flex: 1; padding: 20px; border: 1px solid #ddd; border-radius: 5px; text-align: left; }
.program-list article h3 a { color: #0056b3; text-decoration: none; }
.transparency-summary { background-color: #f7f7ff; }

/* Hero 이미지 관련 스타일 */
.hero-image-container {
    width: 100%;
    max-width: 900px;
    height: 350px;
    margin: 0 auto 30px;
    background-color: #e0e7ff;
    border-radius: 12px;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
}

.generated-hero-image {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

/* --- transparency.html 전용 스타일 --- */
.page-header.transparency-header { background-color: #f0f7ff; }
.admin-section { text-align: left; padding: 40px; }
.report-content { border: 1px solid #e0e0e0; padding: 30px; border-radius: 8px; background-color: #fff; margin-bottom: 30px; }
.data-table { width: 100%; border-collapse: collapse; margin-bottom: 30px; }
.data-table th, .data-table td { border: 1px solid #eee; padding: 12px; }
.data-table th { background-color: #f5f5f5; text-align: center; }
.summary-row td { background-color: #e6f0ff; font-weight: bold; }
.balance-row td { background-color: #fff3e6; color: #ff9900; }
.hidden { display: none; }

.info-block { margin-bottom: 30px; padding: 20px; border: 1px dashed #ccc; border-radius: 5px; }
.info-block h3 { color: #0056b3; border-bottom: 2px solid #ddd; padding-bottom: 10px; margin-top: 10px; }
.tax-table { width: 100%; border-collapse: collapse; margin-top: 15px; text-align: center; }
.tax-table th, .tax-table td { border: 1px solid #ddd; padding: 12px; }
.compliance-grid { display: flex; gap: 20px; }
.compliance-item { flex: 1; padding: 25px; border-radius: 8px; background-color: #fcfcfc; text-align: center; }
.external-link { background-color: #e6f0ff; }
.document-link { background-color: #fff8e1; }
.small-button { padding: 8px 15px !important; font-size: 0.9em !important; }

/* --- culture.html 전용 스타일 --- */
.page-header.culture-header { background-color: #f7fcfb; }
.program-list-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 25px; margin-top: 30px; }
.program-card { border: 1px solid #e0e0e0; border-radius: 8px; padding: 25px; text-align: left; box-shadow: 0 4px 6px rgba(0, 0, 0, 0.05); }
.program-card h3 { color: #00796b; border-bottom: 2px solid #b2dfdb; padding-bottom: 10px; margin-bottom: 15px; }
.photo-gallery { display: grid; grid-template-columns: repeat(3, 1fr); gap: 15px; margin-top: 20px; }
.photo-gallery img { width: 100%; height: auto; border-radius: 6px; object-fit: cover; }
.testimonial-block { background-color: #e8f5e9; padding: 20px; border-left: 5px solid #4caf50; margin: 30px 0; font-style: italic; text-align: center; }

/* --- meal_support.html 전용 스타일 --- */
.page-header.meal-header { background-color: #fff9e6; border-bottom: 5px solid #ff9900; }
.stats-block { background-color: #f7f7f7; padding: 30px; border-radius: 8px; margin-top: 40px; text-align: center; }
.stats-block .stat { display: inline-block; margin: 0 20px; font-size: 1.5em; color: #0056b3; font-weight: bold; }
.program-icons { display: flex; justify-content: space-around; margin: 40px 0; }
.icon-item { flex-basis: 30%; text-align: center; padding: 20px; border: 1px solid #ffe0b2; border-radius: 8px; background-color: #fff8e1; }
.icon-item .icon { font-size: 3em; color: #ff9900; margin-bottom: 10px; }
.meal-gallery { display: grid; grid-template-columns: repeat(2, 1fr); gap: 20px; margin-top: 20px; }
.meal-gallery img { width: 100%; height: 250px; object-fit: cover; border-radius: 6px; }

/* --- volunteer.html 및 contact.html 폼 스타일 --- */
.page-header.volunteer-header { background-color: #e3f2fd; }
.steps-container { display: flex; justify-content: space-around; text-align: center; margin: 40px 0; }
.step-item { flex-basis: 22%; padding: 15px; border-radius: 8px; background-color: #ffffff; border: 1px solid #bbdefb; }
.step-item .number { background-color: #2196f3; color: white; }
.volunteer-form-container, .contact-form-container { max-width: 800px; margin: 40px auto; padding: 30px; background-color: #f9f9f9; border-radius: 10px; text-align: left; }
.volunteer-form-container label, .contact-form-container label { display: block; margin-top: 15px; margin-bottom: 5px; font-weight: bold; color: #0056b3; }
.volunteer-form-container input, .contact-form-container input, .volunteer-form-container select, .contact-form-container textarea { width: 100%; padding: 10px; margin-bottom: 10px; border: 1px solid #ccc; border-radius: 4px; box-sizing: border-box; }
.form-submit-btn { background-color: #00796b; color: white; padding: 15px 30px; border-radius: 5px; width: 100%; cursor: pointer; border: none; }
.privacy-consent { border: 1px solid #ddd; padding: 15px; background-color: #fff; margin-top: 20px; font-size: 0.9em; }

/* --- contact.html 전용 스타일 --- */
.page-header.contact-header { background-color: #fce4ec; border-bottom: 3px solid #e91e63; }
.contact-info-grid { display: flex; justify-content: space-between; gap: 30px; margin-bottom: 40px; }
.contact-item { flex: 1; padding: 20px; border: 1px solid #f48fb1; border-radius: 8px; background-color: #fff; text-align: center; }
.contact-item h3 { color: #e91e63; font-size: 1.3em; margin-bottom: 10px; }
.map-container { width: 100%; height: 400px; background-color: #ccc; margin: 20px 0; border-radius: 8px; line-height: 400px; }
.form-submit-btn-contact { background-color: #e91e63; }
.form-submit-btn-contact:hover { background-color: #c2185b; }

/* --- donation.html 전용 스타일 --- */
.page-header.donation-header { background-color: #ffe0b2; border-bottom: 5px solid #ff9900; }
.donation-options { display: grid; grid-template-columns: repeat(3, 1fr); gap: 20px; margin-top: 30px; }
.option-card { background-color: #fff8f0; padding: 25px; border-radius: 10px; border: 1px solid #ffcc80; text-align: center; }
.option-card h3 { color: #ff9900; font-size: 1.5em; margin-bottom: 15px; }
.option-card .icon { font-size: 2.5em; margin-bottom: 10px; }
.form-section { max-width: 800px; margin: 40px auto; text-align: left; padding: 30px; background-color: #ffffff; border-radius: 10px; box-shadow: 0 4px 10px rgba(0, 0, 0, 0.05); }
.form-submit-btn-donation { background-color: #ff9900; }

/* 푸터 스타일 */
footer { background: #333; color: white; text-align: center; padding: 20px 0; margin-top: 40px; }
footer a { color: #ccc; text-decoration: none; margin: 0 10px; }

/* --- 공통 page-header 스타일 (모든 서브페이지 상단 배너) --- */
.page-header {
    padding: 60px 40px;
    text-align: center;
    border-radius: 8px;
    margin-bottom: 20px;
}
.page-header h1 {
    font-size: 2.2em;
    color: #003366;
    margin-bottom: 10px;
}
.page-header h2 {
    font-size: 1.3em;
    color: #0056b3;
    margin-bottom: 15px;
    font-weight: 500;
}
.page-header p {
    font-size: 1em;
    color: #555;
    max-width: 750px;
    margin: 0 auto;
    line-height: 1.8;
}

/* --- CTA 버튼 그룹 (index.html hero, culture.html 하단 등) --- */
.cta-group {
    margin-top: 30px;
    display: flex;
    justify-content: center;
    gap: 15px;
    flex-wrap: wrap;
}

/* --- programs 섹션 (index.html 핵심 사업) --- */
.programs {
    padding: 60px 40px;
}
.programs h2 {
    color: #0056b3;
    font-size: 2em;
    margin-bottom: 30px;
    text-align: center;
}

/* --- news 섹션 (index.html 최신 소식) --- */
.news {
    padding: 60px 40px;
}
.news h2 {
    color: #0056b3;
    font-size: 2em;
    margin-bottom: 20px;
    text-align: center;
}
.news-list {
    min-height: 80px;
    padding: 20px;
    background: #f9f9f9;
    border-radius: 6px;
    border: 1px dashed #ccc;
    color: #666;
    text-align: center;
}

/* --- more-link (더보기 링크) --- */
.more-link {
    display: inline-block;
    margin-top: 20px;
    color: #0056b3;
    font-weight: bold;
    text-decoration: none;
    font-size: 1em;
}
.more-link:hover {
    text-decoration: underline;
    color: #003366;
}

/* --- address-info (찾아오시는 길 주소 정보) --- */
.address-info {
    margin-top: 20px;
    padding: 20px;
    background-color: #f9f9f9;
    border-radius: 6px;
    border-left: 4px solid #0056b3;
    text-align: left;
}
.address-info p {
    margin-bottom: 8px;
    color: #444;
    line-height: 1.7;
}

/* --- location-section (찾아오시는 길 섹션) --- */
.location-section {
    padding: 40px;
}

/* --- call-to-action 섹션 (culture.html 하단 CTA) --- */
.call-to-action {
    background-color: #e6f0ff;
    text-align: center;
    padding: 60px 40px;
}
.call-to-action h2 {
    color: #003366;
    font-size: 1.8em;
    margin-bottom: 15px;
}
.call-to-action p {
    color: #555;
    margin-bottom: 10px;
}

/* --- loading-message (index.html 이미지 로딩 상태) --- */
.loading-message {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
}
.loading-message-content {
    text-align: center;
    color: #555;
    padding: 20px;
}

/* --- transparency-summary (index.html 투명경영 요약 섹션) --- */
.transparency-summary {
    background-color: #f7f7ff;
    padding: 60px 40px;
}

/* --- footer-links (푸터 내 링크 그룹) --- */
.footer-links {
    margin-bottom: 10px;
}

/* --- gallery.html 전용 스타일 --- */
.gallery-item {
    background-color: #fff;
    padding: 16px;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.08);
    transition: box-shadow 0.3s;
}
.gallery-item:hover {
    box-shadow: 0 6px 20px rgba(0,0,0,0.15);
}

/* ═══════════════════════════════════════════════════════════════════
   모바일 반응형 + PWA 최적화
   ═══════════════════════════════════════════════════════════════════ */

/* ── 터치 디바이스 공통 ─────────────────────────────────────────── */
* { -webkit-tap-highlight-color: transparent; }

button, a, [role="button"] {
    touch-action: manipulation;   /* 더블탭 줌 방지 */
}

/* ── 모바일 바텀 네비게이션 바 (앱처럼) ─────────────────────────── */
.mobile-bottom-nav {
    display: none;
    position: fixed;
    bottom: 0; left: 0; right: 0;
    background: #fff;
    border-top: 1px solid #e0e0e0;
    z-index: 900;
    padding: 0;
    box-shadow: 0 -2px 12px rgba(0,0,0,0.10);
}
.mobile-bottom-nav ul {
    display: flex;
    list-style: none;
    margin: 0; padding: 0;
}
.mobile-bottom-nav ul li {
    flex: 1;
}
.mobile-bottom-nav ul li a {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 8px 4px 10px;
    font-size: 0.65em;
    color: #888;
    text-decoration: none;
    gap: 3px;
    font-weight: 600;
    transition: color 0.2s;
}
.mobile-bottom-nav ul li a .nav-icon {
    font-size: 1.5em;
    line-height: 1;
}
.mobile-bottom-nav ul li a:hover,
.mobile-bottom-nav ul li.active a {
    color: #0056b3;
}

/* ── 햄버거 메뉴 버튼 ───────────────────────────────────────────── */
.hamburger-btn {
    display: none;
    background: none;
    border: none;
    cursor: pointer;
    padding: 8px;
    border-radius: 8px;
    transition: background 0.2s;
}
.hamburger-btn:hover { background: #f0f4f8; }
.hamburger-btn span {
    display: block;
    width: 24px;
    height: 2.5px;
    background: #0056b3;
    border-radius: 2px;
    margin: 5px 0;
    transition: transform 0.3s, opacity 0.3s;
}
.hamburger-btn.open span:nth-child(1) { transform: translateY(7.5px) rotate(45deg); }
.hamburger-btn.open span:nth-child(2) { opacity: 0; }
.hamburger-btn.open span:nth-child(3) { transform: translateY(-7.5px) rotate(-45deg); }

/* ── PWA 설치 배너 ─────────────────────────────────────────────── */
#pwa-install-banner {
    display: none;
    position: fixed;
    bottom: 0; left: 0; right: 0;
    background: linear-gradient(135deg, #0056b3, #003d80);
    color: #fff;
    padding: 14px 20px;
    z-index: 9999;
    box-shadow: 0 -4px 20px rgba(0,0,0,0.2);
    align-items: center;
    gap: 12px;
    font-size: 14px;
}
#pwa-install-banner.show { display: flex; }
#pwa-install-banner .banner-icon { font-size: 2em; flex-shrink: 0; }
#pwa-install-banner .banner-text { flex: 1; }
#pwa-install-banner .banner-text strong { display: block; font-size: 15px; }
#pwa-install-banner .banner-text span { font-size: 12px; opacity: 0.85; }
#pwa-install-banner button {
    padding: 9px 18px;
    border-radius: 20px;
    font-weight: 700;
    font-size: 13px;
    cursor: pointer;
    border: none;
    transition: all 0.2s;
    white-space: nowrap;
}
#pwa-install-banner .btn-install {
    background: #ff9900;
    color: #fff;
}
#pwa-install-banner .btn-install:hover { background: #e58700; }
#pwa-install-banner .btn-dismiss {
    background: transparent;
    color: rgba(255,255,255,0.7);
    border: 1px solid rgba(255,255,255,0.3) !important;
    padding: 8px 12px;
}

/* ── 반응형 breakpoints ─────────────────────────────────────────── */

/* 태블릿 (768px 이하) */
@media (max-width: 768px) {

    /* 헤더 */
    header {
        position: sticky;
        top: 0;
        z-index: 800;
        box-shadow: 0 2px 8px rgba(0,0,0,0.10);
        flex-wrap: nowrap;
        gap: 8px;
        padding: 12px 16px;
    }
    header .site-logo a { font-size: 1.15em; }

    /* 햄버거 버튼 표시 */
    .hamburger-btn { display: block; }

    /* PC 네비게이션 숨김 → 드롭다운 */
    nav {
        position: fixed;
        top: 60px; left: 0; right: 0;
        background: #fff;
        box-shadow: 0 8px 24px rgba(0,0,0,0.14);
        transform: translateY(-110%);
        opacity: 0;
        transition: transform 0.3s ease, opacity 0.3s ease;
        z-index: 799;
        border-bottom: 3px solid #0056b3;
    }
    nav.open {
        transform: translateY(0);
        opacity: 1;
    }
    nav ul {
        flex-direction: column;
        padding: 8px 0;
    }
    nav ul li a {
        padding: 14px 24px;
        font-size: 1em;
        border-bottom: 1px solid #f0f0f0;
    }
    nav ul li:last-child a { border-bottom: none; }
    nav ul li a:hover { background: #f0f7ff; color: #0056b3; }

    /* 기부 버튼 */
    .donate-btn {
        padding: 8px 14px;
        font-size: 0.85em;
        white-space: nowrap;
    }

    /* 인증 버튼 숨김 (바텀 탭으로 대체 가능) */
    #authButtonContainer { display: none; }

    /* 바텀 네비게이션 */
    .mobile-bottom-nav { display: block; }

    /* main 콘텐츠 하단 여백 (바텀 탭 높이만큼) */
    main { padding-bottom: 72px; }
    footer { margin-bottom: 64px; }

    /* 섹션 */
    section { padding: 36px 16px; margin-bottom: 12px; }
    section h2 { font-size: 1.5em; }

    /* 히어로 */
    .hero { padding: 40px 16px; }
    .hero h2, h1 { font-size: 1.7em; }
    .hero-image-container { height: 200px; border-radius: 8px; }

    /* 프로그램 목록 */
    .program-list { flex-direction: column; padding: 0; }
    .program-list article { margin-bottom: 12px; }

    /* 기부 옵션 */
    .donation-options { grid-template-columns: 1fr; gap: 12px; }

    /* 연락처 그리드 */
    .contact-info-grid { flex-direction: column; gap: 12px; }

    /* 규정 준수 그리드 */
    .compliance-grid { flex-direction: column; }

    /* 단계 컨테이너 */
    .steps-container { flex-direction: column; align-items: center; gap: 12px; }
    .step-item { width: 90%; }

    /* CTA 그룹 */
    .cta-group { flex-direction: column; align-items: center; gap: 12px; }
    .cta-group .button { width: 90%; max-width: 320px; text-align: center; }

    /* 사진 갤러리 */
    .photo-gallery { grid-template-columns: 1fr 1fr; gap: 8px; }

    /* 프로그램 아이콘 */
    .program-icons { flex-direction: column; align-items: center; gap: 16px; }
    .icon-item { width: 85%; }

    /* 페이지 헤더 */
    .page-header { padding: 36px 16px; }
    .page-header h1 { font-size: 1.5em; }
    .page-header h2 { font-size: 1.1em; }

    /* 데이터 테이블 스크롤 */
    .data-table, table {
        display: block;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        font-size: 0.88em;
    }

    /* 식당/봉사 갤러리 */
    .meal-gallery { grid-template-columns: 1fr; }
    .meal-gallery img { height: 200px; }

    /* 지도 */
    .map-container { height: 250px; line-height: 250px; }

    /* 폼 */
    .volunteer-form-container,
    .contact-form-container,
    .form-section { padding: 16px; margin: 16px 0; }

    /* 프로그램 목록 그리드 */
    .program-list-grid { grid-template-columns: 1fr; }

    /* 투명성 섹션 */
    .transparency-summary { padding: 36px 16px; }
    .admin-section { padding: 16px; }
    .report-content { padding: 16px; }
}

/* 스마트폰 (480px 이하) */
@media (max-width: 480px) {
    body { font-size: 15px; }

    header { padding: 10px 12px; }
    header .site-logo a { font-size: 1.05em; }

    section h2 { font-size: 1.3em; }
    .hero h2, h1 { font-size: 1.4em; }

    .donate-btn { font-size: 0.8em; padding: 7px 10px; }

    /* 버튼 최소 터치 영역 44px */
    .button, .form-submit-btn, button[type="submit"] {
        min-height: 44px;
        display: flex;
        align-items: center;
        justify-content: center;
    }

    /* 입력 필드 */
    input, select, textarea {
        font-size: 16px !important; /* iOS 자동 줌 방지 */
    }

    /* 사진 갤러리 → 1열 */
    .photo-gallery { grid-template-columns: 1fr; }

    /* stats 블록 */
    .stats-block .stat { display: block; margin: 10px 0; }

    /* 연락처 그리드 */
    .contact-item { padding: 14px; }

    /* 페이지 헤더 */
    .page-header { padding: 24px 12px; }
    .page-header h1 { font-size: 1.3em; }

    /* 푸터 */
    footer { font-size: 0.85em; padding: 16px 12px; }
}

/* 아이폰 X 이상 Safe Area (노치/홈 인디케이터 대응) */
@supports (padding-bottom: env(safe-area-inset-bottom)) {
    .mobile-bottom-nav {
        padding-bottom: env(safe-area-inset-bottom);
    }
    #pwa-install-banner {
        padding-bottom: calc(14px + env(safe-area-inset-bottom));
    }
    footer { padding-bottom: calc(16px + env(safe-area-inset-bottom)); }
}