/* =============================================
   채팅 — 달력 · 모달 (chat-modal.css)
   — chat.css 에서 분리 (CSS 1000줄 한도 대응, 원본 1633줄)

   🔴 로드 순서 고정: common.css → chat.css → chat-modal.css → chat-responsive.css
      chat.css 를 셋으로 자른 '연속 조각'이라 로드 순서가 곧 캐스케이드다.
      순서가 바뀌면 규칙 우선순위가 달라진다.

   담긴 섹션: 달력 UI · 모달 공통 · 완료 모달 · 달력 모달
   (원본 716~1221행 구간을 그대로 옮겼다 — 규칙 추가·삭제·변경 0건)
   ============================================= */

/* ===== 달력 UI ===== */
.date-multi-desc {
    font-size: 14px;
    color: var(--text-sec);
    margin-bottom: 12px;
    font-weight: 500;
    text-align: left;
}

.custom-calendar-wrapper {
    margin: 12px auto;
    background: var(--bg);
    border-radius: 16px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.08);
    padding: 20px;
    max-width: 460px;
    width: 100%;
    display: flex;
    flex-direction: column;
    position: relative;
    overflow: hidden;
}

.custom-calendar-wrapper::before {
    display: none;
}

.calendar-header {
    display: flex;
    align-items: center;
    justify-content: space-between !important;
    margin-bottom: 16px;
    padding: 0;
    gap: 8px !important;
}

.calendar-title {
    font-size: 18px;
    font-weight: 700;
    color: #1e293b;
    letter-spacing: -0.02em;
    flex: 1;
    text-align: center;
    user-select: none;
    white-space: nowrap;
}

.calendar-nav {
    background: var(--bg-alt);
    color: #1e293b;
    border: 1px solid var(--border);
    border-radius: 10px;
    font-size: 16px;
    width: 40px;
    height: 40px;
    cursor: pointer;
    font-weight: 600;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.calendar-nav:hover {
    background: var(--accent);
    color: var(--bg);
    border-color: var(--accent);
    transform: none;
    box-shadow: none;
}

.calendar-nav:active {
    transform: scale(0.95);
}

.calendar-panel {
    background: var(--bg-alt);
    border-radius: 12px;
    padding: 8px;
    position: relative;
    z-index: 1;
    width: 100%;
    box-sizing: border-box;
    border: 1px solid var(--border);
    overflow: hidden;
}

.calendar-days-row {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 4px;
    margin-bottom: 4px;
}

.calendar-dates-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 4px;
}

.calendar-day-header {
    text-align: center;
    font-size: 13px;
    font-weight: 600;
    color: var(--text-sec);
    padding: 8px 0;
}

.calendar-day {
    aspect-ratio: 1;
    min-height: 44px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    position: relative;
    font-size: 15px;
    font-weight: 500;
    color: #1e293b;
    background: var(--bg);
    border-radius: 12px;
    cursor: pointer;
    user-select: none;
    transition: all 0.15s ease;
    border: 2px solid transparent;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
}

.calendar-day .day-number {
    font-size: 15px;
    font-weight: 500;
    transition: none;
}

.calendar-day:not(.disabled):not(.empty) .day-number {
    color: #1e293b !important;
}

@media (hover: hover) and (pointer: fine) {
    .calendar-day:hover:not(.disabled):not(.empty) {
        background: var(--accent-light);
        border-color: var(--accent);
        transform: none;
        box-shadow: none;
    }
}

/* 오늘 날짜 — 테두리 없이 점만 표시 */
.calendar-day.today {
    background: var(--bg);
    border-color: transparent;
}

.calendar-day.today .day-number {
    color: #1e293b !important;
    font-weight: 600;
}

.calendar-day.today .today-text {
    position: absolute;
    bottom: 3px;
    left: 50%;
    transform: translateX(-50%);
    font-size: 0;
    width: 5px;
    height: 5px;
    background: var(--accent);
    border-radius: 50%;
    overflow: hidden;
    text-indent: -9999px;
}

/* 선택된 날짜 */
.calendar-day.selected {
    background: var(--accent);
    border-color: var(--accent);
    transform: none;
    box-shadow: 0 2px 8px rgba(37,99,235,0.3);
}

.calendar-day.selected .day-number {
    color: var(--bg) !important;
    font-weight: 700;
}

.calendar-day.selected.today .today-text {
    background: var(--bg);
}

/* 비활성/빈 날짜 */
.calendar-day.disabled {
    background: var(--bg-alt);
    cursor: not-allowed;
    opacity: 0.4;
}

.calendar-day.disabled .day-number {
    color: #94A3B8 !important;
}

.calendar-day.empty {
    background: transparent;
    cursor: default;
    pointer-events: none;
}

.calendar-day.empty .day-number {
    color: transparent !important;
}

/* 달력 아래 확인 버튼 */
.custom-calendar-wrapper + .btn-primary {
    margin: 12px auto 0 auto !important;
    display: block !important;
}

/* 달력 등장/사라짐 */
.calendar-fade-wrapper {
    margin-top: 8px;
}

.calendar-fade-wrapper.calendar-appear {
    animation: none;
    opacity: 1;
    transform: none;
}

/* 선택된 날짜 칩 */
.date-chip {
    display: inline-block;
    background: rgba(255,255,255,0.2);
    color: var(--bg);
    border-radius: 8px;
    padding: 2px 8px;
    margin: 0 2px;
    font-size: 14px;
    font-weight: 600;
    border: 1px solid rgba(255,255,255,0.3);
    vertical-align: middle;
}

/* ===== 모달 공통 ===== */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(15,23,42,0.5);
    z-index: 1000;
    align-items: center;
    justify-content: center;
    pointer-events: none;
}

.modal.show {
    display: flex;
}

.modal-content {
    background: var(--bg);
    border-radius: 20px;
    max-width: 400px;
    width: 95%;
    margin: 2rem auto;
    box-shadow: 0 8px 40px rgba(15,23,42,0.15);
    max-height: 90vh;
    pointer-events: auto;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    padding: 0;
    box-sizing: border-box;
}

.modal .btn-primary,
.modal .btn-secondary,
.modal .close-btn {
    pointer-events: auto;
}

.modal-header {
    padding: 20px 24px 16px;
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-header h2 {
    margin: 0;
    color: #1e293b;
    font-weight: 700;
    font-size: 18px;
}

.close-btn {
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: #94A3B8;
    padding: 0;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

.close-btn:hover {
    background: #F1F5F9;
    color: #1e293b;
}

.modal-body {
    padding: 24px;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}

.modal-footer {
    padding: 16px 24px 24px;
    display: flex;
    gap: 12px;
    justify-content: center;
}

/* ===== 완료 모달 ===== */
#completionModal .modal-content {
    max-height: 85vh;
    padding: 0;
}

#completionModal .modal-header {
    border-bottom: none;
    padding-bottom: 0;
}

#completionModal .modal-footer {
    justify-content: center;
    padding-bottom: 28px;
}

#completionModal .modal-footer .btn-primary {
    width: 100%;
    padding: 16px;
    font-size: 16px;
}

.completion-bar {
    height: 4px;
    background: linear-gradient(90deg, var(--accent), #60A5FA);
    border-radius: 2px;
    margin-bottom: 20px;
}

.completion-header {
    display: flex;
    align-items: center;
    gap: 8px;
    margin: 0 0 8px;
}

.completion-header .completion-icon {
    font-size: 1.3rem;
    line-height: 1;
}

.completion-header h3 {
    margin: 0;
    font-size: 18px;
    font-weight: 700;
    color: #1e293b;
}

.completion-desc {
    margin: 0 0 20px;
    font-size: 14px;
    color: var(--text-sec);
}

/* ===== 전송 실패 상태 ===== */
/* chat-submit.js가 자동 재시도 3회 실패 시에만 완료 모달의 내용을 교체한다.
   성공 경로는 이 규칙에 전혀 닿지 않는다. 색은 위험(빨강) 아이콘 하나로만 쓴다 */
.submit-failed-icon {
    width: 22px;
    height: 22px;
    flex-shrink: 0;
}

.submit-failed .completion-desc {
    margin-bottom: 4px;
}

#completionModal .modal-footer .btn-primary:disabled {
    opacity: 0.6;
    cursor: default;
}

.summary {
    background: var(--bg-alt);
    border-radius: 12px;
    padding: 16px;
    margin-bottom: 16px;
}

.summary h4 {
    margin: 0 0 12px;
    font-size: 15px;
    font-weight: 700;
    color: #1e293b;
}

.summary-item {
    display: flex;
    justify-content: space-between;
    padding: 8px 0;
    border-bottom: 1px solid var(--border);
}

.summary-item:last-child {
    border-bottom: none;
}

.summary-item .label {
    color: var(--text-sec);
    font-size: 14px;
    font-weight: 500;
}

.summary-item .value {
    color: #1e293b;
    font-size: 14px;
    font-weight: 600;
    text-align: right;
}

.next-steps {
    background: var(--accent-light);
    border-radius: 12px;
    padding: 16px;
}

.next-steps h4 {
    margin: 0 0 8px;
    font-size: 15px;
    font-weight: 700;
    color: #1e293b;
}

.next-steps ul {
    margin: 0;
    padding-left: 0;
    list-style: none;
}

.next-steps li {
    padding: 4px 0;
    font-size: 14px;
    color: #475569;
    position: relative;
    padding-left: 20px;
}

.next-steps li::before {
    content: '\2713';
    position: absolute;
    left: 0;
    color: var(--accent);
    font-weight: 700;
}

/* ===== 달력 모달 ===== */
#calendarModal .modal-content {
    max-width: 480px;
    padding: 0;
    overflow: visible;
}

#calendarModal .modal-header {
    background: var(--accent);
    color: white;
    border-radius: 20px 20px 0 0;
    padding: 20px 24px;
}

#calendarModal .modal-header h2 {
    color: white;
    font-size: 18px;
    font-weight: 700;
}

#calendarModal .modal-body {
    padding: 20px;
    background: var(--bg-alt);
    overflow: hidden !important;
}

#calendarModal .custom-calendar-wrapper {
    box-shadow: none;
    background: transparent;
    padding: 0;
    margin: 0;
}

#calendarModal .modal-footer {
    background: var(--bg-alt);
    padding: 0 20px 20px;
    border-radius: 0 0 20px 20px;
}

#calendarModal .modal-footer .btn-primary {
    width: 100%;
    padding: 14px;
    font-size: 16px;
    border-radius: 12px;
    transform: none !important;
}

