/* 모바일 전용 스타일 - 480px 이하 */
@media only screen and (max-width: 480px) {
    /* 기본 타이포그래피 */
    body {
        font-size: 14px;
        line-height: 1.6;
        overflow-x: hidden; /* 가로 스크롤 방지 */
    }
    
    /* 메인 컨테이너 overflow 설정 */
    .search-hero,
    .search-content,
    .results-section {
        overflow-x: hidden;
    }
    
    /* 네비게이션 바 */
    .navbar {
        padding: 0.5rem 0;
    }
    
    .navbar-container {
        padding: 0 1rem;
    }
    
    .navbar-brand span {
        font-size: 1.125rem;
    }
    
    .navbar-menu {
        display: none;
    }
    
    /* 모바일 메뉴 */
    .mobile-menu {
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        background: white;
        z-index: 1000;
        transform: translateX(100%);
        transition: transform 0.3s ease;
        display: flex !important;
        flex-direction: column;
    }
    
    .mobile-menu.active {
        transform: translateX(0);
    }
    
    .mobile-menu-header {
        display: flex;
        justify-content: space-between;
        align-items: center;
        padding: 1rem;
        border-bottom: 1px solid var(--border-light);
    }
    
    .mobile-menu-nav {
        flex: 1;
        padding: 1rem;
    }
    
    .mobile-menu-link {
        display: block;
        padding: 0.75rem 1rem;
        color: var(--text-primary);
        text-decoration: none;
        border-radius: var(--radius);
        transition: background 0.2s;
    }
    
    .mobile-menu-link:hover,
    .mobile-menu-link.active {
        background: var(--gray-100);
    }
    
    .mobile-menu-close {
        background: none;
        border: none;
        padding: 0.5rem;
        cursor: pointer;
    }
    
    /* Hero 섹션 */
    .hero, .search-hero {
        text-align: center !important;
    }
    
    .hero-title, .search-hero h1 {
        font-size: 1.5rem !important;
        line-height: 1.3;
        word-break: keep-all;
        text-align: center !important;
    }
    
    .hero-subtitle {
        font-size: 0.875rem !important;
        line-height: 1.5;
    }
    
    /* 버튼 */
    .btn {
        font-size: 0.875rem;
        padding: 0.625rem 1.25rem;
        width: 100%;
        margin-bottom: 0.5rem;
    }
    
    .btn-lg {
        font-size: 1rem;
        padding: 0.75rem 1.5rem;
    }
    
    /* 검색 */
    .search-input-group {
        flex-direction: column !important;
        gap: 0.5rem;
    }
    
    .search-input {
        font-size: 1rem;
        padding: 0.875rem 1rem;
    }
    
    .search-btn {
        width: 100%;
        padding: 0.875rem;
    }
    
    /* 위치 버튼 */
    .location-options {
        flex-direction: column !important;
        width: 100%;
        padding: 0 1rem;
    }
    
    .location-btn {
        width: 100% !important;
        justify-content: center;
    }
    
    /* 필터 태그 - 페이지 전체 스크롤 방지 */
    .filter-section {
        overflow-x: hidden;
    }
    
    .filter-container {
        padding: 0 1rem;
        overflow-x: hidden;
    }
    
    .filter-tag {
        font-size: 0.75rem;
        padding: 0.375rem 0.75rem;
        white-space: nowrap;
    }
    
    /* 카드 레이아웃 */
    .franchise-grid {
        grid-template-columns: 1fr !important;
        gap: 1rem;
        padding: 0 1rem;
    }
    
    .franchise-card {
        border-radius: 0.75rem;
    }
    
    .franchise-header {
        padding: 1rem;
    }
    
    .franchise-name {
        font-size: 1.125rem;
        word-break: keep-all;
    }
    
    .franchise-body {
        padding: 1rem;
    }
    
    .franchise-info {
        gap: 0.5rem;
    }
    
    .info-row {
        font-size: 0.8125rem;
        line-height: 1.5;
        word-break: keep-all;
    }
    
    .copy-btn {
        font-size: 0.6875rem;
        padding: 0.25rem 0.5rem;
        white-space: nowrap;
    }
    
    /* 혜택 섹션 */
    .franchise-benefit {
        padding: 0.75rem;
    }
    
    .benefit-detail {
        font-size: 0.875rem;
        word-break: keep-all;
    }
    
    .benefit-desc {
        font-size: 0.75rem;
        line-height: 1.5;
    }
    
    /* 섹션 */
    .section {
        padding: 3rem 0;
    }
    
    .section-header {
        text-align: center !important;
    }
    
    .section-title {
        font-size: 1.5rem;
        word-break: keep-all;
        text-align: center !important;
    }
    
    .section-subtitle {
        font-size: 0.875rem;
        text-align: center !important;
    }
    
    /* About 섹션 텍스트 가운데 정렬 */
    #about .card-body h3,
    #about .card-body p {
        text-align: center !important;
    }
    
    /* 서비스 타입 카드 가운데 정렬 */
    .service-card {
        text-align: center !important;
    }
    
    .service-card .service-icon,
    .service-card h4,
    .service-card p {
        text-align: center !important;
        margin-left: auto;
        margin-right: auto;
    }
    
    /* 이용 방법 섹션 가운데 정렬 */
    .text-center h4,
    .text-center p {
        text-align: center !important;
    }
    
    /* 그리드 */
    .grid {
        gap: 1rem;
    }
    
    .grid-cols-2,
    .grid-cols-3,
    .grid-cols-4 {
        grid-template-columns: 1fr !important;
    }
    
    /* 카드 */
    .card {
        margin-bottom: 1rem;
    }
    
    .card-body {
        padding: 1.25rem;
    }
    
    /* 폼 */
    .form-group {
        margin-bottom: 1rem;
    }
    
    .form-label {
        font-size: 0.875rem;
    }
    
    .form-input,
    .form-select,
    .form-textarea {
        font-size: 1rem;
        padding: 0.75rem;
    }
    
    /* 테이블 - 가로 스크롤 */
    .table-wrapper {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }
    
    table {
        min-width: 600px;
    }
    
    /* 모달 */
    .modal-content {
        margin: 1rem;
        max-height: calc(100vh - 2rem);
        overflow-y: auto;
    }
    
    /* 플로팅 버튼 */
    .floating-contact {
        bottom: 5rem;
        right: 1rem;
    }
    
    .scroll-to-top {
        bottom: 1rem;
        right: 1rem;
    }
    
    /* 컨테이너 패딩 */
    .container {
        padding-left: 1rem;
        padding-right: 1rem;
    }
    
    /* 텍스트 정렬 - 기본값은 유지하되 필요한 경우 덮어쓰기 가능 */
    p:not(.text-center):not(.hero-subtitle):not(.section-subtitle):not(.empty-state-text):not(.cta-text):not(.footer-brand p):not(.copyright), 
    span:not(.text-center span), 
    div:not(.text-center):not(.empty-state):not(.hero-content):not(.cta-content):not(.footer-content) {
        text-align: left;
        word-break: keep-all;
        word-wrap: break-word;
    }
    
    /* Empty State - 가운데 정렬 추가 */
    .empty-state {
        padding: 2rem 1rem;
        text-align: center !important;
    }
    
    .empty-icon {
        font-size: 2.5rem;
        text-align: center !important;
        display: block;
        margin: 0 auto 1rem;
    }
    
    .empty-state-title {
        font-size: 1.125rem;
        text-align: center !important;
    }
    
    .empty-state-text {
        font-size: 0.875rem;
        text-align: center !important;
    }
    
    /* 필수 가운데 정렬 요소들 */
    .text-center,
    .text-center * {
        text-align: center !important;
    }
    
    /* Footer 가운데 정렬 */
    .footer {
        text-align: center !important;
    }
    
    .footer-content {
        text-align: center !important;
    }
    
    .footer-brand,
    .footer-brand p,
    .footer-links,
    .copyright {
        text-align: center !important;
    }
    
    /* Badge 가운데 정렬 */
    .badge {
        text-align: center !important;
        display: inline-block;
        margin: 0 auto;
    }
    
    /* Hero 콘텐츠 가운데 정렬 */
    .hero-content {
        text-align: center !important;
    }
    
    .hero-content * {
        text-align: center !important;
    }
    
    .hero-content .badge {
        display: table;
        margin: 0 auto 1rem;
    }
    
    /* CTA 섹션 가운데 정렬 */
    .cta-section {
        text-align: center !important;
    }
    
    .cta-content,
    .cta-title,
    .cta-text {
        text-align: center !important;
    }
    
    /* 주소 입력 그룹 버튼 가운데 정렬 */
    .address-input-group button {
        margin: 0 auto;
    }
    
    /* 로고 및 브랜드 가운데 정렬 */
    .navbar-brand {
        display: flex;
        align-items: center;
        justify-content: center;
        text-align: center;
    }
    
    /* Contact 페이지 요소들 */
    .contact-hero h1,
    .contact-hero p,
    .contact-form label,
    .contact-form button {
        text-align: center !important;
    }
    
    /* Feature 아이콘 가운데 정렬 */
    .feature-icon {
        margin: 0 auto 1.5rem !important;
        text-align: center !important;
    }
    
    /* Step number 가운데 정렬 */
    .step-number {
        margin: 0 auto 1rem !important;
    }
    
    /* 문의하기 페이지 */
    .contact-header h1,
    .contact-header p {
        text-align: center !important;
    }
    
    .contact-info h2,
    .contact-info p,
    .contact-item {
        text-align: center !important;
    }
    
    /* 가맹점 등록 페이지 */
    .form-header h1,
    .form-header p {
        text-align: center !important;
    }
    
    /* 개인정보처리방침, 이용약관 페이지 */
    .privacy-header h1,
    .privacy-header p,
    .privacy-date {
        text-align: center !important;
    }
    
    /* Success Modal */
    .success-modal .success-content {
        text-align: center !important;
    }
    
    /* 가로 모드 대응 */
    @media (orientation: landscape) and (max-height: 480px) {
        .hero {
            min-height: auto;
            padding: 2rem 0;
        }
        
        .hero-title {
            font-size: 1.25rem !important;
        }
        
        .search-hero {
            padding: 1.5rem 0;
        }
    }
}

/* 태블릿 대응 - 768px 이하 */
@media only screen and (min-width: 481px) and (max-width: 768px) {
    .franchise-grid {
        grid-template-columns: 1fr !important;
    }
    
    .grid-cols-3,
    .grid-cols-4 {
        grid-template-columns: repeat(2, 1fr) !important;
    }
    
    .hero-title {
        font-size: 2rem;
    }
    
    .section-title {
        font-size: 1.75rem;
    }
}

/* 관리자 페이지 모바일 대응 */
@media only screen and (max-width: 768px) {
    /* 관리자 로그인 */
    .login-box {
        margin: 1rem;
        padding: 1.5rem;
    }
    
    /* 관리자 헤더 */
    .header-top {
        flex-direction: column;
        gap: 1rem;
    }
    
    .header-info {
        flex-direction: column;
        text-align: center;
        gap: 0.5rem;
    }
    
    /* 관리자 탭 */
    .tabs {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }
    
    .tab {
        font-size: 0.875rem;
        padding: 0.5rem 1rem;
        white-space: nowrap;
    }
    
    /* 관리자 테이블 */
    .data-table {
        display: block;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }
    
    .data-table table {
        min-width: 800px;
    }
    
    /* 액션 버튼 */
    .action-buttons {
        flex-wrap: wrap;
        gap: 0.25rem;
    }
    
    .action-buttons .btn {
        font-size: 0.75rem;
        padding: 0.25rem 0.5rem;
    }
}

/* 세로 텍스트 정렬 방지 */
.vertical-text-fix {
    writing-mode: horizontal-tb !important;
    text-orientation: mixed !important;
}

/* iOS Safari 대응 */
@supports (-webkit-touch-callout: none) {
    /* iOS에서 100vh 문제 해결 */
    .hero,
    .mobile-menu {
        min-height: -webkit-fill-available;
    }
    
    /* iOS 탭 하이라이트 제거 */
    * {
        -webkit-tap-highlight-color: transparent;
    }
    
    /* iOS 폰트 크기 자동 조정 방지 */
    body {
        -webkit-text-size-adjust: 100%;
    }
}

/* 안드로이드 대응 */
@media screen and (-webkit-min-device-pixel-ratio: 0) {
    /* 안드로이드 크롬 주소바 대응 */
    .hero {
        min-height: calc(100vh - 56px);
    }
}

/* Swiper 모바일 최적화 */
@media only screen and (max-width: 768px) {
    /* 그리드 레이아웃 강제 숨기기 */
    .grid.desktop-only {
        display: none !important;
    }
    
    /* Swiper 컨테이너 최적화 */
    .swiper {
        width: 100%;
        overflow: hidden !important;
        position: relative;
        padding: 0 !important;
        margin: 0 !important;
    }
    
    .swiper-wrapper {
        position: relative;
        width: 100%;
        height: 100%;
        z-index: 1;
        display: flex;
        transition-property: transform;
        box-sizing: content-box;
        align-items: center;
    }
    
    /* 슬라이드 100% 너비로 설정 */
    .swiper-slide {
        width: 100% !important;
        flex-shrink: 0;
        position: relative;
        transition-property: transform;
        display: flex !important;
        align-items: center;
        justify-content: center;
    }
    
    /* 비활성 슬라이드 숨김 */
    .swiper-slide:not(.swiper-slide-active) {
        opacity: 0 !important;
        pointer-events: none;
    }
    
    /* 페이지네이션 중앙 정렬 */
    .swiper-pagination {
        position: static !important;
        margin-top: 1.5rem;
        text-align: center !important;
        display: flex !important;
        justify-content: center !important;
        align-items: center;
        gap: 8px;
    }
    
    /* 슬라이드 안정성 개선 */
    .swiper-wrapper {
        display: flex;
        align-items: stretch;
    }
    
    .swiper-slide {
        height: auto !important;
        display: flex;
        align-items: stretch;
    }
    
    /* 카드 높이 균일화 및 중앙 정렬 */
    .swiper-slide .card,
    .swiper-slide .service-card,
    .swiper-slide .step-item {
        width: 100%;
        height: 100%;
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        text-align: center;
    }
    
    /* 모든 텍스트 중앙 정렬 */
    .swiper-slide h3,
    .swiper-slide h4,
    .swiper-slide p {
        text-align: center;
        width: 100%;
    }
    
    /* 서비스 카드 특별 스타일 */
    .service-card h4 {
        margin-bottom: 0.5rem;
    }
    
    /* 스텝 아이템 특별 스타일 */
    .step-item h4 {
        margin-bottom: 0.5rem;
    }
    
    /* 모바일에서 슬라이드 간격 조정 */
    @media only screen and (max-width: 480px) {
        .about-slider,
        .service-slider,
        .how-slider {
            padding: 0.5rem 0 2.5rem;
        }
        
        /* 작은 화면에서 페이지네이션 조정 */
        .swiper-pagination {
            margin-top: 1.5rem;
        }
        
        .swiper-pagination-bullet {
            width: 8px;
            height: 8px;
        }
        
        .swiper-pagination-bullet-active {
            width: 24px;
        }
    }
}

/* 다크모드 대응 */
@media (prefers-color-scheme: dark) {
    /* 다크모드 색상은 필요시 추가 */
}

/* 프린트 대응 */
@media print {
    .navbar,
    .floating-contact,
    .scroll-to-top,
    .mobile-menu-toggle {
        display: none !important;
    }
}
