﻿/* ===== CSS VARIABLES ===== */
:root {
    /* Color Palette */
    --primary-gradient: linear-gradient(135deg, #0f0c29, #302b63, #24243e);
    --glass-bg: rgba(255, 255, 255, 0.1);
    --glass-border: rgba(255, 255, 255, 0.2);
    --glass-shadow: 0 8px 32px 0 rgba(31, 38, 135, 0.37);
    --glass-shadow-hover: 0 12px 40px 0 rgba(31, 38, 135, 0.5);
    
    /* Text Colors */
    --text-primary: #ffffff;
    --text-secondary: rgba(255, 255, 255, 0.8);
    --text-muted: rgba(255, 255, 255, 0.6);
    
    /* Accent Colors */
    --accent-primary: #667eea;
    --accent-secondary: #764ba2;
    --accent-hover: #5a67d8;
    --success: #48bb78;
    --warning: #ed8936;
    --error: #f56565;
    
    /* Spacing */
    --spacing-xs: 0.5rem;
    --spacing-sm: 1rem;
    --spacing-md: 1.5rem;
    --spacing-lg: 2rem;
    --spacing-xl: 3rem;
    
    /* Border Radius */
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --radius-xl: 24px;
    
    /* Typography */
    --font-family: 'Poppins', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    --font-size-xs: 0.75rem;
    --font-size-sm: 0.875rem;
    --font-size-base: 1rem;
    --font-size-lg: 1.125rem;
    --font-size-xl: 1.25rem;
    --font-size-2xl: 1.5rem;
    --font-size-3xl: 2rem;
    
    /* Transitions */
    --transition-fast: 0.15s ease-in-out;
    --transition-base: 0.3s ease-in-out;
    --transition-slow: 0.5s ease-in-out;
  }
  
  /* ===== RESET & BASE STYLES ===== */
  * {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
  }
  
  html {
    scroll-behavior: smooth;
    font-size: 16px;
  }
  
  body {
    font-family: var(--font-family);
    font-weight: 400;
    line-height: 1.6;
    color: var(--text-primary);
    background: var(--primary-gradient);
    background-attachment: fixed;
    min-height: 100vh;
    overflow-x: hidden;
    position: relative;
  }

  /* ===== ANIMATED STAR BACKGROUND ===== */
  .stars {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: -1;
  }

  .star {
    position: absolute;
    background: white;
    border-radius: 50%;
    animation: twinkle 3s infinite;
  }

  .star:nth-child(1) { top: 10%; left: 20%; width: 2px; height: 2px; animation-delay: 0s; }
  .star:nth-child(2) { top: 20%; left: 80%; width: 1px; height: 1px; animation-delay: 1s; }
  .star:nth-child(3) { top: 30%; left: 40%; width: 3px; height: 3px; animation-delay: 2s; }
  .star:nth-child(4) { top: 40%; left: 70%; width: 1px; height: 1px; animation-delay: 0.5s; }
  .star:nth-child(5) { top: 50%; left: 10%; width: 2px; height: 2px; animation-delay: 1.5s; }
  .star:nth-child(6) { top: 60%; left: 90%; width: 1px; height: 1px; animation-delay: 2.5s; }
  .star:nth-child(7) { top: 70%; left: 30%; width: 2px; height: 2px; animation-delay: 0.8s; }
  .star:nth-child(8) { top: 80%; left: 60%; width: 1px; height: 1px; animation-delay: 1.8s; }
  .star:nth-child(9) { top: 15%; left: 50%; width: 3px; height: 3px; animation-delay: 2.2s; }
  .star:nth-child(10) { top: 25%; left: 15%; width: 1px; height: 1px; animation-delay: 0.3s; }
  .star:nth-child(11) { top: 35%; left: 85%; width: 2px; height: 2px; animation-delay: 1.2s; }
  .star:nth-child(12) { top: 45%; left: 25%; width: 1px; height: 1px; animation-delay: 2.8s; }
  .star:nth-child(13) { top: 55%; left: 75%; width: 3px; height: 3px; animation-delay: 0.7s; }
  .star:nth-child(14) { top: 65%; left: 5%; width: 1px; height: 1px; animation-delay: 1.9s; }
  .star:nth-child(15) { top: 75%; left: 95%; width: 2px; height: 2px; animation-delay: 2.3s; }
  .star:nth-child(16) { top: 85%; left: 35%; width: 1px; height: 1px; animation-delay: 0.9s; }
  .star:nth-child(17) { top: 5%; left: 65%; width: 2px; height: 2px; animation-delay: 1.6s; }
  .star:nth-child(18) { top: 95%; left: 45%; width: 1px; height: 1px; animation-delay: 2.6s; }
  .star:nth-child(19) { top: 12%; left: 8%; width: 3px; height: 3px; animation-delay: 0.4s; }
  .star:nth-child(20) { top: 88%; left: 92%; width: 1px; height: 1px; animation-delay: 1.7s; }

  @keyframes twinkle {
    0%, 100% { opacity: 0.3; transform: scale(1); }
    50% { opacity: 1; transform: scale(1.2); }
  }

  /* ===== FLOATING PARTICLES ===== */
  .particles {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: -1;
  }

  .particle {
    position: absolute;
    background: rgba(102, 126, 234, 0.6);
    border-radius: 50%;
    animation: float 6s infinite linear;
  }

  .particle:nth-child(1) { left: 10%; animation-delay: 0s; width: 4px; height: 4px; }
  .particle:nth-child(2) { left: 20%; animation-delay: 1s; width: 6px; height: 6px; }
  .particle:nth-child(3) { left: 30%; animation-delay: 2s; width: 3px; height: 3px; }
  .particle:nth-child(4) { left: 40%; animation-delay: 3s; width: 5px; height: 5px; }
  .particle:nth-child(5) { left: 50%; animation-delay: 4s; width: 4px; height: 4px; }
  .particle:nth-child(6) { left: 60%; animation-delay: 5s; width: 6px; height: 6px; }
  .particle:nth-child(7) { left: 70%; animation-delay: 0.5s; width: 3px; height: 3px; }
  .particle:nth-child(8) { left: 80%; animation-delay: 1.5s; width: 5px; height: 5px; }
  .particle:nth-child(9) { left: 90%; animation-delay: 2.5s; width: 4px; height: 4px; }

  @keyframes float {
    0% { transform: translateY(100vh) rotate(0deg); opacity: 0; }
    10% { opacity: 1; }
    90% { opacity: 1; }
    100% { transform: translateY(-100px) rotate(360deg); opacity: 0; }
  }
  
  /* ===== TYPOGRAPHY ===== */
  h1, h2, h3, h4, h5, h6 {
    font-weight: 600;
    line-height: 1.3;
    margin-bottom: var(--spacing-sm);
  }
  
  h1 {
    font-size: var(--font-size-3xl);
  }
  
  h2 {
    font-size: var(--font-size-2xl);
  }
  
  p {
    margin-bottom: var(--spacing-sm);
  }
  
  /* ===== GLASSMORPHISM UTILITY ===== */
  .glass {
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-radius: var(--radius-lg);
    box-shadow: var(--glass-shadow);
  }
  
  /* ===== HEADER STYLES ===== */
  header {
    position: sticky;
    top: 0;
    z-index: 100;
    padding: var(--spacing-md) 0;
    margin-bottom: var(--spacing-xl);
  }
  
  .header-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 var(--spacing-md);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--spacing-md);
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-radius: var(--radius-xl);
    box-shadow: var(--glass-shadow);
    padding: var(--spacing-md) var(--spacing-lg);
    transition: all var(--transition-base);
  }
  
  .header-container:hover {
    box-shadow: var(--glass-shadow-hover);
    border-color: rgba(255, 255, 255, 0.3);
  }
  
  .logo-section {
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
  }
  
  .logo-icon {
    font-size: var(--font-size-2xl);
    color: var(--accent-primary);
    filter: drop-shadow(0 2px 4px rgba(102, 126, 234, 0.3));
    animation: pulse 2s infinite;
  }

  @keyframes pulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.1); }
  }
  
  .logo-section h1 {
    font-size: var(--font-size-2xl);
    font-weight: 600;
    background: linear-gradient(135deg, var(--accent-primary), var(--accent-secondary));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin-bottom: 0;
  }
  
  /* ===== SEARCH FORM STYLES ===== */
  .search-form {
    flex: 1;
    max-width: 500px;
  }
  
  .search-input-wrapper {
    display: flex;
    gap: var(--spacing-xs);
    align-items: center;
  }
  
  #mood-search {
    flex: 1;
    padding: var(--spacing-sm) var(--spacing-md);
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-lg);
    color: var(--text-primary);
    font-family: var(--font-family);
    font-size: var(--font-size-base);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    transition: all var(--transition-base);
    outline: none;
  }
  
  #mood-search::placeholder {
    color: var(--text-muted);
  }
  
  #mood-search:focus {
    border-color: var(--accent-primary);
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.2);
    background: rgba(255, 255, 255, 0.15);
  }
  
  .search-form button {
    padding: var(--spacing-sm) var(--spacing-lg);
    background: linear-gradient(135deg, var(--accent-primary), var(--accent-secondary));
    border: none;
    border-radius: var(--radius-lg);
    color: var(--text-primary);
    font-family: var(--font-family);
    font-size: var(--font-size-base);
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition-base);
    white-space: nowrap;
    box-shadow: 0 4px 15px rgba(102, 126, 234, 0.3);
  }
  
  .search-form button:hover {
    background: linear-gradient(135deg, var(--accent-hover), var(--accent-primary));
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(102, 126, 234, 0.4);
  }
  
  .search-form button:active {
    transform: translateY(0);
  }
  
  /* ===== MAIN CONTENT ===== */
  main {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 var(--spacing-md);
    min-height: calc(100vh - 200px);
  }
  
  /* ===== LOADING SPINNER ===== */
  .loading-container {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 300px;
    text-align: center;
  }
  
  .spinner {
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-radius: var(--radius-lg);
    padding: var(--spacing-xl);
    box-shadow: var(--glass-shadow);
  }
  
  .spinner i {
    font-size: var(--font-size-3xl);
    color: var(--accent-primary);
    margin-bottom: var(--spacing-md);
    display: block;
  }
  
  .spinner p {
    color: var(--text-secondary);
    font-size: var(--font-size-lg);
    margin: 0;
  }
  
  /* ===== IMAGE GRID - FIXED ===== */
  .image-grid-container {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: var(--spacing-md);
    padding: var(--spacing-md) 0;
  }
  
  .image-card {
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-radius: var(--radius-lg);
    overflow: hidden;
    box-shadow: var(--glass-shadow);
    transition: all var(--transition-base);
    cursor: pointer;
    display: flex;
    flex-direction: column;
  }
  
  .image-card:hover {
    transform: translateY(-8px) scale(1.02);
    box-shadow: var(--glass-shadow-hover);
    border-color: rgba(255, 255, 255, 0.3);
  }
  
  .image-card img {
    width: 100%;
    height: 250px;
    object-fit: cover;
    display: block;
    transition: transform var(--transition-base);
  }
  
  .image-card:hover img {
    transform: scale(1.05);
  }
  
  .image-info {
    padding: var(--spacing-md);
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
  }
  
  .image-info h3 {
    font-size: var(--font-size-lg);
    font-weight: 600;
    margin-bottom: var(--spacing-xs);
    color: var(--text-primary);
  }
  
  .image-info p {
    font-size: var(--font-size-sm);
    color: var(--text-secondary);
    margin: 0;
  }
  
  /* ===== NO RESULTS ===== */
  .no-results-container {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 400px;
    text-align: center;
  }
  
  .no-results-content {
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-radius: var(--radius-lg);
    padding: var(--spacing-xl);
    box-shadow: var(--glass-shadow);
    max-width: 500px;
  }
  
  .no-results-content i {
    font-size: 4rem;
    color: var(--warning);
    margin-bottom: var(--spacing-md);
    display: block;
  }
  
  .no-results-content h2 {
    color: var(--text-primary);
    margin-bottom: var(--spacing-sm);
  }
  
  .no-results-content p {
    color: var(--text-secondary);
    margin-bottom: var(--spacing-lg);
  }
  
  .retry-button {
    padding: var(--spacing-sm) var(--spacing-lg);
    background: linear-gradient(135deg, var(--accent-primary), var(--accent-secondary));
    border: none;
    border-radius: var(--radius-lg);
    color: var(--text-primary);
    font-family: var(--font-family);
    font-size: var(--font-size-base);
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition-base);
    box-shadow: 0 4px 15px rgba(102, 126, 234, 0.3);
  }
  
  .retry-button:hover {
    background: linear-gradient(135deg, var(--accent-hover), var(--accent-primary));
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(102, 126, 234, 0.4);
  }
  
  /* ===== FOOTER ===== */
  footer {
    margin-top: var(--spacing-xl);
    padding: var(--spacing-xl) 0;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
  }
  
  .footer-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 var(--spacing-md);
  }
  
  .footer-content {
    text-align: center;
    color: var(--text-muted);
    font-size: var(--font-size-sm);
  }
  
  .footer-content p {
    margin-bottom: var(--spacing-xs);
  }
  
  .footer-content a {
    color: var(--accent-primary);
    text-decoration: none;
    transition: color var(--transition-fast);
  }
  
  .footer-content a:hover {
    color: var(--text-primary);
    text-decoration: underline;
  }
  
  .footer-content i {
    font-size: var(--font-size-xs);
    margin-left: var(--spacing-xs);
  }
  
  /* ===== RESPONSIVE DESIGN ===== */
  @media (max-width: 768px) {
    :root {
      --font-size-3xl: 1.75rem;
      --font-size-2xl: 1.375rem;
    }
    
    .header-container {
      flex-direction: column;
      gap: var(--spacing-md);
      padding: var(--spacing-md);
    }
    
    .search-form {
      width: 100%;
      max-width: none;
    }
    
    .search-input-wrapper {
      flex-direction: column;
      gap: var(--spacing-sm);
    }
    
    .search-form button {
      width: 100%;
    }
    
    .image-grid-container {
      grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
      gap: var(--spacing-sm);
    }
    
    main {
      padding: 0 var(--spacing-sm);
    }
  }
  
  @media (max-width: 480px) {
    .image-grid-container {
      grid-template-columns: 1fr;
      gap: var(--spacing-sm);
    }
    
    .logo-section h1 {
      font-size: var(--font-size-xl);
    }
    
    .spinner,
    .no-results-content {
      padding: var(--spacing-lg);
    }
  }
  
  /* ===== ACCESSIBILITY ===== */
  @media (prefers-reduced-motion: reduce) {
    * {
      animation-duration: 0.01ms !important;
      animation-iteration-count: 1 !important;
      transition-duration: 0.01ms !important;
    }
  }
  
  /* Focus styles for keyboard navigation */
  button:focus-visible,
  input:focus-visible {
    outline: 2px solid var(--accent-primary);
    outline-offset: 2px;
  }
  
  /* ===== SCROLL ANIMATIONS ===== */
  @keyframes fadeInUp {
    from {
      opacity: 0;
      transform: translateY(30px);
    }
    to {
      opacity: 1;
      transform: translateY(0);
    }
  }
  
  .image-card {
    animation: fadeInUp var(--transition-base) ease-out;
  }
  
  /* ===== LOADING ANIMATION ===== */
  @keyframes pulse {
    0%, 100% {
      opacity: 1;
    }
    50% {
      opacity: 0.5;
    }
  }
  
  .loading-container {
    animation: pulse 2s ease-in-out infinite;
  }
  
  /* ===== UTILITY CLASSES ===== */
  .visually-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
  }
