/* ========================================
   블록 시스템 스타일
   ======================================== */

/* Row 블록 스타일 */
@import url('blocks/main/row.css');

/* === 블록 섹션 === */
.block-section
{
    position: relative;
}

/* 관리자 모드에서 섹션 영역 강조 */
body.edit-mode-active .block-section
{
    outline: 2px dashed rgba(16, 185, 129, 0.6);
    outline-offset: 4px;
    padding: 8px;
    margin: 8px 0;
    position: relative;
}

body.edit-mode-active .block-section::before
{
    content: attr(data-section);
    position: absolute;
    top: -10px;
    left: 10px;
    background: linear-gradient(135deg, #10b981 0%, #059669 100%);
    color: white;
    padding: 2px 10px;
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    z-index: 10;
    box-shadow: 0 2px 8px rgba(16, 185, 129, 0.3);
}

body.edit-mode-active .block-section:hover
{
    outline-color: rgba(16, 185, 129, 0.9);
    background: rgba(16, 185, 129, 0.05);
}

/* 관리자 모드에서 블록 아이템 강조 */
body.edit-mode-active .block-item
{
    outline: 1px dashed rgba(96, 165, 250, 0.6);
    outline-offset: 2px;
    margin: 6px 0;
    padding: 4px;
    transition: all 0.2s ease;
    position: relative;
}

body.edit-mode-active .block-item::after
{
    content: '';
    position: absolute;
    top: 2px;
    right: 2px;
    width: 8px;
    height: 8px;
    background: #667eea;
    border-radius: 50%;
    opacity: 0;
    transition: opacity 0.2s ease;
}

body.edit-mode-active .block-item:hover
{
    outline: 2px solid rgba(96, 165, 250, 0.9);
    background: rgba(96, 165, 250, 0.1);
}

body.edit-mode-active .block-item:hover::after
{
    opacity: 1;
}

/* === 네비게이션 블록 === */
.block-navigation
{
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap; /* Allow wrapping if items don't fit */
    max-width: 100%; /* Don't exceed parent container */
}

.block-navigation .nav-link
{
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
    color: var(--nav-text);
    text-decoration: none;
    font-size: 0.95rem;
    font-weight: 500;
    border-radius: 6px;
    transition: all 0.2s ease;
}

.block-navigation .nav-link:hover
{
    color: var(--nav-hover);
    background: rgba(0, 0, 0, 0.05);
}

[data-theme="dark"] .block-navigation .nav-link:hover
{
    background: rgba(255, 255, 255, 0.1);
}

.block-navigation .nav-link svg
{
    width: 18px;
    height: 18px;
}

/* === 로고 블록 === */
.block-logo
{
    font-size: 1.25rem;
    font-weight: 700;
}

.block-logo a
{
    color: var(--nav-text);
    text-decoration: none;
    transition: color 0.2s ease;
    display: flex;
    align-items: center;
}

.block-logo a:hover
{
    color: var(--nav-hover);
}

.block-logo img
{
    height: 40px;
    width: auto;
}

.block-logo .logo-text
{
    letter-spacing: -0.5px;
}

/* === 로그인 버튼 블록 === */
.login-button
{
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white !important;
    padding: 8px 20px !important;
    border-radius: 8px;
    font-weight: 600;
    box-shadow: 0 2px 8px rgba(102, 126, 234, 0.3);
    transition: all 0.3s ease;
}

.login-button:hover
{
    background: linear-gradient(135deg, #5568d3 0%, #6a3f8f 100%);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
}

/* ========================================
   블록 에디터 모달
   ======================================== */

#blockEditorBtn
{
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: linear-gradient(135deg, #10b981 0%, #059669 100%);
    border: none;
    color: white;
    box-shadow: 0 4px 12px rgba(16, 185, 129, 0.4);
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

#blockEditorBtn:hover
{
    transform: scale(1.1);
    box-shadow: 0 6px 20px rgba(16, 185, 129, 0.6);
}

#blockEditorBtn i
{
    width: 24px;
    height: 24px;
}

.block-editor-modal
{
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(4px);
    z-index: 10000;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.block-editor-modal.show
{
    opacity: 1;
}

.block-editor-container
{
    background: var(--card-bg);
    border: var(--card-border);
    border-radius: 16px;
    width: 90%;
    max-width: 800px;
    max-height: 80vh;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transform: scale(0.9);
    transition: transform 0.3s ease;
}

.block-editor-modal.show .block-editor-container
{
    transform: scale(1);
}

.block-editor-header
{
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 24px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.block-editor-header h2
{
    margin: 0;
    font-size: 1.5rem;
    color: var(--heading-color);
}

.block-editor-header .close-btn
{
    background: none;
    border: none;
    color: var(--text-color);
    cursor: pointer;
    padding: 8px;
    border-radius: 6px;
    transition: background 0.2s ease;
}

.block-editor-header .close-btn:hover
{
    background: rgba(255, 255, 255, 0.1);
}

.block-editor-header .close-btn i
{
    width: 24px;
    height: 24px;
}

/* 탭 */
.block-editor-tabs
{
    display: flex;
    gap: 8px;
    padding: 16px 24px;
    background: rgba(0, 0, 0, 0.1);
}

.block-editor-tabs .tab-btn
{
    padding: 8px 20px;
    border: none;
    background: transparent;
    color: var(--text-color);
    font-weight: 500;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.block-editor-tabs .tab-btn:hover
{
    background: rgba(255, 255, 255, 0.1);
}

.block-editor-tabs .tab-btn.active
{
    background: var(--nav-hover);
    color: white;
}

/* 바디 */
.block-editor-body
{
    flex: 1;
    overflow-y: auto;
    padding: 24px;
}

.block-list
{
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-bottom: 20px;
}

.empty-state
{
    text-align: center;
    padding: 40px;
    color: var(--text-color);
    opacity: 0.6;
}

/* 블록 아이템 (에디터 내) */
.block-item-editor
{
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 16px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 10px;
    cursor: move;
    transition: all 0.2s ease;
}

.block-item-editor:hover
{
    background: rgba(255, 255, 255, 0.08);
    border-color: rgba(255, 255, 255, 0.2);
}

.block-item-editor.dragging
{
    opacity: 0.5;
}

.block-drag-handle
{
    color: var(--text-color);
    opacity: 0.4;
    cursor: grab;
}

.block-drag-handle:active
{
    cursor: grabbing;
}

.block-drag-handle i
{
    width: 20px;
    height: 20px;
}

.block-info
{
    flex: 1;
}

.block-type
{
    font-weight: 600;
    color: var(--heading-color);
    margin-bottom: 4px;
}

.block-config
{
    font-size: 0.85rem;
    color: var(--text-color);
    opacity: 0.7;
}

.block-controls
{
    display: flex;
    gap: 8px;
}

.block-controls button
{
    padding: 8px;
    border: none;
    background: rgba(255, 255, 255, 0.1);
    color: var(--text-color);
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.block-controls button:hover
{
    background: rgba(255, 255, 255, 0.2);
}

.block-controls .edit-block-btn:hover
{
    background: #667eea;
    color: white;
}

.block-controls .delete-block-btn:hover
{
    background: #ef4444;
    color: white;
}

.block-controls button i
{
    width: 18px;
    height: 18px;
}

/* 액션 버튼 */
.block-actions
{
    display: flex;
    justify-content: center;
    padding-top: 20px;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.add-block-btn
{
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 24px;
    background: linear-gradient(135deg, #10b981 0%, #059669 100%);
    color: white;
    border: none;
    border-radius: 8px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 4px 12px rgba(16, 185, 129, 0.3);
}

.add-block-btn:hover
{
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(16, 185, 129, 0.4);
}

.add-block-btn i
{
    width: 20px;
    height: 20px;
}

/* ========================================
   블록 폼 오버레이
   ======================================== */

.block-form-overlay
{
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    backdrop-filter: blur(4px);
    z-index: 11000;
    display: flex;
    align-items: center;
    justify-content: center;
}

.block-form
{
    background: var(--card-bg);
    border: var(--card-border);
    border-radius: 16px;
    padding: 32px;
    width: 90%;
    max-width: 500px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.4);
}

.block-form h3
{
    margin: 0 0 24px 0;
    color: var(--heading-color);
    font-size: 1.5rem;
}

.form-group
{
    margin-bottom: 20px;
}

.form-group label
{
    display: block;
    margin-bottom: 8px;
    color: var(--text-color);
    font-weight: 500;
}

.form-group input,
.form-group select,
.form-group textarea
{
    width: 100%;
    padding: 12px;
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-color);
    font-family: 'Consolas', 'Monaco', 'Courier New', monospace;
    font-size: 14px;
    transition: border-color 0.2s ease;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus
{
    outline: none;
    border-color: var(--nav-hover);
    box-shadow: 0 0 0 3px rgba(96, 165, 250, 0.1);
}

.form-group select option
{
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-color);
}

.form-group input[readonly]
{
    background: rgba(0, 0, 0, 0.2);
    cursor: not-allowed;
}

.form-actions
{
    display: flex;
    gap: 12px;
    justify-content: flex-end;
    margin-top: 24px;
}

.btn-primary,
.btn-secondary
{
    padding: 10px 20px;
    border: none;
    border-radius: 8px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
}

.btn-primary
{
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.3);
}

.btn-primary:hover
{
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(102, 126, 234, 0.4);
}

.btn-secondary
{
    background: rgba(255, 255, 255, 0.1);
    color: var(--text-color);
}

.btn-secondary:hover
{
    background: rgba(255, 255, 255, 0.2);
}

/* ========================================
   동적 폼 스타일
   ======================================== */

/* 필수 필드 표시 */
.form-group .required
{
    color: #ef4444;
    margin-left: 2px;
}

/* 도움말 텍스트 */
.form-help
{
    display: block;
    margin-top: 6px;
    font-size: 0.85rem;
    color: var(--text-color);
    opacity: 0.7;
}

/* 체크박스 폼 그룹 */
.form-group-checkbox label
{
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
}

.form-group-checkbox input[type="checkbox"]
{
    width: auto;
    margin: 0;
    cursor: pointer;
}

/* 색상 피커 */
.color-picker-wrapper
{
    display: flex;
    gap: 12px;
    align-items: stretch;
}

.color-picker-wrapper input[type="color"]
{
    width: 70px;
    height: 48px;
    padding: 4px;
    border: 2px solid rgba(255, 255, 255, 0.2);
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.05);
    cursor: pointer;
    transition: all 0.2s ease;
}

.color-picker-wrapper input[type="color"]:hover
{
    border-color: var(--nav-hover);
    transform: scale(1.05);
}

.color-picker-wrapper input[type="color"]::-webkit-color-swatch-wrapper
{
    padding: 0;
}

.color-picker-wrapper input[type="color"]::-webkit-color-swatch
{
    border: none;
    border-radius: 5px;
}

.color-picker-wrapper input[type="color"]::-moz-color-swatch
{
    border: none;
    border-radius: 5px;
}

.color-picker-wrapper .color-text-input
{
    flex: 1;
    text-transform: uppercase;
    font-family: 'Consolas', 'Monaco', 'Courier New', monospace;
}

/* 이미지 업로드 */
.form-group-image .image-upload-wrapper
{
    display: flex;
    gap: 8px;
    align-items: stretch;
}

.form-group-image .image-url-input
{
    flex: 1;
}

.form-group-image .btn-upload-image
{
    padding: 0 16px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    border-radius: 8px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    gap: 6px;
    white-space: nowrap;
    box-shadow: 0 2px 8px rgba(102, 126, 234, 0.3);
}

.form-group-image .btn-upload-image:hover
{
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
}

.form-group-image .btn-upload-image i
{
    width: 18px;
    height: 18px;
}

.form-group-image .image-preview-container
{
    margin-top: 12px;
    min-height: 100px;
    border: 2px dashed rgba(255, 255, 255, 0.2);
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.2);
    overflow: hidden;
    transition: border-color 0.2s ease;
}

.form-group-image .image-preview-container:has(.image-preview)
{
    border-style: solid;
    border-color: rgba(16, 185, 129, 0.4);
    background: rgba(16, 185, 129, 0.05);
}

.form-group-image .image-preview
{
    max-width: 100%;
    max-height: 200px;
    display: block;
    object-fit: contain;
}

.form-group-image .image-preview-container:empty::before
{
    content: '이미지 미리보기';
    color: var(--text-color);
    opacity: 0.4;
    font-size: 0.9rem;
}

/* Repeater 필드 */
.form-group-repeater
{
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 10px;
    padding: 16px;
    background: rgba(0, 0, 0, 0.2);
}

.repeater-items
{
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-bottom: 16px;
}

.repeater-item
{
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 8px;
    overflow: hidden;
}

.repeater-item-header
{
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px;
    background: rgba(0, 0, 0, 0.2);
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.repeater-item-number
{
    font-weight: 600;
    color: var(--heading-color);
    font-size: 0.9rem;
}

.btn-remove-item
{
    padding: 6px 12px;
    background: rgba(239, 68, 68, 0.1);
    border: 1px solid rgba(239, 68, 68, 0.3);
    color: #ef4444;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    gap: 4px;
}

.btn-remove-item:hover
{
    background: #ef4444;
    border-color: #ef4444;
    color: white;
}

.btn-remove-item i
{
    width: 16px;
    height: 16px;
}

.repeater-item-body
{
    padding: 16px;
    display: grid;
    gap: 12px;
}

.repeater-field
{
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.repeater-field label
{
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--text-color);
}

.repeater-field input,
.repeater-field select,
.repeater-field textarea
{
    width: 100%;
    padding: 10px;
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 6px;
    background: rgba(255, 255, 255, 0.03);
    color: var(--text-color);
    font-size: 0.9rem;
    transition: border-color 0.2s ease;
}

.repeater-field input:focus,
.repeater-field select:focus,
.repeater-field textarea:focus
{
    outline: none;
    border-color: var(--nav-hover);
    box-shadow: 0 0 0 2px rgba(96, 165, 250, 0.1);
}

.repeater-field select option
{
    background: rgba(255, 255, 255, 0.03);
    color: var(--text-color);
}

.btn-add-item
{
    width: 100%;
    padding: 10px;
    background: rgba(16, 185, 129, 0.1);
    border: 1px dashed rgba(16, 185, 129, 0.4);
    color: #10b981;
    border-radius: 8px;
    cursor: pointer;
    font-weight: 500;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    transition: all 0.2s ease;
}

.btn-add-item:hover
{
    background: rgba(16, 185, 129, 0.2);
    border-color: rgba(16, 185, 129, 0.6);
    transform: translateY(-1px);
}

.btn-add-item i
{
    width: 18px;
    height: 18px;
}

/* 폼 스크롤 개선 */
.block-form
{
    max-height: 85vh;
    overflow-y: auto;
}

#blockFormFields
{
    max-height: 50vh;
    overflow-y: auto;
    padding-right: 8px;
}

/* 스크롤바 스타일 */
#blockFormFields::-webkit-scrollbar
{
    width: 8px;
}

#blockFormFields::-webkit-scrollbar-track
{
    background: rgba(0, 0, 0, 0.1);
    border-radius: 4px;
}

#blockFormFields::-webkit-scrollbar-thumb
{
    background: rgba(255, 255, 255, 0.2);
    border-radius: 4px;
}

#blockFormFields::-webkit-scrollbar-thumb:hover
{
    background: rgba(255, 255, 255, 0.3);
}

/* ========================================
   반응형
   ======================================== */

@media (max-width: 768px)
{
    .block-editor-container
    {
        width: 95%;
        max-height: 90vh;
    }

    .block-editor-header
    {
        padding: 16px;
    }

    .block-editor-tabs
    {
        padding: 12px 16px;
    }

    .block-editor-body
    {
        padding: 16px;
    }

    .block-form
    {
        padding: 24px;
        max-width: 95%;
    }

    .block-navigation
    {
        flex-wrap: wrap;
    }

    .repeater-item-body
    {
        grid-template-columns: 1fr;
    }
}
