/* =============================================
   카폴 (CARPOL) - 모바일 최적화 스타일
   ============================================= */

:root {
    --primary:      #1B3A7A;
    --primary-dark: #122860;
    --primary-light:#2563EB;
    --accent:       #F59E0B;
    --danger:       #EF4444;
    --success:      #10B981;
    --commute:      #2563EB;
    --return:       #7C3AED;
    --bg:           #F3F4F6;
    --card:         #FFFFFF;
    --text:         #111827;
    --text-sub:     #6B7280;
    --border:       #E5E7EB;
    --shadow:       0 1px 4px rgba(0,0,0,.10);
    --radius:       12px;
    --nav-h:        64px;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { font-size: 16px; -webkit-text-size-adjust: 100%; }

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Apple SD Gothic Neo',
                 'Noto Sans KR', 'Malgun Gothic', sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.5;
    max-width: 480px;
    margin: 0 auto;
    min-height: 100vh;
}

/* ── 공통 레이아웃 ── */
.page { padding-bottom: calc(var(--nav-h) + 12px); }
.page-auth { display: flex; flex-direction: column; min-height: 100vh; padding: 0; }

/* ── 헤더 ── */
.app-header {
    position: sticky; top: 0; z-index: 100;
    background: var(--primary);
    color: #fff;
    display: flex; align-items: center; justify-content: space-between;
    padding: 0 16px;
    height: 56px;
    box-shadow: 0 2px 8px rgba(0,0,0,.2);
}
.app-header .logo { font-size: 1.25rem; font-weight: 700; letter-spacing: -.5px; }
.app-header .header-right { display: flex; gap: 8px; }
.btn-icon { background: none; border: none; color: #fff; font-size: 1.25rem;
            cursor: pointer; padding: 6px; border-radius: 8px; }
.btn-icon:hover { background: rgba(255,255,255,.15); }

/* ── 바텀 내비게이션 ── */
.bottom-nav {
    position: fixed; bottom: 0; left: 50%; transform: translateX(-50%);
    width: 100%; max-width: 480px; z-index: 200;
    background: var(--card);
    display: flex;
    border-top: 1px solid var(--border);
    height: var(--nav-h);
    box-shadow: 0 -2px 12px rgba(0,0,0,.08);
}
.nav-item {
    flex: 1; display: flex; flex-direction: column; align-items: center;
    justify-content: center; gap: 4px;
    text-decoration: none; color: var(--text-sub);
    font-size: 0.7rem; font-weight: 500;
    border: none; background: none; cursor: pointer;
    transition: color .15s;
}
.nav-item.active, .nav-item:hover { color: var(--primary); }
.nav-item svg { width: 24px; height: 24px; stroke: currentColor;
                fill: none; stroke-width: 1.8; }
.nav-item.active svg { stroke: var(--primary); }

/* ── 컨테이너 / 카드 ── */
.container { padding: 16px; }
.card {
    background: var(--card);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    overflow: hidden;
}
.card + .card { margin-top: 12px; }
.card-body { padding: 16px; }
.card-header {
    padding: 14px 16px;
    border-bottom: 1px solid var(--border);
    font-weight: 600; font-size: 0.95rem;
    display: flex; align-items: center; gap: 8px;
}

/* ── 섹션 타이틀 ── */
.section-title {
    font-size: 0.8rem; font-weight: 600; color: var(--text-sub);
    text-transform: uppercase; letter-spacing: .5px;
    margin: 20px 0 8px;
}

/* ── 버튼 ── */
.btn {
    display: inline-flex; align-items: center; justify-content: center;
    gap: 6px; padding: 12px 20px;
    border: none; border-radius: 10px;
    font-size: 0.95rem; font-weight: 600; cursor: pointer;
    transition: opacity .15s, transform .1s;
    text-decoration: none; white-space: nowrap;
    -webkit-tap-highlight-color: transparent;
}
.btn:active { transform: scale(.97); opacity: .85; }
.btn-primary  { background: var(--primary); color: #fff; }
.btn-accent   { background: var(--accent); color: #fff; }
.btn-danger   { background: var(--danger); color: #fff; }
.btn-outline  { background: transparent; border: 1.5px solid var(--primary); color: var(--primary); }
.btn-ghost    { background: var(--bg); color: var(--text); }
.btn-full     { width: 100%; }
.btn-sm       { padding: 8px 14px; font-size: 0.85rem; border-radius: 8px; }

/* ── 폼 ── */
.form-group { margin-bottom: 16px; }
.form-label {
    display: block; font-size: 0.875rem; font-weight: 600;
    color: var(--text); margin-bottom: 6px;
}
.form-label .req { color: var(--danger); margin-left: 2px; }
.form-control {
    width: 100%; padding: 12px 14px;
    border: 1.5px solid var(--border); border-radius: 10px;
    font-size: 0.95rem; color: var(--text); background: var(--card);
    transition: border-color .15s;
    appearance: none; -webkit-appearance: none;
}
.form-control:focus { outline: none; border-color: var(--primary-light); }
.form-control::placeholder { color: #9CA3AF; }
.form-control[readonly] { background: #F9FAFB; color: var(--text-sub); }
select.form-control { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%236B7280' stroke-width='1.5' fill='none' stroke-linecap='round'/%3E%3C/svg%3E");
    background-repeat: no-repeat; background-position: right 14px center;
    padding-right: 36px; }
.form-hint { font-size: 0.78rem; color: var(--text-sub); margin-top: 4px; }
.form-error { font-size: 0.78rem; color: var(--danger); margin-top: 4px; }

/* 이메일 입력 (@police.go.kr 고정) */
.email-input-wrap {
    display: flex; align-items: center;
    border: 1.5px solid var(--border); border-radius: 10px;
    background: var(--card); overflow: hidden;
    transition: border-color .15s;
}
.email-input-wrap:focus-within { border-color: var(--primary-light); }
.email-input-wrap .form-control {
    flex: 1; min-width: 0; width: auto;
    border: none; border-radius: 0;
    padding-right: 4px;
}
.email-input-wrap .form-control:focus { border: none; }
.email-input-wrap .email-domain {
    padding: 12px 14px 12px 2px;
    font-size: 0.95rem; color: var(--text-sub); font-weight: 400;
    white-space: nowrap; flex-shrink: 0;
}

/* 주소 입력 그룹 */
.addr-group { display: flex; gap: 8px; align-items: flex-start; }
.addr-group .form-control { flex: 1; }
.addr-group .btn { flex-shrink: 0; margin-top: 0; height: 47px; }

/* 라디오/체크 버튼 그룹 */
.toggle-group { display: flex; gap: 8px; }
.toggle-btn {
    flex: 1; padding: 11px 8px; border: 1.5px solid var(--border);
    border-radius: 10px; background: var(--card); color: var(--text-sub);
    font-size: 0.9rem; font-weight: 600; cursor: pointer; text-align: center;
    transition: all .15s;
}
.toggle-btn.active-commute { border-color: var(--commute); background: #EFF6FF; color: var(--commute); }
.toggle-btn.active-return  { border-color: var(--return);  background: #F5F3FF; color: var(--return); }

/* ── 인증 페이지 (login / register) ── */
.auth-wrap {
    flex: 1; display: flex; flex-direction: column;
    justify-content: center; padding: 32px 24px;
}
.auth-logo {
    text-align: center; margin-bottom: 32px;
}
.auth-logo .logo-badge {
    display: inline-flex; align-items: center; justify-content: center;
    width: 72px; height: 72px; border-radius: 20px;
    background: var(--primary); color: #fff;
    font-size: 2rem; font-weight: 800; margin-bottom: 12px;
}
.auth-logo h1 { font-size: 1.6rem; font-weight: 800; color: var(--primary); letter-spacing: -1px; }
.auth-logo p  { font-size: 0.875rem; color: var(--text-sub); margin-top: 4px; }
.auth-footer  { text-align: center; margin-top: 20px; font-size: 0.875rem; color: var(--text-sub); }
.auth-footer a { color: var(--primary); font-weight: 600; text-decoration: none; }

/* ── 홈 ── */
.home-hero {
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-light) 100%);
    color: #fff; padding: 24px 20px;
}
.home-hero .greeting { font-size: 0.9rem; opacity: .8; }
.home-hero .user-name { font-size: 1.5rem; font-weight: 700; margin: 4px 0 2px; }
.home-hero .affiliation { font-size: 0.875rem; opacity: .85; }
.home-menu { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; padding: 16px; }
.menu-card {
    background: var(--card); border-radius: var(--radius);
    box-shadow: var(--shadow);
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    gap: 10px; padding: 28px 16px;
    text-decoration: none; color: var(--text);
    border: 2px solid transparent; transition: border-color .15s;
    -webkit-tap-highlight-color: transparent;
}
.menu-card:hover, .menu-card:focus { border-color: var(--primary-light); }
.menu-card .menu-icon {
    width: 52px; height: 52px; border-radius: 14px;
    display: flex; align-items: center; justify-content: center; font-size: 1.6rem;
}
.menu-card.recruit .menu-icon { background: #EFF6FF; }
.menu-card.find    .menu-icon { background: #F0FDF4; }
.menu-card .menu-label { font-size: 1rem; font-weight: 700; }
.menu-card .menu-desc  { font-size: 0.75rem; color: var(--text-sub); text-align: center; }

/* ── 배지 ── */
.badge {
    display: inline-flex; align-items: center;
    padding: 3px 9px; border-radius: 20px;
    font-size: 0.75rem; font-weight: 700;
}
.badge-commute { background: #DBEAFE; color: #1D4ED8; }
.badge-return  { background: #EDE9FE; color: #6D28D9; }

/* ── 카풀 목록 아이템 ── */
.post-list { list-style: none; }
.post-item {
    background: var(--card); padding: 14px 16px;
    border-bottom: 1px solid var(--border);
    display: flex; align-items: flex-start; gap: 12px;
    cursor: pointer; -webkit-tap-highlight-color: transparent;
    text-decoration: none; color: var(--text);
    transition: background .1s;
}
.post-item:active { background: var(--bg); }
.post-item:last-child { border-bottom: none; }
.post-item-left { flex-shrink: 0; }
.post-item-body { flex: 1; min-width: 0; }
.post-route {
    display: flex; align-items: center; gap: 6px;
    font-size: 0.9rem; font-weight: 600; margin-bottom: 4px;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.route-arrow { color: var(--text-sub); font-size: 0.8rem; flex-shrink: 0; }
.post-meta { font-size: 0.8rem; color: var(--text-sub); }
.post-time { font-size: 0.85rem; font-weight: 600; color: var(--primary); white-space: nowrap; }

/* ── 날짜 탭 스크롤 ── */
.date-scroll {
    display: flex; gap: 8px; overflow-x: auto;
    padding: 12px 16px; background: var(--card);
    border-bottom: 1px solid var(--border);
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
}
.date-scroll::-webkit-scrollbar { display: none; }
.date-tab {
    flex-shrink: 0; display: flex; flex-direction: column; align-items: center;
    padding: 8px 14px; border-radius: 10px;
    border: 1.5px solid var(--border); background: var(--card);
    cursor: pointer; transition: all .15s; min-width: 56px;
    -webkit-tap-highlight-color: transparent;
}
.date-tab .day-name { font-size: 0.7rem; color: var(--text-sub); }
.date-tab .day-num  { font-size: 1.05rem; font-weight: 700; }
.date-tab.active    { border-color: var(--primary); background: var(--primary); color: #fff; }
.date-tab.active .day-name { color: rgba(255,255,255,.75); }

/* ── 뷰 토글 ── */
.view-toggle {
    display: flex; background: var(--bg);
    border-bottom: 1px solid var(--border);
}
.view-btn {
    flex: 1; padding: 10px; border: none; background: none;
    font-size: 0.875rem; font-weight: 600; color: var(--text-sub);
    cursor: pointer; transition: all .15s;
    border-bottom: 2px solid transparent;
}
.view-btn.active { color: var(--primary); border-bottom-color: var(--primary); background: var(--card); }

/* ── 지도 ── */
#map-container { height: calc(100vh - 56px - 48px - 64px - 64px); min-height: 300px; }

/* ── 상세보기 오버레이 ── */
.detail-sheet {
    position: fixed; bottom: 0; left: 50%; transform: translateX(-50%) translateY(100%);
    width: 100%; max-width: 480px; z-index: 500;
    background: var(--card); border-radius: 20px 20px 0 0;
    box-shadow: 0 -4px 24px rgba(0,0,0,.2);
    transition: transform .3s cubic-bezier(.4,0,.2,1);
    max-height: 80vh; overflow-y: auto;
}
.detail-sheet.open { transform: translateX(-50%) translateY(0); }
.detail-handle {
    display: flex; justify-content: center; padding: 12px;
    position: sticky; top: 0; background: var(--card); z-index: 1;
}
.detail-handle::after {
    content: ''; width: 40px; height: 4px;
    background: var(--border); border-radius: 2px;
}
.detail-overlay {
    position: fixed; inset: 0; background: rgba(0,0,0,.4); z-index: 499; display: none;
}
.detail-overlay.show { display: block; }

/* 상세 내용 */
.detail-body { padding: 0 20px 32px; }
.detail-title { font-size: 1.1rem; font-weight: 700; margin-bottom: 16px; }
.detail-row {
    display: flex; gap: 12px; padding: 10px 0;
    border-bottom: 1px solid var(--border); font-size: 0.9rem;
}
.detail-row:last-child { border-bottom: none; }
.detail-label { flex-shrink: 0; width: 72px; color: var(--text-sub); font-weight: 600; }
.detail-value { flex: 1; color: var(--text); }

/* ── 알림 토스트 ── */
.toast {
    position: fixed; bottom: calc(var(--nav-h) + 12px);
    left: 50%; transform: translateX(-50%) translateY(20px);
    background: #1F2937; color: #fff;
    padding: 12px 20px; border-radius: 10px;
    font-size: 0.875rem; white-space: nowrap;
    opacity: 0; transition: all .3s; z-index: 600; pointer-events: none;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ── 빈 상태 ── */
.empty-state {
    text-align: center; padding: 60px 20px;
    color: var(--text-sub);
}
.empty-state .empty-icon { font-size: 3rem; margin-bottom: 12px; }
.empty-state p { font-size: 0.9rem; }

/* ── 구분선 ── */
.divider { height: 8px; background: var(--bg); margin: 0 -16px; }

/* ── 로딩 ── */
.spinner {
    display: inline-block; width: 20px; height: 20px;
    border: 2px solid rgba(255,255,255,.4);
    border-top-color: #fff; border-radius: 50%;
    animation: spin .6s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── 텍스트 유틸 ── */
.text-primary { color: var(--primary); }
.text-sub     { color: var(--text-sub); font-size: 0.85rem; }
.text-center  { text-align: center; }
.fw-600       { font-weight: 600; }
.mt-8  { margin-top: 8px; }
.mt-12 { margin-top: 12px; }
.mt-16 { margin-top: 16px; }
.mt-24 { margin-top: 24px; }
.mb-8  { margin-bottom: 8px; }
