/**
 * NSKit Layout CSS v1.0
 *
 * Page, Dialog, Panel, Scene 레이아웃
 *
 * @version 1.0.0
 */

/* ============================================
   Main Stage
   ============================================ */

.main-stage {
    width: 100%;
    height: 100%;
    position: relative;
    overflow: hidden;
}

.content-area {
    width: 100%;
    height: 100%;
    position: relative;
    overflow: auto;
}

/* ============================================
   Page Area (#page-area)
   ============================================ */

#page-area {
    width: 100%;
    height: 100%;
    position: relative;
    overflow: auto;
    background-color: var(--nskit-page-bg);
}

/* ============================================
   Sub Page Area (Layout Page Container)
   ============================================ */

#sub-page-area {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: var(--nskit-z-page);
    pointer-events: none;
    overflow: hidden;
}

#sub-page-area-super {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: var(--nskit-z-page-super);
    pointer-events: none;
    overflow: hidden;
}

#sub-page-area.active,
#sub-page-area-super.active {
    pointer-events: auto;
}

/* area-dim (배경 어둡게) */
#sub-page-area .area-dim,
#sub-page-area-super .area-dim {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(0, 0, 0, 0.5);
    opacity: 0;
    transition: opacity var(--nskit-transition-base);
    pointer-events: none;
}

#sub-page-area .area-dim.show,
#sub-page-area-super .area-dim.show {
    opacity: 1;
}

/* sub-page-container (Layout Page) */
.sub-page-container {
    position: absolute;
    top: 0;
    left: 0;  /* leftOffset이 있으면 inline style로 override됨 */
    right: 0;
    bottom: 0;
    width: 100%;
    background-color: var(--nskit-page-bg);
    display: flex;
    flex-direction: column;
    box-shadow: -2px 0 8px rgba(0, 0, 0, 0.1);
    transform: translateX(100%);
    transition: transform var(--nskit-transition-base);
}

.sub-page-container.show {
    transform: translateX(0);
}

/* sub-page-header */
.sub-page-header {
    height: var(--nskit-page-header-height);
    background-color: var(--nskit-page-header-bg);
    border-bottom: 1px solid var(--nskit-border-color);
    display: flex;
    align-items: center;
    padding: 0 16px;
    flex-shrink: 0;
}

.page-header-default {
    display: flex;
    align-items: center;
    gap: 12px;
    flex: 1;
}

.page-header-default .ns-icon.page-back {
    cursor: pointer;
    font-size: 24px;
    color: var(--nskit-text-primary);
}

.page-header-default .page-title {
    font-size: 18px;
    font-weight: 600;
    color: var(--nskit-text-primary);
}

.page-header-buttons {
    display: flex;
    gap: 8px;
}

/* sub-page-content */
.sub-page-content {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 16px;
}

.sub-page-content.with-footer {
    padding-bottom: 0;
}

/* sub-page-footer */
.sub-page-footer {
    height: auto;
    min-height: 60px;
    background-color: var(--nskit-page-header-bg);
    border-top: 1px solid var(--nskit-border-color);
    padding: 12px 16px;
    display: flex;
    gap: 8px;
    align-items: center;
    flex-shrink: 0;
}

/* no-header */
.sub-page-container.no-header .sub-page-content {
    padding-top: 0;
}

/* ============================================
   Dialog Area
   ============================================ */

#dialog-area {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: var(--nskit-z-dialog);
    pointer-events: none;
    display: flex;
    align-items: center;
    justify-content: center;
}

#dialog-area-super {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: var(--nskit-z-dialog-super);
    pointer-events: none;
    display: flex;
    align-items: center;
    justify-content: center;
}

#dialog-area.active,
#dialog-area-super.active {
    pointer-events: auto;
}

#dialog-area .area-dim,
#dialog-area-super .area-dim {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(0, 0, 0, 0.5);
    opacity: 0;
    transition: opacity var(--nskit-transition-base);
}

#dialog-area .area-dim.show,
#dialog-area-super .area-dim.show {
    opacity: 1;
}

/* ============================================
   Dialog Container
   ============================================ */

.dialog-container {
    position: relative;
    background-color: white;
    border-radius: 12px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
    max-width: 90vw;
    max-height: 90vh;
    opacity: 0;
    transform: scale(0.9);
    transition: all 0.3s ease-out;
    overflow: hidden;
}

.dialog-container.show {
    opacity: 1;
    transform: scale(1);
}

/* Dialog Content */
.dialog-content {
    display: flex;
    flex-direction: column;
    max-height: 90vh;
}

/* Dialog Header */
.dialog-header {
    padding: 20px 24px;
    border-bottom: 1px solid var(--nskit-border-color);
    font-size: 18px;
    font-weight: 600;
    color: var(--nskit-text-primary);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.dialog-close {
    cursor: pointer;
    font-size: 24px;
    color: #999;
    transition: color 0.2s;
}

.dialog-close:hover {
    color: #333;
}

/* Dialog Body */
.dialog-body {
    padding: 24px;
    overflow-y: auto;
    flex: 1;
    color: var(--nskit-text-secondary);
    font-size: 15px;
    line-height: 1.6;
}

/* Dialog Footer */
.dialog-footer {
    padding: 16px 24px;
    border-top: 1px solid var(--nskit-border-color);
    display: flex;
    gap: 8px;
    justify-content: flex-end;
}

.dialog-footer button {
    padding: 10px 20px;
    border: none;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
}

.dialog-footer .btn-cancel {
    background-color: #f5f5f5;
    color: #666;
}

.dialog-footer .btn-cancel:hover {
    background-color: #e0e0e0;
}

.dialog-footer .btn-confirm {
    background-color: #007bff;
    color: white;
}

.dialog-footer .btn-confirm:hover {
    background-color: #0056b3;
}

/* Confirm/Alert Dialog (간단한 스타일) */
.dialog-container.confirm .dialog-content,
.dialog-container.alert .dialog-content {
    width: 400px;
}

.dialog-container.confirm .dialog-body,
.dialog-container.alert .dialog-body {
    text-align: center;
    padding: 30px 24px;
}

/* Custom Dialog (템플릿 기반) */
.dialog-container.custom .dialog-content {
    /* width/height는 inline style로 설정됨 */
}

/* ============================================
   Dialog Group Container (Multi Sequential)
   ============================================ */

.dialog-group-container {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    display: flex;
    z-index: 90011;
}

/* PC: 가로 나열 */
@media (min-width: 769px) {
    .dialog-group-container {
        flex-direction: row;
        justify-content: flex-start;
        align-items: center;
        overflow-x: auto;
        overflow-y: hidden;
        gap: 20px;
        padding: 0 20px;
    }

    .dialog-group-container::-webkit-scrollbar {
        display: none;
    }

    .dialog-group-container .dialog-container {
        flex: 0 0 auto;
        position: relative !important;
        transform: none !important;
        top: auto !important;
        left: auto !important;
    }
}

/* Mobile: 세로 쌓기 */
@media (max-width: 768px) {
    .dialog-group-container {
        flex-direction: column;
        justify-content: flex-start;
        align-items: center;
        overflow-x: hidden;
        overflow-y: auto;
        gap: 20px;
        padding: 20px 0;
        width: 90vw;
        max-height: 90vh;
    }

    .dialog-group-container .dialog-container {
        flex: 0 0 auto;
        position: relative !important;
        transform: none !important;
        margin: 0 !important;
    }
}

/* Note: dialog-area-super가 System Dialog로 사용됨 (z-index: 60000) */

/* ============================================
   Panel Area (Side Panel)
   ============================================ */

#side-panel-area {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: var(--nskit-z-panel);
    pointer-events: none;
    overflow: hidden;
}

#side-panel-area.active {
    pointer-events: auto;
}

/* nskit-dim */
#side-panel-area .nskit-dim {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(0, 0, 0, 0.5);
    opacity: 0;
    transition: opacity 0.3s;
    pointer-events: auto;
    display: none;
}

#side-panel-area.active .nskit-dim {
    display: block;
}

/* ============================================
   Side Panel Container
   ============================================ */

.side-panel-container {
    position: absolute;
    background-color: var(--nskit-page-bg);
    display: flex;
    flex-direction: column;
    box-shadow: 0 0 20px rgba(0, 0, 0, 0.3);
    transition: transform 0.3s ease-out;
    overflow: hidden;
}

/* Right Panel (주 사용) */
.side-panel-container.right {
    top: 0;
    right: 0;
    bottom: 0;
    /* width는 inline style로 직접 설정됨 (resize 대응) */
    transform: translateX(100%);
}

.side-panel-container.right.show {
    transform: translateX(0);
}

/* Left Panel */
.side-panel-container.left {
    top: 0;
    left: 0;
    bottom: 0;
    /* width는 inline style로 직접 설정됨 (resize 대응) */
    transform: translateX(-100%);
}

.side-panel-container.left.show {
    transform: translateX(0);
}

/* Bottom Panel */
.side-panel-container.bottom {
    left: 0;
    right: 0;
    bottom: 0;
    /* height는 inline style로 직접 설정됨 (resize 대응) */
    transform: translateY(100%);
}

.side-panel-container.bottom.show {
    transform: translateY(0);
}

/* ============================================
   Panel Content
   ============================================ */

.side-panel-content {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 20px;
}

/* Panel Header (내부 컨텐츠용) */
.panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    border-bottom: 1px solid var(--nskit-border-color);
    background-color: var(--nskit-page-header-bg);
    margin: -20px -20px 20px -20px;
    flex-shrink: 0;
}

.panel-title-box {
    display: flex;
    align-items: center;
    gap: 12px;
}

.panel-title-box .panel-back {
    cursor: pointer;
    font-size: 24px;
    color: var(--nskit-text-primary);
}

.panel-title {
    font-size: 18px;
    font-weight: 600;
    color: var(--nskit-text-primary);
}

.header-actions {
    display: flex;
    gap: 8px;
}

/* ============================================
   Panel Resizer
   ============================================ */

.panel-resizer {
    position: absolute;
    background-color: transparent;
    z-index: 10;
    display: flex;
    align-items: center;
    justify-content: center;
}

.panel-resizer-right {
    left: 0;
    top: 0;
    width: 24px;
    height: 100%;
    cursor: ew-resize;
}

.panel-resizer-left {
    right: 0;
    top: 0;
    width: 24px;
    height: 100%;
    cursor: ew-resize;
}

.panel-resizer-bottom {
    left: 0;
    top: 0;
    width: 100%;
    height: 24px;
    cursor: ns-resize;
}

.resizer-handle {
    position: absolute;
    background-color: rgba(200, 200, 200, 0.5);
    border-radius: 4px;
    transition: background-color 0.2s;
}

.panel-resizer-right .resizer-handle,
.panel-resizer-left .resizer-handle {
    width: 4px;
    height: 40px;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
}

.panel-resizer-bottom .resizer-handle {
    width: 40px;
    height: 4px;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
}

.panel-resizer:hover .resizer-handle {
    background-color: rgba(100, 100, 100, 0.7);
}

/* ============================================
   Scene Area (Mobile SPA)
   ============================================ */

.scene-area {
    width: 100%;
    height: 100%;
    position: relative;
    overflow: hidden;
}

.scene-container {
    width: 100%;
    height: 100%;
    position: absolute;
    top: 0;
    left: 0;
    overflow-y: auto;
    overflow-x: hidden;
    transition: opacity var(--nskit-transition-base);
}

.scene-container.hide {
    opacity: 0;
    pointer-events: none;
}

/* ============================================
   Scrollbar (Custom)
   ============================================ */

.ns-scrollbar::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

.ns-scrollbar::-webkit-scrollbar-track {
    background: transparent;
}

.ns-scrollbar::-webkit-scrollbar-thumb {
    background: rgba(0, 0, 0, 0.2);
    border-radius: 3px;
}

.ns-scrollbar::-webkit-scrollbar-thumb:hover {
    background: rgba(0, 0, 0, 0.3);
}

/* ============================================
   Responsive (Mobile)
   ============================================ */

@media (max-width: 768px) {
    body {
        font-size: 14px;
    }

    .sub-page-content {
        padding: 12px;
    }

    .sub-page-header {
        height: 48px;
        padding: 0 12px;
    }

    .page-header-default .page-title {
        font-size: 16px;
    }
}

/* ============================================
   Scene System (Transition Animation)
   ============================================ */

/* Scene Container 기본 */
[include] {
    transition: opacity 0.3s ease-in-out, transform 0.3s ease-in-out;
}

/* Hidden Scene */
[include].scene-hidden {
    opacity: 0;
    transform: translateX(-20px);
    pointer-events: none;
    position: absolute;
    visibility: hidden;
}

/* Visible Scene */
[include].scene-visible {
    opacity: 1;
    transform: translateX(0);
    position: relative;
    visibility: visible;
}

/* Fade-in Animation */
@keyframes sceneSlideIn {
    from {
        opacity: 0;
        transform: translateX(20px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

[include].scene-visible {
    animation: sceneSlideIn 0.3s ease-out;
}
