/* Google Fonts: Inter & Outfit & Noto Sans KR */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&family=Noto+Sans+KR:wght@300;400;500;700&family=Outfit:wght@400;600;800&display=swap');

:root {
  /* Light Theme Variables */
  --bg-primary: #f8fafc;
  --bg-secondary: #f1f5f9;
  --bg-card: rgba(255, 255, 255, 0.85);
  --bg-glass: rgba(255, 255, 255, 0.45);
  --border-color: rgba(226, 232, 240, 0.8);
  --text-primary: #0f172a;
  --text-secondary: #475569;
  --text-muted: #94a3b8;
  --accent-color: #0d9488; /* Teal */
  --accent-light: #ccfbf1;
  --accent-gradient: linear-gradient(135deg, #0d9488 0%, #3b82f6 100%);
  --shadow-sm: 0 2px 8px rgba(148, 163, 184, 0.05);
  --shadow-md: 0 10px 25px -5px rgba(148, 163, 184, 0.15), 0 8px 16px -6px rgba(148, 163, 184, 0.1);
  --shadow-lg: 0 20px 40px -10px rgba(148, 163, 184, 0.25);
  --radius-sm: 8px;
  --radius-md: 16px;
  --radius-lg: 24px;
}

[data-theme="dark"] {
  /* Dark Theme Variables */
  --bg-primary: #0b0f19;
  --bg-secondary: #111827;
  --bg-card: rgba(17, 24, 39, 0.8);
  --bg-glass: rgba(17, 24, 39, 0.4);
  --border-color: rgba(37, 99, 235, 0.15);
  --text-primary: #f8fafc;
  --text-secondary: #cbd5e1;
  --text-muted: #64748b;
  --accent-color: #14b8a6;
  --accent-light: #115e59;
  --accent-gradient: linear-gradient(135deg, #14b8a6 0%, #2563eb 100%);
  --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.2);
  --shadow-md: 0 10px 25px -5px rgba(0, 0, 0, 0.4), 0 8px 16px -6px rgba(0, 0, 0, 0.3);
  --shadow-lg: 0 20px 40px -10px rgba(0, 0, 0, 0.5);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  transition: background-color 0.4s ease, color 0.3s ease, border-color 0.3s ease, box-shadow 0.3s ease;
}

body {
  font-family: 'Inter', 'Noto Sans KR', sans-serif;
  background-color: var(--bg-primary);
  color: var(--text-primary);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  overflow-x: hidden;
}

/* Header & Glassmorphism */
header {
  background: var(--bg-glass);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--border-color);
  padding: 1.25rem 2rem;
  position: sticky;
  top: 0;
  z-index: 100;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.logo-icon {
  background: var(--accent-gradient);
  color: white;
  width: 40px;
  height: 40px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.25rem;
  font-weight: bold;
  box-shadow: 0 4px 12px rgba(13, 148, 136, 0.3);
  font-family: 'Outfit', sans-serif;
}

.brand h1 {
  font-size: 1.35rem;
  font-weight: 700;
  letter-spacing: -0.025em;
  font-family: 'Outfit', 'Noto Sans KR', sans-serif;
}

.brand p {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 0.1rem;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 1rem;
}

/* Theme Toggle Button */
.theme-btn {
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  color: var(--text-primary);
  width: 42px;
  height: 42px;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.2rem;
}

.theme-btn:hover {
  transform: scale(1.05);
  background: var(--border-color);
}

/* Dashboard Container */
.container {
  max-width: 1440px;
  width: 100%;
  margin: 0 auto;
  padding: 2rem;
  display: grid;
  grid-template-columns: 350px 1fr;
  gap: 2rem;
  flex: 1;
}

@media (max-width: 1024px) {
  .container {
    grid-template-columns: 1fr;
  }
}

/* Sidebar Styling */
.sidebar {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.card {
  background: var(--bg-card);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 1.5rem;
  box-shadow: var(--shadow-md);
}

.card-title {
  font-size: 1.1rem;
  font-weight: 700;
  margin-bottom: 1.25rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  color: var(--text-primary);
  border-bottom: 2px solid var(--border-color);
  padding-bottom: 0.5rem;
}

/* Search bar styling */
.search-wrapper {
  position: relative;
  margin-bottom: 1.25rem;
}

.search-input {
  width: 100%;
  padding: 0.75rem 1rem 0.75rem 2.5rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-color);
  background: var(--bg-secondary);
  color: var(--text-primary);
  font-size: 0.9rem;
  outline: none;
}

.search-input:focus {
  border-color: var(--accent-color);
  box-shadow: 0 0 0 3px rgba(13, 148, 136, 0.15);
}

.search-icon {
  position: absolute;
  left: 0.75rem;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  font-size: 1rem;
}

/* Dropdowns selector style */
.selector-group {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.select-wrapper {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.select-wrapper label {
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--text-secondary);
}

select {
  width: 100%;
  padding: 0.75rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-color);
  background: var(--bg-secondary);
  color: var(--text-primary);
  font-size: 0.85rem;
  outline: none;
  cursor: pointer;
  appearance: none;
  background-image: url("data:image/svg+xml;charset=UTF-8,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23475569' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.75rem center;
  background-size: 1rem;
}

[data-theme="dark"] select {
  background-image: url("data:image/svg+xml;charset=UTF-8,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23cbd5e1' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
}

select:focus {
  border-color: var(--accent-color);
}

/* Suggestions Dropdown box (Autocomplete) */
.autocomplete-results {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  max-height: 200px;
  overflow-y: auto;
  z-index: 10;
  box-shadow: var(--shadow-md);
  margin-top: 0.25rem;
  display: none;
}

.autocomplete-item {
  padding: 0.75rem 1rem;
  font-size: 0.85rem;
  cursor: pointer;
  color: var(--text-primary);
}

.autocomplete-item:hover {
  background: var(--bg-secondary);
  color: var(--accent-color);
}

/* Main Display Panels */
.main-content {
  display: flex;
  flex-direction: column;
  gap: 2rem;
}

/* Chapter Heading */
.chapter-hero {
  padding: 2rem;
  border-radius: var(--radius-md);
  background: var(--accent-gradient);
  color: white;
  box-shadow: var(--shadow-lg);
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  position: relative;
  overflow: hidden;
}

.chapter-hero::before {
  content: '';
  position: absolute;
  top: -50%;
  right: -20%;
  width: 300px;
  height: 300px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.1);
  filter: blur(40px);
  pointer-events: none;
}

.chapter-hero .breadcrumb {
  font-size: 0.8rem;
  font-weight: 500;
  opacity: 0.8;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.chapter-hero h2 {
  font-size: 1.75rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  font-family: 'Outfit', 'Noto Sans KR', sans-serif;
  line-height: 1.3;
}

/* Tabs layout */
.tab-container {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.5rem;
}

@media (max-width: 768px) {
  .tab-container {
    grid-template-columns: 1fr;
  }
}

/* Resource Cards */
.resource-list {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  margin-top: 1rem;
}

.resource-card {
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 1.25rem;
  position: relative;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.resource-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-sm);
  border-color: var(--accent-color);
}

.resource-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 1rem;
}

.resource-title {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--text-primary);
  line-height: 1.4;
}

.resource-badge {
  font-size: 0.7rem;
  font-weight: 600;
  padding: 0.2rem 0.5rem;
  border-radius: 4px;
  background: var(--accent-light);
  color: var(--accent-color);
  white-space: nowrap;
}

.resource-desc {
  font-size: 0.8rem;
  color: var(--text-secondary);
  line-height: 1.5;
}

.resource-footer {
  display: flex;
  justify-content: flex-end;
  gap: 0.5rem;
  margin-top: 0.5rem;
}

/* Buttons style */
.btn {
  padding: 0.5rem 0.85rem;
  font-size: 0.75rem;
  font-weight: 600;
  border-radius: 6px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  text-decoration: none;
  border: 1px solid transparent;
}

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

.btn-primary:hover {
  background: #0f766e;
}

.btn-outline {
  border-color: var(--border-color);
  background: var(--bg-card);
  color: var(--text-secondary);
}

.btn-outline:hover {
  background: var(--bg-secondary);
  color: var(--text-primary);
}

/* Smart Search Panel */
.search-links-box {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin-top: 1rem;
}

.search-link-btn {
  flex: 1;
  min-width: 150px;
  padding: 0.85rem 1rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-color);
  background: var(--bg-card);
  color: var(--text-primary);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  font-size: 0.85rem;
  font-weight: 600;
  text-decoration: none;
  box-shadow: var(--shadow-sm);
}

.search-link-btn:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
  border-color: var(--accent-color);
}

.search-link-btn.youtube-btn:hover {
  color: #ef4444;
  border-color: #ef4444;
}

.search-link-btn.naver-btn:hover {
  color: #22c55e;
  border-color: #22c55e;
}

/* Scratchpad Editor */
.editor-wrapper {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.textarea-memo {
  width: 100%;
  height: 180px;
  padding: 1rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-color);
  background: var(--bg-secondary);
  color: var(--text-primary);
  font-family: inherit;
  font-size: 0.85rem;
  resize: vertical;
  outline: none;
  line-height: 1.5;
}

.textarea-memo:focus {
  border-color: var(--accent-color);
  box-shadow: 0 0 0 3px rgba(13, 148, 136, 0.15);
}

.editor-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.auto-save-status {
  font-size: 0.75rem;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 0.35rem;
}

/* Toast Message Notification */
.toast {
  position: fixed;
  bottom: 2rem;
  right: 2rem;
  background: #0f172a;
  color: white;
  padding: 0.85rem 1.5rem;
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
  font-weight: 500;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
  display: flex;
  align-items: center;
  gap: 0.5rem;
  z-index: 1000;
  opacity: 0;
  transform: translateY(1rem);
  transition: opacity 0.3s ease, transform 0.3s ease;
  pointer-events: none;
}

.toast.show {
  opacity: 1;
  transform: translateY(0);
}

/* Fallback empty view styling */
.empty-state {
  text-align: center;
  padding: 3rem 1.5rem;
  color: var(--text-muted);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1rem;
}

.empty-state-icon {
  font-size: 3rem;
  opacity: 0.5;
}

.empty-state h3 {
  font-size: 1.1rem;
  color: var(--text-secondary);
}

.empty-state p {
  font-size: 0.85rem;
}
