/* 기본 리셋 및 전역 변수 */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

:root {
  --primary: #4f46e5;
  --primary-hover: #4338ca;
  --secondary: #64748b;
  --danger: #ef4444;
  --danger-hover: #dc2626;
  --bg-main: #0f172a;
  --bg-surface: #1e293b;
  --bg-card: #24324d;
  --border-color: #334155;
  --text-main: #f8fafc;
  --text-muted: #94a3b8;
  --pinned-border: #f59e0b;
  --radius: 10px;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background-color: var(--bg-main);
  color: var(--text-main);
  min-height: 100vh;
  line-height: 1.5;
}

/* 유틸리티 */
.hidden {
  display: none !important;
}

/* 1. 로그인 뷰 */
#login-view {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: radial-gradient(circle at top, #1e1b4b 0%, #0f172a 100%);
}

.login-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  padding: 40px;
  border-radius: 16px;
  width: 100%;
  max-width: 420px;
  box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.5), 0 8px 10px -6px rgba(0, 0, 0, 0.4);
}

.login-header {
  text-align: center;
  margin-bottom: 25px;
}

.lock-icon {
  font-size: 3rem;
  display: block;
  margin-bottom: 12px;
}

.login-header h2 {
  font-size: 1.6rem;
  margin-bottom: 6px;
  color: #ffffff;
}

.login-header p {
  color: var(--text-muted);
  font-size: 0.9rem;
}

.hint-box {
  background: #1e293b;
  border: 1px dashed var(--primary);
  padding: 10px 14px;
  border-radius: 6px;
  font-size: 0.85rem;
  color: #cbd5e1;
  margin-bottom: 15px;
}

.error-msg {
  color: #f87171;
  font-size: 0.85rem;
  margin-bottom: 15px;
  text-align: center;
  min-height: 20px;
}

/* 폼 요소 공통 */
.input-group {
  margin-bottom: 18px;
}

.input-group label {
  display: block;
  font-size: 0.85rem;
  font-weight: 600;
  margin-bottom: 6px;
  color: #cbd5e1;
}

input[type="text"],
input[type="password"],
select,
textarea {
  width: 100%;
  padding: 10px 14px;
  background-color: #0f172a;
  border: 1px solid var(--border-color);
  border-radius: 8px;
  color: #ffffff;
  font-size: 0.95rem;
  transition: border-color 0.2s, box-shadow 0.2s;
  outline: none;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.25);
}

textarea {
  resize: vertical;
}

.checkbox-group {
  margin-bottom: 20px;
  display: flex;
  align-items: center;
}

.checkbox-group label {
  font-size: 0.9rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 8px;
  color: #cbd5e1;
}

/* 버튼 */
.btn {
  padding: 10px 18px;
  font-size: 0.95rem;
  font-weight: 600;
  border-radius: 8px;
  cursor: pointer;
  border: none;
  transition: all 0.2s ease;
}

.btn-sm {
  padding: 6px 12px;
  font-size: 0.85rem;
}

.btn-block {
  width: 100%;
}

.btn-primary {
  background-color: var(--primary);
  color: #ffffff;
}

.btn-primary:hover {
  background-color: var(--primary-hover);
}

.btn-secondary {
  background-color: #334155;
  color: #f1f5f9;
}

.btn-secondary:hover {
  background-color: #475569;
}

.btn-outline-danger {
  background: transparent;
  color: #f87171;
  border: 1px solid #ef4444;
}

.btn-outline-danger:hover {
  background-color: #ef4444;
  color: #ffffff;
}

/* 2. 관리자 메인 뷰 */
.admin-header {
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border-color);
  padding: 14px 28px;
  position: sticky;
  top: 0;
  z-index: 100;
}

.header-content {
  max-width: 1400px;
  margin: 0 auto;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
}

.brand-icon {
  font-size: 1.6rem;
}

.brand h1 {
  font-size: 1.25rem;
  font-weight: 700;
}

.badge-admin {
  background-color: rgba(79, 70, 229, 0.2);
  color: #818cf8;
  border: 1px solid rgba(129, 140, 248, 0.3);
  padding: 2px 8px;
  border-radius: 12px;
  font-size: 0.75rem;
  font-weight: 600;
}

.badge-server {
  background-color: rgba(16, 185, 129, 0.2);
  color: #34d399;
  border: 1px solid rgba(52, 211, 153, 0.3);
  padding: 2px 8px;
  border-radius: 12px;
  font-size: 0.75rem;
  font-weight: 600;
}

.user-menu {
  display: flex;
  align-items: center;
  gap: 16px;
}

.user-info {
  font-size: 0.9rem;
  color: var(--text-muted);
}

.user-info strong {
  color: #ffffff;
}

/* 메인 레이아웃 (좌: 작성폼 / 우: 목록) */
.main-wrapper {
  max-width: 1400px;
  margin: 24px auto;
  padding: 0 24px;
  display: grid;
  grid-template-columns: 360px 1fr;
  gap: 28px;
  align-items: start;
}

@media (max-width: 900px) {
  .main-wrapper {
    grid-template-columns: 1fr;
  }
}

.memo-form-card,
.stats-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius);
  padding: 24px;
  margin-bottom: 20px;
}

.memo-form-card h2 {
  font-size: 1.15rem;
  margin-bottom: 18px;
}

.form-actions {
  display: flex;
  gap: 10px;
}

.stats-card h3 {
  font-size: 1rem;
  margin-bottom: 14px;
  color: #cbd5e1;
}

.stats-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.stat-item {
  background: #0f172a;
  border: 1px solid var(--border-color);
  padding: 12px;
  border-radius: 8px;
  text-align: center;
}

.stat-label {
  display: block;
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-bottom: 4px;
}

.stat-value {
  font-size: 1.4rem;
  font-weight: 700;
  color: var(--primary);
}

/* 오른쪽 메모 영역 */
.controls-bar {
  display: flex;
  gap: 14px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}

.search-box {
  flex: 1;
  min-width: 240px;
  position: relative;
}

.search-box input {
  padding-left: 38px;
}

.search-icon {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
}

.filter-box select {
  width: auto;
  min-width: 160px;
}

/* 메모 카드 그리드 */
.memo-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 18px;
}

.memo-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius);
  padding: 20px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.3);
  transition: transform 0.2s, box-shadow 0.2s;
  position: relative;
}

.memo-card:hover {
  transform: translateY(-3px);
  box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.4);
}

.memo-card.pinned {
  border-color: var(--pinned-border);
  background: linear-gradient(180deg, #2a2c4e 0%, var(--bg-card) 100%);
}

.card-header-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}

.category-tag {
  font-size: 0.75rem;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 4px;
  background: #334155;
  color: #93c5fd;
}

.category-tag[data-cat="아재개그"] {
  background: rgba(245, 158, 11, 0.2);
  color: #fbbf24;
  border: 1px solid rgba(245, 158, 11, 0.4);
}

.pin-icon {
  color: #fbbf24;
  font-size: 1.1rem;
}

.memo-card h3 {
  font-size: 1.15rem;
  font-weight: 700;
  margin-bottom: 10px;
  color: #ffffff;
  word-break: break-word;
}

.memo-card .memo-text {
  font-size: 0.9rem;
  color: #cbd5e1;
  white-space: pre-wrap;
  word-break: break-word;
  flex-grow: 1;
  margin-bottom: 16px;
  max-height: 180px;
  overflow-y: auto;
}

.memo-card .memo-footer {
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  padding-top: 12px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.memo-date {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.card-actions {
  display: flex;
  gap: 8px;
}

.btn-icon {
  background: transparent;
  border: 1px solid var(--border-color);
  color: var(--text-muted);
  width: 28px;
  height: 28px;
  border-radius: 6px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0.85rem;
  transition: all 0.2s;
}

.btn-icon:hover {
  background: #334155;
  color: #ffffff;
}

.btn-icon.delete:hover {
  background: rgba(239, 68, 68, 0.2);
  color: #f87171;
  border-color: #ef4444;
}

/* 빈 상태 */
.empty-state {
  text-align: center;
  padding: 60px 20px;
  background: var(--bg-surface);
  border: 1px dashed var(--border-color);
  border-radius: var(--radius);
}

.empty-icon {
  font-size: 3rem;
  margin-bottom: 12px;
}

.empty-state h3 {
  font-size: 1.2rem;
  margin-bottom: 6px;
}

.empty-state p {
  color: var(--text-muted);
  font-size: 0.9rem;
}

/* 모달 스타일 */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  animation: modalFadeIn 0.2s ease;
}

@keyframes modalFadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

.modal-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: 14px;
  width: 100%;
  max-width: 400px;
  padding: 28px;
  box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.6);
  position: relative;
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
}

.modal-header h3 {
  font-size: 1.2rem;
  color: #ffffff;
}

.modal-close {
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 1.5rem;
  cursor: pointer;
  line-height: 1;
  transition: color 0.2s;
}

.modal-close:hover {
  color: #ffffff;
}

.modal-msg {
  font-size: 0.85rem;
  margin-bottom: 14px;
  min-height: 20px;
}

.modal-msg.error {
  color: #f87171;
}

.modal-msg.success {
  color: #34d399;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 10px;
}
