/**
 * 모바일 전용 · PWA 앱처럼 보이기
 * 하단 네비게이션, 상단 앱 바, safe area 대응
 */

/* ---- 브레이크포인트: 모바일 = 768px 이하 ---- */
@media (max-width: 768px) {
    /* 상단 네비(데스크톱) 숨김, 모바일용 상단바만 표시 */
    .navbar .nav-container {
        padding: 0.5rem 1rem;
        min-height: 56px;
    }
    .navbar .nav-menu,
    .navbar .nav-actions {
        display: none !important;
    }
    .navbar .nav-brand a span {
        font-size: 1rem;
    }
    .navbar .nav-brand a {
        font-size: 1rem;
    }
    /* 햄버거는 데스크톱에서만 숨김 유지, 모바일에서 표시 - main.css에 nav-toggle display:none 있음 → mobile에서 flex */
    .nav-toggle {
        display: flex !important;
        align-items: center;
        justify-content: center;
        width: 44px;
        height: 44px;
        min-width: 44px;
        min-height: 44px;
        border: none;
        background: transparent;
        color: var(--gray-700);
        cursor: pointer;
        border-radius: var(--radius);
        font-size: 1.25rem;
    }
    body.dark-mode .nav-toggle {
        color: var(--text-primary);
    }

    /* 메인 콘텐츠: 하단 네비 높이 + safe area 만큼 패딩 */
    main {
        margin-top: 56px;
        padding-bottom: calc(64px + env(safe-area-inset-bottom, 0px));
        min-height: calc(100vh - 56px - 64px - env(safe-area-inset-bottom, 0px));
    }

    /* 푸터: 모바일에서는 간소화(하단 네비가 메인 이동 담당) */
    .footer {
        padding: 2rem 1rem 1.5rem;
        margin-top: 2rem;
        padding-bottom: calc(1.5rem + env(safe-area-inset-bottom, 0px));
    }
    .footer-content {
        grid-template-columns: 1fr;
        gap: 1.5rem;
        text-align: center;
    }
    .footer-section {
        padding: 0;
    }
    .footer-title {
        justify-content: center;
    }
    .footer-social {
        justify-content: center;
    }
    .footer-bottom {
        padding-top: 1rem;
        font-size: 0.875rem;
    }

    /* 터치 타겟 최소 44px */
    .btn-outline,
    .btn-primary,
    .nav-brand a,
    .quick-card,
    .action-btn {
        min-height: 44px;
        display: inline-flex;
        align-items: center;
        justify-content: center;
    }
    .quick-card {
        padding: 1.25rem 1rem;
    }
    a.action-btn {
        min-height: 48px;
        padding: 0.875rem 1rem;
    }
}

/* ---- 하단 네비게이션 바 (앱 스타일) ---- */
.mobile-bottom-nav {
    display: none;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: calc(64px + env(safe-area-inset-bottom, 0px));
    background: var(--card-bg);
    border-top: 1px solid var(--card-border);
    z-index: 1000;
    padding-bottom: env(safe-area-inset-bottom, 0px);
    box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.06);
}
body.dark-mode .mobile-bottom-nav {
    background: var(--card-bg);
    border-top-color: var(--card-border);
    box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.3);
}

@media (max-width: 768px) {
    .mobile-bottom-nav {
        display: flex;
        align-items: stretch;
        justify-content: space-around;
    }
}

.mobile-bottom-nav__item {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.25rem;
    padding: 0.5rem 0.25rem;
    text-decoration: none;
    color: var(--gray-600);
    font-size: 0.6875rem;
    font-weight: 500;
    min-height: 44px;
    transition: color 0.2s, background 0.2s;
    -webkit-tap-highlight-color: transparent;
}
body.dark-mode .mobile-bottom-nav__item {
    color: var(--text-secondary);
}
.mobile-bottom-nav__item:hover,
.mobile-bottom-nav__item:active {
    color: var(--primary);
    background: rgba(99, 102, 241, 0.08);
}
body.dark-mode .mobile-bottom-nav__item:hover,
body.dark-mode .mobile-bottom-nav__item:active {
    color: #a5b4fc;
    background: rgba(99, 102, 241, 0.15);
}
.mobile-bottom-nav__item.active {
    color: var(--primary);
}
body.dark-mode .mobile-bottom-nav__item.active {
    color: #a5b4fc;
}
.mobile-bottom-nav__item i {
    font-size: 1.25rem;
}
.mobile-bottom-nav__item button,
button.mobile-bottom-nav__item {
    border: none;
    background: none;
    cursor: pointer;
    font: inherit;
    width: 100%;
}

/* ---- 더보기 오버레이 (풀스크린 패널) ---- */
.mobile-more-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.4);
    z-index: 1500;
    opacity: 0;
    transition: opacity 0.25s ease;
}
.mobile-more-overlay.visible {
    display: block;
    opacity: 1;
}
.mobile-more-panel {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    max-height: 70vh;
    background: var(--card-bg);
    border-radius: 16px 16px 0 0;
    z-index: 1501;
    transform: translateY(100%);
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    padding: 1rem 1.25rem;
    padding-bottom: calc(1rem + env(safe-area-inset-bottom, 0px));
    box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.15);
}
body.dark-mode .mobile-more-panel {
    background: var(--card-bg);
    box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.4);
}
.mobile-more-overlay.visible .mobile-more-panel {
    transform: translateY(0);
}
.mobile-more-panel__handle {
    width: 40px;
    height: 4px;
    background: var(--gray-300);
    border-radius: 2px;
    margin: 0 auto 1rem;
}
body.dark-mode .mobile-more-panel__handle {
    background: var(--gray-600);
}
.mobile-more-panel__title {
    font-size: 1rem;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 1rem;
    padding: 0 0.25rem;
}
.mobile-more-panel__links {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}
.mobile-more-panel__links a {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.875rem 1rem;
    border-radius: var(--radius);
    color: var(--text-primary);
    text-decoration: none;
    font-weight: 500;
    min-height: 48px;
    transition: background 0.2s;
}
.mobile-more-panel__links a:hover {
    background: var(--gray-100);
}
body.dark-mode .mobile-more-panel__links a:hover {
    background: rgba(255, 255, 255, 0.06);
}
.mobile-more-panel__links a i {
    width: 1.5rem;
    text-align: center;
    color: var(--gray-500);
}
body.dark-mode .mobile-more-panel__links a i {
    color: var(--text-secondary);
}
.mobile-more-panel__theme {
    margin-top: 1rem;
    padding-top: 1rem;
    border-top: 1px solid var(--gray-200);
}
body.dark-mode .mobile-more-panel__theme {
    border-top-color: var(--card-border);
}
.mobile-more-panel__theme button {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.875rem 1rem;
    border: none;
    background: transparent;
    color: var(--text-primary);
    font-size: 1rem;
    font-weight: 500;
    cursor: pointer;
    border-radius: var(--radius);
    min-height: 48px;
}
.mobile-more-panel__theme button:hover {
    background: var(--gray-100);
}
body.dark-mode .mobile-more-panel__theme button:hover {
    background: rgba(255, 255, 255, 0.06);
}

@media (min-width: 769px) {
    .mobile-more-overlay,
    .mobile-more-panel {
        display: none !important;
    }
}

/* ---- 홈(index) 모바일 - PC 배너 숨김, 모바일 전용 배너만 표시 ---- */
.hero-banner-mobile {
    display: none;
}
@media (max-width: 768px) {
    .home-hero .hero-title {
        font-size: 1.5rem;
    }
    .home-hero .hero-subtitle {
        font-size: 0.9375rem;
    }
    /* 모바일 전용 배너: container 밖이라 패딩 없음, 전체 폭·중앙 */
    .hero-banner-mobile {
        display: block !important;
        width: 100%;
        padding: 0 0 1.25rem 0;
        line-height: 0;
        position: relative;
        z-index: 10;
        box-sizing: border-box;
    }
    .hero-banner-mobile .hero-banner-item {
        display: none;
    }
    .hero-banner-mobile .hero-banner-item.active {
        display: block;
    }
    .hero-banner-mobile a {
        display: block;
        width: 100%;
        text-align: center;
    }
    .hero-banner-mobile img {
        width: 100%;
        max-width: 100%;
        height: auto;
        min-height: 120px;
        display: block;
        margin: 0 auto;
        object-fit: cover;
        object-position: center;
    }
    .hero-banner-mobile .hero-banner-coupang-wrap {
        position: relative;
        width: 100%;
        min-height: 140px;
        aspect-ratio: 1310/216;
    }
    .hero-banner-mobile .hero-banner-coupang iframe {
        width: 100%;
        height: 100%;
        position: absolute;
        top: 0;
        left: 0;
        display: block;
        border: 0;
    }
    .hero-banner-mobile .hero-banner-coupang-overlay {
        position: absolute;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        z-index: 1;
    }
    .home-quick .quick-grid {
        grid-template-columns: 1fr;
        gap: 1rem;
    }
    .home-quick {
        padding: 1.5rem 0 2rem;
    }
    .home-cta .cta-inner .btn {
        width: 100%;
        max-width: 280px;
    }
    .home-cta {
        padding: 1.5rem 0;
    }
}

/* ---- 대시보드 모바일 ---- */
@media (max-width: 768px) {
    .page-container .container {
        padding: 1rem;
    }
    .dash-header {
        padding: 1.5rem 1rem;
    }
    .dash-header h1 {
        font-size: 1.375rem;
    }
    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 0.75rem;
    }
    .stat-card {
        padding: 1rem;
    }
    .stat-card .number {
        font-size: 1.375rem;
    }
    .stat-card .icon {
        font-size: 1.5rem;
    }
    .quick-actions .actions-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 0.75rem;
    }
    .quick-actions {
        padding: 1.25rem 1rem;
    }
    .quick-actions h2 {
        font-size: 1.125rem;
        margin-bottom: 1rem;
    }
    .logout-section {
        margin-top: 1rem;
    }
}
