/* ========================================
   연맵(Yon-Map) - 기본 스타일시트
   ======================================== */

/* HTML 전체 리셋 및 기본 설정 */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background-color: #f5f5f5;
    color: #333;
    line-height: 1.6;
}

/* ========================================
   Page Navigation (Welcome / App)
   ======================================== */
.page {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: calc(100vh - 80px);
    display: none;
}

.page.active {
    display: flex;
    z-index: 10;
}

/* Welcome Page */
#welcome-page.active {
    flex-direction: column;
    background: linear-gradient(135deg, #f0f6ff 0%, #e3f2fd 100%);
}

.welcome-container {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 40px 20px;
}

.welcome-content {
    text-align: center;
    max-width: 600px;
}

.welcome-content h2 {
    font-size: 48px;
    color: #003da5;
    margin: 0 0 10px 0;
    font-weight: 700;
}

.welcome-content p {
    font-size: 18px;
    color: #666;
    margin: 10px 0;
}

.welcome-buttons {
    display: flex;
    gap: 24px;
    max-width: 500px;
    margin: 0 auto;
    margin-top: 40px;
}

.welcome-btn {
    flex: 1;
    padding: 30px 20px;
    border: 2px solid transparent;
    border-radius: 12px;
    background: white;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
}

.welcome-btn:hover {
    transform: translateY(-4px);
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.12);
}

.welcome-btn .btn-icon {
    font-size: 48px;
    margin-bottom: 12px;
}

.welcome-btn .btn-title {
    font-size: 20px;
    font-weight: 700;
    color: #003da5;
    margin-bottom: 8px;
}

.welcome-btn .btn-desc {
    font-size: 13px;
    color: #666;
}

.welcome-btn.when2meet-btn {
    border-color: #f0ad4e;
}

.welcome-btn.when2meet-btn:hover {
    background: #fffbf0;
    border-color: #f0ad4e;
}

.welcome-btn.map-btn {
    border-color: #5cb85c;
}

.welcome-btn.map-btn:hover {
    background: #f0fff0;
    border-color: #5cb85c;
}



/* ========================================
   헤더 스타일
   ======================================== */
header {
    background: linear-gradient(135deg, #003da5 0%, #0066cc 100%);
    color: white;
    padding: 20px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.header-content {
    text-align: left;
    flex: 1;
}

#btn-home {
    white-space: nowrap;
}

header h1 {
    font-size: 28px;
    margin-bottom: 5px;
}

header p {
    font-size: 14px;
    opacity: 0.9;
}

/* ========================================
   메인 레이아웃 (3단 구조)
   ======================================== */
main {
    position: relative;
    width: 100%;
    height: calc(100vh - 80px);
    /* 전체 높이에서 헤더 높이 제외 */
}

/* App Page - 기본 3단 가로 레이아웃 */
#app-page.active {
    display: flex !important;
    flex-direction: row;
}

/* App Page - When2meet 모드: 세로 레이아웃 */
#app-page.active.when2meet-mode {
    flex-direction: column !important;
}

#app-page.active.when2meet-mode .sidebar {
    width: 100% !important;
    border-right: none !important;
    border-bottom: 1px solid #ddd;
    max-height: calc(100vh - 80px) !important;
    padding: 40px 20px !important;
}

#app-page.active.when2meet-mode .map-section {
    display: none !important;
}

#app-page.active.when2meet-mode .info-panel {
    display: none !important;
}

/* App Page - Map 모드: 기본 3단 가로 레이아웃 */
#app-page.active.map-mode {
    flex-direction: row !important;
}

#app-page.active.map-mode .sidebar {
    width: 250px !important;
    border-right: 1px solid #ddd !important;
    border-bottom: none !important;
}

#app-page.active.map-mode .map-section {
    display: flex !important;
}

#app-page.active.map-mode .info-panel {
    display: flex !important;
}

/* 좌측 사이드바 */
.sidebar {
    width: 250px;
    background-color: white;
    padding: 20px;
    border-right: 1px solid #ddd;
    overflow-y: auto;
    box-shadow: 2px 0 8px rgba(0, 0, 0, 0.05);
    flex-shrink: 0;
}

.sidebar h2 {
    font-size: 16px;
    margin-bottom: 15px;
    color: #003da5;
}

.map-search-panel {
    margin-bottom: 16px;
}

.map-search-title {
    font-size: 18px;
    color: #003da5;
    margin-bottom: 10px;
}

.map-search-form {
    display: flex;
    gap: 8px;
    margin-bottom: 10px;
}

.map-search-input {
    flex: 1;
    min-width: 0;
    padding: 8px 10px;
    border: 1px solid #ccc;
    border-radius: 6px;
    font-size: 13px;
}

.map-search-button {
    background: #003da5;
    color: #fff;
    border: none;
    border-radius: 6px;
    padding: 8px 10px;
    cursor: pointer;
    font-size: 13px;
}

.map-search-results {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.map-search-item {
    border: 1px solid #e5e5e5;
    border-radius: 8px;
    padding: 8px;
    cursor: pointer;
    background: #fff;
}

.map-search-item:hover {
    border-color: #003da5;
    background: #f3f8ff;
}

.map-search-meta {
    margin-top: 4px;
    font-size: 12px;
    color: #666;
}

.map-search-empty {
    padding: 8px;
    font-size: 13px;
    color: #666;
    border: 1px dashed #ddd;
    border-radius: 8px;
}

/* 중앙 지도 영역 */
.map-section {
    flex: 1;
    position: relative;
    background-color: #eee;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.map-container {
    width: 100%;
    height: 100%;
}

/* 우측 정보 패널 */
.info-panel {
    width: 300px;
    background-color: white;
    padding: 20px;
    border-left: 1px solid #ddd;
    overflow-y: auto;
    box-shadow: -2px 0 8px rgba(0, 0, 0, 0.05);
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
}

.info-panel h2 {
    font-size: 16px;
    margin-bottom: 15px;
    color: #003da5;
}

/* info-panel 상세 스타일 */
.info-panel {
    display: flex;
    flex-direction: column;
}

.info-panel h2 {
    margin: 0 0 8px 0;
}

.info-panel .tag {
    display: inline-block;
    background: #eef6ff;
    color: #003da5;
    padding: 4px 8px;
    border-radius: 12px;
    font-size: 12px;
    margin-right: 6px;
}

/* when2meet styles */
.when2meet {
    margin-top: 12px;
    display: none;
}

.when2meet-app {
    width: 100%;
    max-width: 920px;
    margin: 0 auto;
}

.w2m-card {
    background: #fff;
    border-radius: 12px;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.1);
    padding: 24px;
}

.w2m-main-title {
    color: #003da5;
    font-size: 28px;
    text-align: center;
    margin-bottom: 12px;
}

.w2m-sub {
    text-align: center;
    color: #666;
    font-size: 14px;
    margin-bottom: 8px;
}

.w2m-form {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-top: 16px;
}

.w2m-form input,
.w2m-form select {
    border: 1px solid #ccc;
    border-radius: 8px;
    padding: 10px 12px;
    font-size: 14px;
}

.w2m-time-range {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

.w2m-time-range span {
    display: block;
    font-size: 12px;
    color: #666;
    margin-bottom: 4px;
}

.w2m-slot-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
    gap: 8px;
    margin-top: 16px;
}

.w2m-slot-btn {
    border: 1px solid #d6d6d6;
    border-radius: 8px;
    background: #fff;
    padding: 10px;
    text-align: left;
    font-size: 13px;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.w2m-slot-btn span {
    font-size: 11px;
    color: #666;
}

.w2m-slot-btn.selected {
    border-color: #003da5;
    background: #e8f1ff;
}

.w2m-actions {
    margin-top: 16px;
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.w2m-message {
    margin-top: 12px;
    font-size: 14px;
    color: #333;
}

.w2m-success {
    color: #0a7a2f;
    font-weight: 700;
    margin-bottom: 8px;
}

.w2m-share {
    font-size: 13px;
    margin-bottom: 6px;
    word-break: break-all;
}

.w2m-mode-switch {
    display: flex;
    gap: 8px;
    margin-bottom: 14px;
}

.w2m-mini-btn {
    border: 1px solid #cfd8ea;
    background: #fff;
    color: #003da5;
    border-radius: 8px;
    padding: 8px 12px;
    cursor: pointer;
    font-weight: 600;
}

.w2m-mini-btn.active {
    background: #003da5;
    color: #fff;
    border-color: #003da5;
}

.w2m-date-add-row {
    display: flex;
    gap: 8px;
}

.w2m-calendar-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
}

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

.w2m-calendar-weekday div {
    text-align: center;
    font-size: 12px;
    color: #666;
}

.w2m-cal-cell {
    border: 1px solid #ddd;
    background: #fff;
    border-radius: 8px;
    min-height: 36px;
    cursor: pointer;
    font-size: 12px;
}

.w2m-cal-cell.empty {
    border: none;
    background: transparent;
    cursor: default;
}

.w2m-cal-cell.selected {
    border-color: #003da5;
    background: #e8f1ff;
    color: #003da5;
    font-weight: 700;
}

.w2m-calendar-help {
    margin-top: 6px;
    font-size: 12px;
    color: #666;
}

.w2m-picked-dates {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 4px;
}

.w2m-date-chip {
    border: 1px solid #b9d2ff;
    background: #eef5ff;
    color: #003da5;
    border-radius: 999px;
    padding: 6px 10px;
    font-size: 12px;
    cursor: pointer;
}

.w2m-date-empty {
    font-size: 12px;
    color: #666;
}

.w2m-top-actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    margin-bottom: 8px;
}

.w2m-matrix-wrap {
    margin-top: 16px;
    overflow: auto;
}

.w2m-matrix-table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 4px;
    min-width: 560px;
}

.w2m-matrix-table th,
.w2m-matrix-table td {
    text-align: center;
}

.w2m-matrix-table thead th {
    font-size: 12px;
    color: #003da5;
    background: #eaf2ff;
    padding: 8px;
    border-radius: 6px;
}

.w2m-time-col {
    background: #f7f7f7;
    color: #666;
    font-size: 12px;
    border-radius: 6px;
    min-width: 72px;
}

.w2m-matrix-cell {
    width: 100%;
    min-height: 40px;
    border: 1px solid #d9d9d9;
    border-radius: 8px;
    background: #fff;
    color: #333;
    cursor: pointer;
    font-weight: 600;
    transition: transform 0.08s ease, box-shadow 0.08s ease;
}

.w2m-matrix-cell.selected {
    border-color: #003da5;
    box-shadow: 0 0 0 3px rgba(255, 152, 0, 0.45), 0 6px 14px rgba(255, 87, 34, 0.35);
    transform: scale(1.04);
}

.w2m-matrix-cell:hover {
    box-shadow: 0 2px 8px rgba(0, 61, 165, 0.2);
}

.w2m-toast {
    position: fixed;
    right: 20px;
    bottom: 20px;
    z-index: 9999;
    padding: 10px 14px;
    border-radius: 10px;
    color: #fff;
    font-weight: 600;
    opacity: 0;
    transform: translateY(8px);
    pointer-events: none;
    transition: opacity 0.18s ease, transform 0.18s ease;
}

.w2m-toast.success {
    background: #0a7a2f;
}

.w2m-toast.error {
    background: #b42318;
}

.w2m-toast.show {
    opacity: 1;
    transform: translateY(0);
}

.when2meet:not([style*="display: none"]) {
    width: 100%;
    max-width: 1400px;
    margin: 20px auto;
}

.when2meet h2 {
    text-align: center;
    color: #003da5;
    margin-bottom: 20px;
    font-size: 24px;
}

/* 사람별 섹션 */
.w2m-person-section {
    margin-bottom: 8px;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

.w2m-person-title {
    padding: 12px 16px;
    font-weight: 600;
    font-size: 14px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

/* 각 사람의 그리드 */
.w2m-person-grid {
    display: grid;
    gap: 2px;
    grid-template-columns: 60px repeat(5, 1fr);
    padding: 12px;
    background: #fafafa;
}

.when2meet h3 {
    font-size: 15px;
    color: #003da5;
    margin-bottom: 8px;
}

.when2meet .when2meet-controls {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 8px;
    margin-bottom: 8px;
}

.when2meet .person-select label {
    margin-right: 8px;
    font-weight: 600;
}

/* ========================================
   When2meet: 2열 레이아웃 (선택 + 히트맵)
   ======================================== */

/* 2열 그리드 레이아웃 */
.w2m-layout {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 24px;
    margin-bottom: 20px;
}

.w2m-left,
.w2m-right {
    background: #fafafa;
    border-radius: 8px;
    padding: 16px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
}

.w2m-section-title {
    font-size: 16px;
    font-weight: 700;
    color: #003da5;
    margin-bottom: 12px;
    text-align: center;
}

/* 그리드 컨테이너 */
#w2m-grid-selection,
#w2m-grid-heatmap {
    display: grid;
    gap: 2px;
    grid-template-columns: 60px repeat(5, 1fr);
    background: #fff;
    padding: 12px;
    border-radius: 6px;
}

.w2m-row {
    display: contents;
}

.w2m-cell {
    padding: 6px;
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 500;
    min-height: 44px;
    font-size: 13px;
    transition: all 0.2s ease;
    border: 1px solid #ddd;
}

/* 시간 라벨 */
.w2m-time {
    background: transparent;
    color: #666;
    font-weight: 700;
    padding: 8px 12px;
    text-align: right;
    font-size: 12px;
    border: none;
    cursor: default !important;
}

/* 헤더 행 */
.header-row .w2m-cell {
    background: #e3f2fd;
    color: #003da5;
    font-weight: 700;
    font-size: 11px;
    border: 1px solid #bdd7f5;
}

/* A의 선택 셀 (왼쪽) */
.w2m-slot-selection {
    background: #fff4f0;
    border: 1px solid #ffcab0;
    font-size: 16px;
    cursor: pointer;
}

.w2m-slot-selection:hover {
    background: #ffe8d6;
    border: 1px solid #ff8c42;
}

.w2m-slot-selection.selected {
    background: #d32f2f;
    color: #fff;
    border: 1px solid #b71c1c;
    font-weight: 600;
}

.w2m-slot-selection.selected:hover {
    background: #c62828;
}

/* 히트맵 셀 (오른쪽) - 사람 수에 따른 색상 */
.w2m-slot-heatmap {
    background: #fff;
    border: 1px solid #e0e0e0;
    font-size: 14px;
    cursor: default;
    font-weight: 600;
}

.w2m-slot-heatmap.count-0 {
    background: #fff;
    color: #999;
}

.w2m-slot-heatmap.count-1 {
    background: #e3f2fd;
    color: #1976d2;
}

.w2m-slot-heatmap.count-2 {
    background: #64b5f6;
    color: #fff;
}

.w2m-slot-heatmap.count-3 {
    background: #1976d2;
    color: #fff;
    border: 2px solid #0d47a1;
}

/* 추천 시간 표시 박스 */
.w2m-recommend-box {
    margin-top: 20px;
    padding: 20px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border-radius: 8px;
    text-align: center;
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.3);
}

.w2m-recommend-title {
    font-size: 16px;
    font-weight: 700;
    color: #fff;
    margin-bottom: 8px;
}

.w2m-recommend-content {
    font-size: 24px;
    font-weight: 700;
    color: #fff;
}

.w2m-recommend-content.empty {
    font-size: 14px;
    opacity: 0.8;
}

/* 범례 */
.w2m-legend {
    display: flex;
    justify-content: center;
    gap: 16px;
    margin-top: 16px;
    padding: 12px;
    background: #f5f5f5;
    border-radius: 6px;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 13px;
    color: #666;
}

.legend-color {
    width: 24px;
    height: 24px;
    border-radius: 4px;
    display: inline-block;
}

/* 버튼 */
.w2m-btn {
    border: none;
    padding: 16px 24px;
    border-radius: 8px;
    cursor: pointer;
    font-weight: 600;
    font-size: 16px;
    transition: all 0.3s;
}

.w2m-btn.primary {
    background: #003da5;
    color: #fff;
}

.w2m-btn.primary:hover {
    background: #002f7f;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 61, 165, 0.3);
}

.w2m-btn.secondary {
    background: #eee;
    color: #333;
}

.w2m-btn.secondary:hover {
    background: #ddd;
}

.empty {
    background: transparent;
    border: none;
}

.empty-header {
    background: transparent;
    border: none;
}

.time-label {
    background: transparent;
    color: #666;
    font-weight: 700;
    padding: 8px 12px;
    text-align: right;
    font-size: 12px;
}

.day-label {
    background: #e3f2fd;
    color: #003da5;
    font-weight: 700;
    font-size: 11px;
}

.header-person {
    background: #003da5;
    color: #fff;
    padding: 12px;
    font-size: 14px;
    text-align: center;
    font-weight: 600;
}

.header-person.person-B {
    background: #0066cc;
    color: #fff;
}

.header-person.person-A {
    background: #003da5;
    color: #fff;
}

.header-person.person-overlap {
    background: #ff9800;
    color: #fff;
}

@keyframes pulse {

    0%,
    100% {
        box-shadow: 0 0 12px rgba(0, 100, 200, 0.3);
    }

    50% {
        box-shadow: 0 0 24px rgba(0, 100, 200, 0.6);
    }
}

/* ========================================
   반응형 디자인 (모바일)
   ======================================== */
@media (max-width: 1024px) {

    /* 데스크톱에서는 3단 레이아웃, 1024px 이하에서는 조정 */
    #app-page.active.map-mode {
        flex-direction: column;
    }

    #app-page.active.map-mode .sidebar {
        width: 100%;
        border-right: none;
        border-bottom: 1px solid #ddd;
        max-height: 200px;
    }

    #app-page.active.map-mode .map-section {
        height: 400px;
        flex: none;
    }

    #app-page.active.map-mode .info-panel {
        width: 100%;
        border-left: none;
        border-top: 1px solid #ddd;
        max-height: 200px;
    }

    /* when2meet-mode는 유지 */
    #app-page.active.when2meet-mode .sidebar {
        max-height: calc(100vh - 80px);
    }

    /* When2meet 2열 레이아웃 → 1열로 변경 */
    .w2m-layout {
        grid-template-columns: 1fr;
        gap: 16px;
    }

    #w2m-grid-selection,
    #w2m-grid-heatmap {
        grid-template-columns: 50px repeat(5, 1fr);
    }

    .w2m-cell {
        min-height: 40px;
        font-size: 12px;
    }
}

@media (max-width: 768px) {
    header h1 {
        font-size: 22px;
    }

    .welcome-buttons {
        flex-direction: column;
        gap: 16px;
    }

    #app-page.active.map-mode .map-section {
        height: 300px;
    }

    /* When2meet 극소형 화면 */
    #w2m-grid-selection,
    #w2m-grid-heatmap {
        grid-template-columns: 45px repeat(5, 1fr);
        gap: 1px;
        padding: 8px;
    }

    .w2m-cell {
        min-height: 36px;
        font-size: 11px;
    }

    .w2m-time {
        font-size: 10px;
    }
}

/* Phase 2: mock list styling */
.mock-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.mock-item {
    padding: 10px;
    background: #fafafa;
    border-radius: 8px;
    border: 1px solid #eee;
}

.mock-item .muted {
    color: #666;
    font-size: 13px;
    margin-bottom: 6px;
}

/* Phase 3: custom overlay card */
.custom-overlay-card {
    width: 240px;
    background: white;
    border-radius: 8px;
    box-shadow: 0 6px 18px rgba(0, 0, 0, 0.12);
    font-size: 13px;
    color: #222;
    overflow: hidden;
}

.custom-overlay-card .card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 12px;
    background: linear-gradient(90deg, #003da5, #0066cc);
    color: #fff;
}

.custom-overlay-card .card-header strong {
    font-size: 14px;
}

.custom-overlay-card .overlay-close {
    background: transparent;
    border: none;
    color: #fff;
    font-size: 14px;
    cursor: pointer;
}

.custom-overlay-card .card-body {
    padding: 10px 12px 14px 12px;
}

.custom-overlay-card .category {
    color: #003da5;
    font-weight: 600;
    font-size: 12px;
    margin-bottom: 6px;
}

.custom-overlay-card .desc {
    margin: 0 0 8px 0;
    color: #444;
    font-size: 12px;
}

.custom-overlay-card .meta {
    font-size: 12px;
    color: #888;
}