<script setup>
import { ref, computed, onMounted } from 'vue'
import { useCollaborationStore } from '../stores/collaboration'

const emit = defineEmits(['session-created'])

const collaborationStore = useCollaborationStore()

const prompt = ref('')
const contextFile = ref(null)
const agentCount = ref(7)
const isCreating = ref(false)
const previousSessions = ref([])
const loadingPreviousSessions = ref(false)
const showAllSessions = ref(false)
const showArchives = ref(false)
const sessionStatusFilter = ref('all') // 'all', 'completed', 'ongoing', 'created'
const searchQuery = ref('')

onMounted(async () => {
  loadingPreviousSessions.value = true
  try {
    const response = await fetch('/api/collaborate')
    const data = await response.json()
    previousSessions.value = data.sessions || []
  } catch (error) {
    console.error('Error loading previous sessions:', error)
  } finally {
    loadingPreviousSessions.value = false
  }
})

const handleOpenSession = (sessionId) => {
  emit('session-created', { sessionId })
}

const agentOptions = computed(() => {
  return Array.from({ length: 48 }, (_, i) => ({
    value: i + 3,
    label: `${i + 3} agents`
  }))
})

const filteredSessions = computed(() => {
  let filtered = previousSessions.value

  if (sessionStatusFilter.value !== 'all') {
    filtered = filtered.filter(s => s.status === sessionStatusFilter.value)
  }

  if (searchQuery.value.trim()) {
    const query = searchQuery.value.toLowerCase()
    filtered = filtered.filter(s =>
      s.prompt.toLowerCase().includes(query) ||
      s.sessionId.toString().includes(query)
    )
  }

  return filtered
})

const displayedSessions = computed(() => {
  return showAllSessions.value ? filteredSessions.value : filteredSessions.value.slice(0, 6)
})

const completedCount = computed(() => {
  return previousSessions.value.filter(s => s.status === 'completed').length
})

const ongoingCount = computed(() => {
  return previousSessions.value.filter(s => s.status === 'ongoing').length
})

const handleFileSelect = (event) => {
  const file = event.target.files?.[0]
  if (file) {
    const validTypes = ['text/markdown', 'text/plain', 'application/octet-stream']
    const validExtensions = ['.md', '.txt']
    const hasValidType = validTypes.includes(file.type)
    const hasValidExtension = validExtensions.some(ext => file.name.endsWith(ext))

    if (!hasValidType && !hasValidExtension) {
      alert('Please upload a Markdown (.md) or Text (.txt) file')
      return
    }

    contextFile.value = file
  }
}

const handleCreateSession = async () => {
  if (!prompt.value.trim()) {
    alert('Please enter a project description')
    return
  }

  isCreating.value = true
  try {
    let finalPrompt = prompt.value

    // If a context file was uploaded, prepend it to the prompt
    if (contextFile.value) {
      const fileContent = await contextFile.value.text()
      finalPrompt = `Context file content:\n\`\`\`\n${fileContent}\n\`\`\`\n\nProject description:\n${prompt.value}`
    }

    // Always use 'md' format for output
    const session = await collaborationStore.createSession(
      finalPrompt,
      'md',
      agentCount.value
    )

    emit('session-created', session)

    // Reset form
    prompt.value = ''
    contextFile.value = null
    agentCount.value = 7
  } catch (error) {
    alert(`Error creating session: ${collaborationStore.error}`)
  } finally {
    isCreating.value = false
  }
}

const handleKeydown = (e) => {
  if (e.key === 'Enter' && e.ctrlKey) {
    handleCreateSession()
  }
}

const removeFile = () => {
  contextFile.value = null
}
</script>

<template>
  <div class="collaborative-input">
    <div class="container">
      <header class="header">
        <h1>AI Architecture Design</h1>
        <p class="subtitle">
          Describe your software project. AI specialists collaboratively design
          the architecture through iterative refinement.
        </p>
      </header>

      <!-- Quick Access Section -->
      <div v-if="previousSessions.length > 0" class="quick-access-section">
        <div class="stats-bar">
          <div class="stat">
            <span class="stat-label">Completed</span>
            <span class="stat-value">{{ completedCount }}</span>
          </div>
          <div class="stat">
            <span class="stat-label">In Progress</span>
            <span class="stat-value">{{ ongoingCount }}</span>
          </div>
          <div class="stat">
            <span class="stat-label">Total</span>
            <span class="stat-value">{{ previousSessions.length }}</span>
          </div>
        </div>

        <!-- Search Bar -->
        <div class="search-bar">
          <input
            v-model="searchQuery"
            type="text"
            placeholder="Search by session ID or description..."
            class="search-input"
          />
        </div>

        <!-- Status Filter -->
        <div class="filter-tabs">
          <button
            @click="sessionStatusFilter = 'all'"
            class="filter-btn"
            :class="{ active: sessionStatusFilter === 'all' }"
          >
            All Sessions ({{ previousSessions.length }})
          </button>
          <button
            @click="sessionStatusFilter = 'completed'"
            class="filter-btn"
            :class="{ active: sessionStatusFilter === 'completed' }"
          >
            Completed ({{ completedCount }})
          </button>
          <button
            @click="sessionStatusFilter = 'ongoing'"
            class="filter-btn"
            :class="{ active: sessionStatusFilter === 'ongoing' }"
          >
            In Progress ({{ ongoingCount }})
          </button>
        </div>

        <!-- Recent Sessions Grid -->
        <div class="recent-sessions-scroll">
          <div class="sessions-carousel">
            <div
              v-for="session in displayedSessions"
              :key="session.sessionId"
              @click="handleOpenSession(session.sessionId)"
              class="session-card-horizontal"
              :class="['status-' + session.status]"
              :title="session.prompt"
            >
              <div class="card-left">
                <div class="session-id">#{{ session.sessionId }}</div>
              </div>
              <div class="card-main">
                <p class="session-prompt-short">{{ session.prompt.substring(0, 75) }}{{ session.prompt.length > 75 ? '...' : '' }}</p>
                <p class="session-meta">{{ new Date(session.createdAt).toLocaleDateString() }}</p>
              </div>
              <div class="card-right">
                <span class="status-badge">{{ session.status }}</span>
              </div>
            </div>
          </div>
        </div>

        <div v-if="filteredSessions.length > 6" class="view-all-container">
          <button
            @click="showAllSessions = !showAllSessions"
            class="view-all-btn"
          >
            {{ showAllSessions ? 'Show Less' : `View All (${filteredSessions.length} sessions)` }}
          </button>
        </div>
      </div>

      <!-- Divider -->
      <div v-if="previousSessions.length > 0" class="divider">
        <span>Or start a new session</span>
      </div>

      <form @submit.prevent="handleCreateSession" class="form">
        <!-- Project Description -->
        <div class="form-section">
          <label for="prompt" class="label">Project Description</label>
          <p class="label-hint">
            Describe your software project in detail. What is it? What problems does it solve? What are the key requirements?
          </p>
          <textarea
            id="prompt"
            v-model="prompt"
            @keydown="handleKeydown"
            placeholder="Example: Real-time collaborative document editing platform with multiple users, version history, and commenting..."
            class="textarea"
            rows="8"
          ></textarea>
          <p class="hint">The more detailed your description, the better the AI collaboration.</p>
        </div>

        <!-- Optional Context File -->
        <div class="form-section">
          <label class="label">Context File (Optional)</label>
          <p class="label-hint">
            Upload an existing Markdown or text file to use as context for the AI specialists.
          </p>

          <div class="file-input-wrapper">
            <input
              type="file"
              id="contextFile"
              accept=".md,.txt"
              @change="handleFileSelect"
              class="file-input"
            />
            <label for="contextFile" class="file-label">
              Choose a file (.md or .txt)
            </label>
          </div>

          <div v-if="contextFile" class="file-selected">
            <span class="file-name">{{ contextFile.name }}</span>
            <button
              type="button"
              @click="removeFile"
              class="remove-btn"
            >
              Remove
            </button>
          </div>

          <p class="hint">Optional: Provide existing documentation or requirements to guide the design.</p>
        </div>

        <!-- Agent Count Selection -->
        <div class="form-grid">
          <div class="form-group">
            <label for="agents" class="label">Number of AI Specialists</label>
            <select v-model.number="agentCount" id="agents" class="select">
              <option v-for="opt in agentOptions" :key="opt.value" :value="opt.value">
                {{ opt.label }}
              </option>
            </select>
            <p class="hint">More agents = more diverse perspectives.</p>
          </div>
        </div>

        <!-- Info Box -->
        <div class="info-box">
          <p><strong>Process:</strong></p>
          <ul>
            <li>Lead Architect creates initial design</li>
            <li>{{ agentCount }} specialists review iteratively</li>
            <li>Each proposes improvements based on expertise</li>
            <li>Document evolves through refinement</li>
            <li>Converges when consensus reached</li>
            <li>Output: Markdown architectural specification</li>
          </ul>
        </div>

        <!-- Submit Button -->
        <button
          @click="handleCreateSession"
          :disabled="!prompt.trim() || isCreating"
          type="button"
          class="submit-btn"
        >
          {{ isCreating ? 'Starting...' : 'Start Design Session' }}
        </button>
      </form>

      <footer class="footer">
        <p>Typical session: 2-5 rounds for complete consensus. Output format: Markdown</p>
      </footer>
    </div>
  </div>
</template>

<style scoped>
.collaborative-input {
  min-height: 100vh;
  padding: 2rem;
  background: linear-gradient(
    -45deg,
    #0f0c29 0%,
    #302b63 25%,
    #24243e 50%,
    #302b63 75%,
    #0f0c29 100%
  );
  background-size: 400% 400%;
  animation: gradient-shift 15s ease infinite;
  position: relative;
  overflow: hidden;
}

.collaborative-input::before {
  content: '';
  position: fixed;
  top: 0;
  left: 0;
  width: 200%;
  height: 200%;
  background: radial-gradient(circle at 20% 50%, rgba(102, 126, 234, 0.1) 0%, transparent 50%),
              radial-gradient(circle at 80% 80%, rgba(118, 75, 162, 0.08) 0%, transparent 50%);
  animation: float1 20s ease-in-out infinite;
  pointer-events: none;
  z-index: 0;
}

@keyframes gradient-shift {
  0% {
    background-position: 0% 50%;
  }
  50% {
    background-position: 100% 50%;
  }
  100% {
    background-position: 0% 50%;
  }
}

@keyframes float1 {
  0%, 100% {
    transform: translate(0, 0) rotate(0deg);
    opacity: 0.03;
  }
  25% {
    transform: translate(100px, -100px) rotate(90deg);
    opacity: 0.05;
  }
  50% {
    transform: translate(-50px, 150px) rotate(180deg);
    opacity: 0.03;
  }
  75% {
    transform: translate(-100px, -50px) rotate(270deg);
    opacity: 0.04;
  }
}

.container {
  max-width: 900px;
  margin: 0 auto;
  position: relative;
  z-index: 2;
}

.header {
  text-align: center;
  color: white;
  margin-bottom: 3rem;
}

.header h1 {
  font-size: 2.5rem;
  margin: 0;
  margin-bottom: 0.5rem;
  font-weight: 700;
  letter-spacing: -0.5px;
}

.subtitle {
  font-size: 1.1rem;
  opacity: 0.85;
  margin: 0;
  line-height: 1.6;
}

.form {
  background: rgba(255, 255, 255, 0.08);
  backdrop-filter: blur(10px);
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 20px;
  padding: 2.5rem;
  box-shadow: 0 8px 32px rgba(31, 38, 135, 0.2);
  margin-bottom: 2rem;
}

.form-section {
  margin-bottom: 2rem;
}

.label {
  display: block;
  font-weight: 600;
  color: white;
  margin-bottom: 0.5rem;
  font-size: 1rem;
}

.label-hint {
  color: rgba(255, 255, 255, 0.7);
  font-size: 0.95rem;
  margin: 0 0 0.75rem 0;
}

.textarea {
  width: 100%;
  padding: 1rem;
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 12px;
  font-family: inherit;
  font-size: 1rem;
  resize: vertical;
  transition: all 0.3s;
  background: rgba(255, 255, 255, 0.05);
  color: white;
  backdrop-filter: blur(5px);
}

.textarea::placeholder {
  color: rgba(255, 255, 255, 0.5);
}

.textarea:focus {
  outline: none;
  border-color: rgba(102, 126, 234, 0.6);
  background: rgba(255, 255, 255, 0.1);
  box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1), inset 0 0 20px rgba(102, 126, 234, 0.05);
}

.hint {
  font-size: 0.85rem;
  color: rgba(255, 255, 255, 0.6);
  margin-top: 0.5rem;
  margin-bottom: 0;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 1.5rem;
  margin-bottom: 2rem;
}

.form-group {
  display: flex;
  flex-direction: column;
}

.select {
  padding: 0.75rem;
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 12px;
  font-size: 1rem;
  background: rgba(255, 255, 255, 0.05);
  color: white;
  cursor: pointer;
  transition: all 0.3s;
  backdrop-filter: blur(5px);
}

.select option {
  background: #302b63;
  color: white;
}

.select:focus {
  outline: none;
  border-color: rgba(102, 126, 234, 0.6);
  background: rgba(255, 255, 255, 0.1);
  box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.info-box {
  background: rgba(102, 126, 234, 0.1);
  border: 1px solid rgba(102, 126, 234, 0.3);
  border-radius: 12px;
  padding: 1.5rem;
  margin-bottom: 2rem;
  backdrop-filter: blur(10px);
}

.info-box p {
  margin: 0 0 0.75rem 0;
  color: white;
  font-weight: 600;
}

.info-box ul {
  margin: 0;
  padding-left: 1.5rem;
  color: rgba(255, 255, 255, 0.8);
}

.info-box li {
  margin-bottom: 0.5rem;
}

.submit-btn {
  width: 100%;
  padding: 1.25rem;
  background: linear-gradient(135deg, rgba(102, 126, 234, 0.8) 0%, rgba(118, 75, 162, 0.8) 100%);
  color: white;
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 12px;
  font-size: 1.1rem;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.3s;
  box-shadow: 0 8px 32px rgba(31, 38, 135, 0.2);
  backdrop-filter: blur(10px);
}

.submit-btn:hover:not(:disabled) {
  transform: translateY(-2px);
  background: linear-gradient(135deg, rgba(102, 126, 234, 0.95) 0%, rgba(118, 75, 162, 0.95) 100%);
  box-shadow: 0 12px 40px rgba(102, 126, 234, 0.4);
  border-color: rgba(255, 255, 255, 0.3);
}

.submit-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.file-input-wrapper {
  position: relative;
  margin-bottom: 1rem;
}

.file-input {
  display: none;
}

.file-label {
  display: block;
  padding: 1rem;
  border: 2px dashed rgba(102, 126, 234, 0.5);
  border-radius: 12px;
  text-align: center;
  cursor: pointer;
  transition: all 0.3s;
  background: rgba(102, 126, 234, 0.05);
  color: rgba(255, 255, 255, 0.8);
  font-weight: 600;
  backdrop-filter: blur(5px);
}

.file-label:hover {
  background: rgba(102, 126, 234, 0.15);
  border-color: rgba(102, 126, 234, 0.8);
  color: white;
}

.file-input:focus + .file-label {
  border-color: rgba(102, 126, 234, 0.8);
  box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.15), inset 0 0 20px rgba(102, 126, 234, 0.05);
}

.file-selected {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.75rem 1rem;
  background: rgba(76, 175, 80, 0.15);
  border: 1px solid rgba(76, 175, 80, 0.4);
  border-radius: 8px;
  margin-top: 0.75rem;
  backdrop-filter: blur(5px);
}

.file-name {
  color: rgba(76, 175, 80, 0.9);
  font-weight: 600;
  font-size: 0.95rem;
}

.remove-btn {
  background: none;
  border: none;
  color: rgba(244, 67, 54, 0.7);
  font-size: 0.85rem;
  cursor: pointer;
  padding: 0 0.75rem;
  transition: color 0.3s;
  font-weight: 600;
}

.remove-btn:hover {
  color: rgba(244, 67, 54, 1);
}

.footer {
  text-align: center;
  color: rgba(255, 255, 255, 0.7);
  font-size: 0.95rem;
}

.previous-sessions-section {
  margin-top: 3rem;
  padding-top: 2rem;
  border-top: 1px solid rgba(102, 126, 234, 0.2);
}

.previous-sessions-section h2 {
  font-size: 1.5rem;
  margin-bottom: 1.5rem;
  color: rgba(102, 126, 234, 0.9);
}

.sessions-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 1rem;
}

.session-card {
  padding: 1.25rem;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(102, 126, 234, 0.3);
  border-radius: 12px;
  cursor: pointer;
  transition: all 0.3s ease;
  backdrop-filter: blur(10px);
}

.session-card:hover {
  background: rgba(102, 126, 234, 0.15);
  border-color: rgba(102, 126, 234, 0.5);
  transform: translateY(-2px);
  box-shadow: 0 8px 24px rgba(102, 126, 234, 0.2);
}

.session-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.75rem;
}

.session-id {
  font-weight: 700;
  color: rgba(102, 126, 234, 0.9);
  font-size: 1.1rem;
}

.session-status {
  padding: 0.25rem 0.75rem;
  background: rgba(76, 175, 80, 0.25);
  color: rgba(76, 175, 80, 0.9);
  border-radius: 20px;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: capitalize;
}

.session-card.status-completed .session-status {
  background: rgba(76, 175, 80, 0.3);
  color: rgba(76, 175, 80, 0.95);
}

.session-prompt {
  margin: 0.75rem 0;
  color: rgba(255, 255, 255, 0.7);
  font-size: 0.9rem;
  line-height: 1.4;
}

.session-date {
  margin: 0;
  color: rgba(255, 255, 255, 0.5);
  font-size: 0.85rem;
}

/* Quick Access Section */
.quick-access-section {
  margin-bottom: 2rem;
}

.stats-bar {
  display: flex;
  gap: 1.5rem;
  margin-bottom: 1.5rem;
  padding: 1rem 1.5rem;
  background: rgba(102, 126, 234, 0.08);
  border: 1px solid rgba(102, 126, 234, 0.2);
  border-radius: 12px;
  backdrop-filter: blur(10px);
}

.stat {
  display: flex;
  flex-direction: column;
  align-items: center;
}

.stat-label {
  font-size: 0.8rem;
  color: rgba(255, 255, 255, 0.5);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  font-weight: 600;
}

.stat-value {
  font-size: 1.8rem;
  color: rgba(102, 126, 234, 0.95);
  font-weight: 700;
  margin-top: 0.25rem;
}

.search-bar {
  margin-bottom: 1.5rem;
}

.search-input {
  width: 100%;
  padding: 0.75rem 1rem;
  background: rgba(255, 255, 255, 0.07);
  border: 1px solid rgba(102, 126, 234, 0.3);
  color: rgba(255, 255, 255, 0.9);
  border-radius: 8px;
  font-size: 0.95rem;
  backdrop-filter: blur(5px);
  transition: all 0.3s ease;
}

.search-input::placeholder {
  color: rgba(255, 255, 255, 0.4);
}

.search-input:focus {
  outline: none;
  border-color: rgba(102, 126, 234, 0.6);
  background: rgba(102, 126, 234, 0.1);
  box-shadow: 0 0 15px rgba(102, 126, 234, 0.2);
}

.filter-tabs {
  display: flex;
  gap: 0.75rem;
  margin-bottom: 1.5rem;
  flex-wrap: wrap;
}

.filter-btn {
  padding: 0.6rem 1.2rem;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.1);
  color: rgba(255, 255, 255, 0.6);
  border-radius: 8px;
  cursor: pointer;
  font-size: 0.9rem;
  font-weight: 500;
  transition: all 0.3s ease;
  backdrop-filter: blur(5px);
}

.filter-btn:hover {
  background: rgba(102, 126, 234, 0.2);
  border-color: rgba(102, 126, 234, 0.4);
  color: rgba(255, 255, 255, 0.8);
}

.filter-btn.active {
  background: rgba(102, 126, 234, 0.3);
  border-color: rgba(102, 126, 234, 0.6);
  color: rgba(255, 255, 255, 0.95);
  box-shadow: 0 0 15px rgba(102, 126, 234, 0.2);
}

.recent-sessions-scroll {
  overflow-x: auto;
  margin-bottom: 1rem;
  padding-bottom: 0.5rem;
}

.sessions-carousel {
  display: flex;
  gap: 1rem;
  min-width: min-content;
}

.session-card-horizontal {
  display: flex;
  align-items: center;
  gap: 1rem;
  min-width: 350px;
  padding: 1rem;
  background: rgba(102, 126, 234, 0.1);
  border: 1px solid rgba(102, 126, 234, 0.3);
  border-radius: 12px;
  cursor: pointer;
  transition: all 0.3s ease;
  backdrop-filter: blur(10px);
}

.session-card-horizontal:hover {
  background: rgba(102, 126, 234, 0.15);
  border-color: rgba(102, 126, 234, 0.5);
  transform: translateY(-2px);
  box-shadow: 0 8px 20px rgba(102, 126, 234, 0.2);
}

.session-card-horizontal.status-completed {
  border-color: rgba(76, 175, 80, 0.3);
  background: rgba(76, 175, 80, 0.05);
}

.session-card-horizontal.status-completed:hover {
  background: rgba(76, 175, 80, 0.12);
  border-color: rgba(76, 175, 80, 0.5);
  box-shadow: 0 8px 20px rgba(76, 175, 80, 0.15);
}

.card-left {
  flex-shrink: 0;
}

.card-main {
  flex: 1;
  min-width: 0;
}

.session-prompt-short {
  margin: 0;
  color: rgba(255, 255, 255, 0.8);
  font-size: 0.95rem;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.session-meta {
  margin: 0.25rem 0 0 0;
  color: rgba(255, 255, 255, 0.4);
  font-size: 0.8rem;
}

.card-right {
  flex-shrink: 0;
}

.status-badge {
  display: inline-flex;
  align-items: center;
  padding: 0.4rem 0.8rem;
  background: rgba(76, 175, 80, 0.2);
  color: rgba(76, 175, 80, 0.9);
  border-radius: 20px;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: capitalize;
  white-space: nowrap;
}

.session-card-horizontal.status-ongoing .status-badge {
  background: rgba(102, 126, 234, 0.2);
  color: rgba(102, 126, 234, 0.9);
}

.view-all-container {
  text-align: center;
  margin-top: 1rem;
}

.view-all-btn {
  padding: 0.7rem 1.5rem;
  background: rgba(102, 126, 234, 0.15);
  border: 1px solid rgba(102, 126, 234, 0.3);
  color: rgba(102, 126, 234, 0.9);
  border-radius: 8px;
  cursor: pointer;
  font-size: 0.9rem;
  font-weight: 600;
  transition: all 0.3s ease;
  backdrop-filter: blur(5px);
}

.view-all-btn:hover {
  background: rgba(102, 126, 234, 0.25);
  border-color: rgba(102, 126, 234, 0.5);
  box-shadow: 0 4px 12px rgba(102, 126, 234, 0.15);
}

.divider {
  text-align: center;
  margin: 2rem 0;
  position: relative;
}

.divider span {
  background: linear-gradient(
    -45deg,
    #0f0c29 0%,
    #302b63 25%,
    #24243e 50%,
    #302b63 75%,
    #0f0c29 100%
  );
  padding: 0 1rem;
  color: rgba(255, 255, 255, 0.4);
  font-size: 0.9rem;
  font-weight: 500;
  position: relative;
  z-index: 1;
}

.divider::before {
  content: '';
  position: absolute;
  top: 50%;
  left: 0;
  right: 0;
  height: 1px;
  background: linear-gradient(to right, transparent, rgba(102, 126, 234, 0.2), transparent);
  z-index: 0;
}

@media (max-width: 768px) {
  .collaborative-input {
    padding: 1rem;
  }

  .header h1 {
    font-size: 2rem;
  }

  .form {
    padding: 1.5rem;
  }

  .form-grid {
    grid-template-columns: 1fr;
  }
}
</style>
