/* ─── Reset & Base ─────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
body { font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif; background: #f8f9fa; color: #1a1a2e; line-height: 1.5; }
a { color: #4361ee; text-decoration: none; }
a:hover { text-decoration: underline; }

/* ─── Layout ──────────────────────────────────────── */
.layout { display: flex; min-height: 100vh; }

/* ─── Sidebar ─────────────────────────────────────── */
.sidebar { width: 220px; background: #1a1a2e; color: #e0e0e0; padding: 0; flex-shrink: 0; position: fixed; top: 0; bottom: 0; overflow-y: auto; z-index: 50; }
.sidebar-brand { padding: 20px 16px; border-bottom: 1px solid rgba(255,255,255,0.08); }
.sidebar-brand h1 { font-size: 16px; font-weight: 700; color: #fff; }
.sidebar-brand p { font-size: 11px; color: #8888aa; margin-top: 2px; }

.sidebar-nav { padding: 12px 0; }
.nav-group { margin-bottom: 8px; }
.nav-group-label { padding: 8px 16px 4px; font-size: 10px; text-transform: uppercase; letter-spacing: 1px; color: #6b7280; font-weight: 600; }
.nav-item { display: flex; align-items: center; gap: 10px; padding: 8px 16px; font-size: 13px; color: #c0c0d0; transition: all 0.15s; border-left: 3px solid transparent; }
.nav-item:hover { background: rgba(255,255,255,0.06); color: #fff; text-decoration: none; }
.nav-item.active { background: rgba(67,97,238,0.15); color: #4361ee; border-left-color: #4361ee; font-weight: 600; }
.nav-item svg { width: 16px; height: 16px; opacity: 0.7; }

/* ─── Main Content ────────────────────────────────── */
.main { flex: 1; margin-left: 220px; }

.page-header { background: #fff; border-bottom: 1px solid #e5e7eb; padding: 16px 24px; display: flex; justify-content: space-between; align-items: center; }
.page-header h2 { font-size: 18px; font-weight: 600; color: #1a1a2e; }
.page-header .breadcrumb { font-size: 12px; color: #9ca3af; }
.page-header .breadcrumb a { color: #6b7280; }

.content { padding: 24px; }

/* ─── KPI Cards ───────────────────────────────────── */
.kpi-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 16px; margin-bottom: 24px; }
.kpi-card { background: #fff; border-radius: 10px; padding: 20px; border: 1px solid #e5e7eb; }
.kpi-card .label { font-size: 12px; color: #6b7280; font-weight: 500; text-transform: uppercase; letter-spacing: 0.5px; }
.kpi-card .value { font-size: 28px; font-weight: 700; margin-top: 4px; color: #1a1a2e; }
.kpi-card .sub { font-size: 12px; color: #9ca3af; margin-top: 2px; }
.kpi-card.accent-blue .value { color: #4361ee; }
.kpi-card.accent-green .value { color: #10b981; }
.kpi-card.accent-orange .value { color: #f59e0b; }
.kpi-card.accent-purple .value { color: #8b5cf6; }

/* ─── Progress Bar ────────────────────────────────── */
.progress-bar { height: 6px; background: #e5e7eb; border-radius: 3px; margin-top: 8px; overflow: hidden; }
.progress-bar .fill { height: 100%; border-radius: 3px; transition: width 0.3s; }
.fill-blue { background: #4361ee; }
.fill-green { background: #10b981; }
.fill-orange { background: #f59e0b; }

/* ─── Filter Bar ──────────────────────────────────── */
.filter-bar { background: #fff; padding: 12px 24px; border-bottom: 1px solid #e5e7eb; display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.filter-bar select, .filter-bar input[type=search] { padding: 7px 12px; border: 1px solid #d1d5db; border-radius: 6px; font-size: 13px; background: #fff; color: #374151; }
.filter-bar input[type=search] { width: 220px; }
.filter-bar select:focus, .filter-bar input:focus { outline: none; border-color: #4361ee; box-shadow: 0 0 0 2px rgba(67,97,238,0.15); }

/* ─── Buttons ─────────────────────────────────────── */
.btn { display: inline-flex; align-items: center; gap: 6px; padding: 7px 16px; border: none; border-radius: 6px; font-size: 13px; font-weight: 500; cursor: pointer; transition: all 0.15s; }
.btn-primary { background: #4361ee; color: #fff; }
.btn-primary:hover { background: #3a56d4; }
.btn-secondary { background: #f3f4f6; color: #374151; border: 1px solid #d1d5db; }
.btn-secondary:hover { background: #e5e7eb; }
.btn-danger { background: #ef4444; color: #fff; }
.btn-danger:hover { background: #dc2626; }
.btn-success { background: #10b981; color: #fff; }
.btn-success:hover { background: #059669; }
.btn-sm { padding: 4px 10px; font-size: 12px; }
.btn-ghost { background: transparent; color: #6b7280; }
.btn-ghost:hover { background: #f3f4f6; color: #374151; }

/* ─── Status Badge ────────────────────────────────── */
.badge { display: inline-flex; padding: 2px 8px; border-radius: 10px; font-size: 11px; font-weight: 600; }
.badge-success { background: #d1fae5; color: #065f46; }
.badge-warning { background: #fef3c7; color: #92400e; }
.badge-error { background: #fee2e2; color: #991b1b; }
.badge-info { background: #dbeafe; color: #1e40af; }
.badge-default { background: #f3f4f6; color: #6b7280; }

/* ─── Card Grid ───────────────────────────────────── */
.card-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 14px; }

.word-card { background: #fff; border-radius: 10px; overflow: hidden; border: 1px solid #e5e7eb; transition: all 0.2s; position: relative; }
.word-card:hover { border-color: #4361ee; box-shadow: 0 4px 12px rgba(67,97,238,0.1); }
.word-card .img-area { aspect-ratio: 1; background: #f9fafb; display: flex; align-items: center; justify-content: center; overflow: hidden; position: relative; }
.word-card .img-area img { width: 100%; height: 100%; object-fit: cover; }
.word-card .img-area .placeholder { color: #d1d5db; font-size: 36px; font-weight: 300; }
.word-card .card-body { padding: 10px 12px; }
.word-card .english { font-size: 15px; font-weight: 600; color: #1a1a2e; }
.word-card .korean { font-size: 12px; color: #6b7280; margin-top: 1px; }
.word-card .card-meta { display: flex; gap: 4px; margin-top: 6px; flex-wrap: wrap; }

.word-card .overlay { position: absolute; inset: 0; background: rgba(26,26,46,0.7); display: flex; align-items: center; justify-content: center; gap: 8px; opacity: 0; transition: opacity 0.2s; }
.word-card:hover .overlay { opacity: 1; }
.overlay .btn-icon { width: 36px; height: 36px; border-radius: 50%; border: none; cursor: pointer; font-size: 16px; display: flex; align-items: center; justify-content: center; color: #fff; transition: transform 0.15s; }
.overlay .btn-icon:hover { transform: scale(1.1); }
.btn-icon-edit { background: #4361ee; }
.btn-icon-search { background: #8b5cf6; }
.btn-icon-delete { background: #ef4444; }

/* ─── Detail Page ─────────────────────────────────── */
.detail-grid { display: grid; grid-template-columns: 340px 1fr; gap: 24px; }
@media (max-width: 768px) { .detail-grid { grid-template-columns: 1fr; } }

.detail-card { background: #fff; border-radius: 10px; border: 1px solid #e5e7eb; padding: 20px; }
.detail-card h3 { font-size: 14px; font-weight: 600; color: #374151; margin-bottom: 14px; padding-bottom: 10px; border-bottom: 1px solid #f3f4f6; }

.img-preview { width: 100%; aspect-ratio: 1; background: #f9fafb; border-radius: 8px; overflow: hidden; display: flex; align-items: center; justify-content: center; margin-bottom: 12px; border: 1px solid #e5e7eb; }
.img-preview img { width: 100%; height: 100%; object-fit: cover; }
.img-preview .placeholder { color: #d1d5db; font-size: 48px; }

.audio-player { display: flex; align-items: center; gap: 8px; padding: 10px; background: #f9fafb; border-radius: 8px; margin-bottom: 12px; }
.audio-player audio { flex: 1; height: 32px; }

.form-group { margin-bottom: 14px; }
.form-group label { display: block; font-size: 12px; font-weight: 600; color: #6b7280; margin-bottom: 4px; text-transform: uppercase; letter-spacing: 0.5px; }
.form-group input, .form-group select, .form-group textarea { width: 100%; padding: 8px 12px; border: 1px solid #d1d5db; border-radius: 6px; font-size: 14px; color: #1a1a2e; background: #fff; }
.form-group input:focus, .form-group select:focus, .form-group textarea:focus { outline: none; border-color: #4361ee; box-shadow: 0 0 0 2px rgba(67,97,238,0.15); }
.form-actions { display: flex; gap: 8px; margin-top: 16px; }

/* ─── Dialogue Table ──────────────────────────────── */
.dialogue-table { width: 100%; border-collapse: collapse; }
.dialogue-table th { text-align: left; font-size: 11px; font-weight: 600; color: #6b7280; text-transform: uppercase; padding: 8px 10px; border-bottom: 2px solid #e5e7eb; }
.dialogue-table td { padding: 8px 10px; border-bottom: 1px solid #f3f4f6; font-size: 13px; }
.dialogue-table tr:hover { background: #f9fafb; }

/* ─── Upload Zone ─────────────────────────────────── */
.upload-zone { border: 2px dashed #d1d5db; border-radius: 8px; padding: 20px; text-align: center; cursor: pointer; transition: all 0.2s; color: #9ca3af; font-size: 13px; }
.upload-zone:hover { border-color: #4361ee; background: #f8f9ff; color: #4361ee; }
.upload-zone input[type=file] { display: none; }

/* ─── Modal ───────────────────────────────────────── */
.modal-overlay { display: none; position: fixed; inset: 0; background: rgba(0,0,0,0.5); z-index: 100; align-items: center; justify-content: center; }
.modal-overlay.active { display: flex; }
.modal { background: #fff; border-radius: 12px; padding: 24px; max-width: 640px; width: 90%; max-height: 80vh; overflow-y: auto; }
.modal h3 { font-size: 16px; font-weight: 600; margin-bottom: 16px; }
.modal .close { float: right; background: none; border: none; font-size: 20px; cursor: pointer; color: #9ca3af; }
.modal .close:hover { color: #374151; }
.modal .search-bar { display: flex; gap: 8px; margin-bottom: 12px; }
.modal .search-bar input { flex: 1; padding: 8px 12px; border: 1px solid #d1d5db; border-radius: 6px; font-size: 14px; }
.modal .search-results { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.modal .search-results img { width: 100%; aspect-ratio: 1; object-fit: cover; border-radius: 6px; cursor: pointer; border: 2px solid transparent; transition: border-color 0.15s; }
.modal .search-results img:hover { border-color: #4361ee; }

/* ─── Pagination ──────────────────────────────────── */
.pagination { display: flex; justify-content: center; gap: 6px; padding: 24px; }
.pagination a, .pagination span { padding: 6px 12px; border-radius: 6px; font-size: 13px; }
.pagination a { background: #fff; border: 1px solid #d1d5db; color: #374151; }
.pagination a:hover { background: #f3f4f6; text-decoration: none; }
.pagination a.active { background: #4361ee; color: #fff; border-color: #4361ee; }
.pagination span { color: #9ca3af; }

/* ─── Table (category stats) ──────────────────────── */
.stats-table { width: 100%; border-collapse: collapse; }
.stats-table th { text-align: left; font-size: 11px; font-weight: 600; color: #6b7280; text-transform: uppercase; padding: 8px 12px; border-bottom: 2px solid #e5e7eb; }
.stats-table td { padding: 8px 12px; font-size: 13px; border-bottom: 1px solid #f3f4f6; }
.stats-table tr:hover { background: #f9fafb; }

/* ─── Toast ───────────────────────────────────────── */
.toast { position: fixed; bottom: 24px; right: 24px; background: #1a1a2e; color: #fff; padding: 12px 20px; border-radius: 8px; z-index: 200; display: none; font-size: 14px; box-shadow: 0 4px 12px rgba(0,0,0,0.2); }
.toast.show { display: block; animation: slideUp 0.3s ease; }
@keyframes slideUp { from { transform: translateY(10px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }

/* ─── Count label ─────────────────────────────────── */
.count-label { font-size: 13px; color: #6b7280; margin-left: auto; }
