/* eMediKey 모바일 공통 스타일 */

/* Reset & Base Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    font-size: 16px;
    -webkit-text-size-adjust: 100%;
    -webkit-tap-highlight-color: transparent;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    font-size: 16px;
    line-height: 1.6;
    color: #333;
    background-color: #f8f9fa;
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* Mobile App Container */
.mobile-app {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    background: #f8f9fa;
}

.no-show {
  display: none !important;
}
/* 상단 헤더 */
.app-header {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: 60px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 5px;
    z-index: 1000;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
    backdrop-filter: blur(10px);
}

.header-btn {
    width: 44px;
    height: 44px;
    border: none;
    background: none;
    color: white;
    font-size: 35px;
    font-weight: 600;
    cursor: pointer;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    -webkit-touch-callout: none;
    user-select: none;
}

.header-btn:hover,
.header-btn:active {
    background: rgba(255,255,255,0.2);
    transform: scale(0.95);
}

.header-title {
    font-size: 18px;
    font-weight: 600;
    text-align: center;
    flex: 1;
    margin: 0 8px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.back-btn {
    margin-bottom: 5px;
    font-size: 25px;
}

.back-btn.hidden {
    opacity: 0;
    pointer-events: none;
}

/* 메인 콘텐츠 */
.main-content {
    flex: 1;
    margin-top: 60px;
    margin-bottom: 80px;
    padding: 20px 16px;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}

/* 홈 화면 콘텐츠 */
.welcome-section {
    text-align: center;
    padding: 20px 20px;
    background: white;
    border-radius: 16px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.08);
    margin-bottom: 24px;
}

.app-icon {
    font-size: 64px;
    margin-bottom: 16px;
    display: block;
}

.welcome-section h2 {
    font-size: 24px;
    font-weight: 700;
    color: #2c3e50;
    margin-bottom: 8px;
}

.welcome-section p {
    color: #6c757d;
    font-size: 16px;
}

/* 빠른 작업 그리드 */
.quick-actions {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 16px;
    margin-bottom: 24px;
}

.action-card {
    background: white;
    border-radius: 12px;
    padding: 20px;
    text-align: center;
    box-shadow: 5px 5px 10px 0px rgba(0, 0, 0, 0.06);
    cursor: pointer;
    transition: all 0.2s ease;
    border: 1px solid #eaeaea;
}

.action-card:active {
    transform: scale(0.98);
    box-shadow: 0 1px 6px rgba(0,0,0,0.1);
}

.action-icon {
    font-size: 32px;
    margin-bottom: 12px;
    display: block;
}

.action-card h3 {
    font-size: 16px;
    font-weight: 600;
    color: #2c3e50;
    margin-bottom: 4px;
}

.action-card p {
  display: none;
    font-size: 13px;
    color: #6c757d;
    line-height: 1.4;
}

/* 응급연락처 */
.emergency-contact {
    margin-bottom: 24px;
}

.emergency-card {
    background: linear-gradient(135deg, #ff6b6b 0%, #ee5a52 100%);
    color: white;
    padding: 20px;
    border-radius: 12px;
    box-shadow: 0 4px 16px rgba(255,107,107,0.3);
}

.emergency-card h3 {
    font-size: 18px;
    font-weight: 600;
    margin-bottom: 16px;
    text-align: center;
}

.emergency-numbers {
    display: flex;
    gap: 12px;
}

.emergency-btn {
    flex: 1;
    background: rgba(255,255,255,0.2);
    color: white;
    text-decoration: none;
    padding: 16px 12px;
    border-radius: 8px;
    text-align: center;
    font-weight: 600;
    font-size: 14px;
    transition: all 0.2s ease;
    backdrop-filter: blur(10px);
}

.emergency-btn:active {
    background: rgba(255,255,255,0.3);
    transform: scale(0.98);
}

/* 하단 탭 네비게이션 */
.bottom-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: 80px;
    background: white;
    display: flex;
    border-top: 1px solid #f1f3f4;
    box-shadow: 0 -2px 10px rgba(0,0,0,0.05);
    z-index: 1000;
}

.nav-item {
    flex: 1;
    border: none;
    background: none;
    padding: 8px 4px;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    color: #6c757d;
    text-decoration: none;
}

.nav-item.active {
    color: #667eea;
}

.nav-item:active {
    transform: scale(0.95);
    background: rgba(102, 126, 234, 0.05);
}

.nav-icon {
    font-size: 24px;
    margin-bottom: 4px;
    display: block;
}

.nav-label {
    font-size: 11px;
    font-weight: 500;
    line-height: 1;
}

/* 햄버거 메뉴 */
.menu-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.5);
    z-index: 2000;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
}

.menu-overlay.show {
    opacity: 1;
    visibility: visible;
}

.menu-content {
    position: absolute;
    top: 0;
    right: 0;
    width: 280px;
    max-width: 85vw;
    height: 100vh;
    background: white;
    transform: translateX(100%);
    transition: transform 0.3s ease;
    overflow-y: auto;
    box-shadow: -4px 0 20px rgba(0,0,0,0.15);
}

.menu-overlay.show .menu-content {
    transform: translateX(0);
}

.menu-header {
    padding: 14px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.menu-header h3 {
    font-size: 18px;
    font-weight: 600;
}

.menu-close {
    width: 32px;
    height: 32px;
    border: none;
    background: none;
    color: white;
    font-size: 24px;
    cursor: pointer;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.menu-close:hover {
    background: rgba(255,255,255,0.2);
}

/* 메뉴 사용자 정보 */
.menu-user-info {
    padding: 20px;
    border-bottom: 1px solid #f1f3f4;
}

.user-info {
    display: flex;
    align-items: center;
    gap: 12px;
}

.user-avatar {
    margin: 10px;
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    color: white;
}

.user-details {
    flex: 1;
}

.user-name {
    font-size: 16px;
    font-weight: 600;
    color: #2c3e50;
    margin-bottom: 2px;
}

.user-email {
    font-size: 13px;
    color: #6c757d;
}

/* 메뉴 아이템 */
.menu-items {
    padding: 8px 0;
}

.menu-item {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 16px 20px;
    color: #2c3e50;
    text-decoration: none;
    transition: background-color 0.2s ease;
    border: none;
    background: none;
    width: 100%;
    text-align: left;
    cursor: pointer;
}

.menu-item:hover,
.menu-item:active {
    background: #f8f9fa;
}

.menu-icon {
    font-size: 20px;
    width: 24px;
    text-align: center;
}

.menu-divider {
    height: 1px;
    background: #f1f3f4;
    margin: 8px 20px;
}

.auth-item {
    color: #667eea;
    font-weight: 600;
}

/* 로딩 오버레이 */
.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 3000;
    backdrop-filter: blur(4px);
}

.loading-spinner {
    text-align: center;
    color: white;
}

.spinner {
    width: 40px;
    height: 40px;
    border: 4px solid rgba(255,255,255,0.3);
    border-top: 4px solid white;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto 16px;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.loading-text {
    font-size: 14px;
    font-weight: 500;
}

/* 토스트 알림 */
.toast-container {
    position: fixed;
    top: 80px;
    left: 16px;
    right: 16px;
    z-index: 4000;
    pointer-events: none;
}

.toast {
    background: rgba(0,0,0,0.8);
    color: white;
    padding: 16px 20px;
    border-radius: 8px;
    margin-bottom: 8px;
    transform: translateY(-20px);
    opacity: 0;
    animation: toastIn 0.3s ease forwards;
    backdrop-filter: blur(10px);
    font-size: 14px;
    line-height: 1.4;
}

.toast.success {
    background: rgba(40, 167, 69, 0.9);
}

.toast.error {
    background: rgba(220, 53, 69, 0.9);
}

.toast.warning {
    background: rgba(255, 193, 7, 0.9);
    color: #333;
}

@keyframes toastIn {
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

/* 폼 스타일 */
.form-container {
    padding: 20px 16px;
    max-width: 400px;
    margin: 0 auto;
}

.form-group {
    margin-bottom: 20px;
}

.form-label {
    display: block;
    margin-bottom: 8px;
    font-weight: 600;
    color: #495057;
    font-size: 14px;
}

.form-label .required {
    color: #dc3545;
}

.form-input {
    width: 100%;
    padding: 16px;
    border: 2px solid #e9ecef;
    border-radius: 12px;
    font-size: 16px;
    transition: all 0.2s ease;
    background: #f8f9fa;
    -webkit-appearance: none;
}

.form-input:focus {
    outline: none;
    border-color: #667eea;
    background: white;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.form-input.error {
    border-color: #dc3545;
    background: #fff5f5;
}

.form-input.success {
    border-color: #28a745;
    background: #f8fff9;
}

.form-error {
    color: #dc3545;
    font-size: 12px;
    margin-top: 6px;
    display: block;
}

.form-success {
    color: #28a745;
    font-size: 12px;
    margin-top: 6px;
    display: block;
}

.form-textarea {
    width: 100%;
    min-height: 100px;
    padding: 16px;
    border: 2px solid #e9ecef;
    border-radius: 12px;
    font-size: 16px;
    font-family: inherit;
    resize: vertical;
    transition: all 0.2s ease;
    background: #f8f9fa;
    -webkit-appearance: none;
}

.form-textarea:focus {
    outline: none;
    border-color: #667eea;
    background: white;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.form-select {
    width: 100%;
    padding: 16px;
    border: 2px solid #e9ecef;
    border-radius: 12px;
    font-size: 16px;
    background: #f8f9fa;
    -webkit-appearance: none;
    appearance: none;
    background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 20 20'%3e%3cpath stroke='%236b7280' stroke-linecap='round' stroke-linejoin='round' stroke-width='1.5' d='M6 8l4 4 4-4'/%3e%3c/svg%3e");
    background-position: right 12px center;
    background-repeat: no-repeat;
    background-size: 16px;
    padding-right: 40px;
}

.form-select:focus {
    outline: none;
    border-color: #667eea;
    background-color: white;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

/* 체크박스 */
.checkbox-group {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    margin-bottom: 16px;
}

.checkbox-input {
    width: 20px;
    height: 20px;
    margin-top: 2px;
    cursor: pointer;
    flex-shrink: 0;
}

.checkbox-label {
    font-size: 14px;
    line-height: 1.5;
    color: #495057;
    cursor: pointer;
}

.checkbox-label strong {
    color: #2c3e50;
    font-weight: 600;
}

.checkbox-label small {
    color: #6c757d;
    font-size: 12px;
    display: block;
    margin-top: 2px;
}

/* 버튼 */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 16px 24px;
    border: none;
    border-radius: 12px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    text-decoration: none;
    min-height: 48px;
    -webkit-touch-callout: none;
    user-select: none;
}

.btn:active {
    transform: scale(0.98);
}

.btn-primary {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    box-shadow: 0 4px 15px rgba(102, 126, 234, 0.3);
}

.btn-primary:hover {
    box-shadow: 0 6px 20px rgba(102, 126, 234, 0.4);
}

.btn-secondary {
  background: #fcedbe;
  color: #000000;
  border: solid 0.9px #6b6b6b;
}

.btn-secondary:hover {
    background: #545b62;
}

.btn-block {
    width: 100%;
}

.btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none !important;
}



/* ✅ PNG 이미지 아이콘 스타일 */
.nav-icon-img {
    width: 28px;
    height: 28px;
    margin-bottom: 4px;
    display: block;
    opacity: 0.5; /* 비활성 상태 */
    transition: all 0.2s ease;
    filter: grayscale(100%); /* 회색 처리 */
}

/* active 상태일 때 */
.nav-item.active .nav-icon-img {
    opacity: 1;
    filter: grayscale(0%) brightness(1.1);
    /* 또는 색상 필터 적용 */
    /* filter: brightness(0) saturate(100%) invert(47%) sepia(89%) saturate(1345%) hue-rotate(219deg) brightness(98%) contrast(92%); */
}

/* 호버/액티브 효과 */
.nav-item:active .nav-icon-img {
    transform: scale(0.9);
}

/* 기존 .nav-icon 스타일 (이모지용) - 필요 없으면 제거 */
.nav-icon {
    font-size: 24px;
    margin-bottom: 4px;
    display: block;
}

/* 카드 */
.card {
    background: white;
    border-radius: 12px;
    padding: 20px;
    box-shadow: 0 2px 12px rgba(0,0,0,0.06);
    border: 1px solid #f1f3f4;
    margin-bottom: 16px;
}

.card-header {
    margin-bottom: 16px;
    padding-bottom: 12px;
    border-bottom: 1px solid #f1f3f4;
}

.card-title {
    font-size: 18px;
    font-weight: 600;
    color: #2c3e50;
    margin: 0;
}

.card-subtitle {
    font-size: 14px;
    color: #6c757d;
    margin: 4px 0 0 0;
}

/* 유틸리티 클래스 */
.hidden {
    display: none !important;
}

.text-center {
    text-align: center;
}

.text-left {
    text-align: left;
}

.text-right {
    text-align: right;
}

.mb-0 { margin-bottom: 0 !important; }
.mb-1 { margin-bottom: 8px !important; }
.mb-2 { margin-bottom: 16px !important; }
.mb-3 { margin-bottom: 24px !important; }

.mt-0 { margin-top: 0 !important; }
.mt-1 { margin-top: 8px !important; }
.mt-2 { margin-top: 16px !important; }
.mt-3 { margin-top: 24px !important; }

.p-0 { padding: 0 !important; }
.p-1 { padding: 8px !important; }
.p-2 { padding: 16px !important; }
.p-3 { padding: 24px !important; }

/* 반응형 디자인 */
@media (max-width: 375px) {
    .main-content {
        padding: 16px 12px;
    }

    .quick-actions {
        grid-template-columns1: 2fr;
        grid-template-columns: repeat(2, 1fr);
        gap: 12px;
    }

    .emergency-numbers {
        flex-direction: column;
        gap: 8px;
    }
}

@media (max-height: 667px) {
    .welcome-section {
        padding: 30px 20px;
    }

    .app-icon {
        font-size: 48px;
        margin-bottom: 12px;
    }
}

/* 다크모드 지원 */
@media (prefers-color-scheme: dark1) {
    body {
        background-color: #1a1a1a;
        color: #ffffff;
    }

    .welcome-section,
    .action-card,
    .card,
    .bottom-nav,
    .menu-content {
        background: #2d2d2d;
        border-color: #404040;
    }

    .form-input,
    .form-textarea,
    .form-select {
        background: #404040;
        border-color: #555;
        color: white;
    }

    .form-input:focus,
    .form-textarea:focus,
    .form-select:focus {
        background: #2d2d2d;
    }
}

/* iOS 안전 영역 대응 */
@supports (padding: max(0px)) {
    .app-header {
        padding-top: max(env(safe-area-inset-top), 0px);
        height: calc(60px + max(env(safe-area-inset-top), 0px));
    }

    .main-content {
        margin-top: calc(60px + max(env(safe-area-inset-top), 0px));
        margin-bottom: calc(60px + max(env(safe-area-inset-bottom), 0px));
    }

    .bottom-nav {
        padding-bottom: max(env(safe-area-inset-bottom), 0px);
        height: calc(60px + max(env(safe-area-inset-bottom), 0px));
    }
}

/* 접근성 개선 */
@media (prefers-reduced-motion: reduce) {
    * {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* 포커스 표시 개선 */
.header-btn:focus-visible,
.nav-item:focus-visible,
.btn:focus-visible,
.form-input:focus-visible,
.form-textarea:focus-visible,
.form-select:focus-visible {
    outline: 2px solid #667eea;
    outline-offset: 2px;
}
