/* ============================================================================
   CUSTOM STYLES FOR EUGENE THE AI SEA COW
   ============================================================================
   
   This file contains custom CSS styles that override and extend Pico CSS.
   Pico CSS is a minimal CSS framework that provides nice default styles.
   
   We customize it in two ways:
   1. CSS Custom Properties (variables) - Override Pico's default values
   2. Component-specific styles - Add our own styles for chat interface
   
   Learn more about Pico CSS customization:
   https://picocss.com/docs/customize/css-custom-properties
*/


/* ============================================================================
   1. CSS CUSTOM PROPERTIES (VARIABLES)
   ============================================================================
   
   These variables override Pico CSS defaults. By using variables, we can
   easily change the look of the entire site by modifying just a few values.
   
   The :root selector means these variables are available everywhere in the CSS.
*/

:root {
  /* Base font size for the entire site */
  /* 16px is a good default for readability */
  --pico-font-size: 16px;
  
  /* Border radius for rounded corners on buttons, inputs, etc. */
  /* Smaller values = sharper corners, larger values = rounder corners */
  --pico-border-radius: 0.25rem;
  --border-radius-card: 0.3rem; /* For containers, cards, and chat area */
  --border-radius-pill: 0.25rem;   /* For pill-shaped elements (buttons, inputs, bubbles) */
  
  /* Professional color palette with ocean accents */
  --primary-color: #0f172a;
  --primary-hover: #1e293b;
  --accent-color: #0891b2; /* Cyan/ocean accent */
  --accent-light: #06b6d4;
  --secondary-color: #64748b;
  --background-light: #f0f9ff; /* Light cyan tint */
  --border-color: #e0f2fe;
  --text-dark: #1e293b;
  --text-muted: #64748b;
}


/* ============================================================================
   2. LAYOUT STYLES
   ============================================================================
   
   These styles control the overall page layout and structure.
*/

/* Page background - ocean-inspired gradient with depth */
html,
body {
  padding: 0;
  background: linear-gradient(135deg, #e0f2fe 0%, #bae6fd 25%, #7dd3fc 50%, #38bdf8 75%, #0ea5e9 100%);
  background-attachment: fixed;
  min-height: 100vh;
}

/* Main container that holds all content */
.container {
  max-width: 900px;
  margin: 1.5rem auto 2rem auto;
  padding: 1.5rem;
  background-color: #fff;
  border-radius: var(--border-radius-card);
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.15), 
              0 10px 30px rgba(14, 165, 233, 0.2);
  backdrop-filter: blur(10px);
}

/* Page header block */
.header {
  text-align: center;
  margin: -2.5rem -2.5rem 2rem -2.5rem;
  padding: .75rem 2.5rem 1rem 2.5rem;
  position: relative;
  background: linear-gradient(180deg, rgba(14, 165, 233, 0.08) 0%, rgba(14, 165, 233, 0.03) 100%);
  border-bottom: 3px solid;
  border-image: linear-gradient(90deg, transparent 10%, var(--accent-color) 50%, transparent 90%) 1;
  box-shadow: 0 2px 8px rgba(14, 165, 233, 0.05);
}

.header__logo {
  font-size: 2.75rem;
  margin-bottom: 0.25rem;
  animation: float 3s ease-in-out infinite;
  display: inline-block;
  filter: drop-shadow(0 3px 6px rgba(14, 165, 233, 0.25));
}

@keyframes float {
  0%, 100% { 
    transform: translateY(0px) rotate(-2deg); 
  }
  50% { 
    transform: translateY(-8px) rotate(2deg); 
  }
}

.header__title {
  margin-bottom: 0.35rem;
  background: linear-gradient(135deg, var(--primary-color) 0%, var(--accent-color) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  font-size: 1.75rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.2;
}

.header__subtitle {
  color: var(--secondary-color);
  font-size: 0.875rem;
  margin: 0;
  font-weight: 400;
  line-height: 1.4;
  opacity: 0.85;
}


/* ============================================================================
   3. CONTROLS (MODEL & SOURCE SELECTORS)
   ============================================================================
   
   Dropdowns for selecting AI model and data source.
*/

.controls {
  margin: 1rem 0 1.5rem 0;
  display: flex;
  gap: 1.5rem;
  justify-content: flex-end;
  align-items: center;
}

.dropdown {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.dropdown__label {
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--text-dark);
  margin: 0;
}

.dropdown__select {
  margin: 0;
  width: auto;
  font-size: 0.85rem;
  padding: 0.375rem 0.5rem 0.375rem 0.5rem;
  padding-right: 2rem; /* Space for dropdown arrow */
  height: auto;
  border: 2px solid rgba(14, 165, 233, 0.2);
  border-radius: var(--pico-border-radius);
  transition: all 0.2s ease;
}

.dropdown__select:focus {
  border-color: var(--accent-color);
  box-shadow: 0 0 0 3px rgba(14, 165, 233, 0.15);
  outline: none;
}

/* Mobile responsive layout */
@media (max-width: 768px) {
  .controls {
    flex-direction: column;
    align-items: stretch;
    gap: 1rem;
  }
  
  .dropdown {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.25rem;
  }
  
  .dropdown__label {
    font-size: 0.9rem;
  }
  
  .dropdown__select {
    width: 100%;
    min-width: 0;
    font-size: 1rem;
    padding: 0.625rem 1rem;
  }
  
  .dropdown__select option {
    font-size: 1rem;
    padding: 0.5rem;
  }
}

/* ============================================================================
   4. INPUT FORM
   ============================================================================
   
   Form with text input and submit button.
*/

.form {
  display: flex;
  gap: 0.5rem;
  align-items: center;
  margin-top: 1rem;
}

.form__input {
  flex: 1;
  border-radius: var(--border-radius-card);
  padding: 0.75rem 1.5rem;
  border: 2px solid rgba(14, 165, 233, 0.2);
  transition: all 0.2s ease;
  box-shadow: 0 2px 8px rgba(14, 165, 233, 0.05);
}

.form__input:focus {
  border-color: var(--accent-color);
  box-shadow: 0 0 0 3px rgba(14, 165, 233, 0.15),
              0 4px 12px rgba(14, 165, 233, 0.1);
  outline: none;
}

.form__button {
  margin-bottom: 0;
  white-space: nowrap;
  background: linear-gradient(135deg, var(--accent-color), var(--accent-light));
  border: none;
  color: #fff;
  font-weight: 600;
  padding: 0.75rem 2rem;
  border-radius: var(--border-radius-pill);
  transition: all 0.2s ease;
  box-shadow: 0 4px 12px rgba(14, 165, 233, 0.3);
  cursor: pointer;
  position: relative;
  top: -8px;
}

.form__button:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 16px rgba(14, 165, 233, 0.4);
}

.form__button:active {
  transform: translateY(0);
}

.form__button:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  transform: none;
}

/* Mobile responsive layout */
@media (max-width: 768px) {
  .form {
    flex-direction: column;
    align-items: stretch;
    gap: 0.75rem;
  }
  
  .form__input {
    width: 100%;
    font-size: 1rem;
    padding: 0.875rem 1.25rem;
  }
  
  .form__button {
    width: 100%;
    padding: 0.875rem 1.5rem;
    font-size: 1rem;
    top: 0;
  }
}


/* ============================================================================
   5. CHAT
   ============================================================================
   
   Chat log and messages.
*/

.chat {
  margin-top: 0.75rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
  min-height: 250px;
  background: linear-gradient(135deg, #f0f9ff 0%, #e0f2fe 100%);
  padding: 2rem;
  border-radius: var(--border-radius-card);
  border: 2px solid rgba(14, 165, 233, 0.1);
  box-shadow: inset 0 2px 8px rgba(14, 165, 233, 0.05);
}

.chat__message {
  max-width: 80%;
  padding: 1rem 1.25rem;
  border-radius: var(--border-radius-card);
  white-space: pre-wrap;
  word-break: break-word;
  overflow-wrap: anywhere;
  animation: slideIn 0.3s ease-out;
}

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

.chat__message--user {
  align-self: flex-end;
  background: linear-gradient(135deg, var(--primary-color), var(--primary-hover));
  color: #ffffff;
  box-shadow: 0 4px 12px rgba(15, 23, 42, 0.15);
}

.chat__message--assistant {
  align-self: flex-start;
  background: #ffffff;
  border: 2px solid rgba(14, 165, 233, 0.15);
  line-height: 1.7;
  white-space: normal;
  font-size: 1rem;
  box-shadow: 0 4px 12px rgba(14, 165, 233, 0.08);
  color: var(--text-dark);
}

.chat__message--user + .chat__message--assistant,
.chat__message--assistant + .chat__message--user {
  margin-top: 1.5rem;
}

.chat__placeholder {
  text-align: center;
  color: var(--accent-color);
  font-size: 1.15rem;
  font-style: italic;
  padding: 4rem 1.5rem;
  opacity: 0.6;
  animation: placeholderPulse 2s ease-in-out infinite;
}

@keyframes placeholderPulse {
  0%, 100% { opacity: 0.6; }
  50% { opacity: 0.8; }
}


/* ============================================================================
   6. STATUS MESSAGE STYLES
   ============================================================================
   
   The status message shows "Swimming for your answers..." while waiting.
*/

.status {
  /* Position above chat area with proper spacing */
  margin-top: 1rem;
  margin-bottom: 0.5rem;
  
  /* Slightly smaller text */
  font-size: 0.875rem;
  
  /* Minimum height to prevent layout shift */
  min-height: 1.2rem;
  
  /* Professional styling */
  color: var(--text-muted);
  font-weight: 400;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.status:not(:empty)::before {
  content: "🌊";
  font-size: 0.85rem;
  animation: wavePulse 1.5s ease-in-out infinite;
}

@keyframes wavePulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.3; }
}


/* ============================================================================
   7. MARKDOWN FORMATTING
   ============================================================================
   
   Styles for markdown-formatted text in assistant messages.
*/

.chat__message--assistant h1,
.chat__message--assistant h2,
.chat__message--assistant h3 {
  margin-top: 1rem;
  margin-bottom: 0.5rem;
  font-weight: 600;
  line-height: 1.3;
}

.chat__message--assistant h1 {
  font-size: 1.3rem;
}

.chat__message--assistant h2 {
  font-size: 1.15rem;
}

.chat__message--assistant h3 {
  font-size: 1.05rem;
}

.chat__message--assistant code {
  background: #f4f4f4;
  padding: 0.2rem 0.4rem;
  border-radius: 0.25rem;
  font-size: 0.9em;
  font-family: 'Monaco', 'Courier New', monospace;
}

.chat__message--assistant a {
  color: var(--accent-color);
  text-decoration: none;
  font-weight: 500;
  border-bottom: 1px solid var(--accent-light);
  transition: all 0.15s ease;
}

.chat__message--assistant a:hover {
  background: rgba(8, 145, 178, 0.08);
  color: var(--accent-light);
}

.chat__message--assistant strong {
  font-weight: 600;
  color: #2c3e50;
}

.chat__message--assistant em {
  font-style: italic;
  color: #34495e;
}


/* ============================================================================
   8. DARK MODE OVERRIDE
   ============================================================================
   
   Force light mode regardless of system settings.
*/

@media (min-width: 768px) {
  .container {
    padding: 2.5rem;
  }
}

@media only screen and (prefers-color-scheme: dark) {
  :root:not([data-theme="dark"]) {
    --pico-background-color: #fff;
    --pico-color: #1e293b;
    --pico-text-selection-color: rgba(8, 145, 178, 0.2);
  }
  
  /* Force light mode for form inputs */
  .form__input,
  .dropdown__select {
    background-color: #fff !important;
    color: #1e293b !important;
    border-color: rgba(14, 165, 233, 0.2) !important;
  }
  
  /* Force light mode for button */
  .form__button {
    background: linear-gradient(135deg, var(--accent-color), var(--accent-light)) !important;
    color: #fff !important;
  }
  
  /* Force light mode for container */
  .container {
    background-color: #fff !important;
    color: #1e293b !important;
  }
}