/* =========================================================
    Day Modal (예약 목록 모달) - FINAL
    - html[data-theme="dark"] 테마 기준
    - columns: (체크) | 시간 | 고객명 | 번호 | 설명 | 담당자 | 진행상태
    - 모달 크기 확장 + 텍스트 색상 일관 + 모바일 대응
   ========================================================= */

/* modal root */
.modal {
    position: fixed;
    inset: 0;
    z-index: 200000;
}

.modal.hidden {
    display: none !important;
}

.modal-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.45);
}

/* open state */
#dayModal.modal:not(.hidden) {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
}

/* card */
#dayModal .modal-card {
    position: relative;
    width: min(1200px, calc(100vw - 48px));
    max-height: calc(100vh - 96px);
    overflow: hidden;
    display: flex;
    flex-direction: column;

    background: var(--panel);
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: 14px;
    box-shadow: 0 18px 45px rgba(0, 0, 0, 0.35);
}

/* header */
#dayModal .modal-header {
    display: flex;
    align-items: center;
    justify-content: flex-start;
    gap: 12px;

    padding: 14px 16px;
    border-bottom: 1px solid var(--border);
}

#dayModal #dayModalTitle {
    margin: 0;
    font-size: 18px;
    font-weight: 800;
    letter-spacing: -0.2px;
}

/* 우측 상단 X 버튼 제거 */

/* body */
#dayModal .modal-body {
    flex: 1;
    min-height: 0; /* flex 내부 스크롤이 적상 동작을 위해서 필요한 코드 */
    overflow: auto;
    padding: 14px 16px;
}

/* footer */
#dayModal .modal-footer {
    padding: 12px 16px;
    border-top: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
}

#dayModal .modal-footer .footer-left {
    color: var(--muted);
    font-size: 13px;
    min-height: 18px;
}

#dayModal .modal-footer .footer-right {
    display: flex;
    align-items: center;
    gap: 8px;
}

#dayModal .btn-close {
    padding: 10px 14px;
    border-radius: 10px;
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--text);
    font-weight: 700;
    cursor: pointer;
}

#dayModal .btn-close:hover {
    filter: brightness(1.05);
}

/* =========================================================
    Day list table (FINAL)
   ========================================================= */

#dayModal .day-head,
#dayModal .day-row {
    display: grid;
    grid-template-columns: 36px 84px 160px 120px 1fr 140px 140px;
    gap: 12px;
    align-items: center;

    padding: 10px 12px;
    border-radius: 10px;
    border: 1px solid var(--border);
}

#dayModal .day-head {
    background: var(--surface);
    font-weight: 800;
    opacity: 0.95;

    position: relative;
    z-index: 1;
}

#dayModal .day-row {
    background: var(--panel);

    position: relative;
    z-index: 1;
}

#dayModal .day-row:hover {
    filter: brightness(1.05);
}

/* columns */
#dayModal .day-head .col,
#dayModal .day-row .col {
    color: var(--text) !important;
    font-size: 13px;
    min-width: 0;
}

#dayModal .col.time {
    font-weight: 900;
}
#dayModal .col.check {
    display: flex;
    align-items: center;
    justify-content: center;
}

#dayModal input.day-check {
    width: 16px;
    height: 16px;
    accent-color: var(--primary);
    cursor: pointer;
}

#dayModal .day-row.is-selected {
    outline: none;
    box-shadow: 0 0 0 2px var(--primary);
    background: rgba(59, 130, 246, 0.08);
    z-index: 5;
}



#dayModal .col.name {
    font-weight: 800;
}

#dayModal .col.phone {
    font-variant-numeric: tabular-nums;
}

#dayModal .col.message {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

#dayModal .col.assignee,
#dayModal .col.status {
    justify-self: end;
    white-space: nowrap;
}

/* badge */
#dayModal .badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;

    padding: 4px 8px;
    border-radius: 999px;

    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--text);

    font-size: 12px;
    font-weight: 800;
}

/* empty text */
#dayModal .muted {
    color: var(--muted);
    font-size: 13px;
}

/* =========================================================
    Mobile
   ========================================================= */

@media (max-width: 640px) {
    #dayModal.modal:not(.hidden) {
        padding: 16px;
    }

    #dayModal .modal-card {
        width: calc(100vw - 32px);
        max-height: calc(100vh - 32px);
    }

    /* hide header row */
    #dayModal .day-head {
        display: none;
    }

    /* stacked layout */
    #dayModal .day-row {
        grid-template-columns: 36px 72px 1fr;
        grid-template-areas:
            "check time name"
            "check time phone"
            "check time message"
            "check time assignee"
            "check time status";
    }

    #dayModal .col.check { grid-area: check; }
    #dayModal .col.time { grid-area: time; }
    #dayModal .col.name { grid-area: name; }
    #dayModal .col.phone { grid-area: phone; }
    #dayModal .col.message { grid-area: message; }
    #dayModal .col.assignee { grid-area: assignee; justify-self: start; }
    #dayModal .col.status { grid-area: status; justify-self: start; }
}


/* B안: 메모 토글(행 확장) */
.day-row .col.message {
    min-width: 0;
}

.day-row .msg-top {
    display: flex;
    align-items: center;
    gap: 8px;
}

.day-row .msg-title {
    flex: 1;
    min-width: 0;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.day-row .memo-toggle {
    border: 1px solid var(--border);
    background: transparent;
    color: var(--text);
    padding: 4px 8px;
    border-radius: 10px;
    cursor: pointer;
    font-size: 12px;
    opacity: 0.9;
}

.day-row .memo-toggle:hover {
    opacity: 1;
}

.day-row .memo-body {
    margin-top: 6px;
    opacity: 0.9;
    font-size: 12px;
    line-height: 1.4;
    white-space: pre-wrap; /* 줄바꿈 유지 */
    word-break: break-word;

    /* 펼침 애니메이션 느낌 */
    max-height: 160px;
    overflow: auto;
    transition: max-height 160ms ease, opacity 160ms ease;
}

.day-row .memo-body.is-collapsed {
    max-height: 0;
    opacity: 0;
    overflow: hidden;
    margin-top: 0;
}

.day-row .memo-empty {
    margin-top: 6px;
    opacity: 0.55;
    font-size: 12px;
}

/* =========================================================
    Edit View (모달 2단 편집 모드)
   ========================================================= */

#dayModal #dayModalEditView.hidden {
    display: none !important;
}

/* modal 내부 수정칸 사이즈 변경 */
#dayModal #dayModalEditView .edit-form{
    max-width: 880px;
    margin: 0 auto;
}

#dayModal #dayModalEditView .edit-form{
    padding-left: 14px;
    padding-right: 14px;
}

#dayModal .edit-form {
    display: flex;
    flex-direction: column;
    gap: 10px;
    padding: 2px 2px 6px 2px;
}

#dayModal .edit-row .label {
    margin: 0 0 6px 0;
    font-size: 13px;
    font-weight: 800;
    color: var(--muted);
}

#dayModal .edit-form input,
#dayModal .edit-form textarea,
#dayModal .edit-form select {
    width: 100%;
    padding: 10px 12px;
    border-radius: 10px;
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--text);
    font-size: 14px;
}

#dayModal .input-like {
    width: 100%;
    padding: 10px 12px;
    border-radius: 10px;
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--text);
    font-size: 14px;
}

#dayModal .input-like.readonly {
    opacity: 0.92;
}

#dayModal .hint {
    color: var(--muted);
    font-size: 13px;
    padding-top: 2px;
}

#dayModal .hidden {
    display: none !important;
}

/* Admin Modal specific tweaks (v2.0.0a Final) */
/* adminModal overrides - Moved to admin-console.css */

/* Modal UI Enhancements for Admin Log - Moved to admin-console.css */
#logDetailModal .modal-card {
    max-width: 600px;
    background: var(--panel);
}

#logDetailJsonContent {
    max-height: 60vh;
    overflow-y: auto;
    padding: 16px;
}
