/**
 * NOTED 전체 공용 테마 CSS
 * 다크/라이트 모드 지원
 * /assets/css/theme.css
 */

/* ============================================
   CSS 변수 - 공통
   ============================================ */
:root {
    --radius-sm: 4px;
    --radius: 8px;
    --radius-lg: 16px;
    --radius-xl: 24px;
    --transition: 0.2s ease;
    
    /* 공통 컬러 */
    --primary: #6366f1;
    --primary-hover: #4f46e5;
    --accent-1: #6366f1;
    --accent-2: #f59e0b;
    --accent-3: #10b981;
    --success: #22c55e;
    --warning: #f59e0b;
    --danger: #ef4444;
    
    /* 그라데이션 */
    --gradient-primary: linear-gradient(135deg, #6366f1 0%, #a855f7 100%);
    --gradient-accent-2: linear-gradient(135deg, #f59e0b 0%, #f97316 100%);
    --gradient-accent-3: linear-gradient(135deg, #10b981 0%, #14b8a6 100%);
}

/* ============================================
   다크 테마 (기본)
   ============================================ */
[data-theme="dark"] {
    --bg-primary: #0a0a0b;
    --bg-secondary: #111113;
    --bg-tertiary: #1a1a1d;
    --bg-hover: #222225;
    --bg-card: #111113;
    
    --text-primary: #ffffff;
    --text-secondary: #a0a4ab;
    --text-muted: #6c7078;
    
    --border-color: rgba(255, 255, 255, 0.08);
    --border-light: rgba(255, 255, 255, 0.12);
    
    --shadow-sm: 0 1px 2px rgba(0,0,0,0.3);
    --shadow: 0 4px 12px rgba(0,0,0,0.4);
    --shadow-lg: 0 8px 24px rgba(0,0,0,0.5);
    --shadow-glow: 0 0 60px -15px;
    
    /* 에디터 */
    --editor-bg: #111113;
    --editor-border: rgba(255, 255, 255, 0.08);
    --editor-toolbar-bg: #0a0a0b;
    
    /* 배경 효과 */
    --bg-gradient-1: rgba(99, 102, 241, 0.08);
    --bg-gradient-2: rgba(245, 158, 11, 0.06);
    --bg-gradient-3: rgba(16, 185, 129, 0.04);
}

/* ============================================
   라이트 테마
   ============================================ */
[data-theme="light"] {
    --bg-primary: #fafafa;
    --bg-secondary: #ffffff;
    --bg-tertiary: #f4f4f5;
    --bg-hover: #e4e4e7;
    --bg-card: #ffffff;
    
    --text-primary: #18181b;
    --text-secondary: #52525b;
    --text-muted: #a1a1aa;
    
    --border-color: #e4e4e7;
    --border-light: #d4d4d8;
    
    --shadow-sm: 0 1px 2px rgba(0,0,0,0.04);
    --shadow: 0 2px 8px rgba(0,0,0,0.06);
    --shadow-lg: 0 4px 16px rgba(0,0,0,0.08);
    --shadow-glow: 0 0 40px -15px;
    
    /* 에디터 */
    --editor-bg: #ffffff;
    --editor-border: #e4e4e7;
    --editor-toolbar-bg: #fafafa;
    
    /* 배경 효과 */
    --bg-gradient-1: rgba(99, 102, 241, 0.05);
    --bg-gradient-2: rgba(245, 158, 11, 0.04);
    --bg-gradient-3: rgba(16, 185, 129, 0.03);
}

/* ============================================
   기본 리셋 & 타이포그래피
   ============================================ */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
}

body {
    font-family: 'Noto Sans KR', -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
    transition: background 0.3s ease, color 0.3s ease;
}

a {
    color: inherit;
    text-decoration: none;
}

/* ============================================
   버튼
   ============================================ */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.875rem 1.75rem;
    font-size: 0.9375rem;
    font-weight: 600;
    border: none;
    border-radius: var(--radius);
    cursor: pointer;
    transition: all 0.3s ease;
    text-decoration: none;
    font-family: inherit;
}

.btn-primary {
    background: var(--gradient-primary);
    color: #fff;
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-glow) rgba(99, 102, 241, 0.5);
}

.btn-secondary {
    background: var(--bg-tertiary);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
}

.btn-secondary:hover {
    background: var(--bg-hover);
    border-color: var(--border-light);
}

.btn-ghost {
    background: transparent;
    color: var(--text-secondary);
}

.btn-ghost:hover {
    color: var(--text-primary);
    background: var(--bg-tertiary);
}

.btn-outline {
    background: transparent;
    border: 1px solid var(--border-color);
    color: var(--text-primary);
}

.btn-outline:hover {
    background: var(--bg-secondary);
    border-color: var(--accent-1);
}

.btn-success { background: var(--success); color: white; }
.btn-danger { background: var(--danger); color: white; }
.btn-lg { padding: 1rem 2rem; font-size: 1rem; }
.btn-sm { padding: 0.5rem 1rem; font-size: 0.875rem; }
.btn-block { width: 100%; }

.btn-group {
    display: flex;
    gap: 0.75rem;
    flex-wrap: wrap;
}

/* ============================================
   카드
   ============================================ */
.card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    margin-bottom: 1.5rem;
    box-shadow: var(--shadow-sm);
    transition: background 0.3s ease, border 0.3s ease;
}

.card-header {
    padding: 1rem 1.5rem;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.card-title {
    font-size: 1rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.card-body {
    padding: 1.5rem;
}

/* ============================================
   폼 요소
   ============================================ */
.form-group {
    margin-bottom: 1.25rem;
}

.form-label {
    display: block;
    margin-bottom: 0.5rem;
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text-secondary);
}

.form-control {
    width: 100%;
    padding: 0.875rem 1rem;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    color: var(--text-primary);
    font-size: 0.9375rem;
    font-family: inherit;
    transition: all 0.2s ease;
}

.form-control:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.15);
}

.form-control::placeholder {
    color: var(--text-muted);
}

textarea.form-control {
    min-height: 120px;
    resize: vertical;
}

/* ============================================
   알림 (Alert)
   ============================================ */
.alert {
    padding: 0.875rem 1rem;
    border-radius: var(--radius);
    margin-bottom: 1.25rem;
    font-size: 0.9375rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.alert-danger {
    background: rgba(239, 68, 68, 0.1);
    border: 1px solid rgba(239, 68, 68, 0.3);
    color: var(--danger);
}

.alert-success {
    background: rgba(34, 197, 94, 0.1);
    border: 1px solid rgba(34, 197, 94, 0.3);
    color: var(--success);
}

.alert-warning {
    background: rgba(245, 158, 11, 0.1);
    border: 1px solid rgba(245, 158, 11, 0.3);
    color: var(--warning);
}

/* ============================================
   그리드
   ============================================ */
.grid {
    display: grid;
    gap: 1.5rem;
}

.grid-2 { grid-template-columns: repeat(2, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-4 { grid-template-columns: repeat(4, 1fr); }

@media (max-width: 1024px) {
    .grid-4 { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 768px) {
    .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; }
}

/* ============================================
   테마 토글 버튼
   ============================================ */
.theme-btn {
    width: 40px;
    height: 40px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    color: var(--text-secondary);
    font-size: 1rem;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.theme-btn:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
    border-color: var(--border-light);
}

/* ============================================
   로고
   ============================================ */
.logo-noted {
    background: var(--gradient-primary);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

/* ============================================
   Quill 에디터
   ============================================ */
.editor-wrapper {
    border: 1px solid var(--editor-border);
    border-radius: var(--radius);
    overflow: hidden;
    background: var(--editor-bg);
}

.ql-toolbar.ql-snow {
    background: var(--editor-toolbar-bg);
    border: none;
    border-bottom: 1px solid var(--editor-border);
    padding: 0.75rem;
}

.ql-container.ql-snow {
    border: none;
    font-family: 'Noto Sans KR', sans-serif;
    font-size: 1rem;
}

.ql-editor {
    min-height: 300px;
    padding: 1rem 1.25rem;
    color: var(--text-primary);
    line-height: 1.8;
}

.ql-editor.ql-blank::before {
    color: var(--text-muted);
    font-style: normal;
}

.ql-snow .ql-stroke { stroke: var(--text-secondary); }
.ql-snow .ql-fill { fill: var(--text-secondary); }
.ql-snow .ql-picker { color: var(--text-secondary); }

.ql-snow .ql-picker-options {
    background: var(--bg-secondary);
    border-color: var(--border-color);
    border-radius: var(--radius);
}

.ql-toolbar.ql-snow .ql-formats button:hover,
.ql-toolbar.ql-snow .ql-formats button.ql-active { color: var(--primary); }

.ql-toolbar.ql-snow .ql-formats button:hover .ql-stroke,
.ql-toolbar.ql-snow .ql-formats button.ql-active .ql-stroke { stroke: var(--primary); }

.ql-toolbar.ql-snow .ql-formats button:hover .ql-fill,
.ql-toolbar.ql-snow .ql-formats button.ql-active .ql-fill { fill: var(--primary); }

.ql-editor img {
    max-width: 100%;
    height: auto;
    border-radius: var(--radius);
    margin: 0.5rem 0;
}

/* ============================================
   첨부파일
   ============================================ */
.attachment-section {
    margin-top: 1rem;
    padding: 1rem;
    background: var(--bg-tertiary);
    border-radius: var(--radius);
    border: 2px dashed var(--border-color);
    transition: all 0.2s ease;
}

.attachment-section:hover { border-color: var(--primary); }
.attachment-section.dragover {
    border-color: var(--primary);
    background: rgba(99, 102, 241, 0.1);
}

.attachment-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 0.75rem;
}

.attachment-title {
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.attachment-buttons { display: flex; gap: 0.5rem; }

.attach-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.5rem 0.75rem;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    color: var(--text-secondary);
    font-size: 0.85rem;
    cursor: pointer;
    transition: all 0.2s ease;
}

.attach-btn:hover {
    border-color: var(--primary);
    color: var(--primary);
}

.attach-btn input[type="file"] { display: none; }

.attachment-drop-text {
    text-align: center;
    padding: 1rem;
    color: var(--text-muted);
    font-size: 0.9rem;
}

.attachment-drop-text i {
    font-size: 2rem;
    display: block;
    margin-bottom: 0.5rem;
    color: var(--text-secondary);
}

.attachment-list { display: flex; flex-direction: column; gap: 0.5rem; }

.attachment-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
}

.attachment-icon {
    width: 40px;
    height: 40px;
    border-radius: var(--radius);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.1rem;
}

.attachment-icon.image { background: rgba(99, 102, 241, 0.1); color: var(--accent-1); }
.attachment-icon.document { background: rgba(34, 197, 94, 0.1); color: var(--success); }
.attachment-icon.pdf { background: rgba(239, 68, 68, 0.1); color: var(--danger); }
.attachment-icon.other { background: rgba(245, 158, 11, 0.1); color: var(--warning); }

.attachment-info { flex: 1; min-width: 0; }

.attachment-name {
    font-size: 0.9rem;
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.attachment-size { font-size: 0.8rem; color: var(--text-muted); }

.attachment-preview {
    width: 50px;
    height: 50px;
    border-radius: var(--radius-sm);
    object-fit: cover;
    cursor: pointer;
}

.attachment-remove {
    width: 32px;
    height: 32px;
    border: none;
    background: transparent;
    color: var(--text-muted);
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.attachment-remove:hover {
    background: rgba(239, 68, 68, 0.1);
    color: var(--danger);
}

/* ============================================
   이미지 미리보기 모달
   ============================================ */
.image-preview-modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.9);
    z-index: 1000;
    align-items: center;
    justify-content: center;
    padding: 2rem;
}

.image-preview-modal.show { display: flex; }

.image-preview-modal img {
    max-width: 100%;
    max-height: 90vh;
    border-radius: var(--radius);
}

.image-preview-close {
    position: absolute;
    top: 1rem;
    right: 1rem;
    width: 50px;
    height: 50px;
    background: rgba(255, 255, 255, 0.1);
    border: none;
    border-radius: 50%;
    color: white;
    font-size: 1.5rem;
    cursor: pointer;
    transition: background 0.2s;
}

.image-preview-close:hover { background: rgba(255, 255, 255, 0.2); }

/* ============================================
   유틸리티
   ============================================ */
.text-center { text-align: center; }
.text-primary { color: var(--text-primary); }
.text-secondary { color: var(--text-secondary); }
.text-muted { color: var(--text-muted); }

.mb-0 { margin-bottom: 0; }
.mb-1 { margin-bottom: 0.5rem; }
.mb-2 { margin-bottom: 1rem; }
.mb-3 { margin-bottom: 1.5rem; }
.mb-4 { margin-bottom: 2rem; }

.mt-0 { margin-top: 0; }
.mt-1 { margin-top: 0.5rem; }
.mt-2 { margin-top: 1rem; }
.mt-3 { margin-top: 1.5rem; }
.mt-4 { margin-top: 2rem; }

/* ============================================
   반응형
   ============================================ */
@media (max-width: 768px) {
    .attachment-header {
        flex-direction: column;
        gap: 0.75rem;
        align-items: flex-start;
    }
    
    .attachment-buttons { width: 100%; }
    .attach-btn { flex: 1; justify-content: center; }
    
    .btn-group { flex-direction: column; }
    .btn-group .btn { width: 100%; }
    
    .card-body { padding: 1rem; }
    .ql-editor { min-height: 200px; }
}
