/* ¿¡µðÅÍ ½ºÅ¸ÀÏ */

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

.editor-wrapper {
    max-width: 900px;
    margin: 0 auto;
    padding: 20px;
    background: #f8f9fa;
    min-height: 100vh;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
}

/* Àü¿ª ¿¡µðÅÍ ½ºÅ¸ÀÏ */
.editor-main {
    font-family: -apple-system, BlinkMacSystemFont, "Apple SD Gothic Neo", "Pretendard", "Malgun Gothic", "¸¼Àº °íµñ", helvetica, "Apple Color Emoji", sans-serif;
}

/* Á¦¸ñ ÀÔ·Â */
.title-section input {
    font-family: -apple-system, BlinkMacSystemFont, "Apple SD Gothic Neo", "Pretendard", "Malgun Gothic", "¸¼Àº °íµñ", helvetica, "Apple Color Emoji", sans-serif;
}

/* ¿¡µðÅÍ ÄÁÅÙÃ÷ */
.editor-content {
    font-family: -apple-system, BlinkMacSystemFont, "Apple SD Gothic Neo", "Pretendard", "Malgun Gothic", "¸¼Àº °íµñ", helvetica, "Apple Color Emoji", sans-serif;
}

/* Çì´õ */
.editor-header {
    background: white;
    border-radius: 12px;
    padding: 24px;
    margin-bottom: 20px;
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    box-shadow: 0 1px 3px rgba(0,0,0,0.08);
}

.header-content h1 {
    font-size: 28px;
    font-weight: 700;
    color: #222;
    margin-bottom: 4px;
}

.header-content .subtitle {
    font-size: 14px;
    color: #666;
}

.header-actions {
    display: flex;
    gap: 12px;
}

/* Åä½ºÆ® */
.toast {
    position: fixed;
    bottom: 20px;
    right: 20px;
    padding: 16px 20px;
    border-radius: 8px;
    font-size: 14px;
    display: flex;
    align-items: center;
    gap: 12px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    z-index: 1000;
}

.toast-success {
    background: #10b981;
    color: white;
}

.toast-error {
    background: #ef4444;
    color: white;
}

.toast-info {
    background: #3b82f6;
    color: white;
}

.toast-close {
    background: none;
    border: none;
    color: inherit;
    font-size: 20px;
    cursor: pointer;
    opacity: 0.8;
}

.toast-close:hover {
    opacity: 1;
}

/* ¼½¼Ç */
.editor-section {
    background: white;
    border-radius: 12px;
    padding: 20px;
    margin-bottom: 16px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.08);
}

.title-section {
    padding: 0;
}

.title-input {
    width: 100%;
    padding: 20px;
    font-size: 20px;
    font-weight: 600;
    border: none;
    outline: none;
    color: #222;
    background: white;
    border-radius: 12px;
}

.title-input::placeholder {
    color: #999;
}

.title-info {
    padding: 0 20px 12px;
    text-align: right;
}

.char-count {
    font-size: 12px;
    color: #999;
}

/* ÅÂ±× */
.tags-section {
    padding: 16px 20px;
}

.tags-input-wrapper {
    display: flex;
    gap: 8px;
    margin-bottom: 12px;
}

.tags-input {
    flex: 1;
    padding: 10px 12px;
    border: 1px solid #ddd;
    border-radius: 6px;
    font-size: 14px;
    outline: none;
}

.tags-input:focus {
    border-color: #3b82f6;
    box-shadow: 0 0 0 2px rgba(59,130,246,0.1);
}

.btn-icon {
    padding: 10px 16px;
    background: #f3f4f6;
    border: 1px solid #ddd;
    border-radius: 6px;
    cursor: pointer;
    font-size: 13px;
    font-weight: 500;
}

.btn-icon:hover {
    background: #e5e7eb;
}

.tags-list {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.tag-chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 10px;
    background: #dbeafe;
    color: #1e40af;
    border-radius: 6px;
    font-size: 13px;
}

.tag-remove {
    background: none;
    border: none;
    color: inherit;
    cursor: pointer;
    font-size: 16px;
    padding: 0;
}

/* ¸ÞÀÎ ¿¡µðÅÍ */
.editor-main {
    background: white;
    border-radius: 12px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.08);
    overflow: hidden;
}

/* Åø¹Ù */
.editor-toolbar {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 4px;
    padding: 12px;
    background: #f9fafb;
    border-bottom: 1px solid #e5e7eb;
    min-height: 48px;
}

.toolbar-group {
    display: flex;
    align-items: center;
    gap: 4px;
}

.toolbar-btn {
    width: 36px;
    height: 36px;
    border: none;
    background: transparent;
    color: #666;
    cursor: pointer;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 500;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.toolbar-btn:hover:not(:disabled) {
    background: #e5e7eb;
    color: #222;
}

.toolbar-btn.active {
    background: #3b82f6;
    color: white;
}

.toolbar-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.toolbar-btn.highlight {
    color: #ef4444;
}

.toolbar-btn svg {
    width: 16px;
    height: 16px;
}

.toolbar-select {
    padding: 6px 10px;
    border: 1px solid #ddd;
    border-radius: 6px;
    background: white;
    font-size: 13px;
    cursor: pointer;
    outline: none;
}

.toolbar-select:focus {
    border-color: #3b82f6;
}

.color-picker-wrapper {
    position: relative;
    display: inline-block;
}

.color-picker-wrapper input[type="color"] {
    position: absolute;
    opacity: 0;
    width: 0;
    height: 0;
}

.color-picker-dropdown {
    position: absolute;
    top: 100%;
    left: 0;
    margin-top: 4px;
    background: white;
    border: 1px solid #ddd;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    padding: 8px;
    z-index: 1000;
    min-width: 200px;
}

.color-grid {
    display: grid;
    grid-template-columns: repeat(8, 1fr);
    gap: 4px;
}

.color-swatch {
    width: 24px;
    height: 24px;
    border-radius: 4px;
    border: 1px solid transparent;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
    padding: 0;
}

.color-swatch:hover {
    transform: scale(1.15);
    box-shadow: 0 2px 8px rgba(0,0,0,0.2);
    border-color: #3b82f6;
}

.toolbar-separator {
    width: 1px;
    height: 24px;
    background: #d1d5db;
    margin: 0 4px;
}

/* ÄÜÅÙÃ÷ ¿µ¿ª */
.editor-content-wrapper {
    display: flex;
    position: relative;
    min-height: 500px;
}

.editor-content-wrapper.show-preview {
    display: grid;
    grid-template-columns: 1fr 1fr;
}

.editor-pane {
    flex: 1;
    overflow: hidden;
}

.editor-content {
    min-height: 500px;
    padding: 20px;
    font-size: 15px;
    line-height: 1.6;
    color: #333;
    outline: none;
    word-break: break-word;
}

.editor-content:empty:before {
    content: attr(placeholder);
    color: #999;
}

/* ¹Ì¸®º¸±â */
.preview-pane {
    flex: 1;
    padding: 20px;
    background: #f9fafb;
    border-left: 1px solid #e5e7eb;
    overflow-y: auto;
}

.preview-content {
    font-size: 15px;
    line-height: 1.6;
    color: #333;
}

.preview-content img {
    max-width: 100%;
    height: auto;
    border-radius: 6px;
    margin: 12px 0;
}

/* YouTube ÀÓº£µå ·¡ÆÛ */
.youtube-wrapper {
    position: relative;
    margin: 16px 0;
    border-radius: 8px;
    background: #000;
    user-select: none;
}

.youtube-wrapper.selected {
    outline: 3px solid #3b82f6;
    outline-offset: 2px;
}

.youtube-embed {
    position: relative;
    padding-bottom: 56.25%;
    height: 0;
    overflow: hidden;
    border-radius: 8px;
}

.youtube-embed iframe {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    border: 0;
    border-radius: 8px;
    pointer-events: auto;
}

/* YouTube ÄÁÆ®·Ñ ¹öÆ° */
.youtube-controls {
    position: absolute;
    top: 8px;
    right: 8px;
    display: flex;
    gap: 4px;
    opacity: 0;
    transition: opacity 0.2s;
    z-index: 10;
    pointer-events: none;
}

.youtube-wrapper:hover .youtube-controls,
.youtube-wrapper.selected .youtube-controls {
    opacity: 1;
    pointer-events: auto;
}

.youtube-control-btn {
    width: 32px;
    height: 32px;
    background: rgba(0, 0, 0, 0.8);
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    font-weight: bold;
    line-height: 1;
    transition: background 0.2s;
}

.youtube-control-btn:hover {
    background: rgba(0, 0, 0, 0.95);
}

.youtube-control-btn.delete {
    background: rgba(239, 68, 68, 0.9);
}

.youtube-control-btn.delete:hover {
    background: rgba(239, 68, 68, 1);
}

/* Å©±â Á¶Á¤ ÇÚµé */
.youtube-resize-handle {
    position: absolute;
    bottom: 0;
    right: 0;
    width: 20px;
    height: 20px;
    background: #3b82f6;
    border-radius: 4px 0 8px 0;
    cursor: nwse-resize;
    opacity: 0;
    transition: opacity 0.2s;
    z-index: 10;
    pointer-events: none;
}

.youtube-wrapper.selected .youtube-resize-handle {
    opacity: 1;
    pointer-events: auto;
}

.youtube-resize-handle::before {
    content: '?';
    position: absolute;
    bottom: 2px;
    right: 2px;
    color: white;
    font-size: 10px;
}

.editor-content .youtube-wrapper {
    margin: 16px 0;
}

/* ÀÌ¹ÌÁö ·¡ÆÛ */
.image-wrapper {
    position: relative;
    display: inline-block;
    margin: 16px 0;
    max-width: 100%;
    user-select: none;
    -webkit-user-drag: none;
    -moz-user-drag: none;
    -ms-user-drag: none;
    user-drag: none;
}

.image-wrapper img {
    display: block;
    max-width: 100%;
    height: auto;
    border-radius: 6px;
    -webkit-user-drag: none;
    -moz-user-drag: none;
    -ms-user-drag: none;
    user-drag: none;
    pointer-events: none;
}

.image-wrapper.selected {
    outline: 3px solid #3b82f6;
    outline-offset: 2px;
}

/* ÀÌ¹ÌÁö ÄÁÆ®·Ñ ¹öÆ° */
.image-controls {
    position: absolute;
    top: 6px;
    right: 6px;
    display: flex;
    gap: 4px;
    opacity: 0;
    transition: opacity 0.2s;
    z-index: 10;
    pointer-events: none;
}

.image-wrapper.selected .image-controls {
    opacity: 1;
    pointer-events: auto;
}

.image-control-btn {
    width: 24px;
    height: 24px;
    background: rgba(0, 0, 0, 0.8);
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
    padding: 0;
}

.image-control-btn:hover {
    background: rgba(0, 0, 0, 0.95);
}

.image-control-btn.delete {
    background: rgba(239, 68, 68, 0.9);
    font-size: 0;
    position: relative;
}

.image-control-btn.delete::before,
.image-control-btn.delete::after {
    content: '';
    position: absolute;
    width: 12px;
    height: 2px;
    background-color: white;
    border-radius: 1px;
    top: 50%;
    left: 50%;
}

.image-control-btn.delete::before {
    transform: translate(-50%, -50%) rotate(45deg);
}

.image-control-btn.delete::after {
    transform: translate(-50%, -50%) rotate(-45deg);
}

.image-control-btn.delete:hover {
    background: rgba(239, 68, 68, 1);
}

/* ÀÌ¹ÌÁö Å©±â Á¶Á¤ ÇÚµé */
.image-resize-handle {
    position: absolute;
    bottom: -8px;
    right: -8px;
    width: 24px;
    height: 24px;
    background-color: white;
    border: 1px solid #e5e7eb;
    border-radius: 50%;
    cursor: nwse-resize;
    opacity: 0;
    transition: opacity 0.2s;
    z-index: 10;
    pointer-events: none;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    display: flex;
    align-items: center;
    justify-content: center;
}

.image-wrapper.selected .image-resize-handle {
    opacity: 1;
    pointer-events: auto;
}

.image-resize-handle::after {
    content: '';
    width: 14px;
    height: 14px;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 24 24' stroke='%236b7280' stroke-width='2'%3E%3Cpath stroke-linecap='round' stroke-linejoin='round' d='M4 20h16m0 0V4m0 16L4 4' /%3E%3C/svg%3E");
    background-size: contain;
    background-repeat: no-repeat;
}

.image-resize-handle::before {
    display: none;
}

.editor-content .image-wrapper {
    margin: 16px 0;
}

/* ÇÏ´Ü Á¤º¸ */
.editor-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 20px;
    background: #f9fafb;
    border-top: 1px solid #e5e7eb;
    font-size: 12px;
    color: #666;
}

.editor-stats {
    display: flex;
    gap: 16px;
}

.auto-save-status {
    display: flex;
    gap: 12px;
    align-items: center;
}

.status-active {
    color: #10b981;
    font-weight: 500;
}

.status-inactive {
    color: #ef4444;
}

.save-time {
    font-size: 11px;
    color: #999;
}

/* ¸ð´Þ */
.modal {
    position: fixed;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 999;
}

.modal-overlay {
    position: absolute;
    inset: 0;
    background: rgba(0,0,0,0.4);
}

.modal-content {
    position: relative;
    background: white;
    border-radius: 12px;
    box-shadow: 0 10px 40px rgba(0,0,0,0.2);
    width: 90%;
    max-width: 500px;
    max-height: 90vh;
    overflow: auto;
}

.modal-lg {
    max-width: 700px;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px;
    border-bottom: 1px solid #e5e7eb;
}

.modal-header h3 {
    font-size: 18px;
    font-weight: 600;
    color: #222;
}

.modal-close {
    background: none;
    border: none;
    font-size: 28px;
    color: #999;
    cursor: pointer;
}

.modal-close:hover {
    color: #222;
}

.modal-body {
    padding: 20px;
}

.modal-input {
    width: 100%;
    padding: 10px 12px;
    margin-bottom: 12px;
    border: 1px solid #ddd;
    border-radius: 6px;
    font-size: 14px;
    outline: none;
}

.modal-input:focus {
    border-color: #3b82f6;
    box-shadow: 0 0 0 2px rgba(59,130,246,0.1);
}

.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    padding: 20px;
    border-top: 1px solid #e5e7eb;
    background: #f9fafb;
}

/* ÀÌ¹ÌÁö ¾÷·Îµå */
.image-upload-area {
    border: 2px dashed #ddd;
    border-radius: 8px;
    padding: 40px 20px;
    text-align: center;
    cursor: pointer;
    transition: all 0.2s;
}

.image-upload-area:hover,
.image-upload-area.drag-active {
    border-color: #3b82f6;
    background: #eff6ff;
}

.image-upload-area svg {
    width: 48px;
    height: 48px;
    color: #3b82f6;
    margin: 0 auto 12px;
}

.upload-text {
    font-size: 14px;
    font-weight: 500;
    color: #222;
    margin: 0;
}

.upload-hint {
    font-size: 12px;
    color: #999;
    margin-top: 4px;
}

.upload-progress {
    margin-top: 16px;
}

.progress-bar {
    width: 100%;
    height: 4px;
    background: #e5e7eb;
    border-radius: 2px;
    overflow: hidden;
    margin-bottom: 8px;
}

.progress-fill {
    height: 100%;
    background: #3b82f6;
    transition: width 0.3s ease;
}

.progress-text {
    font-size: 12px;
    color: #666;
    text-align: center;
}

.image-preview {
    margin-top: 20px;
    text-align: center;
}

.image-preview img {
    max-width: 100%;
    max-height: 300px;
    border-radius: 8px;
    margin-bottom: 12px;
}

/* ¹öÆ° */
.btn {
    padding: 10px 20px;
    border: none;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    transition: all 0.2s;
}

.btn-primary {
    background: #3b82f6;
    color: white;
}

.btn-primary:hover:not(:disabled) {
    background: #2563eb;
}

.btn-primary:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.btn-secondary {
    background: #f3f4f6;
    color: #333;
    border: 1px solid #ddd;
}

.btn-secondary:hover {
    background: #e5e7eb;
}

.mt-3 {
    margin-top: 12px;
}

/* ¹ÝÀÀÇü */
@media (max-width: 768px) {
    .editor-wrapper {
        padding: 12px;
    }

    .editor-header {
        flex-direction: column;
        gap: 16px;
    }

    .editor-content-wrapper.show-preview {
        grid-template-columns: 1fr;
    }

    .preview-pane {
        display: none;
    }

    .modal-content {
        max-width: 95%;
    }
}
