/* ============== App Header ============== */

.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;
    }
}


/* 앱에서만 상단 여백 추가 */

.capacitor-app .app-header {
    top: 24px;
}

.header-container {
    max-width: 100%;
    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 Button ============== */

.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: -100%;
    width: 100%;
    height: 100vh;
    background: #f7f9fa;
    z-index: 10001;
    transition: right 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    padding: 0;
}

.side-menu.active {
    right: 0;
}


/* 메뉴 헤더 */

.menu-header {
    background: #ffffff;
    padding: 16px 20px;
    border-bottom: 1px solid #e5e8eb;
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: relative;
}

.menu-title {
    font-size: 1.3rem;
    font-weight: 700;
    color: #333;
}


/* 닫기 버튼 */

.close-menu-btn {
    background: transparent;
    border: none;
    color: #333;
    font-size: 2rem;
    width: 40px;
    height: 40px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    font-weight: 300;
}

.close-menu-btn:hover {
    color: #667eea;
    transform: scale(1.1);
}


/* ============== 컴팩트 프로필 섹션 (한 줄) ============== */

.menu-profile-compact {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 20px;
    background: #ffffff;
    border-bottom: 1px solid #e5e8eb;
}

.profile-image-small {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: linear-gradient(135deg, #667eea, #764ba2);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    flex-shrink: 0;
    color: white;
    overflow: hidden;
}

.profile-image-small img {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    object-fit: cover;
}

.profile-info-inline {
    flex: 1;
    min-width: 0;
}

.profile-name-link {
    display: flex;
    align-items: center;
    gap: 4px;
    text-decoration: none;
    margin-bottom: 2px;
    transition: all 0.2s ease;
}

.profile-name-link:hover .profile-name-small {
    color: #667eea;
}

.profile-name-link:hover .profile-arrow {
    color: #667eea;
    transform: translateX(2px);
}

.profile-name-small {
    font-size: 1rem;
    font-weight: 700;
    color: #333;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.profile-arrow {
    font-size: 1.2rem;
    color: #8b95a1;
    font-weight: 600;
    transition: all 0.2s ease;
    flex-shrink: 0;
}

#menuProfileNameNoLink {
    margin-bottom: 2px;
}

.profile-email-small {
    font-size: 0.75rem;
    color: #8b95a1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.profile-auth-btn {
    padding: 8px 16px;
    border-radius: 8px;
    font-size: 0.85rem;
    font-weight: 600;
    text-decoration: none;
    flex-shrink: 0;
    transition: all 0.2s ease;
    border: none;
    cursor: pointer;
    white-space: nowrap;
}

.profile-auth-btn.login-btn {
    background: linear-gradient(135deg, #667eea, #764ba2);
    color: white;
}

.profile-auth-btn.login-btn:hover {
    opacity: 0.9;
    transform: translateY(-1px);
}

.menu-profile-compact .profile-auth-btn.logout-btn {
    background: #ffffff;
    color: #ff6b6b;
    border: 1px solid #e5e8eb;
    padding: 8px 16px;
    font-size: 0.85rem;
}

.menu-profile-compact .profile-auth-btn.logout-btn:hover {
    background: #fff5f5;
}

.profile-auth-btn:active {
    transform: scale(0.97);
}


/* ============== 자주 사용하는 서비스 ============== */

.favorite-services {
    background: #ffffff;
    padding: 20px;
    border-bottom: 8px solid #f7f9fa;
}

.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
}

.section-header h3 {
    font-size: 0.9rem;
    font-weight: 700;
    color: #333;
}

.edit-btn {
    background: transparent;
    border: none;
    color: #8b95a1;
    font-size: 0.85rem;
    cursor: pointer;
    padding: 4px 8px;
    transition: color 0.2s ease;
}

.edit-btn:hover {
    color: #667eea;
}

.favorite-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 8px;
}

.favorite-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-decoration: none;
    padding: 8px 4px;
    border-radius: 12px;
    transition: all 0.2s ease;
    position: relative;
}

.favorite-item:active {
    background: #f7f9fa;
    transform: scale(0.95);
}

.favorite-icon {
    width: 56px;
    height: 56px;
    border-radius: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.8rem;
    margin-bottom: 8px;
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.2);
    position: relative;
}

.favorite-label {
    font-size: 0.75rem;
    color: #333;
    font-weight: 500;
    text-align: center;
}


/* 편집 모드 - 삭제 버튼 (자주 사용 - 큰 아이콘 56px) */

.delete-badge {
    position: absolute;
    top: -9px;
    right: -9px;
    width: 20px;
    height: 20px;
    background: #ff6b6b;
    color: white;
    border: 2px solid white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.9rem;
    font-weight: bold;
    line-height: 1;
    cursor: pointer;
    box-shadow: 0 2px 8px rgba(255, 107, 107, 0.4);
    transition: all 0.2s ease;
    z-index: 10;
}

.delete-badge:hover {
    background: #ff5252;
    transform: scale(1.1);
}

.delete-badge:active {
    transform: scale(0.95);
}


/* 편집 모드 - 추가 버튼 (전체 서비스 - 작은 아이콘 40px) */

.add-badge {
    position: absolute;
    top: -10px;
    right: -10px;
    width: 18px;
    height: 18px;
    background: #667eea;
    color: white;
    border: 2px solid white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.85rem;
    font-weight: bold;
    line-height: 1;
    cursor: pointer;
    box-shadow: 0 2px 8px rgba(102, 126, 234, 0.4);
    transition: all 0.2s ease;
    z-index: 10;
}

.add-badge:hover {
    background: #5a6fd8;
    transform: scale(1.1);
}

.add-badge:active {
    transform: scale(0.95);
}


/* 편집 모드 애니메이션 */

.edit-mode .favorite-item {
    animation: shake 0.5s ease;
}

@keyframes shake {
    0%,
    100% {
        transform: rotate(0deg);
    }
    25% {
        transform: rotate(-2deg);
    }
    75% {
        transform: rotate(2deg);
    }
}


/* ============== 전체 서비스 ============== */

.all-services {
    flex: 1;
    padding: 20px;
    background: #ffffff;
}

.all-services .section-header {
    margin-bottom: 20px;
}

.service-category {
    margin-bottom: 28px;
}

.service-category:last-child {
    margin-bottom: 0;
}

.category-title {
    font-size: 0.85rem;
    font-weight: 700;
    color: #333;
    margin-bottom: 12px;
    padding-bottom: 8px;
    border-bottom: 2px solid #f7f9fa;
}

.category-count {
    color: #667eea;
    font-size: 0.8rem;
    margin-left: 4px;
}

.service-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    row-gap: 8px;
}

.service-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-decoration: none;
    padding: 6px 8px;
    border-radius: 8px;
    transition: all 0.2s ease;
    position: relative;
    flex-shrink: 0;
}

.service-item:active {
    background: #f7f9fa;
    transform: scale(0.95);
}

.service-icon {
    width: 48px;
    height: 48px;
    background: #f7f9fa;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    margin-bottom: 6px;
    position: relative;
}

.service-label {
    font-size: 0.7rem;
    color: #333;
    font-weight: 500;
    text-align: center;
    line-height: 1.2;
}


/* ============== 메뉴 오버레이 ============== */

.menu-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.4);
    z-index: 10000;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
}

.menu-overlay.active {
    opacity: 1;
    visibility: visible;
}


/* ============== 540px 제약 ============== */

@media (min-width: 541px) {
    .side-menu {
        left: 50%;
        transform: translateX(-50%);
        max-width: 540px;
        right: auto;
        margin-left: 100%;
    }
    .side-menu.active {
        margin-left: 0;
    }
}


/* ============== 모바일 최적화 ============== */

@media (max-width: 400px) {
    .favorite-grid {
        grid-template-columns: repeat(4, 1fr);
        gap: 8px;
    }
    .favorite-icon {
        width: 48px;
        height: 48px;
        font-size: 1.5rem;
    }
    .favorite-label {
        font-size: 0.7rem;
    }
    .service-grid {
        gap: 4px;
    }
    .service-icon {
        width: 36px;
        height: 36px;
        font-size: 1.2rem;
    }
    .service-label {
        font-size: 0.65rem;
    }
}

@media (max-width: 540px) {
    .menu-header {
        padding: 14px 16px;
    }
    .menu-title {
        font-size: 1.2rem;
    }
    .menu-profile-compact {
        padding: 16px;
    }
    .favorite-services {
        padding: 16px;
    }
    .all-services {
        padding: 16px;
    }
    .profile-auth-btn {
        padding: 6px 12px;
        font-size: 0.8rem;
    }
    .profile-arrow {
        font-size: 1.1rem;
    }
}


/* 앱에서만 상단 여백 */

.capacitor-app .app-header {
    top: env(safe-area-inset-top, 30px);
}


/* 상단 여백 흰색 배경 */

.capacitor-app body::before {
    content: '';
    position: fixed;
    top: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 100%;
    max-width: 540px;
    height: env(safe-area-inset-top, 30px);
    background: #ffffff;
    z-index: 999;
}


/* 헤더 컨테이너 중앙 정렬 강제 */

.capacitor-app .header-container {
    align-items: center !important;
    padding: 15px 20px 0 20px !important;
}


/* 로고 중앙 배치 */

.capacitor-app .logo-section {
    display: flex !important;
    align-items: center !important;
    justify-content: flex-start !important;
}


/* 앱에서만 메뉴 여백 */

.side-menu.active.app-mode .menu-header {
    padding-top: 46px !important;
}