/* ============================================================
   common.css — FS MISO 공통 스타일
   nav-bar, 페이드인, Pretendard 폰트, 디자인 토큰, 공통 컴포넌트
   ============================================================ */

/* ── 디자인 토큰 (CSS 변수) ── */
:root {
    /* 색상 */
    --color-primary:          #0071e3;
    --color-primary-hover:    #0077ed;
    --color-success:          #34c759;
    --color-danger:           #ff3b30;
    --color-warning:          #ff9500;
    --color-nav-bg:           #1d1d1f;
    --color-text:             #1d1d1f;
    --color-text-secondary:   #6e6e73;
    --color-text-tertiary:    #a1a1a6;
    --color-bg:               #f5f5f7;
    --color-surface:          #ffffff;
    --color-border:           #e0e0e5;

    /* 모서리 */
    --radius-sm:  8px;
    --radius-md:  12px;
    --radius-lg:  16px;

    /* 간격 */
    --space-xs:  4px;
    --space-sm:  8px;
    --space-md:  16px;
    --space-lg:  24px;

    /* 전환 */
    --transition-fast:  0.15s ease;
    --transition-base:  0.2s ease;
    --transition-slow:  0.3s ease;

    /* 그림자 */
    --shadow-sm:  0 1px 4px rgba(0,0,0,0.08);
    --shadow-md:  0 4px 16px rgba(0,0,0,0.12);
    --shadow-lg:  0 8px 32px rgba(0,0,0,0.18);
}

/* ── Pretendard 폰트 ── */
@import url('https://cdn.jsdelivr.net/gh/orioncactus/pretendard@v1.3.9/dist/web/static/pretendard.min.css');

/* ── 페이드인 애니메이션 ── */
body {
    margin: 0;
    padding: 0;
    opacity: 0;
    transition: opacity 0.2s ease-in-out;
}

body.loaded {
    opacity: 1;
}

/* ── 상단 네비게이션 ── */
.nav-bar {
    background: #1d1d1f;
    padding: 0 24px;
    /* 아이폰 노치/다이나믹 아일랜드 safe-area 지원 */
    padding-left: max(24px, env(safe-area-inset-left));
    padding-right: max(24px, env(safe-area-inset-right));
    height: 52px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: sticky;
    top: 0;
    z-index: 100;
}

.nav-logo {
    font-size: 15px;
    font-weight: 600;
    color: #ffffff;
    margin-right: 20px;
}

.nav-menu {
    display: flex;
    gap: 24px;
}

.nav-link {
    color: #a1a1a6;
    text-decoration: none;
    font-size: 13px;
    font-weight: 400;
    padding: 4px 0;
    margin: 0 14px;
    transition: color 0.2s;
    position: relative;
    /* 터치 타깃 최소 44px 보장 (Apple HIG 기준) */
    min-height: 44px;
    display: inline-flex;
    align-items: center;
}

.nav-link:hover {
    color: #f5f5f7;
    background: transparent;
}

.nav-link::after {
    content: '';
    position: absolute;
    width: 100%;
    height: 1px;
    bottom: 0;
    left: 0;
    background-color: #f5f5f7;
    transform: scaleX(0);
    transition: transform 0.2s ease-in-out;
}

.nav-link:hover::after,
.nav-link.active::after {
    transform: scaleX(1);
}

.nav-link.active {
    color: #f5f5f7;
    background: transparent;
    font-weight: 600;
}

.nav-actions {
    display: flex;
    align-items: center;
    gap: 10px;
}

#logoutBtn:hover {
    color: #ff4b4b !important;
    background: rgba(255, 59, 48, 0.1) !important;
    border-radius: 6px;
}

/* ── 반응형 네비게이션 (768px 이하) ── */
@media (max-width: 768px) {
    /* 상단 네비 숨김 — 하단 탭 바로 대체 */
    .nav-bar {
        display: none !important;
    }

    /* 모바일에서 숨길 네비 요소 */
    .nav-hide-mobile {
        display: none !important;
    }
}

/* ── 하단 탭 바 / 프로필 팝업 (모바일 전용 — 기본 숨김) ── */
.mob-tab-bar,
.mob-profile-backdrop,
.mob-profile-popup {
    display: none;
}

@media (max-width: 768px) {
    .mob-tab-bar {
        display: flex;
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        height: calc(60px + env(safe-area-inset-bottom));
        background: #1d1d1f;
        border-top: 1px solid rgba(255, 255, 255, 0.08);
        z-index: 500;
        align-items: flex-start;
        padding-top: 6px;
        padding-left: max(0px, env(safe-area-inset-left));
        padding-right: max(0px, env(safe-area-inset-right));
    }

    .mob-tab-item {
        flex: 1;
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        gap: 3px;
        cursor: pointer;
        -webkit-tap-highlight-color: transparent;
        color: #6e6e73;
        text-decoration: none;
        padding: 2px 0;
        min-height: 44px;
        transition: transform 0.1s ease;
        background: none;
        border: none;
        font-family: 'Pretendard', -apple-system, sans-serif;
    }

    .mob-tab-item.active {
        color: #ffffff;
    }

    .mob-tab-item.active .mob-tab-icon {
        background: rgba(255, 255, 255, 0.12);
    }

    .mob-tab-item:active {
        opacity: 0.7;
        transform: scale(0.88);
    }

    .mob-tab-icon {
        font-size: 22px;
        line-height: 1;
        padding: 3px 16px;
        border-radius: 8px;
        transition: background 0.15s ease;
    }

    .mob-tab-label {
        font-size: 10px;
        font-weight: 500;
    }

    /* ── 프로필 팝업 ── */
    .mob-profile-backdrop {
        display: none;
        position: fixed;
        inset: 0;
        z-index: 498;
    }

    .mob-profile-backdrop.open {
        display: block;
    }

    .mob-profile-popup {
        display: block;
        position: fixed;
        bottom: calc(60px + env(safe-area-inset-bottom) + 8px);
        right: 12px;
        background: rgba(28, 28, 30, 0.97);
        backdrop-filter: blur(20px);
        -webkit-backdrop-filter: blur(20px);
        border-radius: 14px;
        padding: 16px;
        z-index: 499;
        min-width: 200px;
        border: 1px solid rgba(255, 255, 255, 0.1);
        box-shadow: 0 -4px 32px rgba(0, 0, 0, 0.5);
        transform: translateY(8px) scale(0.96);
        opacity: 0;
        pointer-events: none;
        transition: transform 0.2s ease, opacity 0.2s ease;
    }

    .mob-profile-popup.open {
        transform: translateY(0) scale(1);
        opacity: 1;
        pointer-events: auto;
    }

    .mob-profile-name {
        color: #ffffff;
        font-size: 14px;
        font-weight: 600;
        font-family: 'Pretendard', -apple-system, sans-serif;
        padding-bottom: 12px;
        margin-bottom: 12px;
        border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    }

    .mob-profile-plan-btn {
        color: #1d1d1f;
        font-size: 14px;
        font-weight: 500;
        font-family: 'Pretendard', -apple-system, sans-serif;
        cursor: pointer;
        padding: 4px 0;
        display: block;
        -webkit-tap-highlight-color: transparent;
        background: none;
        border: none;
        width: 100%;
        text-align: left;
        margin-bottom: 4px;
    }

    .mob-profile-logout-btn {
        color: #ff6b6b;
        font-size: 14px;
        font-weight: 500;
        font-family: 'Pretendard', -apple-system, sans-serif;
        cursor: pointer;
        padding: 4px 0;
        display: block;
        -webkit-tap-highlight-color: transparent;
        background: none;
        border: none;
        width: 100%;
        text-align: left;
    }
}

/* ============================================================
   공통 컴포넌트
   ============================================================ */

/* ── 스피너 ── */
@keyframes miso-spin {
    to { transform: rotate(360deg); }
}

.miso-spinner {
    width: 20px;
    height: 20px;
    border: 2px solid rgba(0,0,0,0.1);
    border-top-color: var(--color-primary);
    border-radius: 50%;
    animation: miso-spin 0.7s linear infinite;
    flex-shrink: 0;
    display: inline-block;
}
.miso-spinner.sm  { width: 14px; height: 14px; }
.miso-spinner.lg  { width: 32px; height: 32px; border-width: 3px; }
.miso-spinner.white {
    border-color: rgba(255,255,255,0.3);
    border-top-color: #fff;
}

/* ── 스켈레톤 로더 ── */
@keyframes miso-shimmer {
    0%   { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

.skeleton {
    background: linear-gradient(90deg, #e8e8ed 25%, #f0f0f5 50%, #e8e8ed 75%);
    background-size: 200% 100%;
    animation: miso-shimmer 1.4s ease infinite;
    border-radius: var(--radius-sm);
    color: transparent !important;
}

/* ── 토스트 알림 ── */
.miso-toast-container {
    position: fixed;
    bottom: max(24px, calc(env(safe-area-inset-bottom) + 16px));
    left: 50%;
    transform: translateX(-50%);
    z-index: 99999;
    display: flex;
    flex-direction: column-reverse;
    align-items: center;
    gap: 8px;
    pointer-events: none;
}

.miso-toast {
    background: #1d1d1f;
    color: #fff;
    padding: 11px 20px;
    border-radius: 24px;
    font-size: 13px;
    font-weight: 500;
    font-family: 'Pretendard', -apple-system, sans-serif;
    box-shadow: var(--shadow-lg);
    opacity: 0;
    transform: translateY(10px) scale(0.95);
    transition: opacity 0.2s ease, transform 0.2s ease;
    pointer-events: auto;
    max-width: calc(100vw - 48px);
    text-align: center;
    line-height: 1.4;
    white-space: pre-line;
}
.miso-toast.show    { opacity: 1; transform: translateY(0) scale(1); }
.miso-toast.success { background: #1a7f4a; }
.miso-toast.error   { background: #c0392b; }
.miso-toast.warning { background: #b7710a; }

/* ── 모바일 탭 피드백 ── */
@media (max-width: 768px) {
    button, a, [role="button"], label {
        -webkit-tap-highlight-color: transparent;
    }

    .miso-toast-container {
        bottom: calc(60px + env(safe-area-inset-bottom) + 12px);
    }
}

/* ============================================================
   PC 프로필 드롭다운
   ============================================================ */
.pc-profile-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 99;
}
.pc-profile-backdrop.open { display: block; }

.pc-profile-dropdown {
    position: fixed;
    top: 56px;
    right: 16px;
    background: rgba(28, 28, 30, 0.97);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 12px;
    padding: 8px;
    min-width: 160px;
    z-index: 100;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
    transform: translateY(-6px) scale(0.97);
    opacity: 0;
    pointer-events: none;
    transition: transform 0.18s ease, opacity 0.18s ease;
}
.pc-profile-dropdown.open {
    transform: translateY(0) scale(1);
    opacity: 1;
    pointer-events: auto;
}

.pc-profile-btn {
    display: block;
    width: 100%;
    padding: 9px 12px;
    background: none;
    border: none;
    border-radius: 8px;
    color: #f5f5f7;
    font-size: 13px;
    font-family: 'Pretendard', -apple-system, sans-serif;
    font-weight: 500;
    text-align: left;
    cursor: pointer;
    transition: background 0.12s;
}
.pc-profile-btn:hover { background: rgba(255, 255, 255, 0.1); }
.pc-profile-btn.logout { color: #ff6b6b; margin-top: 4px; border-top: 1px solid rgba(255,255,255,0.08); padding-top: 12px; }

@media (max-width: 768px) {
    .pc-profile-backdrop,
    .pc-profile-dropdown { display: none !important; }
}

/* ============================================================
   설정 모달
   ============================================================ */
.settings-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.4);
    z-index: 1000;
}
.settings-backdrop.open { display: block; }

.settings-modal {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -46%) scale(0.97);
    background: #ffffff;
    border-radius: 16px;
    padding: 24px;
    width: min(360px, calc(100vw - 48px));
    z-index: 1001;
    box-shadow: 0 16px 48px rgba(0, 0, 0, 0.2);
    opacity: 0;
    pointer-events: none;
    transition: transform 0.2s ease, opacity 0.2s ease;
}
.settings-modal.open {
    transform: translate(-50%, -50%) scale(1);
    opacity: 1;
    pointer-events: auto;
}

.settings-modal-title {
    font-size: 17px;
    font-weight: 700;
    color: #1d1d1f;
    margin-bottom: 20px;
}

.settings-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 0;
    border-top: 1px solid #f0f0f5;
}

.settings-row-info {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.settings-row-label {
    font-size: 14px;
    font-weight: 500;
    color: #1d1d1f;
}

.settings-row-desc {
    font-size: 12px;
    color: #86868b;
}

/* 토글 스위치 */
.miso-toggle {
    position: relative;
    display: inline-block;
    width: 44px;
    height: 26px;
    flex-shrink: 0;
}
.miso-toggle input { opacity: 0; width: 0; height: 0; }
.miso-toggle-slider {
    position: absolute;
    inset: 0;
    background: #d1d1d6;
    border-radius: 13px;
    cursor: pointer;
    transition: background 0.2s;
}
.miso-toggle-slider::before {
    content: '';
    position: absolute;
    width: 20px;
    height: 20px;
    left: 3px;
    top: 3px;
    background: white;
    border-radius: 50%;
    box-shadow: 0 1px 4px rgba(0,0,0,0.2);
    transition: transform 0.2s;
}
.miso-toggle input:checked + .miso-toggle-slider { background: var(--color-primary); }
.miso-toggle input:checked + .miso-toggle-slider::before { transform: translateX(18px); }

.settings-close-btn {
    display: block;
    width: 100%;
    margin-top: 20px;
    padding: 11px;
    background: #f5f5f7;
    border: none;
    border-radius: 10px;
    font-size: 14px;
    font-weight: 600;
    font-family: 'Pretendard', -apple-system, sans-serif;
    color: #1d1d1f;
    cursor: pointer;
    transition: background 0.15s;
}
.settings-close-btn:hover { background: #e5e5ea; }

/* ============================================================
   색각 보정 모드 (.colorblind)
   ============================================================ */
body.colorblind {
    --color-success: #0099CC;
    --color-danger:  #CC0099;
}

/* index.html 상태 카드 */
body.colorblind .status-card.licensed { border-left-color: #0099CC; }
body.colorblind .status-card.no-deal  { border-left-color: #CC0099; }

/* 토스트 */
body.colorblind .miso-toast.success { background: #006688; }
body.colorblind .miso-toast.error   { background: #880066; }