/* ============================================================
   File: assets/css/endemic.css
   Description: Complete standalone styles for endemic flora page
   ============================================================ */

/* ---- Variables ---- */
:root {
  --primary: #2d6a4f;
  --primary-light: #409f7a;
  --primary-dark: #1b4332;
  --secondary: #d4a373;
  --accent: #e9c46a;
  --background: #f8fafc;
  --surface: #ffffff;
  --text: #1a1a2e;
  --text-light: #4a4a6a;
  --border: #e2e8f0;
  --shadow: 0 4px 24px rgba(0, 0, 0, 0.08);
  --radius: 12px;
  --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ---- Global Reset ---- */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}
/* ============================================================
   RESPONSIVE HEADER - Desktop & Mobile Optimized
   ============================================================ */

/* Desktop: Medium header */
.hero-section {
  min-height: 50vh;
  padding: 40px 0;
}

.hero-text h1 {
  font-size: 2.8rem;
}

.hero-subtitle {
  font-size: 1.05rem;
  max-width: 480px;
}

.hero-stats {
  padding: 16px 28px;
  gap: 24px;
}

.stat-number {
  font-size: 1.5rem;
}

.hero-image svg {
  max-width: 220px;
  height: 220px;
}

/* Tablet: Smaller header */
@media (max-width: 1024px) {
  .hero-section {
    min-height: 40vh;
    padding: 30px 0;
  }
  
  .hero-text h1 {
    font-size: 2.2rem;
  }
  
  .hero-image svg {
    max-width: 180px;
    height: 180px;
  }
  
  .hero-stats {
    padding: 14px 20px;
    gap: 16px;
  }
  
  .stat-number {
    font-size: 1.3rem;
  }
}

/* Mobile: Compact header */
@media (max-width: 768px) {
  .hero-section {
    min-height: 35vh;
    padding: 20px 0;
  }
  
  .hero-text h1 {
    font-size: 1.8rem;
  }
  
  .hero-subtitle {
    font-size: 0.9rem;
  }
  
  .hero-image {
    display: none;
  }
  
  .hero-stats {
    padding: 12px 16px;
    gap: 12px;
    flex-wrap: wrap;
  }
  
  .stat-number {
    font-size: 1.1rem;
  }
  
  .stat-label {
    font-size: 0.6rem;
  }
  
  .scroll-indicator {
    display: none;
  }
}

/* Small mobile: Very compact */
@media (max-width: 480px) {
  .hero-section {
    min-height: 30vh;
    padding: 15px 0;
  }
  
  .hero-text h1 {
    font-size: 1.4rem;
  }
  
  .hero-badge {
    font-size: 0.6rem;
    padding: 3px 10px;
    margin-bottom: 8px;
  }
  
  .hero-subtitle {
    font-size: 0.8rem;
    margin-bottom: 10px;
  }
  
  .hero-stats {
    padding: 10px 12px;
    gap: 8px;
  }
  
  .stat-number {
    font-size: 0.9rem;
  }
}
body {
  font-family: 'Segoe UI', -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--background);
  color: var(--text);
  line-height: 1.6;
}

.container {
  max-width: 1280px;
  margin: 0 auto;
  padding: 0 24px;
}

/* ---- Section Headers ---- */
.section-header {
  text-align: center;
  margin-bottom: 48px;
}

.section-header h2 {
  font-size: 2.25rem;
  font-weight: 700;
  color: var(--primary-dark);
  margin-bottom: 8px;
}

.section-header p {
  color: var(--text-light);
  font-size: 1.1rem;
}

/* ============================================================
   BREADCRUMB
   ============================================================ */
.breadcrumb {
  padding: 16px 0;
  font-size: 0.9rem;
  color: var(--text-light);
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}

.breadcrumb a {
  color: var(--primary);
  text-decoration: none;
}

.breadcrumb a:hover {
  text-decoration: underline;
}

.breadcrumb span {
  margin: 0 4px;
}

/* ============================================================
   HERO SECTION
   ============================================================ */
.hero-section {
  position: relative;
  min-height: 70vh;
  background: linear-gradient(135deg, #1b4332 0%, #2d6a4f 50%, #409f7a 100%);
  display: flex;
  align-items: center;
  padding: 60px 0;
  overflow: hidden;
}

.hero-overlay {
  position: absolute;
  inset: 0;
  background: 
    radial-gradient(ellipse at 20% 80%, rgba(233, 196, 106, 0.15) 0%, transparent 60%),
    radial-gradient(ellipse at 80% 20%, rgba(45, 106, 79, 0.3) 0%, transparent 50%);
  pointer-events: none;
}

.hero-content {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 60px;
  align-items: center;
  width: 100%;
  max-width: 1280px;
  margin: 0 auto;
  padding: 0 24px;
}

.hero-text {
  color: #fff;
}

.hero-badge {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  background: rgba(255, 255, 255, 0.15);
  backdrop-filter: blur(8px);
  padding: 8px 20px;
  border-radius: 50px;
  font-size: 0.875rem;
  letter-spacing: 0.5px;
  margin-bottom: 24px;
  border: 1px solid rgba(255, 255, 255, 0.1);
}

.hero-badge i {
  color: var(--accent);
}

.hero-text h1 {
  font-size: 3.5rem;
  font-weight: 800;
  line-height: 1.1;
  margin-bottom: 16px;
  background: linear-gradient(to right, #ffffff, #e9c46a);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.hero-subtitle {
  font-size: 1.2rem;
  color: rgba(255, 255, 255, 0.8);
  max-width: 500px;
  margin-bottom: 32px;
  line-height: 1.7;
}

.hero-stats {
  display: flex;
  align-items: center;
  gap: 32px;
  background: rgba(255, 255, 255, 0.08);
  backdrop-filter: blur(12px);
  padding: 20px 32px;
  border-radius: var(--radius);
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.stat-item {
  text-align: center;
}

.stat-number {
  font-size: 1.75rem;
  font-weight: 700;
  color: #fff;
  display: block;
}

.stat-label {
  font-size: 0.8rem;
  color: rgba(255, 255, 255, 0.7);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.stat-divider {
  color: rgba(255, 255, 255, 0.2);
  font-size: 1.5rem;
}

.hero-image {
  display: flex;
  justify-content: center;
  align-items: center;
}

.hero-image svg {
  max-width: 100%;
  height: auto;
  filter: drop-shadow(0 20px 40px rgba(0, 0, 0, 0.3));
  animation: float 6s ease-in-out infinite;
}

@keyframes float {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-16px); }
}

/* Scroll Indicator */
.scroll-indicator {
  position: absolute;
  bottom: 32px;
  left: 50%;
  transform: translateX(-50%);
  color: rgba(255, 255, 255, 0.6);
  font-size: 0.8rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  animation: bounce 2s infinite;
}

@keyframes bounce {
  0%, 100% { transform: translateX(-50%) translateY(0); }
  50% { transform: translateX(-50%) translateY(8px); }
}

/* ============================================================
   SEARCH SECTION
   ============================================================ */
.search-section {
  padding: 60px 0 40px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}

.search-container {
  max-width: 900px;
  margin: 0 auto;
  position: relative;
}

.search-main {
  display: flex;
  align-items: center;
  gap: 16px;
  background: var(--background);
  border-radius: var(--radius);
  padding: 4px 4px 4px 20px;
  border: 2px solid var(--border);
  transition: border-color 0.3s;
}

.search-main:focus-within {
  border-color: var(--primary);
}

.search-icon {
  color: var(--text-light);
  font-size: 1.1rem;
}

.search-main input {
  flex: 1;
  border: none;
  background: transparent;
  padding: 14px 0;
  font-size: 1rem;
  color: var(--text);
  outline: none;
}

.search-main input::placeholder {
  color: #a0aec0;
}

.btn {
  padding: 12px 28px;
  border-radius: var(--radius);
  font-weight: 600;
  border: none;
  cursor: pointer;
  transition: var(--transition);
  font-size: 0.95rem;
}

.btn-primary {
  background: var(--primary);
  color: #fff;
}

.btn-primary:hover {
  background: var(--primary-dark);
  transform: scale(1.02);
}

.btn-outline {
  background: transparent;
  color: var(--text);
  border: 1px solid var(--border);
}

.btn-outline:hover {
  background: var(--background);
  border-color: var(--primary);
}

/* Search Filters */
.search-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 16px;
  align-items: flex-end;
}

.filter-group {
  flex: 1;
  min-width: 140px;
}

.filter-group label {
  display: block;
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  font-weight: 600;
  color: var(--text-light);
  margin-bottom: 4px;
}

.filter-group select {
  width: 100%;
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  font-size: 0.9rem;
  color: var(--text);
  cursor: pointer;
  transition: var(--transition);
}

.filter-group select:focus {
  outline: none;
  border-color: var(--primary);
}

/* Autocomplete */
.autocomplete-results {
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  right: 0;
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
  max-height: 300px;
  overflow-y: auto;
  display: none;
  z-index: 100;
}

.autocomplete-results.show {
  display: block;
}

.autocomplete-item {
  padding: 12px 20px;
  cursor: pointer;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid var(--border);
  transition: var(--transition);
}

.autocomplete-item:hover {
  background: var(--background);
}

.autocomplete-item .name {
  font-weight: 500;
}

.autocomplete-item .meta {
  font-size: 0.8rem;
  color: var(--text-light);
}

/* ============================================================
   RESULTS SECTION
   ============================================================ */
.results-section {
  padding: 40px 0 60px;
}

.results-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 24px;
  flex-wrap: wrap;
  gap: 16px;
}

.results-left h3 {
  font-size: 1.25rem;
  font-weight: 600;
}

.result-count {
  color: var(--text-light);
  font-weight: 400;
  margin-left: 8px;
}

.view-toggle {
  display: flex;
  gap: 4px;
  background: var(--background);
  padding: 4px;
  border-radius: 8px;
}

.view-btn {
  padding: 8px 12px;
  border: none;
  background: transparent;
  border-radius: 6px;
  cursor: pointer;
  color: var(--text-light);
  transition: var(--transition);
}

.view-btn.active {
  background: var(--surface);
  color: var(--primary);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
}

.view-btn:hover:not(.active) {
  color: var(--text);
}

/* Loading */
.loading-indicator {
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 60px 0;
  gap: 16px;
}

.loading-indicator.active {
  display: flex;
}

.spinner {
  width: 40px;
  height: 40px;
  border: 4px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* Results Container */
.results-container {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
}

.results-container.grid-view {
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
}

.results-container.map-view {
  display: block;
  height: 600px;
}

/* List Item */
.result-item {
  display: grid;
  grid-template-columns: 40px 3fr 2fr 1.5fr auto;
  align-items: center;
  gap: 16px;
  padding: 16px 20px;
  background: var(--surface);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  transition: var(--transition);
  cursor: pointer;
}

.result-item:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow);
  border-color: var(--primary-light);
}

.result-index {
  color: var(--text-light);
  font-size: 0.8rem;
  font-weight: 500;
}

.result-name {
  font-weight: 600;
}

.result-name .genus {
  color: var(--primary);
}

.result-name .species {
  font-style: italic;
}

.result-family {
  color: var(--text-light);
  font-size: 0.9rem;
}

.result-meta {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.result-badge {
  font-size: 0.65rem;
  padding: 2px 10px;
  border-radius: 50px;
  font-weight: 500;
  text-transform: uppercase;
  white-space: nowrap;
}

.badge-narrow {
  background: #fee2e2;
  color: #dc2626;
}

.badge-medium {
  background: #fef3c7;
  color: #d97706;
}

.badge-wide {
  background: #d1fae5;
  color: #059669;
}

.badge-iucn {
  background: #e0e7ff;
  color: #4f46e5;
}

.badge-neutral {
  background: #f3f4f6;
  color: #6b7280;
}

.result-link {
  color: var(--primary);
}

.result-link i {
  font-size: 0.9rem;
  transition: var(--transition);
}

.result-item:hover .result-link i {
  transform: translateX(4px);
}

/* Grid Item */
.grid-item {
  background: var(--surface);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  padding: 20px;
  transition: var(--transition);
  cursor: pointer;
}

.grid-item:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow);
}

.grid-item .header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 8px;
}

.grid-item .name {
  font-weight: 600;
  font-size: 1.05rem;
}

.grid-item .name .species {
  font-style: italic;
}

.grid-item .family {
  color: var(--text-light);
  font-size: 0.85rem;
}

.grid-item .badges {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin-top: 12px;
}

.grid-item .badge {
  font-size: 0.65rem;
  padding: 2px 10px;
  border-radius: 50px;
  background: var(--background);
  color: var(--text-light);
}

/* Empty State */
.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-light);
}

.empty-state i {
  font-size: 3rem;
  color: var(--border);
  margin-bottom: 16px;
}

.empty-state h3 {
  font-size: 1.25rem;
  color: var(--text);
  margin-bottom: 8px;
}

/* Error Message */
.error-message {
  text-align: center;
  padding: 40px 20px;
  color: #dc2626;
}

.error-message i {
  font-size: 2rem;
  margin-bottom: 12px;
}

.error-detail {
  font-size: 0.85rem;
  color: var(--text-light);
  margin-top: 8px;
}

/* ============================================================
   PAGINATION
   ============================================================ */
.pagination-container {
  display: flex;
  justify-content: center;
  gap: 6px;
  margin-top: 32px;
  flex-wrap: wrap;
}

.pagination-btn {
  padding: 8px 14px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
  transition: var(--transition);
  font-size: 0.9rem;
}

.pagination-btn:hover:not(.active):not(.disabled) {
  background: var(--background);
}

.pagination-btn.active {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
}

.pagination-btn.disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.pagination-ellipsis {
  padding: 8px 4px;
  color: var(--text-light);
}

/* ============================================================
   STATISTICS SECTION
   ============================================================ */
.stats-section {
  padding: 60px 0;
  background: var(--surface);
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 24px;
}

.stat-card {
  background: var(--background);
  padding: 24px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
}

.stat-card h4 {
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-light);
  margin-bottom: 12px;
}

.stat-card h4 i {
  margin-right: 8px;
  color: var(--primary);
}

.stat-card .stat-list {
  list-style: none;
}

.stat-card .stat-list li {
  display: flex;
  justify-content: space-between;
  padding: 6px 0;
  border-bottom: 1px solid var(--border);
  font-size: 0.9rem;
}

.stat-card .stat-list li:last-child {
  border-bottom: none;
}

.stat-card .stat-list .value {
  font-weight: 600;
  color: var(--primary);
}

/* ============================================================
   MODAL
   ============================================================ */
.modal {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(4px);
  z-index: 1000;
  justify-content: center;
  align-items: center;
  padding: 20px;
}

.modal.show {
  display: flex;
}

.modal-content {
  background: var(--surface);
  border-radius: var(--radius);
  max-width: 900px;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  padding: 40px;
  position: relative;
  animation: modalIn 0.3s ease;
}

@keyframes modalIn {
  from { opacity: 0; transform: scale(0.95) translateY(20px); }
  to { opacity: 1; transform: scale(1) translateY(0); }
}

.modal-close {
  position: absolute;
  top: 16px;
  right: 20px;
  font-size: 1.5rem;
  cursor: pointer;
  color: var(--text-light);
  transition: var(--transition);
}

.modal-close:hover {
  color: var(--text);
}

.modal-header {
  margin-bottom: 24px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--border);
}

.modal-header h2 {
  font-size: 1.5rem;
  font-weight: 700;
}

.modal-header h2 em {
  font-style: italic;
}

.modal-family {
  color: var(--text-light);
  font-size: 1rem;
}

.modal-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px;
}

.modal-section h4 {
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-light);
  margin-bottom: 12px;
  border-bottom: 1px solid var(--border);
  padding-bottom: 8px;
}

.modal-section h4 i {
  margin-right: 8px;
  color: var(--primary);
}

.modal-section dl {
  display: grid;
  grid-template-columns: 1fr 2fr;
  gap: 4px 12px;
  font-size: 0.9rem;
}

.modal-section dt {
  color: var(--text-light);
  font-weight: 500;
}

.modal-section dd {
  margin: 0;
  word-break: break-word;
}

.modal-section dd a {
  color: var(--primary);
  text-decoration: none;
}

.modal-section dd a:hover {
  text-decoration: underline;
}

.type-locality {
  font-style: italic;
  font-size: 0.85rem;
}

.modal-footer {
  margin-top: 24px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
  font-size: 0.85rem;
  color: var(--text-light);
}

/* ============================================================
   FOOTER
   ============================================================ */
.site-footer {
  background: var(--primary-dark);
  color: rgba(255, 255, 255, 0.8);
  padding: 40px 0;
  margin-top: 40px;
}

.footer-content {
  display: grid;
  grid-template-columns: 2fr 1fr 1fr;
  gap: 40px;
}

.footer-info h3 {
  color: #fff;
  font-size: 1.25rem;
  margin-bottom: 8px;
}

.footer-info p {
  font-size: 0.9rem;
  line-height: 1.6;
}

.footer-copyright {
  margin-top: 12px;
  font-size: 0.8rem;
  opacity: 0.6;
}

.footer-links {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.footer-links a {
  color: rgba(255, 255, 255, 0.7);
  text-decoration: none;
  transition: var(--transition);
}

.footer-links a:hover {
  color: #fff;
}

.footer-resources {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.footer-resources span {
  font-weight: 500;
  color: #fff;
}

.footer-resources a {
  color: rgba(255, 255, 255, 0.7);
  text-decoration: none;
  transition: var(--transition);
}

.footer-resources a:hover {
  color: #fff;
}

/* ============================================================
   RESPONSIVE
   ============================================================ */
@media (max-width: 1024px) {
  .hero-content {
    grid-template-columns: 1fr;
    text-align: center;
  }
  
  .hero-text h1 {
    font-size: 2.5rem;
  }
  
  .hero-subtitle {
    max-width: 100%;
  }
  
  .hero-stats {
    justify-content: center;
  }
  
  .hero-image {
    display: none;
  }
}

@media (max-width: 768px) {
  .hero-text h1 {
    font-size: 1.8rem;
  }
  
  .hero-stats {
    flex-wrap: wrap;
    gap: 16px;
    padding: 16px;
  }
  
  .stat-divider {
    display: none;
  }
  
  .stat-number {
    font-size: 1.25rem;
  }
  
  .search-main {
    flex-wrap: wrap;
    padding: 12px;
  }
  
  .search-main input {
    width: 100%;
    padding: 10px 0;
  }
  
  .search-main .btn {
    width: 100%;
  }
  
  .search-filters {
    flex-direction: column;
  }
  
  .filter-group {
    min-width: 100%;
  }
  
  .result-item {
    grid-template-columns: 1fr;
    gap: 8px;
    padding: 16px;
  }
  
  .result-index {
    display: none;
  }
  
  .results-header {
    flex-direction: column;
    align-items: flex-start;
  }
  
  .modal-content {
    padding: 24px;
  }
  
  .modal-grid {
    grid-template-columns: 1fr;
  }
  
  .footer-content {
    grid-template-columns: 1fr;
    gap: 24px;
  }
}

@media (max-width: 480px) {
  .container {
    padding: 0 16px;
  }
  
  .section-header h2 {
    font-size: 1.5rem;
  }
  
  .results-container.grid-view {
    grid-template-columns: 1fr;
  }
}

/* ============================================================
   PRINT STYLES
   ============================================================ */
@media print {
  .hero-section {
    min-height: auto;
    padding: 40px 0;
    background: #fff !important;
    color: #000 !important;
  }
  
  .hero-text h1 {
    -webkit-text-fill-color: #000 !important;
  }
  
  .hero-stats {
    background: #f0f0f0 !important;
  }
  
  .stat-number {
    color: #000 !important;
  }
  
  .search-section,
  .scroll-indicator,
  .view-toggle,
  .result-link {
    display: none !important;
  }
  
  .result-item {
    break-inside: avoid;
    border: 1px solid #ddd !important;
  }
  
  .modal {
    position: static !important;
    background: none !important;
    backdrop-filter: none !important;
    display: block !important;
  }
  
  .modal-content {
    box-shadow: none !important;
    border: 1px solid #ddd !important;
    max-height: none !important;
  }
  
  .modal-close {
    display: none !important;
  }
  
  .site-footer {
    background: #f0f0f0 !important;
    color: #000 !important;
    padding: 20px 0 !important;
  }
  
  .site-footer a {
    color: #000 !important;
  }
}