*,
*::before,
*::after {
  box-sizing: border-box;
}

:root {
  --background-primary: #f8fafc;
  --background-secondary: #ffffff;
  --background-secondary-translucent: rgba(255, 255, 255, 0.7);
  --background-tertiary: #f5f5f7;
  --background-quaternary: rgba(0, 0, 0, 0.03);
  --text-primary: #1d1d1f;
  --text-secondary: #6b7a90;
  --text-tertiary: #3c3c4399;
  --border-color: rgba(0, 0, 0, 0.08);
  --shadow-color: rgba(0, 0, 0, 0.07);
  --accent-primary: #007aff;
  --accent-primary-hover: #f0f0f0;
  --accent-secondary: rgba(0, 122, 255, 0.1);
  --button-shadow: rgba(0, 0, 0, 0.1);
  --button-background: #f0f0f0;
  --button-hover-background: #e5e5e5;
}

body.dark-mode,
html.dark-mode {
  --background-primary: #000000;
  --background-secondary: #1c1c1e;
  --background-secondary-translucent: rgba(28, 28, 30, 0.7);
  --background-tertiary: #2c2c2e;
  --background-quaternary: rgba(255, 255, 255, 0.08);
  --text-primary: #ffffff;
  --text-secondary: #8d8d92;
  --text-tertiary: #a0a0a5;
  --border-color: rgba(255, 255, 255, 0.15);
  --shadow-color: rgba(0, 0, 0, 0.2);
  --accent-primary: #0a84ff;
  --accent-primary-hover: #1a1a1c;
  --accent-secondary: rgba(10, 132, 255, 0.2);
  --button-shadow: rgba(0, 0, 0, 0.3);
  --button-background: #2c2c2e;
  --button-hover-background: #3a3a3c;
}

body, html {
  min-height: 100vh;
  margin: 0;
  padding: 0;
  background: var(--background-primary);
  color: var(--text-primary);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  transition: background-color 0.3s ease, color 0.3s ease;
}

a {
  color: var(--accent-primary);
  text-decoration: none;
  transition: color 0.2s ease;
  transition: fill 0.3s ease;
}

a:hover {
  text-decoration: underline;
}

.app-wrapper {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  background: var(--background-primary);
  transition: background-color 0.3s ease;
  padding-top: 5rem;
  padding-bottom: 2rem;
}

.container {
  width: 100%;
  max-width: 680px;
  margin: 0 auto;
  padding: 0 20px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 32px;
}

/* Header */
.main-header {
  width: 100%;
  text-align: center;
  margin-bottom: 2rem;
}

.header-content {
  text-align: center;
}

.title {
  font-family: 'Sora', sans-serif;
  font-size: 1.8rem;
  font-weight: 800;
  color: var(--text-primary);
  text-shadow: 0 2px 12px var(--shadow-color);
  margin-bottom: 8px;
  white-space: nowrap;
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 0.8rem;
  vertical-align: middle;
}

.title .fa-book {
    position: static;
    transform: none;
    margin-right: 0;
    font-size: 1.5rem;
    vertical-align: middle;
}

.subtitle {
  font-size: 1.08rem;
  color: var(--text-secondary);
  margin-top: 8px;
  margin-bottom: 0;
}

.home-btn,
.theme-switch-wrapper {
  position: absolute;
  top: 2rem;
  z-index: 10;
}
.home-btn {
  left: 2rem;
}
.theme-switch-wrapper {
  right: 2rem;
  width: auto;
  height: auto;
}

.home-btn,
#theme-switch {
  border: none;
  padding: 0;
  background-color: var(--button-background);
  border-radius: 50%;
  cursor: pointer;
  height: 50px;
  width: 50px;
  display: flex;
  justify-content: center;
  align-items: center;
  transition: background-color 0.3s ease;
  box-shadow: 0 4px 12px var(--shadow-color);
  text-decoration: none;
}

.home-btn:hover,
#theme-switch:hover {
  background-color: var(--button-hover-background);
}

.home-btn svg,
#theme-switch svg {
    fill: var(--text-primary);
    width: 24px;
    height: 24px;
}

#theme-switch {
    font: inherit;
}

#theme-switch .moon-icon { display: none; }
html.dark-mode #theme-switch .sun-icon { display: none; }
html.dark-mode #theme-switch .moon-icon { display: block; }

/* Search */
.search-container {
  width: 100%;
  max-width: 680px;
  margin: 0 auto;
  position: relative;
}

.search-box {
  background: var(--background-secondary-translucent);
  backdrop-filter: blur(30px);
  -webkit-backdrop-filter: blur(30px);
  border: 1px solid var(--border-color);
  border-radius: 34px;
  box-shadow: 0 8px 32px var(--shadow-color);
  display: flex;
  align-items: center;
  padding: 6px;
  position: relative;
  width: 100%;
  transition: background-color 0.3s ease, border-color 0.3s ease;
}

.search-input {
  background: transparent;
  border: none;
  padding: 14px 24px;
  font-size: 18px;
  width: 100%;
  color: var(--text-primary);
  flex-grow: 1;
  outline: none;
}

.search-input::placeholder {
  color: var(--text-tertiary);
  font-weight: 400;
  font-size: 18px;
}

.search-input:focus {
  outline: none;
}

.search-btn {
  background: var(--background-secondary);
  border: 0.5px solid var(--border-color);
  color: var(--accent-primary);
  font-size: 17px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  width: 48px;
  height: 48px;
  min-width: 48px;
  box-shadow: 0 4px 12px var(--button-shadow);
  transition: background-color 0.2s ease, border-color 0.2s ease, box-shadow 0.2s ease;
}

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

.suggestions {
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  right: 0;
  background: var(--background-secondary-translucent);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-radius: 18px;
  box-shadow: 0 8px 32px var(--shadow-color);
  border: 1px solid var(--border-color);
  z-index: 100;
  overflow: hidden;
  display: none;
  transition: background-color 0.3s ease, border-color 0.3s ease;
}

.suggestion-item {
  padding: 14px 24px;
  cursor: pointer;
  transition: background-color 0.2s ease;
  font-size: 17px;
  color: var(--text-primary);
}

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

.suggestion-item:not(:last-child) {
  border-bottom: 1px solid var(--border-color);
}

/* Results */
.result-section {
  width: 100%;
  max-width: 680px;
  margin: 32px auto 0 auto;
  background: var(--background-secondary-translucent);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-radius: 18px;
  padding: 28px 24px;
  box-shadow: 0 4px 24px var(--shadow-color);
  display: none;
  transition: background-color 0.3s ease;
}

.result-section.active {
  display: block;
}

#resultContent > div:last-child {
  border-bottom: none;
  padding-bottom: 0;
}

.entry-container:not(:last-child) {
    margin-bottom: 32px;
    padding-bottom: 32px;
    border-bottom: 1px solid var(--border-color);
}

.word-header {
  margin-bottom: 2rem;
}

.word-title {
  font-size: 2rem;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 1rem;
}

.part-of-speech {
  display: inline-block;
  padding: 6px 18px;
  background: var(--background-tertiary);
  border-radius: 24px;
  font-size: 16px;
  color: var(--text-secondary);
  transition: background-color 0.3s ease, color 0.3s ease;
}

/* Definition Block */
.definitions-container {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  width: 100%;
}

.definition-block {
  background: var(--background-secondary);
  padding: 1.5rem;
  border-radius: 12px;
  border: 1px solid var(--border-color);
  transition: background-color 0.3s ease, border-color 0.3s ease;
}

.definition-header {
  display: flex;
  align-items: center;
  margin-bottom: 0.75rem;
}

.definition-number {
  font-size: 1rem;
  font-weight: 700;
  color: var(--text-secondary);
  background-color: var(--background-tertiary);
  border-radius: 6px;
  padding: 4px 8px;
  margin-right: 12px;
  transition: background-color 0.3s ease, color 0.3s ease;
}

.definition-content {
  color: var(--text-primary);
  line-height: 1.7;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.english-section {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-bottom: 1.25rem;
}

.synonyms, .antonyms {
  margin-top: 1.25rem;
}

.synonym {
  display: inline-block;
  color: var(--accent-primary);
  text-decoration: none;
  margin-right: 0.5rem;
  cursor: pointer;
}

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

.synonym.has-marker {
  margin-right: 0.1rem;
}

.markers {
  display: inline;
  margin-left: 0.25rem;
}

.marker {
  font-style: italic;
  color: var(--text-secondary);
  font-size: 0.9em;
  display: inline-block;
  margin: 0 0.3rem;
  padding: 0.2rem 0.5rem;
  border-radius: 4px;
}

.marker.informal {
  background: rgba(255, 193, 7, 0.2);
  color: #856404;
}
body.dark-mode .marker.informal {
    background: rgba(255, 204, 0, 0.2);
    color: #ffcc00;
}

.marker.british {
  background: rgba(0, 123, 255, 0.2);
  color: #004085;
}
body.dark-mode .marker.british {
    background: rgba(10, 132, 255, 0.2);
    color: #0a84ff;
}

.marker.archaic {
  background: rgba(108, 117, 125, 0.2);
  color: #383d41;
}
body.dark-mode .marker.archaic {
    background: rgba(142, 142, 147, 0.2);
    color: #8e8e93;
}

.example {
  margin-top: 1rem;
  padding: 12px 16px;
  border-radius: 10px;
  background-color: var(--background-quaternary);
  color: var(--text-secondary);
  transition: background-color 0.3s ease;
  font-style: italic;
}

.example i {
  font-style: normal;
  color: var(--text-primary);
}

.antonyms-label {
  font-weight: bold;
  font-size: 0.9rem;
  text-transform: uppercase;
  color: #ff3b30;
  letter-spacing: 0.5px;
  margin-right: 0.5rem;
}

.vietnamese-section {
  margin-top: 1rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border-color);
  transition: border-color 0.3s ease;
}

.vietnamese-label {
  font-weight: bold;
  color: var(--text-secondary);
  margin-bottom: 0.5rem;
}

.vietnamese-content {
  color: var(--text-primary);
  font-weight: 500;
}

/* Phrases Section */
.phrases-section {
  margin-top: 32px;
  padding-top: 24px;
  border-top: 1px solid var(--border-color);
  transition: border-color 0.3s ease;
}

.phrases-section h3 {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 20px;
  transition: color 0.3s ease;
}

.phrase-block {
  /* This class receives .definition-block styles from script.js */
}

.phrase-title-header {
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 8px;
    display: block;
}

.phrases-content {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  color: var(--text-primary);
  line-height: 1.7;
}

.phrase-entry {
    /* Individual phrase entries inside phrases-content */
}

.phrase-title {
  font-weight: 500;
  /* Intentionally no color property to inherit from parent */
}

.phrase-definition {
   /* Intentionally no color property to inherit from parent */
   padding-left: 1em;
}

/* Word Links Section */
.word-links-section {
    margin-top: 32px;
    padding-top: 32px;
    border-top: 1px solid var(--border-color);
}

.word-links-section h3 {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 16px;
}

.word-link-item {
    margin-bottom: 12px;
}

.word-link-term {
    color: var(--accent-primary);
    font-weight: 500;
}

.word-link-definition {
    color: var(--text-primary);
    padding-left: 1em;
}

.word-links-footer {
    margin-top: 24px;
    font-size: 0.9rem;
    color: var(--text-secondary);
    font-style: italic;
}

/* Footer */
.footer {
  width: 100%;
  max-width: 680px;
  padding: 40px 20px 20px 20px;
  font-size: 0.9rem;
  color: var(--text-secondary);
  text-align: center;
  transition: color 0.3s ease;
}

.footer a {
  color: var(--text-secondary);
  text-decoration: none;
  font-weight: 500;
}

.footer a:hover {
  color: var(--accent-primary);
}

/* Utility */
.loading, .no-result, .error-message {
  width: 100%;
  max-width: 680px;
  margin: 32px auto 0 auto;
  padding: 24px;
  border-radius: 18px;
  text-align: center;
  color: var(--text-secondary);
  background: var(--background-secondary-translucent);
  box-shadow: 0 4px 24px var(--shadow-color);
  transition: background-color 0.3s ease, color 0.3s ease;
}

.loading, .no-result {
    display: none;
}

.loading.active, .no-result.active {
    display: block;
}

.error-message {
  color: #ff3b30;
  background-color: rgba(255, 59, 48, 0.1);
  border: 1px solid rgba(255, 59, 48, 0.2);
}

/* Media Queries */
@media (max-width: 700px) {
  .app-wrapper {
    padding-top: 6rem;
  }
  .container {
    padding: 0 15px;
    gap: 24px;
  }
  .search-container, .result-section, .loading, .footer {
    max-width: 100%;
  }
  .result-section, .loading, .no-result, .error-message {
    padding: 0 10px;
  }
  .search-input {
    font-size: 16px;
    padding: 12px 18px;
  }
  .search-input::placeholder {
    font-size: 16px;
  }
  .search-btn {
    height: 48px;
    width: 48px;
  }
  .search-btn .fa-search {
    font-size: 18px;
  }
  .suggestion-item {
    padding: 12px 15px;
  }
  .footer {
    padding: 24px 15px 48px;
    font-size: 0.8rem;
  }
  .home-btn, .theme-switch-wrapper {
    top: 1.5rem;
  }
  .home-btn {
    left: 1rem;
  }
  .theme-switch-wrapper {
    right: 1rem;
  }
  .word-header h2 {
    font-size: 1.8rem;
  }
  .title {
    font-size: 1.5rem;
  }
  .title .fa-book {
    margin-right: 8px;
    font-size: 1.3rem;
  }
  .subtitle {
    font-size: 0.9rem;
  }
}

/* Ghi đè để sửa lỗi màu nút Home - Có thể không cần nữa nhưng giữ lại để chắc chắn */
.home-btn i {
    color: var(--text-primary) !important;
} 