/* Custom CSS for Financial Glossary App */

:root {
  /* Color Palette */
  --primary-color: #2196F3;
  --success-color: #4CAF50;
  --warning-color: #FFC107;
  --danger-color: #F44336;
  --purple-color: #9C27B0;
  
  /* Light Theme */
  --bg-color: #ffffff;
  --text-color: #333333;
  --card-bg: #ffffff;
  --border-color: #e0e0e0;
  --shadow: 0 2px 10px rgba(0,0,0,0.1);
  
  /* Spacing */
  --header-height: 76px;
  --footer-height: 100px;
}

/* Dark Theme Variables */
[data-theme="dark"] {
  --bg-color: #121212;
  --text-color: #ffffff;
  --card-bg: #1e1e1e;
  --border-color: #333333;
  --shadow: 0 2px 10px rgba(0,0,0,0.3);
}

/* Base Styles */
* {
  box-sizing: border-box;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background-color: var(--bg-color);
  color: var(--text-color);
  transition: background-color 0.3s ease, color 0.3s ease;
  padding-top: var(--header-height);
  padding-bottom: var(--footer-height);
}

/* Navigation Styles */
.navbar {
  box-shadow: var(--shadow);
  backdrop-filter: blur(10px);
}

.navbar-brand {
  font-size: 1.5rem;
}

/* Main Content */
.main-content {
  min-height: calc(100vh - var(--header-height) - var(--footer-height));
  padding: 2rem 0;
}

/* Search Container */
.search-container {
  position: relative;
  max-width: 600px;
  margin: 0 auto;
}

.search-suggestions {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  background: var(--card-bg);
  border: 1px solid var(--border-color);
  border-top: none;
  border-radius: 0 0 0.5rem 0.5rem;
  box-shadow: var(--shadow);
  z-index: 1000;
  max-height: 300px;
  overflow-y: auto;
  display: none;
}

.search-suggestion-item {
  padding: 0.75rem 1rem;
  cursor: pointer;
  border-bottom: 1px solid var(--border-color);
  transition: background-color 0.2s ease;
}

.search-suggestion-item:hover {
  background-color: rgba(33, 150, 243, 0.1);
}

.search-suggestion-item:last-child {
  border-bottom: none;
}

/* Popular Terms */
.popular-terms {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.popular-term {
  background: linear-gradient(45deg, var(--primary-color), var(--purple-color));
  color: white;
  padding: 0.5rem 1rem;
  border-radius: 25px;
  text-decoration: none;
  font-size: 0.9rem;
  font-weight: 500;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
  cursor: pointer;
  border: none;
}

.popular-term:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 15px rgba(33, 150, 243, 0.3);
  color: white;
}

/* Terms Container */
.terms-container {
  display: grid;
  gap: 1.5rem;
}

/* Alphabet Section */
.alphabet-section {
  margin-bottom: 2rem;
}

.alphabet-header {
  background: linear-gradient(135deg, var(--primary-color), var(--success-color));
  color: white;
  padding: 1rem;
  border-radius: 0.5rem;
  margin-bottom: 1rem;
  text-align: center;
  font-size: 1.5rem;
  font-weight: bold;
  box-shadow: var(--shadow);
}

/* Term Cards */
.term-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 1rem;
}

.term-card {
  background: var(--card-bg);
  border: 1px solid var(--border-color);
  border-radius: 0.75rem;
  padding: 1.5rem;
  transition: all 0.3s ease;
  cursor: pointer;
  box-shadow: var(--shadow);
  position: relative;
  overflow: hidden;
}

.term-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 4px;
  height: 100%;
  background: linear-gradient(to bottom, var(--primary-color), var(--success-color));
  transition: width 0.3s ease;
}

.term-card:hover {
  transform: translateY(-5px);
  box-shadow: 0 8px 25px rgba(0,0,0,0.15);
}

.term-card:hover::before {
  width: 8px;
}

.term-title {
  font-size: 1.25rem;
  font-weight: 600;
  margin-bottom: 0.5rem;
  color: var(--primary-color);
}

.term-category {
  display: inline-block;
  background: var(--warning-color);
  color: #333;
  padding: 0.25rem 0.75rem;
  border-radius: 15px;
  font-size: 0.8rem;
  font-weight: 500;
  margin-bottom: 0.75rem;
}

.term-preview {
  color: var(--text-color);
  opacity: 0.8;
  line-height: 1.5;
  margin-bottom: 1rem;
}

.term-actions {
  display: flex;
  gap: 0.5rem;
  margin-top: 1rem;
}

.term-action-btn {
  background: none;
  border: 1px solid var(--border-color);
  padding: 0.5rem;
  border-radius: 0.375rem;
  cursor: pointer;
  transition: all 0.2s ease;
  color: var(--text-color);
}

.term-action-btn:hover {
  background: var(--primary-color);
  color: white;
  border-color: var(--primary-color);
}

/* Offcanvas Styles */
.offcanvas {
  background: var(--card-bg);
  color: var(--text-color);
}

.offcanvas-header {
  border-bottom: 1px solid var(--border-color);
}

.list-group-item {
  background: var(--card-bg);
  color: var(--text-color);
  border-color: var(--border-color);
}

.list-group-item.active {
  background: var(--primary-color);
  border-color: var(--primary-color);
}

/* Recent Terms */
.recent-terms {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.recent-term {
  background: var(--card-bg);
  border: 1px solid var(--border-color);
  padding: 0.75rem;
  border-radius: 0.5rem;
  cursor: pointer;
  transition: background-color 0.2s ease;
  text-decoration: none;
  color: var(--text-color);
}

.recent-term:hover {
  background: rgba(33, 150, 243, 0.1);
  color: var(--text-color);
}

/* Modal Styles */
.modal-content {
  background: var(--card-bg);
  color: var(--text-color);
  border: 1px solid var(--border-color);
}

.modal-header {
  border-bottom: 1px solid var(--border-color);
}

.modal-footer {
  border-top: 1px solid var(--border-color);
}

/* Term Detail in Modal */
.term-definition {
  font-size: 1.1rem;
  line-height: 1.6;
  margin-bottom: 1.5rem;
}

.term-examples {
  background: rgba(33, 150, 243, 0.1);
  padding: 1rem;
  border-radius: 0.5rem;
  margin: 1rem 0;
}

.related-terms {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 1rem;
}

.related-term {
  background: var(--success-color);
  color: white;
  padding: 0.25rem 0.75rem;
  border-radius: 15px;
  font-size: 0.9rem;
  text-decoration: none;
  transition: opacity 0.2s ease;
}

.related-term:hover {
  opacity: 0.8;
  color: white;
}

/* Advertisement Banners */
.ad-banner {
  position: fixed;
  top: 50%;
  right: 20px;
  width: 160px;
  height: 600px;
  background: var(--card-bg);
  border: 2px dashed var(--border-color);
  border-radius: 0.5rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  z-index: 100;
  transform: translateY(-50%);
}

.mobile-ad-banner {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: 60px;
  background: var(--card-bg);
  border-top: 2px dashed var(--border-color);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}

.ad-placeholder {
  text-align: center;
  color: var(--text-color);
  opacity: 0.5;
}

.ad-placeholder i {
  font-size: 2rem;
  margin-bottom: 0.5rem;
}

/* Footer */
.footer {
  background: #212529 !important;
  margin-top: auto;
}

.footer a {
  color: #ffffff;
  text-decoration: none;
}

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

/* Loading States */
.spinner-border {
  width: 3rem;
  height: 3rem;
}

/* Responsive Design */
@media (max-width: 768px) {
  .main-content {
    padding: 1rem 0;
  }
  
  .term-grid {
    grid-template-columns: 1fr;
  }
  
  .ad-banner {
    display: none;
  }
  
  .mobile-ad-banner {
    display: flex;
  }
  
  .popular-terms {
    justify-content: center;
  }
  
  .term-card {
    padding: 1rem;
  }
  
  .alphabet-header {
    font-size: 1.25rem;
    padding: 0.75rem;
  }
}

@media (min-width: 769px) {
  .mobile-ad-banner {
    display: none;
  }
  
  body {
    padding-bottom: 0;
  }
}

@media (max-width: 576px) {
  .navbar-brand {
    font-size: 1.25rem;
  }
  
  .search-container {
    padding: 0 1rem;
  }
  
  .term-actions {
    justify-content: center;
  }
  
  .popular-term {
    font-size: 0.8rem;
    padding: 0.4rem 0.8rem;
  }
}

/* Animation Classes */
.fade-in {
  animation: fadeIn 0.5s ease-in;
}

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.slide-up {
  animation: slideUp 0.3s ease-out;
}

@keyframes slideUp {
  from {
    transform: translateY(100%);
    opacity: 0;
  }
  to {
    transform: translateY(0);
    opacity: 1;
  }
}

/* Scroll Behavior */
html {
  scroll-behavior: smooth;
}

/* Focus States for Accessibility */
.term-card:focus,
.popular-term:focus,
.recent-term:focus {
  outline: 2px solid var(--primary-color);
  outline-offset: 2px;
}

/* High Contrast Mode Support */
@media (prefers-contrast: high) {
  :root {
    --shadow: 0 2px 10px rgba(0,0,0,0.5);
  }
  
  .term-card {
    border-width: 2px;
  }
}

/* Reduced Motion Support */
@media (prefers-reduced-motion: reduce) {
  * {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
  
  html {
    scroll-behavior: auto;
  }
}

/* Print Styles */
@media print {
  .navbar,
  .offcanvas,
  .ad-banner,
  .mobile-ad-banner,
  .footer {
    display: none !important;
  }
  
  .main-content {
    padding-top: 0;
  }
  
  .term-card {
    break-inside: avoid;
    box-shadow: none;
    border: 1px solid #000;
  }
}
