/* 전역 리셋 */

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}


/* PC에서 모바일 뷰 강조를 위한 배경 */

html {
    background: #e0e0e0;
}


/* 기본 스타일 */

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    line-height: 1.6;
    background: #f5f5f5;
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    max-width: 540px;
    margin: 0 auto;
    position: relative;
    box-shadow: 0 0 20px rgba(0, 0, 0, 0.1);
}


/* 상단 헤더 */

.app-header {
    position: fixed;
    top: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 100%;
    max-width: 540px;
    background: rgba(255, 255, 255, 0.98);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    box-shadow: 0 2px 15px rgba(0, 0, 0, 0.08);
    z-index: 1000;
    padding: 0;
    height: 120px;
    display: flex;
    align-items: center;
}


/* 모바일에서 헤더 높이 조정 */

@media (max-width: 480px) {
    .app-header {
        height: 110px;
    }
}

.header-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    height: 100%;
    width: 100%;
}

.logo-section {
    display: flex;
    align-items: center;
    height: 100%;
}

.header-logo {
    height: 10rem;
    width: auto;
    cursor: pointer;
    transition: transform 0.3s ease;
}

.header-logo:hover {
    transform: scale(1.05);
}


/* 모바일에서 로고 크기 조정 */

@media (max-width: 480px) {
    .header-logo {
        height: 8rem;
    }
}


/* 햄버거 버튼 */

.hamburger-btn {
    background: none;
    border: none;
    cursor: pointer;
    padding: 8px;
    display: flex;
    flex-direction: column;
    gap: 5px;
    z-index: 1001;
    transition: transform 0.3s ease;
}

.hamburger-btn:hover {
    transform: scale(1.1);
}

.hamburger-line {
    width: 28px;
    height: 3px;
    background: #333;
    border-radius: 2px;
    transition: all 0.3s ease;
}

.hamburger-btn.active .hamburger-line:nth-child(1) {
    transform: rotate(45deg) translate(7px, 7px);
}

.hamburger-btn.active .hamburger-line:nth-child(2) {
    opacity: 0;
}

.hamburger-btn.active .hamburger-line:nth-child(3) {
    transform: rotate(-45deg) translate(7px, -7px);
}


/* 사이드 메뉴 */

.side-menu {
    position: fixed;
    top: 0;
    right: -320px;
    width: 280px;
    height: 100vh;
    background: white;
    box-shadow: -5px 0 20px rgba(0, 0, 0, 0.1);
    z-index: 1100;
    transition: right 0.3s ease;
    overflow-y: auto;
}


/* 540px 이하에서 사이드 메뉴 위치 조정 */

@media (max-width: 540px) {
    .side-menu {
        right: -280px;
    }
    .side-menu.active {
        right: 0;
    }
}

.side-menu.active {
    right: 0;
}

.side-menu-header {
    padding: 24px 20px;
    border-bottom: 1px solid #eee;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.side-menu-header h2 {
    font-size: 1.5rem;
    color: #333;
}

.close-menu-btn {
    background: none;
    border: none;
    font-size: 2rem;
    color: #666;
    cursor: pointer;
    padding: 0;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: color 0.3s ease;
}

.close-menu-btn:hover {
    color: #333;
}

.menu-list {
    list-style: none;
    padding: 20px 0;
}

.subindex-menu-item {
    display: block;
    width: 100%;
    padding: 16px 24px;
    text-decoration: none;
    color: #333;
    font-size: 1rem;
    font-weight: 500;
    border: none;
    background: none;
    text-align: left;
    cursor: pointer;
    transition: all 0.3s ease;
}

.subindex-menu-item:hover {
    background: rgba(102, 126, 234, 0.1);
    color: #667eea;
}

.logout-btn {
    color: #ff6b6b;
}

.logout-btn:hover {
    background: rgba(255, 107, 107, 0.1);
    color: #ff5252;
}


/* 메뉴 오버레이 */

.menu-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100vh;
    background: rgba(0, 0, 0, 0.5);
    z-index: 1050;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
}

.menu-overlay.active {
    opacity: 1;
    visibility: visible;
}


/* 메인 컨텐츠 */

.main-content {
    margin-top: 120px;
    margin-bottom: 60px;
    min-height: calc(100vh - 180px);
    padding-top: 24px;
}


/* 모바일에서 메인 컨텐츠 마진 조정 */

@media (max-width: 480px) {
    .main-content {
        margin-top: 110px;
        min-height: calc(100vh - 170px);
        padding-top: 20px;
    }
}


/* 슬라이더 섹션 */


/* ============== 슬라이더 섹션 (4:3 비율 반응형) ============== */

.slider-section {
    position: relative;
    width: 100%;
    overflow: hidden;
    background: white;
    border-radius: 20px 20px 0 0;
    box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.05);
}

.slider-container {
    position: relative;
    width: 100%;
    padding-bottom: 75%;
    overflow: hidden;
    touch-action: pan-y pinch-zoom;
    background: #f5f5f5;
    /* iOS WebKit compatibility */
    -webkit-transform: translateZ(0);
    transform: translateZ(0);
    will-change: transform;
}

.slider-track {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    transition: transform 0.5s ease;
}

.slide {
    position: relative;
    min-width: 100%;
    height: 100%;
    flex-shrink: 0;
    /* iOS WebKit 호환성 - 하드웨어 가속 */
    -webkit-transform: translateZ(0);
    transform: translateZ(0);
    -webkit-backface-visibility: hidden;
    backface-visibility: hidden;
}

.slide[data-link] {
    cursor: pointer;
}

.slide[data-link]:active {
    opacity: 0.9;
}

.slide img {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: center;
    display: block;
    /* iOS WebKit 호환성 */
    max-width: 100%;
    max-height: 100%;
    -webkit-transform: translateZ(0);
    transform: translateZ(0);
}

.slide-content {
    position: absolute;
    bottom: 30px;
    left: 24px;
    color: white;
    z-index: 10;
    text-shadow: 2px 2px 8px rgba(0, 0, 0, 0.5);
}

.slide-content h2 {
    font-size: 1.8rem;
    font-weight: 700;
    margin-bottom: 8px;
}

.slide-content p {
    font-size: 1rem;
    opacity: 0.95;
}


/* 슬라이더 인디케이터 */

.slider-indicators {
    position: absolute;
    bottom: 20px;
    right: 20px;
    display: flex;
    align-items: center;
    z-index: 20;
    background: rgba(0, 0, 0, 0.5);
    padding: 6px 14px;
    border-radius: 20px;
}

.slide-counter {
    color: white;
    font-size: 0.9rem;
    font-weight: 600;
}


/* 컨텐츠 섹션 */

.content-section {
    padding: 30px 0;
    background: #f5f5f5;
}

.content-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px;
}


/* 메뉴 그리드 */

.menu-grid {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 16px 8px;
    background: white;
    padding: 20px 12px;
    border-radius: 16px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
}

.subindex-menu-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    text-decoration: none;
    color: #333;
    padding: 4px 2px;
    border-radius: 12px;
    transition: all 0.3s ease;
    cursor: pointer;
}

.subindex-menu-item:active {
    transform: scale(0.95);
    background: rgba(102, 126, 234, 0.05);
}

.subindex-menu-icon {
    width: 100%;
    max-width: 56px;
    aspect-ratio: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: clamp(1.5rem, 8vw, 2.5rem);
    margin-bottom: 6px;
    flex-shrink: 0;
}

.subindex-menu-icon-special {
    width: 100%;
    max-width: 56px;
    aspect-ratio: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: clamp(1.2rem, 6.5vw, 2rem);
    font-weight: 700;
    color: #667eea;
    margin-bottom: 6px;
    flex-shrink: 0;
}

.subindex-menu-label {
    font-size: clamp(0.6rem, 2.5vw, 0.75rem);
    font-weight: 500;
    text-align: center;
    line-height: 1.2;
    color: #333;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
}


/* 540px 이상에서 최대 크기 제한 */

@media (min-width: 540px) {
    .menu-grid {
        gap: 20px 12px;
        padding: 24px 16px;
    }
    .subindex-menu-item {
        padding: 8px 4px;
    }
    .subindex-menu-icon {
        margin-bottom: 8px;
    }
    .subindex.subindex-menu-icon-special {
        margin-bottom: 8px;
    }
}


/* 호버 효과 (데스크톱) */

@media (hover: hover) and (pointer: fine) {
    .subindex-menu-item:hover {
        background: rgba(102, 126, 234, 0.05);
    }
    .subindex-menu-item:hover .subindex-menu-icon {
        transform: scale(1.1);
    }
    .subindex-menu-item:hover .subindex.subindex-menu-icon-special {
        transform: scale(1.1);
    }
}


/* 예시 컨텐츠 카드 */

.content-card {
    background: white;
    border-radius: 16px;
    padding: 24px;
    margin-top: 16px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
    transition: all 0.3s ease;
}

.content-card:hover {
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.1);
    transform: translateY(-2px);
}

.card-title {
    font-size: 1.25rem;
    font-weight: 700;
    color: #333;
    margin-bottom: 12px;
}

.card-description {
    font-size: 0.95rem;
    color: #666;
    line-height: 1.6;
}


/* 터치 디바이스 최적화 */

@media (hover: none) and (pointer: coarse) {
    .content-card:active {
        transform: scale(0.98);
    }
    .subindex-menu-item:active {
        background: rgba(102, 126, 234, 0.2);
    }
}


/* 하단 네비게이션 바 */

.bottom-nav {
    position: fixed;
    bottom: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 100%;
    max-width: 540px;
    background: rgba(255, 255, 255, 0.98);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.08);
    z-index: 1000;
    display: flex;
    justify-content: space-around;
    align-items: center;
    padding: 6px 0 8px 0;
    border-top: 1px solid rgba(0, 0, 0, 0.05);
}

.nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-decoration: none;
    color: #999;
    transition: all 0.3s ease;
    padding: 2px 8px;
    min-width: 50px;
    position: relative;
}

.nav-item:active {
    transform: scale(0.95);
}

.nav-icon {
    font-size: 1.3rem;
    margin-bottom: 2px;
    transition: all 0.3s ease;
}

.nav-label {
    font-size: 0.65rem;
    font-weight: 500;
    transition: all 0.3s ease;
}


/* 활성화된 메뉴 */

.nav-item.active {
    color: #667eea;
}

.nav-item.active .nav-icon {
    transform: scale(1.1);
}

.nav-item.active .nav-label {
    font-weight: 700;
}


/* 메인 아이콘 (가운데) */

.main-icon {
    width: 44px;
    height: 44px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 1.1rem;
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.3);
    margin-bottom: 0;
}

.nav-item:nth-child(3) {
    margin-top: -16px;
}

.nav-item:nth-child(3) .nav-label {
    display: none;
}


/* 호버 효과 (데스크톱) */

@media (hover: hover) and (pointer: fine) {
    .nav-item:hover {
        color: #667eea;
    }
    .nav-item:hover .nav-icon {
        transform: scale(1.15);
    }
    .nav-item:hover .main-icon {
        box-shadow: 0 6px 16px rgba(102, 126, 234, 0.4);
    }
}


/* 아이폰 하단 안전 영역 고려 */

@supports (padding-bottom: env(safe-area-inset-bottom)) {
    .bottom-nav {
        padding-bottom: calc(8px + env(safe-area-inset-bottom));
    }
}


/* ============== 관리자 슬라이드 관리 버튼 ============== */

.admin-slide-btn {
    position: absolute;
    top: 10px;
    right: 10px;
    z-index: 10;
    background: rgba(255, 255, 255, 0.9);
    border: 2px solid #667eea;
    color: #667eea;
    padding: 8px 16px;
    border-radius: 20px;
    font-weight: 600;
    font-size: 0.85rem;
    cursor: pointer;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    transition: all 0.3s;
}

.admin-slide-btn:hover {
    background: #667eea;
    color: white;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.3);
}


/* ============== 슬라이드 관리 모달 ============== */

.slide-manager {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.slide-item {
    background: #f9f9f9;
    padding: 20px;
    border-radius: 12px;
    border: 2px solid #e0e0e0;
}

.slide-item-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
}

.slide-item-header h3 {
    margin: 0;
    color: #333;
    font-size: 1.1rem;
}

.slide-preview {
    width: 100%;
    height: 200px;
    background: #fff;
    border: 2px dashed #ccc;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 15px;
    overflow: hidden;
}

.slide-preview img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.slide-preview .no-image {
    color: #999;
    font-size: 0.9rem;
}

.upload-slide-btn {
    width: 100%;
    padding: 12px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    border-radius: 8px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s;
}

.upload-slide-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.3);
}

.delete-slide-btn {
    padding: 6px 12px;
    background: #ffebee;
    color: #c62828;
    border: 2px solid #c62828;
    border-radius: 6px;
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s;
}

.delete-slide-btn:hover {
    background: #c62828;
    color: white;
}


/* 슬라이드 추가 섹션 */

.add-slide-section {
    text-align: center;
    padding: 20px;
    background: #f0f4ff;
    border-radius: 12px;
    margin-bottom: 20px;
}

.add-slide-btn {
    padding: 12px 30px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    border-radius: 25px;
    font-weight: 700;
    font-size: 1rem;
    cursor: pointer;
    transition: all 0.3s;
    box-shadow: 0 4px 15px rgba(102, 126, 234, 0.3);
}

.add-slide-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(102, 126, 234, 0.4);
}

.help-text {
    margin: 10px 0 0 0;
    color: #666;
    font-size: 0.9rem;
}

.slide-list {
    display: flex;
    flex-direction: column;
    gap: 15px;
    max-height: 500px;
    overflow-y: auto;
}

.slide-item-actions {
    display: flex;
    gap: 8px;
    align-items: center;
}

.move-slide-btn {
    width: 35px;
    height: 35px;
    padding: 0;
    background: #e3f2fd;
    color: #1976d2;
    border: 2px solid #1976d2;
    border-radius: 6px;
    font-size: 1.2rem;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.3s;
}

.move-slide-btn:hover:not(:disabled) {
    background: #1976d2;
    color: white;
}

.move-slide-btn:disabled {
    opacity: 0.3;
    cursor: not-allowed;
}

@media (max-width: 768px) {
    .slide-preview {
        height: 150px;
    }
}