/* ============================================================
   IDIS 복리후생 - 공통 테마
   Figma "Dubu Design System" 토큰을 그대로 옮긴다.
   페이지별 CSS 는 이 파일 다음에 로드한다.
   ============================================================ */

:root {
    /* 브랜드 */
    --brand: #009CA6;
    --brand-hover: #00909A;
    --brand-pressed: #008892;
    --brand-soft: #E6F6F6;
    --brand-soft-hover: #EDFAFA;
    --brand-link-hover: #00858F;

    /* 배경 */
    --bg-base: #FFFFFF;
    --bg-soft: #F9FAFB;
    --bg-screen: #F8FAFA;

    /* 텍스트 */
    --text-strong: #111827;
    --text-heading: #1F2937;
    --text-secondary: #6B7280;
    --text-placeholder: #9CA3AF;
    --text-on-primary: #FFFFFF;

    /* 선 */
    --border: #E5E7EB;
    --border-soft: #F3F4F6;

    /* 상태 */
    --required: #EF4444;
    --warn-bg: #FFFBEB;
    --warn-border: #FDE68A;
    --warn-text: #D97706;
    --dday: #F97316;
    --error: #E0524E;
    --error-bg: #FDF0EF;

    /* 형태 */
    --radius: 8px;
    --radius-pill: 20px;
    --h-btn: 51px;
    --h-input: 48px;

    /* 데스크탑 중앙 카드 폭 (시안 638px) */
    --card: 640px;
}

* {
    box-sizing: border-box;
    margin: 0;
}

body {
    font-family: "Pretendard Variable", Pretendard, "Noto Sans KR", sans-serif;
    background: var(--bg-base);
    color: var(--text-strong);
    -webkit-text-size-adjust: 100%;
}

/* 화면 전체를 세로로 채워 하단 배너가 바닥에 붙게 한다 */
body.app {
    display: flex;
    flex-direction: column;
    min-height: 100dvh;
}

/* ── 앱 헤더 (뒤로가기 + 화면 제목) ────────────────────── */

.app-header {
    display: flex;
    align-items: center;
    gap: 12px;
    height: 56px;
    padding: 0 20px;
    background: var(--bg-base);
    border-bottom: 1px solid var(--border);
}

.app-header .back {
    display: flex;
    align-items: center;
    justify-content: center;
    flex: 0 0 auto;
    width: 24px;
    height: 24px;
    /* 터치 영역 44px 확보 */
    margin: -10px 0 -10px -10px;
    padding: 10px;
    box-sizing: content-box;
}

.app-header .back img {
    width: 16px;
    height: 16px;
}

.app-header h1 {
    flex: 1;
    min-width: 0;
    font-size: 20px;
    font-weight: 700;
    line-height: 1.4;
    color: var(--text-heading);
}

.app-header .home-link {
    display: flex;
    align-items: center;
    justify-content: center;
    flex: 0 0 auto;
    width: 24px;
    height: 24px;
    /* 터치 영역 44px 확보 */
    margin: -10px -10px -10px 0;
    padding: 10px;
    box-sizing: content-box;
}

.app-header .home-link img {
    width: 24px;
    height: 24px;
}

.logout-btn {
    flex: 0 0 auto;
    padding: 10px 0 10px 10px;
    border: 0;
    background: none;
    font-family: inherit;
    font-size: 13px;
    font-weight: 500;
    color: var(--text-secondary);
    text-decoration: none;
    cursor: pointer;
}

.logout-btn:active {
    color: var(--brand);
}

/* ── 버튼 ──────────────────────────────────────────────── */

.btn-primary {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: var(--h-btn);
    border: 0;
    border-radius: var(--radius);
    background: var(--brand);
    color: var(--text-on-primary);
    font-family: inherit;
    font-size: 16px;
    font-weight: 700;
    line-height: 1;
    text-decoration: none;
    cursor: pointer;
    filter: drop-shadow(0 6px 8px rgba(0, 156, 166, .2));
}

.btn-primary {
    transition: background-color .15s ease;
}

/* 터치 기기에서 탭 후 hover 가 눌린 채로 남는 것을 막는다 */
@media (hover: hover) {
    .btn-primary:hover:not(:disabled) {
        background: var(--brand-hover);
    }
}

.btn-primary:active:not(:disabled) {
    background: var(--brand-pressed);
}

.btn-primary:disabled {
    background: var(--border);
    color: var(--text-placeholder);
    cursor: default;
    filter: none;
}

.btn-outline {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: 100%;
    height: var(--h-btn);
    border: 1px solid var(--brand);
    border-radius: var(--radius);
    background: var(--bg-base);
    color: var(--brand);
    font-family: inherit;
    font-size: 16px;
    font-weight: 700;
    line-height: 1;
    text-decoration: none;
    cursor: pointer;
}

.btn-outline {
    transition: background-color .15s ease, border-color .15s ease, color .15s ease;
}

@media (hover: hover) {
    .btn-outline:hover:not(:disabled) {
        background: var(--brand-soft-hover);
    }
}

.btn-outline:active:not(:disabled) {
    background: var(--bg-soft);
}

.btn-outline:disabled {
    border-color: var(--border);
    color: var(--text-placeholder);
    cursor: default;
}

.btn-outline img {
    width: 16px;
    height: 16px;
}

/* 알약형 링크 버튼 (신청내역 보기 →) */
.btn-pill {
    display: inline-flex;
    align-items: center;
    padding: 8px 16px;
    border: 1px solid var(--brand);
    border-radius: var(--radius-pill);
    background: transparent;
    color: var(--brand);
    font-family: inherit;
    font-size: 14px;
    font-weight: 700;
    text-decoration: none;
    cursor: pointer;
}

.btn-pill {
    transition: background-color .15s ease;
}

@media (hover: hover) {
    .btn-pill:hover {
        background: var(--brand-soft-hover);
    }
}

.btn-pill:active {
    background: var(--bg-soft);
}

/* ── 텍스트 링크 ───────────────────────────────────────── */

.text-link {
    color: var(--brand);
    border-bottom: 1px solid var(--brand);
    text-decoration: none;
    transition: color .15s ease, border-color .15s ease;
}

@media (hover: hover) {
    .text-link:hover {
        color: var(--brand-link-hover);
        border-bottom-color: var(--brand-link-hover);
    }
}

/* ── 필터 칩 ───────────────────────────────────────────── */

.chips {
    display: flex;
    gap: 8px;
    padding: 12px 20px;
}

.chip {
    padding: 8px 16px;
    border: 1px solid var(--border);
    border-radius: var(--radius-pill);
    background: var(--bg-soft);
    color: var(--text-secondary);
    font-family: inherit;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    white-space: nowrap;
}

.chip.is-active {
    background: var(--brand);
    border-color: var(--brand);
    color: var(--text-on-primary);
    font-weight: 700;
}

/* ── 배지 ──────────────────────────────────────────────── */

.badge {
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 11px;
    font-weight: 700;
    white-space: nowrap;
}

.badge.is-open {
    background: var(--brand-soft);
    color: var(--brand-pressed);
}

.badge.is-closed {
    background: var(--border-soft);
    color: var(--text-secondary);
}

/* ── 안내 배너 ─────────────────────────────────────────── */

.alert {
    padding: 12px 14px;
    border-radius: var(--radius);
    background: var(--error-bg);
    font-size: 13px;
    font-weight: 500;
    line-height: 1.5;
    color: var(--error);
}

.info {
    padding: 12px 14px;
    border-radius: var(--radius);
    background: var(--brand-soft);
    font-size: 13px;
    font-weight: 500;
    line-height: 1.5;
    color: var(--brand-pressed);
}

.info.readonly {
    background: var(--border-soft);
    color: var(--text-secondary);
}

/* ── 빈 화면 ───────────────────────────────────────────── */

.empty-state {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 32px;
    padding: 48px 24px;
    text-align: center;
}

.empty-state .mascot {
    width: 180px;
    height: 180px;
    object-fit: contain;
}

.empty-state .texts {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.empty-state h2 {
    font-size: 22px;
    font-weight: 700;
    line-height: 1.4;
    color: var(--text-strong);
}

.empty-state p {
    font-size: 14px;
    line-height: 1.5;
    color: var(--text-secondary);
}

/* ── 수정 모드 배너 ────────────────────────────────────── */

.edit-banner {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 20px;
    background: var(--warn-bg);
    border-bottom: 1px solid var(--warn-border);
    font-size: 13px;
    font-weight: 700;
    color: var(--warn-text);
}

.edit-banner img {
    flex: 0 0 auto;
    width: 16px;
    height: 16px;
}

/* ── 모달 ──────────────────────────────────────────────── */

dialog {
    /* 전역 리셋(* { margin: 0 })이 dialog 기본 가운데 정렬을 지우므로 되살린다 */
    margin: auto;
    width: min(340px, calc(100vw - 48px));
    border: 0;
    border-radius: 16px;
    padding: 28px 24px 24px;
    text-align: center;
}

dialog::backdrop {
    background: rgba(17, 24, 39, .45);
}

dialog h2 {
    font-size: 18px;
    font-weight: 700;
    color: var(--text-heading);
}

dialog p {
    margin-top: 12px;
    font-size: 14px;
    line-height: 1.6;
    color: var(--text-secondary);
}

/* 모달 안에서는 버튼 그림자를 뺀다 */
dialog .btn-primary {
    filter: none;
}

/* 버튼이 하나뿐인 모달(로그인 문의). 두 개짜리는 .modal-actions 가 맡는다 */
dialog > .btn-primary {
    height: 46px;
    margin-top: 20px;
    font-size: 15px;
}

/* 취소 / 확인 두 개를 나란히 두는 모달 */
dialog.confirm {
    padding: 24px;
    text-align: center;
}

dialog.confirm h2 {
    font-size: 22px;
    line-height: 1.4;
    color: var(--text-strong);
}

dialog.confirm p {
    margin-top: 8px;
}

/* 두 칸을 정확히 반씩 나눈다. flex: 1 은 취소 버튼의 1.5px 테두리가
   flex-basis(border-box)에 들어가 2px 어긋나므로 쓰지 않는다 */
.modal-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    margin-top: 24px;
}

.modal-actions > * {
    width: auto;
    min-width: 0;
    height: 48px;
    margin-top: 0;
    font-size: 15px;
}

.btn-cancel {
    display: flex;
    align-items: center;
    justify-content: center;
    border: 1.5px solid var(--border);
    border-radius: var(--radius);
    background: var(--bg-base);
    color: var(--text-secondary);
    font-family: inherit;
    font-weight: 700;
    cursor: pointer;
    transition: background-color .15s ease;
}

@media (hover: hover) {
    .btn-cancel:hover {
        background: var(--bg-soft);
    }
}

.btn-cancel:active {
    background: var(--border-soft);
}

/* ── 데스크탑: 시안 'PC 웹 (중앙 카드)' 대로 가운데 카드 ── */

@media (min-width: 768px) {
    /*
     * 사용자 화면에만 건다. 관리자 콘솔(body.admin)은 전체 폭을 쓰므로
     * html 을 무조건 flex 로 만들면 사이드바까지 가운데로 몰린다.
     */
    html:has(body.app) {
        display: flex;
        justify-content: center;
        /* 내용이 길어 넘칠 때 위쪽이 잘리지 않도록 safe 를 쓴다 */
        align-items: safe center;
        min-height: 100dvh;
        background: var(--bg-soft);
    }

    body.app {
        flex: none;
        width: var(--card);
        max-width: calc(100vw - 48px);
        /* 모바일에서 화면을 채우던 높이를 풀어 내용만큼만 차지하게 한다 */
        min-height: 0;
        margin: 40px 0;
        /* 시안의 카드 안쪽 여백 47px = 각 화면이 이미 쓰는 24px + 23px */
        padding: 0 23px;
        background: var(--bg-base);
        border: 1px solid var(--border);
        border-radius: 16px;
        box-shadow: 0 2px 16px rgba(17, 24, 32, .05);
    }

    /* 카드 안에서는 상단바가 화면 맨 위가 아니라 여백을 두고 시작하고, 구분선도 없다 */
    .app-header {
        height: auto;
        padding: 46px 24px 20px;
        border-bottom: 0;
    }
}

/* ── 관리자 화면으로 넘어가는 링크 (ADMIN 에게만 보인다) ── */

.top-actions {
    flex: 0 0 auto;
    display: flex;
    align-items: center;
    gap: 4px;
}

.admin-link {
    padding: 5px 12px;
    background: var(--brand-soft);
    border-radius: var(--radius-pill);
    font-size: 13px;
    font-weight: 700;
    color: var(--brand);
    text-decoration: none;
}

.admin-link:active {
    background: var(--brand-soft-hover);
}
