/* ===================================================
   공샘's HUB - 통합 CSS
   =================================================== */

/* [변수 및 기본 설정] */
:root {
    --bg: #0f172a;
    --side: #131c2f;
    --txt: #f8fafc;
    --blue: #38bdf8;
    --green: #4ade80;
    --yellow: #fbbf24;
    --red: #fb7185;
    --purp: #a855f7;
}

/* 💡 추가된 부분: 전체 페이지에서 터치(패닝, 줌)를 브라우저 기본 동작으로 강제 보장합니다. */
html, body {
    touch-action: pan-x pan-y pinch-zoom !important;
}

* {
    box-sizing: border-box;
}

body {
    font-family: 'Nanum Gothic', sans-serif;
    background: var(--bg);
    color: var(--txt);
    margin: 0;
    display: flex;
    /* 💡 수정된 부분: 고정된 100vh 대신 최소 높이 지정 및 넘침(overflow) 허용 */
    min-height: 100vh;
    overflow: auto;
}

/* ===================================================
   [햄버거 메뉴 버튼]
   =================================================== */
.mobile-menu-toggle {
    display: none;
    position: fixed;
    top: 15px;
    left: 15px;
    z-index: 1001;
    background: var(--blue);
    border: none;
    width: 50px;
    height: 50px;
    border-radius: 12px;
    cursor: pointer;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    gap: 5px;
    box-shadow: 0 4px 15px rgba(56, 189, 248, 0.4);
    transition: all 0.3s ease;
}

.mobile-menu-toggle span {
    width: 24px;
    height: 3px;
    background: #fff;
    border-radius: 2px;
    transition: all 0.3s ease;
}

.mobile-menu-toggle.active span:nth-child(1) {
    transform: rotate(45deg) translate(7px, 7px);
}

.mobile-menu-toggle.active span:nth-child(2) {
    opacity: 0;
}

.mobile-menu-toggle.active span:nth-child(3) {
    transform: rotate(-45deg) translate(7px, -7px);
}

/* ===================================================
   [모바일 오버레이]
   =================================================== */
.mobile-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.7);
    z-index: 999;
    backdrop-filter: blur(5px);
}

.mobile-overlay.active {
    display: block;
}

/* ===================================================
   [반응형 - 모바일 최적화] max-width: 900px
   =================================================== */
@media (max-width: 900px) {
    body {
        flex-direction: column;
    }

    .mobile-menu-toggle {
        display: flex;
    }

    .sidebar {
        position: fixed !important;
        left: -100% !important;
        top: 0 !important;
        width: 280px !important;
        height: 100vh !important;
        border-right: 2px solid rgba(56, 189, 248, 0.3) !important;
        border-bottom: none !important;
        padding: 80px 20px 20px 20px !important;
        z-index: 1000 !important;
        transition: left 0.3s ease;
        overflow-y: auto;
        box-shadow: 5px 0 25px rgba(0, 0, 0, 0.5);
    }

    .sidebar.active {
        left: 0 !important;
    }

    .mobile-overlay.active {
        display: block;
    }

    .sidebar-brand {
        display: flex;
        justify-content: space-between;
        align-items: center;
        margin-bottom: 20px;
    }

    .sidebar-brand h2 {
        font-size: 1.3rem;
        margin: 0;
    }

    .sidebar-brand a {
        margin: 0;
    }

    .live-wrap {
        padding: 12px;
        margin-bottom: 15px;
    }

    .sidebar-menu {
        margin-bottom: 10px;
    }

    .sidebar-menu a {
        padding: 14px;
        font-size: 0.95rem;
        margin-bottom: 10px;
    }

    /* 💡 수정된 부분: 모바일에서 화면 높이를 고정하지 않고 유연하게 변경 */
    .main-viewport {
        width: 100% !important;
        min-height: 100vh !important;
        height: auto !important;
        flex: 1;
        -webkit-overflow-scrolling: touch; /* iOS 스크롤 부드럽게 */
    }

    .info-box {
        display: block !important;
    }

    .ip-list {
        max-height: 100px;
        font-size: 0.7rem;
    }

    .auth-card {
        padding: 30px 20px;
        width: 95%;
        max-width: 400px;
    }

    nav span {
        font-size: 0.75rem;
        margin-bottom: 8px;
    }
}

/* ===================================================
   [반응형 - 태블릿 최적화] 901px ~ 1200px
   =================================================== */
@media (min-width: 901px) and (max-width: 1200px) {
    .sidebar {
        width: 240px;
        padding: 20px 15px;
    }

    .sidebar-brand h2 {
        font-size: 1.3rem;
    }
}

/* ===================================================
   [터치 디바이스 최적화]
   =================================================== */
@media (hover: none) and (pointer: coarse) {
    .sidebar-menu a {
        padding: 16px;
        margin-bottom: 12px;
        min-height: 48px;
    }

    .sidebar-menu a:active {
        background: rgba(255, 255, 255, 0.15);
        transform: scale(0.98);
    }

    .auth-card input {
        font-size: 16px;
        padding: 16px;
    }

    .auth-card button {
        font-size: 16px;
        padding: 16px;
        min-height: 50px;
    }
}

/* ===================================================
   [사이드바]
   =================================================== */
.sidebar {
    width: 280px;
    background: var(--side);
    border-right: 1px solid rgba(255, 255, 255, 0.1);
    padding: 25px 20px;
    display: flex;
    flex-direction: column;
    gap: 15px;
    flex-shrink: 0;
    overflow-y: auto;
}

/* ===================================================
   [Project Focus Mode]
   - 메인 iframe이 /project 일 때 HUB 사이드바를 기본 숨김
   =================================================== */
body.project-focus .mobile-menu-toggle {
    display: flex !important;
}

body.project-focus .sidebar {
    position: fixed;
    left: 0;
    top: 0;
    bottom: 0;
    z-index: 1000;
    transform: translateX(calc(-100% - 24px));
    opacity: 0;
    pointer-events: none;
    transition: transform 0.24s cubic-bezier(0.4, 0, 0.2, 1), opacity 0.24s ease;
}

body.project-focus .sidebar.active {
    transform: translateX(0);
    opacity: 1;
    pointer-events: auto;
}

body.project-focus .main-viewport {
    width: 100%;
}

.sidebar-brand h2 {
    font-size: 1.4rem;
    font-weight: 800;
    background: linear-gradient(135deg, var(--blue), var(--green));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    margin: 0;
}

/* ===================================================
   [인원 및 IP 트래킹 영역]
   =================================================== */
.live-wrap {
    background: rgba(0, 0, 0, 0.3);
    border-radius: 12px;
    padding: 15px;
    border: 1px solid rgba(56, 189, 248, 0.1);
}

.live-counter {
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--green);
    font-size: 0.85rem;
    font-weight: 800;
}

.dot {
    width: 8px;
    height: 8px;
    background: var(--green);
    border-radius: 50%;
    animation: blink 1.5s infinite;
    box-shadow: 0 0 10px var(--green);
}

@keyframes blink {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.2; }
}

/* ===================================================
   [관리자 전용 영역]
   =================================================== */
.admin-monitor-box {
    margin-top: 12px;
    padding: 10px;
    background: rgba(168, 85, 247, 0.05);
    border: 1px solid rgba(168, 85, 247, 0.3);
    border-radius: 8px;
}

.ip-list {
    font-size: 0.75rem;
    color: #94a3b8;
    max-height: 120px;
    overflow-y: auto;
}

.ip-item {
    font-family: 'Courier New', monospace;
    margin-top: 5px;
    display: flex;
    justify-content: space-between;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    padding-bottom: 3px;
}

/* ===================================================
   [네비게이션 메뉴]
   =================================================== */
.sidebar-menu {
    list-style: none;
    padding: 0;
    margin: 0;
}

.sidebar-menu a {
    text-decoration: none;
    color: var(--txt);
    font-size: 0.9rem;
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px;
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.03);
    transition: all 0.3s ease;
    margin-bottom: 8px;
    border: 1px solid rgba(255, 255, 255, 0.05);
}

.sidebar-menu a:hover {
    background: rgba(255, 255, 255, 0.1);
    border-color: var(--blue);
    transform: translateX(8px);
}

/* ===================================================
   [메인 뷰포트]
   =================================================== */
.main-viewport {
    flex-grow: 1;
    background: #000;
    position: relative;
    /* 💡 수정된 부분: 부모가 늘어나더라도 대응하도록 min-height 부여 */
    min-height: 100vh;
}

#mainFrame {
    width: 100%;
    /* 💡 수정된 부분: 액자(iframe) 자체도 크기를 유연하게 가져가도록 변경 */
    min-height: 100vh;
    height: 100%;
    border: none;
    display: block;
}

/* ===================================================
   [인증 오버레이]
   =================================================== */
.auth-overlay {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.98);
    z-index: 2000;
    display: flex;
    justify-content: center;
    align-items: center;
    backdrop-filter: blur(15px);
}

.auth-card {
    background: #1e293b;
    padding: 40px;
    border-radius: 25px;
    text-align: center;
    border: 1px solid var(--blue);
    width: 90%;
    max-width: 350px;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
}

.auth-card input {
    width: 100%;
    padding: 14px;
    border-radius: 10px;
    border: 1px solid #444;
    background: #000;
    color: #fff;
    margin: 20px 0;
    text-align: center;
    font-size: 1.1rem;
}

.auth-card button {
    width: 100%;
    padding: 14px;
    border-radius: 10px;
    border: none;
    background: var(--blue);
    color: #fff;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.3s ease;
}

.auth-card button:hover {
    background: #0ea5e9;
    transform: translateY(-2px);
    box-shadow: 0 10px 20px rgba(56, 189, 248, 0.3);
}

.auth-card button:active {
    transform: translateY(0);
}

/* ===================================================
   [하단 정보 박스]
   =================================================== */
.info-box {
    margin-top: auto;
    padding: 15px;
    border-radius: 15px;
    background: rgba(0, 0, 0, 0.2);
    font-size: 0.8rem;
    border: 1px dashed rgba(255, 255, 255, 0.1);
}

/* ===================================================
   [과정 진행률 위젯]
   =================================================== */
.progress-widget {
    background: rgba(0, 0, 0, 0.3);
    border-radius: 12px;
    padding: 15px;
    border: 1px solid rgba(74, 222, 128, 0.2);
    margin-bottom: 15px;
}

.progress-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
}

.progress-title {
    font-size: 0.85rem;
    font-weight: 800;
    color: var(--green);
    display: flex;
    align-items: center;
    gap: 6px;
}

.progress-percentage {
    font-size: 1.3rem;
    font-weight: 800;
    color: var(--blue);
}

.progress-bar-container {
    width: 100%;
    height: 12px;
    background: rgba(0, 0, 0, 0.5);
    border-radius: 10px;
    overflow: hidden;
    margin-bottom: 10px;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.progress-bar-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--blue), var(--green));
    border-radius: 10px;
    transition: width 1s ease;
    box-shadow: 0 0 10px rgba(56, 189, 248, 0.5);
}

.progress-details {
    font-size: 0.7rem;
    color: #94a3b8;
    line-height: 1.6;
}

.progress-stat {
    display: flex;
    justify-content: space-between;
    margin-top: 5px;
}

.progress-stat strong {
    color: var(--txt);
}

/* ===================================================
   [휴강일 클릭 버튼]
   =================================================== */
.holiday-info-btn {
    background: rgba(251, 113, 133, 0.1);
    border: 1px solid rgba(251, 113, 133, 0.3);
    color: var(--red);
    padding: 4px 10px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.7rem;
    transition: all 0.3s ease;
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

.holiday-info-btn:hover {
    background: rgba(251, 113, 133, 0.2);
    border-color: var(--red);
}

/* ===================================================
   [휴강일 모달]
   =================================================== */
.modal-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.8);
    z-index: 3000;
    backdrop-filter: blur(5px);
    align-items: center;
    justify-content: center;
}

.modal-overlay.active {
    display: flex;
}

.modal-content {
    background: var(--side);
    border-radius: 20px;
    padding: 25px;
    max-width: 400px;
    width: 90%;
    border: 2px solid var(--red);
    box-shadow: 0 25px 50px rgba(0, 0, 0, 0.5);
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.modal-title {
    font-size: 1.1rem;
    font-weight: 800;
    color: var(--red);
}

.modal-close {
    background: none;
    border: none;
    color: #94a3b8;
    font-size: 1.5rem;
    cursor: pointer;
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
    transition: all 0.3s ease;
}

.modal-close:hover {
    background: rgba(255, 255, 255, 0.1);
    color: var(--txt);
}

.holiday-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.holiday-item {
    background: rgba(0, 0, 0, 0.3);
    padding: 12px;
    border-radius: 10px;
    border-left: 3px solid var(--red);
}

.holiday-date {
    font-weight: 800;
    color: var(--blue);
    font-size: 0.9rem;
    margin-bottom: 5px;
}

.holiday-reason {
    color: #94a3b8;
    font-size: 0.8rem;
}

/* ===================================================
   [개강/수료일 표시]
   =================================================== */
.date-info {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 8px;
    padding-top: 8px;
    border-top: 1px solid rgba(255, 255, 255, 0.05);
    font-size: 0.65rem;
}

.date-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 8px;
    border-radius: 6px;
    font-weight: 700;
}

.date-badge.start {
    background: rgba(74, 222, 128, 0.1);
    color: var(--green);
    border: 1px solid rgba(74, 222, 128, 0.3);
}

.date-badge.end {
    background: rgba(56, 189, 248, 0.1);
    color: var(--blue);
    border: 1px solid rgba(56, 189, 248, 0.3);
}

/* ===================================================
   [반응형 - 모달/위젯 보완]
   =================================================== */
@media (max-width: 900px) {
    .progress-widget {
        padding: 12px;
    }

    .progress-percentage {
        font-size: 1.1rem;
    }

    .modal-content {
        max-width: 350px;
        padding: 20px;
    }
}
