/**
 * rhwp 편집기 페이지 스타일
 */

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Noto Sans KR', sans-serif;
    background: #e8eaed;
    height: 100vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

/* 헤더 */
header {
    background: linear-gradient(135deg, #1b5e20 0%, #388e3c 100%);
    color: white;
    padding: 0.75rem 2rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
    flex-shrink: 0;
}

header h1 {
    font-size: 1.3rem;
    font-weight: 600;
}

.header-controls {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

#file-input {
    display: none;
}

.header-link, .header-btn {
    background: rgba(255, 255, 255, 0.2);
    padding: 0.4rem 0.8rem;
    border-radius: 4px;
    cursor: pointer;
    transition: background 0.2s;
    color: white;
    text-decoration: none;
    font-size: 0.85rem;
}

.header-link:hover, .header-btn:hover {
    background: rgba(255, 255, 255, 0.3);
}

/* 툴바 */
#toolbar {
    display: flex;
    align-items: center;
    padding: 0 0.75rem;
    height: 40px;
    background: #fff;
    border-bottom: 1px solid #ddd;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
    flex-shrink: 0;
}

#toolbar.hidden {
    display: none;
}

.toolbar-group {
    display: flex;
    align-items: center;
    gap: 0.3rem;
    padding: 0 0.75rem;
    height: 100%;
}

.toolbar-group + .toolbar-group {
    border-left: 1px solid #ddd;
}

.toolbar-btn {
    padding: 0.2rem 0.5rem;
    background: transparent;
    color: #555;
    border: 1px solid transparent;
    border-radius: 3px;
    cursor: pointer;
    font-size: 0.8rem;
    min-width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.15s, border-color 0.15s;
}

.toolbar-btn:hover:not(:disabled) {
    background: #f0f0f0;
    border-color: #ccc;
}

.toolbar-btn:disabled {
    color: #ccc;
    cursor: not-allowed;
    background: transparent;
}

#page-info, #zoom-level {
    font-size: 0.8rem;
    font-weight: 500;
    color: #333;
    min-width: 50px;
    text-align: center;
    user-select: none;
}

.toolbar-input {
    padding: 0.2rem 0.5rem;
    border: 1px solid #ddd;
    border-radius: 3px;
    font-size: 0.8rem;
    width: 160px;
    height: 28px;
    outline: none;
    transition: border-color 0.2s;
}

.toolbar-input:focus {
    border-color: #388e3c;
}

#search-info {
    font-size: 0.75rem;
    color: #666;
    min-width: 45px;
    text-align: center;
}

#search-info.hidden {
    display: none;
}

#search-clear-btn.hidden {
    display: none;
}

/* 파일정보 팝업 */
.toolbar-dropdown-wrapper {
    position: relative;
}

.toolbar-popup {
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    background: #fff;
    border: 1px solid #ddd;
    border-radius: 6px;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.15);
    padding: 0.75rem 1rem;
    min-width: 280px;
    z-index: 100;
    font-size: 0.85rem;
}

.toolbar-popup.hidden {
    display: none;
}

.toolbar-popup .info-grid {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
}

.toolbar-popup .info-item {
    display: flex;
    gap: 0.5rem;
}

.toolbar-popup .info-item .label {
    color: #666;
    font-weight: 500;
    min-width: 50px;
}

.toolbar-popup .info-item .value {
    color: #333;
}

/* 서식 툴바 */
#format-toolbar {
    display: flex;
    align-items: center;
    padding: 0 0.5rem;
    height: 36px;
    background: #fafafa;
    border-bottom: 1px solid #ddd;
    flex-shrink: 0;
    gap: 0;
    overflow-x: auto;
}

#format-toolbar.hidden {
    display: none;
}

.fmt-group {
    display: flex;
    align-items: center;
    gap: 2px;
    padding: 0 6px;
    height: 100%;
}

.fmt-group + .fmt-group {
    border-left: 1px solid #ddd;
}

.fmt-btn {
    padding: 2px 5px;
    background: transparent;
    color: #444;
    border: 1px solid transparent;
    border-radius: 3px;
    cursor: pointer;
    font-size: 13px;
    min-width: 26px;
    height: 26px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.1s, border-color 0.1s;
    font-family: inherit;
}

.fmt-btn:hover {
    background: #e8e8e8;
    border-color: #ccc;
}

.fmt-btn.fmt-toggle.active {
    background: #d0e8d0;
    border-color: #4caf50;
    color: #1b5e20;
}

.fmt-select {
    height: 26px;
    border: 1px solid #ccc;
    border-radius: 3px;
    font-size: 12px;
    padding: 0 4px;
    background: #fff;
    color: #333;
    outline: none;
    cursor: pointer;
}

.fmt-select:focus {
    border-color: #4caf50;
}

.fmt-font-select {
    width: 120px;
}

.fmt-spacing-select {
    width: 65px;
}

.fmt-size-input {
    width: 40px;
    height: 26px;
    border: 1px solid #ccc;
    border-radius: 3px;
    text-align: center;
    font-size: 12px;
    padding: 0 2px;
    outline: none;
}

.fmt-size-input:focus {
    border-color: #4caf50;
}

.fmt-size-btn {
    min-width: 22px;
    font-size: 14px;
    font-weight: bold;
}

/* 색상 버튼 */
.fmt-color-wrapper {
    position: relative;
    display: inline-flex;
}

.fmt-color-label {
    font-weight: bold;
    font-size: 14px;
    line-height: 1;
}

.fmt-shade-icon {
    font-size: 12px;
}

.fmt-color-bar {
    position: absolute;
    bottom: 1px;
    left: 3px;
    right: 3px;
    height: 3px;
    border-radius: 1px;
}

.fmt-color-picker {
    position: absolute;
    bottom: -2px;
    left: 0;
    width: 100%;
    height: 1px;
    opacity: 0;
    cursor: pointer;
}

/* 메인 컨텐츠 */
main {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 0;
    overflow: hidden;
}

.placeholder {
    color: #999;
    font-style: italic;
}

.error {
    color: #d32f2f;
    padding: 1rem;
}

/* 편집 영역 */
#editor-area {
    flex: 1;
    display: flex;
    justify-content: center;
    align-items: flex-start;
    padding: 1rem;
    overflow: auto;
    background: #d5d8dc;
    min-height: 0;
}

#editor-area.loaded #editor-placeholder {
    display: none;
}

/* 줌 스케일러 */
#canvas-scaler {
    display: inline-block;
}

#canvas-wrapper {
    position: relative;
    display: inline-block;
    transform-origin: 0 0;
}

#hwp-canvas {
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.2);
    background: #fff;
    display: block;
}

#hwp-canvas.hidden {
    display: none;
}

#selection-canvas {
    position: absolute;
    top: 0;
    left: 0;
    pointer-events: none;
}

#selection-canvas.hidden {
    display: none;
}

/* 푸터 */
footer {
    background: #333;
    color: #999;
    padding: 0.5rem;
    text-align: center;
    font-size: 0.8rem;
    flex-shrink: 0;
}

footer span {
    color: #ccc;
}

/* 로딩 오버레이 */
#loading {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    gap: 1rem;
    color: white;
    z-index: 1000;
}

#loading.hidden {
    display: none;
}

#table-context-menu.hidden {
    display: none;
}

.spinner {
    width: 48px;
    height: 48px;
    border: 4px solid rgba(255, 255, 255, 0.3);
    border-top-color: white;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* 반응형 */
@media (max-width: 600px) {
    header {
        flex-direction: column;
        gap: 0.75rem;
        text-align: center;
    }

    #toolbar {
        flex-wrap: wrap;
        height: auto;
        padding: 0.25rem 0.5rem;
    }

    .toolbar-group {
        padding: 0.25rem 0.5rem;
    }
}

/* ===== 글자 모양 대화상자 ===== */
.dialog-overlay {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.3);
    z-index: 2000;
    display: flex;
    align-items: center;
    justify-content: center;
}
.dialog-overlay.hidden { display: none; }

.dialog-wrap {
    position: absolute;
    width: 500px;
    background: #fafafa;
    border: 1px solid #748bc9;
    border-radius: 4px;
    box-shadow: 0 8px 32px rgba(0,0,0,0.25);
    font-size: 13px;
    color: #333;
}

.dialog-title {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: #e7eaf4;
    padding: 8px 12px;
    font-weight: bold;
    font-size: 13px;
    cursor: move;
    border-bottom: 1px solid #c5c5c5;
    border-radius: 4px 4px 0 0;
    user-select: none;
}

.dialog-close {
    background: none;
    border: none;
    font-size: 16px;
    cursor: pointer;
    color: #666;
    padding: 0 4px;
    line-height: 1;
}
.dialog-close:hover { color: #333; }

.dialog-tab-group {
    display: flex;
    padding: 0 12px;
    margin-top: 8px;
    border-bottom: 1px solid #c5c5c5;
    gap: 0;
}

.dialog-tab {
    padding: 6px 14px;
    border: none;
    background: none;
    cursor: pointer;
    font-size: 13px;
    color: #666;
    border-bottom: 2px solid transparent;
    margin-bottom: -1px;
}
.dialog-tab:hover { color: #335095; }
.dialog-tab.on {
    color: #335095;
    font-weight: bold;
    border-bottom-color: #6182d6;
}

.dialog-body {
    padding: 12px;
}

.dialog-tab-panel { display: none; }
.dialog-tab-panel.active { display: block; }

.dialog-section {
    border: 1px solid #d8d8d8;
    border-radius: 3px;
    padding: 10px;
    margin-bottom: 10px;
    background: #fff;
}

.dialog-section-title {
    font-weight: bold;
    font-size: 12px;
    color: #335095;
    margin-bottom: 8px;
}

.dialog-row {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 6px;
}
.dialog-row:last-child { margin-bottom: 0; }

.dialog-label {
    font-size: 12px;
    color: #555;
    min-width: 55px;
    text-align: right;
    flex-shrink: 0;
}

.dialog-input {
    width: 70px;
    height: 24px;
    border: 1px solid #c5c5c5;
    border-radius: 2px;
    padding: 0 6px;
    font-size: 12px;
    text-align: right;
}
.dialog-input:focus { outline: 1px solid #6182d6; border-color: #6182d6; }

.dialog-select {
    height: 24px;
    border: 1px solid #c5c5c5;
    border-radius: 2px;
    padding: 0 4px;
    font-size: 12px;
    background: #fff;
}
.dialog-select:focus { outline: 1px solid #6182d6; border-color: #6182d6; }

.dialog-color-btn {
    width: 28px;
    height: 24px;
    border: 1px solid #c5c5c5;
    border-radius: 2px;
    cursor: pointer;
    padding: 0;
}
.dialog-color-btn:hover { border-color: #6182d6; }

.dialog-icon-btn {
    width: 28px;
    height: 28px;
    border: 1px solid transparent;
    background: none;
    cursor: pointer;
    font-size: 14px;
    font-weight: bold;
    border-radius: 3px;
    color: #555;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}
.dialog-icon-btn:hover { background: #e9eefb; border-color: #c5c5c5; }
.dialog-icon-btn.active { background: #c0cdec; border-color: #90a5dc; color: #335095; }

.dialog-lang-tabs {
    display: flex;
    gap: 0;
    margin-bottom: 8px;
    border-bottom: 1px solid #ddd;
}
.dialog-lang-tab {
    padding: 3px 8px;
    border: none;
    background: none;
    cursor: pointer;
    font-size: 11px;
    color: #888;
    border-bottom: 2px solid transparent;
    margin-bottom: -1px;
}
.dialog-lang-tab:hover { color: #335095; }
.dialog-lang-tab.on {
    color: #335095;
    font-weight: bold;
    border-bottom-color: #6182d6;
}

.dialog-button-box {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    padding: 10px 12px;
    border-top: 1px solid #d8d8d8;
}

.dialog-btn {
    height: 28px;
    padding: 0 20px;
    border: 1px solid #c5c5c5;
    border-radius: 3px;
    background: #f5f5f5;
    font-size: 13px;
    cursor: pointer;
}
.dialog-btn:hover { background: #e9eefb; }
.dialog-btn-primary {
    background: #335095;
    color: #fff;
    border-color: #335095;
}
.dialog-btn-primary:hover { background: #3d5cb8; }

.dialog-unit {
    font-size: 11px;
    color: #888;
}

.dialog-font-select {
    flex: 1;
    min-width: 0;
}
