/* 
🚨🚨🚨 AI 수정 금지 경고 🚨🚨🚨
❌ 사용자 명시적 요청 없이 이 파일을 수정하는 것은 절대 금지됨
❌ 파일 수정 전 반드시 사용자에게 보고하고 승인받을 것  
❌ "개선" "최적화" "리팩토링" 등의 이유로 임의 수정 금지
✅ 사용자가 명확히 요청한 내용만 정확히 수정할 것

공통 헤더 및 사이드메뉴 스타일 - 모든 페이지 통일 
*/

/* === 🎯 Z-INDEX 계층 시스템 === */
/* 통일된 z-index 관리로 모바일 팝업 계층 문제 해결 */
:root {
    --z-header: 1000;
    --z-dropdown: 2000;
    --z-toast: 3000;
    --z-modal: 9000;
    --z-popup: 9500;
    --z-event-modal: 999999;
    --z-plan-popup: 999998;      /* 요금제 팝업 - 이벤트 모달 아래 */
    --z-system-modal: 999999999; /* 이벤트 모달 - 최상위 계층 */
}

/* === 🎯 통일된 팝업 시스템 === */
/* 모든 페이지에서 일관된 팝업 동작 보장 */
.custom-popup-overlay {
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    width: 100% !important;
    height: 100% !important;
    background: rgba(0, 0, 0, 0.5) !important;
    display: none !important;
    justify-content: center !important;
    align-items: center !important;
    z-index: var(--z-plan-popup) !important; /* 999998 - 계층 변수 사용 */
    opacity: 0 !important;
    visibility: hidden !important;
    transition: all 0.3s ease !important;
}

.custom-popup-overlay.show {
    display: flex !important;
    opacity: 1 !important;
    visibility: visible !important;
}

.custom-popup {
    background: #ffffff !important;
    padding: 30px !important;
    border-radius: 16px !important;
    max-width: min(90vw, 450px) !important;
    max-height: 80vh !important;
    overflow-y: auto !important;
    position: relative !important;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.3) !important;
    animation: popupShow 0.3s ease-out !important;
    transform: scale(1) !important;
}

@keyframes popupShow {
    from {
        transform: scale(0.8);
        opacity: 0;
    }
    to {
        transform: scale(1);
        opacity: 1;
    }
}

/* === 🔧 MOBILE: 터치 액션 최적화 === */
/* 모든 상호작용 요소에 터치 액션 적용 */
button, .btn, .option-btn, .plan-item, 
.event-cta, .event-cta-style,
.fixed-header .menu-button,
.fixed-header .header-consult-button,
a[href], input, select, textarea {
    touch-action: manipulation !important;
    -webkit-tap-highlight-color: transparent !important;
    -webkit-touch-callout: none;
    user-select: none;
    -webkit-user-select: none;
    /* 🔧 MOBILE: 최소 터치 영역 보장 (44px) */
    min-height: 44px;
    min-width: 44px;
}

/* 텍스트 입력 요소는 선택 가능하도록 설정 */
input, select, textarea {
    user-select: auto;
    -webkit-user-select: auto;
}

/* 🔧 MOBILE: 터치 피드백 최적화 */
button:active, .btn:active, .option-btn:active {
    transform: scale(0.98);
    transition: transform 0.1s ease;
}

/* --- 더 슬림한 고정 헤더 스타일 --- */
.fixed-header {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    background: #ffffff;
    border-bottom: 1px solid rgba(0, 0, 0, 0.06);
    z-index: var(--z-header);
    height: 50px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 20px;
    box-sizing: border-box;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
    /* 🔧 MOBILE: 안전 영역 대응 */
    padding-left: max(20px, env(safe-area-inset-left));
    padding-right: max(20px, env(safe-area-inset-right));
}

.fixed-header .logo img {
    height: 32px;
    width: auto;
    transform: translateY(0px);
    display: block;
    margin: auto;
}

.header-buttons {
    display: flex;
    align-items: center;
    gap: 8px;
}

.fixed-header .menu-button,
.fixed-header .header-consult-button {
    background: none;
    border: none;
    cursor: pointer;
    padding: 8px;
    border-radius: 8px;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    transform: translateY(0px);
    /* 🔧 MOBILE: 터치 최적화 */
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent !important;
    position: relative;
}

/* 호버 효과 - 터치 디바이스 구분 */
@media (hover: hover) {
    .fixed-header .menu-button:hover {
        background-color: rgba(0, 0, 0, 0.05);
        transform: translateY(-1px);
    }

    .fixed-header .header-consult-button:hover {
        background-color: rgba(0, 122, 255, 0.1);
        transform: translateY(-1px);
    }
}

/* 터치 피드백 */
.fixed-header .menu-button:active,
.fixed-header .header-consult-button:active {
    background-color: rgba(0, 122, 255, 0.15);
    transform: scale(0.95);
}

.fixed-header .menu-button svg,
.fixed-header .header-consult-button svg {
    width: 24px;
    height: 24px;
    fill: #333;
}

.fixed-header .header-consult-button svg {
    fill: #333;
}

/* 🔧 MOBILE: 모바일 최적화 */
@media (max-width: 767px) {
    .fixed-header {
        height: 56px;
        padding: 6px 10px;
        width: 100%;
        max-width: 100vw;
        box-sizing: border-box;
        /* 🔧 안전 영역 대응 */
        padding-left: max(10px, env(safe-area-inset-left));
        padding-right: max(10px, env(safe-area-inset-right));
    }

    .fixed-header .logo img {
        height: 32px;
        max-width: 120px;
    }

    .fixed-header .header-buttons {
        gap: 8px;
    }

    .fixed-header .menu-button,
    .fixed-header .header-consult-button {
        width: 44px;
        height: 44px;
        padding: 10px;
        border-radius: 8px;
    }

    .fixed-header .menu-button svg,
    .fixed-header .header-consult-button svg {
        width: 20px;
        height: 20px;
    }
}

/* 🔧 MOBILE: 매우 작은 화면 (360px 이하) */
@media (max-width: 360px) {
    .fixed-header {
        padding: 6px 8px;
        height: 52px;
    }

    .fixed-header .logo img {
        height: 28px;
        max-width: 100px;
    }

    .fixed-header .menu-button,
    .fixed-header .header-consult-button {
        width: 44px;
        height: 44px;
        padding: 12px;
    }

    .fixed-header .menu-button svg,
    .fixed-header .header-consult-button svg {
        width: 18px;
        height: 18px;
    }
}

/* --- 사이드 메뉴 스타일 (주문내역과 통일) --- */
.side-menu-overlay { 
    display: none; 
    position: fixed; 
    top: 0; 
    left: 0; 
    width: 100%; 
    height: 100%; 
    background-color: rgba(0, 0, 0, 0.5) !important;
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    z-index: 999998 !important;
    /* 🔧 MOBILE: 터치 최적화 */
    touch-action: none;
    -webkit-tap-highlight-color: transparent;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.side-menu-overlay.show {
    opacity: 1;
}

.side-menu { 
    position: fixed; 
    top: 0; 
    right: -300px; 
    width: 280px; 
    height: 100%; 
    background-color: rgba(255, 255, 255, 0.95) !important;
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    box-shadow: -4px 0 24px rgba(0, 0, 0, 0.2);
    z-index: 999999 !important;
    transition: right 0.3s ease-out; 
    padding-top: 72px;
    border-left: 1px solid rgba(0, 0, 0, 0.1);
    /* 🔧 MOBILE: 스크롤 최적화 */
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
    /* 🔧 안전 영역 대응 */
    padding-bottom: env(safe-area-inset-bottom, 0px);
    box-sizing: border-box;
}

/* 🔧 MOBILE: 작은 화면 대응 */
@media (max-width: 360px) {
    .side-menu {
        width: calc(100vw - 60px);
        max-width: 280px;
    }
}

.side-menu.open { 
    right: 0; 
}

.side-menu ul { 
    list-style: none; 
    padding: 0; 
    margin: 0;
    width: 100%;
    box-sizing: border-box;
}

.side-menu ul li {
    margin: 0;
    padding: 0;
    width: 100%;
    box-sizing: border-box;
}

.side-menu ul li a, 
.side-menu ul li a.menu-item { 
    display: block;
    padding: 16px 20px;
    color: #1d1d1f;
    text-decoration: none;
    border-bottom: 1px solid #eee;
    transition: all 0.2s ease;
    /* 🔧 MOBILE: 터치 최적화 */
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent !important;
    min-height: 48px;
    font-size: 16px;
    font-weight: 500;
    line-height: 1.47;
    letter-spacing: -0.01em;
    margin: 0;
    box-sizing: border-box;
}

/* 호버 효과 - 터치 디바이스 구분 */
@media (hover: hover) {
    .side-menu ul li a:hover { 
        background-color: #f5f5f7; 
    }
}

/* 터치 피드백 */
.side-menu ul li a:active {
    background-color: #f5f5f7;
}

/* 이벤트 메뉴 하이라이트 */
.side-menu ul li a.event-highlight {
    background: linear-gradient(135deg, #ff6b6b, #feca57);
    color: white !important;
    font-weight: 600;
    position: relative;
    overflow: hidden;
}

.side-menu ul li a.event-highlight::before {
    content: '✨';
    margin-right: 8px;
    animation: sparkle 2s infinite;
}

.side-menu ul li a.event-highlight:hover {
    background: linear-gradient(135deg, #ff5252, #ffb347) !important;
    transform: translateX(2px);
}

@keyframes sparkle {
    0%, 100% { transform: scale(1) rotate(0deg); }
    50% { transform: scale(1.1) rotate(180deg); }
}

.side-menu .close-button { 
    position: absolute; 
    top: 16px; 
    right: 20px; 
    background: transparent; 
    border: none; 
    width: 44px;
    height: 44px;
    border-radius: 50%;
    cursor: pointer;
    color: #666;
    font-size: 24px;
    font-weight: 300;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    /* 🔧 MOBILE: 터치 영역 최적화 */
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent !important;
}

.side-menu .close-button:hover {
    background-color: rgba(0, 0, 0, 0.05);
    color: #333;
    transform: scale(1.1);
}

.side-menu .close-button:active {
    transform: scale(0.9);
    background-color: rgba(0, 0, 0, 0.1);
}

/* 컨테이너 여백 - 고정 헤더에 맞게 조정 */
.container {
    margin-top: 50px;
}

/* 🔧 MOBILE: 기본 body 스타일 - 모든 페이지에 적용 */
body {
    padding-top: 60px !important;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    font-size: 16px;
    line-height: 1.6;
    margin: 0;
    color: #1d1d1f;
    background: #ffffff;
    overflow-x: hidden;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
    -webkit-touch-callout: none;
    width: 100%;
    max-width: 100vw;
    /* 🔧 MOBILE: iOS bounce 스크롤 방지 */
    overscroll-behavior: none;
    -webkit-overscroll-behavior: none;
    /* 🔧 MOBILE: 터치 스크롤 최적화 */
    -webkit-overflow-scrolling: touch;
    /* 🔧 MOBILE: 확대/축소 방지 */
    -webkit-text-size-adjust: 100%;
    -ms-text-size-adjust: 100%;
    /* 🔧 안전 영역 대응 */
    padding-left: env(safe-area-inset-left, 0);
    padding-right: env(safe-area-inset-right, 0);
}

@media (max-width: 767px) {
    body {
        padding-top: 56px !important;
        width: 100%;
        max-width: 100vw;
        /* 🔧 MOBILE: 뷰포트 최적화 */
        min-height: 100vh;
        min-height: 100dvh; /* 동적 뷰포트 대응 */
    }

    .container {
        margin: 5px auto 10px;
        padding: 8px 6px 10px;
        border-radius: 0;
        width: 100%;
        max-width: 100vw;
        box-sizing: border-box;
        /* 🔧 안전 영역 패딩 */
        padding-left: max(8px, env(safe-area-inset-left));
        padding-right: max(8px, env(safe-area-inset-right));
        padding-bottom: max(15px, env(safe-area-inset-bottom));
    }
}

/* 요금제 비교 기능 제거됨 - 중복 CSS 정리 완료 */

/* 기본 스타일 복구 */

/* 중복 CSS 정리 및 비교 기능 제거 완료 */

/* 🔒 팝업 열림 시 스크롤 방지 */
body.modal-open {
    overflow: hidden !important;
    position: fixed !important;
    width: 100% !important;
    height: 100% !important;
    /* 🔧 MOBILE: iOS 키보드 대응 */
    -webkit-overflow-scrolling: auto;
    overscroll-behavior: none;
    /* 🔧 안전 영역 유지 */
    padding-left: env(safe-area-inset-left, 0) !important;
    padding-right: env(safe-area-inset-right, 0) !important;
}

/* === 🔧 MOBILE: 전역 터치 최적화 === */
/* 300ms 딜레이 제거 및 터치 반응성 개선 */
* {
    -webkit-tap-highlight-color: transparent;
}

/* 스크롤 가능한 요소들 터치 스크롤 최적화 */
.scrollable, .scroll-container, .modal-content {
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
}

/* 🔧 MOBILE: 링크 및 버튼 터치 최적화 */
a, button, [role="button"], .clickable {
    -webkit-tap-highlight-color: transparent !important;
    tap-highlight-color: transparent !important;
}

/* 🔧 MOBILE: 포커스 가능한 요소 최적화 */
/* 제목 크기 정규화 */
h1 { font-size: 1.8rem; font-weight: 700; margin-bottom: 1rem; }
h2 { font-size: 1.5rem; font-weight: 600; margin-bottom: 0.8rem; }
h3 { font-size: 1.3rem; font-weight: 600; margin-bottom: 0.6rem; }

/* 입력 필드 크기 축소 */
input, select, textarea {
    padding: 8px 12px;
    font-size: 16px;
    border-radius: 6px;
    border: 1px solid #ddd;
}

input, textarea, select, [contenteditable] {
    -webkit-tap-highlight-color: transparent !important;
    tap-highlight-color: transparent !important;
}