/* ==========================================================================
   VocabVault - Modern Glassmorphism Styling System
   ========================================================================== */

:root {
  /* Color Palette */
  --bg-dark: #0b0f19;
  --bg-card: rgba(17, 24, 39, 0.7);
  --bg-card-hover: rgba(30, 41, 59, 0.85);
  --glass-border: rgba(255, 255, 255, 0.1);
  --glass-border-focus: rgba(99, 102, 241, 0.5);

  --primary: #6366f1;
  --primary-hover: #4f46e5;
  --primary-glow: rgba(99, 102, 241, 0.35);

  --secondary: #8b5cf6;
  --secondary-hover: #7c3aed;

  --accent-word: #10b981;
  --accent-word-bg: rgba(16, 185, 129, 0.15);
  --accent-idiom: #f59e0b;
  --accent-idiom-bg: rgba(245, 158, 11, 0.15);
  --accent-phrasal: #ec4899;
  --accent-phrasal-bg: rgba(236, 72, 153, 0.15);
  --accent-slang: #06b6d4;
  --accent-slang-bg: rgba(6, 182, 212, 0.15);

  --text-main: #f8fafc;
  --text-muted: #94a3b8;
  --text-dim: #64748b;

  --danger: #ef4444;
  --danger-hover: #dc2626;
  --star-active: #fbbf24;

  --radius-sm: 8px;
  --radius-md: 14px;
  --radius-lg: 20px;

  --font-family: 'Outfit', 'Prompt', -apple-system, sans-serif;
  --shadow-main: 0 20px 40px rgba(0, 0, 0, 0.4);
  --transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Reset & Base */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: var(--font-family);
  background-color: var(--bg-dark);
  color: var(--text-main);
  min-height: 100vh;
  line-height: 1.6;
  overflow-x: hidden;
  position: relative;
}

/* Background Animated Globs */
.background-glob {
  position: fixed;
  border-radius: 50%;
  filter: blur(120px);
  z-index: -1;
  pointer-events: none;
  opacity: 0.4;
}

.bg-glob-1 {
  width: 500px;
  height: 500px;
  background: radial-gradient(circle, var(--primary) 0%, rgba(0,0,0,0) 70%);
  top: -100px;
  left: -100px;
}

.bg-glob-2 {
  width: 600px;
  height: 600px;
  background: radial-gradient(circle, var(--secondary) 0%, rgba(0,0,0,0) 70%);
  bottom: -150px;
  right: -150px;
}

/* Glassmorphism Card Utility */
.glass-card {
  background: var(--bg-card);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-main);
}

.app-container {
  max-width: 1380px;
  margin: 0 auto;
  padding: 24px;
}

/* Header */
.app-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 28px;
  padding-bottom: 20px;
  border-bottom: 1px solid var(--glass-border);
}

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

.brand-icon {
  width: 52px;
  height: 52px;
  background: linear-gradient(135deg, var(--primary), var(--secondary));
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
  color: white;
  box-shadow: 0 8px 20px var(--primary-glow);
}

.brand-text h1 {
  font-size: 28px;
  font-weight: 700;
  letter-spacing: -0.5px;
  line-height: 1.2;
}

.brand-text h1 span {
  color: var(--primary);
  background: linear-gradient(90deg, var(--primary), var(--secondary));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.brand-text p {
  font-size: 14px;
  color: var(--text-muted);
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 20px;
  font-family: var(--font-family);
  font-size: 15px;
  font-weight: 600;
  border-radius: var(--radius-md);
  border: none;
  cursor: pointer;
  transition: var(--transition);
  outline: none;
}

.btn-primary {
  background: linear-gradient(135deg, var(--primary), var(--primary-hover));
  color: white;
  box-shadow: 0 4px 15px var(--primary-glow);
}

.btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 25px var(--primary-glow);
}

.btn-secondary {
  background: linear-gradient(135deg, var(--secondary), var(--secondary-hover));
  color: white;
}

.btn-secondary:hover {
  transform: translateY(-2px);
  filter: brightness(1.1);
}

.btn-outline {
  background: rgba(255, 255, 255, 0.05);
  color: var(--text-main);
  border: 1px solid var(--glass-border);
}

.btn-outline:hover {
  background: rgba(255, 255, 255, 0.12);
  border-color: rgba(255, 255, 255, 0.25);
}

.btn-block {
  width: 100%;
}

.btn-text {
  background: none;
  border: none;
  color: var(--primary);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  padding: 4px 8px;
}

.btn-text:hover {
  text-decoration: underline;
}

/* Main Layout Grid */
.main-layout {
  display: grid;
  grid-template-columns: 420px 1fr;
  gap: 28px;
}

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

/* Form Panel */
.form-panel {
  padding: 24px;
  height: fit-content;
  position: sticky;
  top: 24px;
}

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

.panel-header h2 {
  font-size: 18px;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--text-main);
}

.panel-header h2 i {
  color: var(--primary);
}

.form-group {
  margin-bottom: 18px;
}

.form-row {
  display: flex;
  gap: 14px;
}

.flex-1 {
  flex: 1;
}

label {
  display: block;
  font-size: 14px;
  font-weight: 500;
  margin-bottom: 6px;
  color: var(--text-muted);
}

.required {
  color: var(--danger);
}

.input-with-icon {
  position: relative;
  display: flex;
  align-items: center;
}

.input-with-icon i {
  position: absolute;
  left: 14px;
  color: var(--text-dim);
  font-size: 15px;
  pointer-events: none;
}

input[type="text"],
select,
textarea {
  width: 100%;
  font-family: var(--font-family);
  font-size: 15px;
  background: rgba(15, 23, 42, 0.6);
  color: var(--text-main);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-sm);
  padding: 11px 14px;
  outline: none;
  transition: var(--transition);
}

.input-with-icon input[type="text"] {
  padding-left: 40px;
}

input[type="text"]:focus,
select:focus,
textarea:focus {
  border-color: var(--primary);
  background: rgba(15, 23, 42, 0.85);
  box-shadow: 0 0 0 3px var(--primary-glow);
}

textarea {
  resize: vertical;
  min-height: 140px;
  line-height: 1.6;
}

.input-hint {
  display: block;
  font-size: 12px;
  color: var(--text-dim);
  margin-top: 6px;
}

/* Search Section & Autocomplete Dropdown */
.search-section {
  padding: 20px;
  margin-bottom: 24px;
}

.search-container {
  position: relative;
  margin-bottom: 16px;
}

.search-input-wrapper {
  position: relative;
  display: flex;
  align-items: center;
}

.search-icon {
  position: absolute;
  left: 16px;
  color: var(--primary);
  font-size: 18px;
}

.search-input-wrapper input {
  padding: 14px 44px 14px 46px;
  font-size: 16px;
  border-radius: var(--radius-md);
  background: rgba(15, 23, 42, 0.8);
}

.clear-icon {
  position: absolute;
  right: 14px;
  background: none;
  border: none;
  color: var(--text-dim);
  font-size: 16px;
  cursor: pointer;
}

.clear-icon:hover {
  color: var(--text-main);
}

/* Live Autocomplete Dropdown Styling */
.autocomplete-suggestions {
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  right: 0;
  background: rgba(15, 23, 42, 0.95);
  backdrop-filter: blur(20px);
  border: 1px solid var(--primary-glow);
  border-radius: var(--radius-md);
  box-shadow: 0 16px 36px rgba(0, 0, 0, 0.6);
  z-index: 100;
  overflow: hidden;
  max-height: 360px;
  overflow-y: auto;
}

.autocomplete-header {
  padding: 10px 16px;
  font-size: 12px;
  font-weight: 600;
  color: var(--primary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  border-bottom: 1px solid var(--glass-border);
  background: rgba(99, 102, 241, 0.08);
}

.autocomplete-suggestions ul {
  list-style: none;
}

.autocomplete-suggestions li {
  padding: 12px 16px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  cursor: pointer;
  border-bottom: 1px solid rgba(255, 255, 255, 0.04);
  transition: var(--transition);
}

.autocomplete-suggestions li:last-child {
  border-bottom: none;
}

.autocomplete-suggestions li:hover,
.autocomplete-suggestions li.active-item {
  background: rgba(99, 102, 241, 0.2);
}

.auto-term {
  font-weight: 600;
  font-size: 15px;
  color: var(--text-main);

}

.auto-term mark {
  background: rgba(99, 102, 241, 0.4);
  color: #fff;
  border-radius: 2px;
  padding: 0 2px;
}

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

.auto-meaning {
  font-size: 13px;
  color: var(--text-muted);
  max-width: 250px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Filter Controls */
.controls-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
}

.filter-tabs {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.tab-btn {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--glass-border);
  color: var(--text-muted);
  padding: 7px 14px;
  border-radius: 20px;
  font-family: var(--font-family);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: var(--transition);
}

.tab-btn:hover {
  background: rgba(255, 255, 255, 0.1);
  color: var(--text-main);
}

.tab-btn.active {
  background: var(--primary);
  border-color: var(--primary);
  color: white;
  box-shadow: 0 4px 12px var(--primary-glow);
}

.sort-wrapper {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--text-muted);
}

.sort-wrapper select {
  padding: 6px 12px;
  font-size: 13px;
  width: auto;
}

/* Cards Grid */
.cards-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 20px;
}

.vocab-card {
  padding: 22px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  transition: var(--transition);
  position: relative;
}

.vocab-card:hover {
  transform: translateY(-4px);
  border-color: rgba(99, 102, 241, 0.3);
  background: var(--bg-card-hover);
}

.vocab-card.highlighted-card {
  border-color: var(--primary);
  box-shadow: 0 0 0 2px var(--primary), 0 12px 30px var(--primary-glow);
  animation: pulseHighlight 1.5s ease-out;
}

@keyframes pulseHighlight {
  0% { transform: scale(1.02); }
  50% { transform: scale(1); }
  100% { transform: scale(1); }
}

.card-top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 12px;
}

.badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 12px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.badge-word { background: var(--accent-word-bg); color: var(--accent-word); border: 1px solid rgba(16, 185, 129, 0.3); }
.badge-idiom { background: var(--accent-idiom-bg); color: var(--accent-idiom); border: 1px solid rgba(245, 158, 11, 0.3); }
.badge-phrasal { background: var(--accent-phrasal-bg); color: var(--accent-phrasal); border: 1px solid rgba(236, 72, 153, 0.3); }
.badge-slang { background: var(--accent-slang-bg); color: var(--accent-slang); border: 1px solid rgba(6, 182, 212, 0.3); }

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

.action-btn {
  background: none;
  border: none;
  color: var(--text-dim);
  font-size: 15px;
  cursor: pointer;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: var(--transition);
}

.action-btn:hover {
  background: rgba(255, 255, 255, 0.1);
  color: var(--text-main);
}

.action-btn.star-btn.active {
  color: var(--star-active);
}

.action-btn.delete-btn:hover {
  color: var(--danger);
  background: rgba(239, 68, 68, 0.15);
}

.card-title {
  font-size: 22px;
  font-weight: 700;
  color: var(--text-main);
  margin-bottom: 12px;
  line-height: 1.3;
  word-break: break-word;
}

.card-meaning {
  font-size: 15px;
  color: #cbd5e1;
  background: rgba(0, 0, 0, 0.25);
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  border-left: 3px solid var(--primary);
  margin-bottom: 14px;
  white-space: pre-wrap;
  word-break: break-word;
}

.card-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 10px;
}

.tag-item {
  font-size: 11px;
  color: var(--text-muted);
  background: rgba(255, 255, 255, 0.06);
  padding: 2px 8px;
  border-radius: 10px;
}

.card-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 16px;
  padding-top: 12px;
  border-top: 1px solid rgba(255, 255, 255, 0.05);
  font-size: 12px;
  color: var(--text-dim);
}

/* Empty State */
.empty-state {
  text-align: center;
  padding: 60px 20px;
  margin-top: 20px;
}

.empty-icon {
  font-size: 48px;
  color: var(--text-dim);
  margin-bottom: 16px;
  opacity: 0.5;
}

.empty-state h3 {
  font-size: 18px;
  font-weight: 600;
  margin-bottom: 8px;
}

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

/* Modal Overlay & Base */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(8px);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  animation: fadeIn 0.2s ease-out;
}

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

.modal-content {
  width: 100%;
  max-width: 600px;
  padding: 32px;
  position: relative;
  max-height: 90vh;
  overflow-y: auto;
}

.modal-close {
  position: absolute;
  top: 20px;
  right: 20px;
  background: rgba(255, 255, 255, 0.08);
  border: none;
  color: var(--text-muted);
  width: 36px;
  height: 36px;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  transition: var(--transition);
}

.modal-close:hover {
  background: rgba(255, 255, 255, 0.2);
  color: white;
}

/* Flashcard Modal */
.flashcard-modal {
  max-width: 520px;
  text-align: center;
}

.flashcard-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 24px;
  padding-right: 40px;
}

.flashcard-header h3 {
  font-size: 18px;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 8px;
}

.flashcard-container {
  perspective: 1000px;
  height: 280px;
  margin-bottom: 24px;
  cursor: pointer;
}

.flashcard-inner {
  position: relative;
  width: 100%;
  height: 100%;
  transition: transform 0.6s cubic-bezier(0.4, 0, 0.2, 1);
  transform-style: preserve-3d;
}

.flashcard-container.flipped .flashcard-inner {
  transform: rotateY(180deg);
}

.flashcard-face {
  position: absolute;
  width: 100%;
  height: 100%;
  backface-visibility: hidden;
  border-radius: var(--radius-lg);
  padding: 30px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  border: 1px solid var(--glass-border);
}

.flashcard-front {
  background: linear-gradient(145deg, rgba(30, 41, 59, 0.9), rgba(15, 23, 42, 0.9));
}

.flashcard-front h2 {
  font-size: 32px;
  font-weight: 700;
  margin: 16px 0;
  word-break: break-word;
}

.flashcard-back {
  background: linear-gradient(145deg, rgba(15, 23, 42, 0.95), rgba(30, 41, 59, 0.95));
  transform: rotateY(180deg);
  border-color: var(--primary-glow);
}

.fc-back-title {
  font-size: 13px;
  color: var(--primary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 10px;
}

.fc-meaning {
  font-size: 16px;
  color: var(--text-main);
  max-height: 140px;
  overflow-y: auto;
  white-space: pre-wrap;
  line-height: 1.5;
}

.fc-hint {
  font-size: 12px;
  color: var(--text-dim);
  margin-top: auto;
}

.flashcard-controls {
  display: flex;
  justify-content: space-between;
  gap: 12px;
}

/* Helpers */
.hidden {
  display: none !important;
}

/* Responsive adjust */
@media (max-width: 640px) {
  .app-container {
    padding: 16px;
  }

  .brand-text h1 {
    font-size: 22px;
  }

  .form-row {
    flex-direction: column;
    gap: 0;
  }

  .controls-row {
    flex-direction: column;
    align-items: stretch;
  }

  .cards-grid {
    grid-template-columns: 1fr;
  }
}
