/* Local Gemini AI Demo CSS Stylesheet - Premium Dark Theme & Glassmorphism */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800&family=Outfit:wght@400;500;600;700;800&display=swap');

:root {
  --bg-color: #080710;
  --bg-gradient: radial-gradient(circle at 50% 0%, #1e1145 0%, #080710 70%);
  --panel-bg: rgba(17, 12, 33, 0.45);
  --panel-bg-hover: rgba(25, 18, 48, 0.6);
  --border-color: rgba(255, 255, 255, 0.08);
  --border-color-glow: rgba(139, 92, 246, 0.4);
  
  --primary: #8b5cf6;
  --primary-glow: rgba(139, 92, 246, 0.5);
  --secondary: #06b6d4;
  --secondary-glow: rgba(6, 182, 212, 0.5);
  --accent: #ec4899;
  
  --text-primary: #f8fafc;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;
  
  --font-display: 'Outfit', 'Inter', system-ui, -apple-system, sans-serif;
  --font-sans: 'Inter', system-ui, -apple-system, sans-serif;
  
  --transition-smooth: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  --transition-fast: all 0.15s ease;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: var(--font-sans);
  background-color: var(--bg-color);
  background-image: var(--bg-gradient);
  color: var(--text-primary);
  height: 100vh; /* Fixed height */
  overflow: hidden; /* Prevent page-level scrollbar */
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

/* Custom Scrollbar */
::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}

::-webkit-scrollbar-track {
  background: rgba(8, 7, 16, 0.5);
}

::-webkit-scrollbar-thumb {
  background: rgba(139, 92, 246, 0.3);
  border-radius: 10px;
  border: 2px solid var(--bg-color);
}

::-webkit-scrollbar-thumb:hover {
  background: rgba(139, 92, 246, 0.6);
}

/* App Layout */
.app-container {
  max-width: 1600px;
  margin: 0 auto;
  padding: 1.5rem;
  display: grid;
  grid-template-columns: 1fr 400px;
  grid-template-rows: auto 1fr; /* Row 1: Header, Row 2: Content Grid */
  gap: 1.5rem;
  height: 100vh; /* Fit to viewport strictly */
  box-sizing: border-box;
  overflow: hidden;
}

@media (max-width: 1200px) {
  .app-container {
    grid-template-columns: 1fr;
  }
}

/* Header Styles */
header {
  grid-column: 1 / -1;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1rem 1.5rem;
  background: var(--panel-bg);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid var(--border-color);
  border-radius: 20px;
  box-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.37);
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.logo-icon {
  width: 42px;
  height: 42px;
  background: linear-gradient(135deg, var(--primary), var(--secondary));
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 0 20px var(--primary-glow);
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 1.5rem;
  color: white;
}

.brand-text h1 {
  font-family: var(--font-display);
  font-size: 1.75rem;
  font-weight: 800;
  letter-spacing: -0.025em;
  background: linear-gradient(to right, #ffffff, #a78bfa, #22d3ee);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.brand-text p {
  font-size: 0.85rem;
  color: var(--text-secondary);
}

/* Developer Profile Card */
.developer-profile {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.2rem;
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid rgba(255, 255, 255, 0.05);
  border-radius: 12px;
  padding: 0.5rem 1.25rem;
  max-width: 550px;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
  transition: var(--transition-smooth);
}

.developer-profile:hover {
  background: rgba(255, 255, 255, 0.04);
  border-color: rgba(139, 92, 246, 0.2);
  box-shadow: 0 4px 20px rgba(139, 92, 246, 0.08);
}

.dev-name {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 0.95rem;
  letter-spacing: -0.01em;
  background: linear-gradient(to right, #ffffff, #c084fc);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.dev-title {
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--secondary);
  letter-spacing: 0.01em;
  text-align: center;
}

.dev-meta {
  display: flex;
  gap: 0.6rem;
  font-size: 0.68rem;
  color: var(--text-secondary);
  align-items: center;
  flex-wrap: wrap;
  justify-content: center;
}

.dev-meta a {
  color: var(--text-secondary);
  text-decoration: none;
  font-weight: 500;
  transition: var(--transition-fast);
}

.dev-meta a:hover {
  color: var(--primary);
  text-decoration: underline;
}

/* Local AI Status Badge */
.status-badge {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.6rem 1rem;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--border-color);
  border-radius: 50px;
  font-size: 0.8rem;
  font-weight: 500;
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  position: relative;
}

.status-dot::after {
  content: '';
  position: absolute;
  top: -4px;
  left: -4px;
  right: -4px;
  bottom: -4px;
  border-radius: 50%;
  animation: pulse 2s infinite;
}

/* Status States */
.status-active .status-dot { background-color: #10b981; }
.status-active .status-dot::after { background-color: rgba(16, 185, 129, 0.4); }

.status-initializing .status-dot { background-color: #f59e0b; }
.status-initializing .status-dot::after { background-color: rgba(245, 158, 11, 0.4); }

.status-simulated .status-dot { background-color: #06b6d4; }
.status-simulated .status-dot::after { background-color: rgba(6, 182, 210, 0.4); }

.status-disabled .status-dot { background-color: #ef4444; }
.status-disabled .status-dot::after { background-color: rgba(239, 68, 68, 0.4); }

@keyframes pulse {
  0% { transform: scale(1); opacity: 1; }
  100% { transform: scale(2.2); opacity: 0; }
}

/* Main Content: Table Area */
.table-section {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  min-width: 0; /* Prevents flex items from overflowing */
  height: 100%;
  overflow: hidden; /* Fits strictly within its grid row */
}

/* Search & Filter Bar */
.filter-bar {
  background: var(--panel-bg);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid var(--border-color);
  border-radius: 20px;
  padding: 1.25rem;
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  align-items: center;
}

.search-wrapper {
  position: relative;
  flex: 1;
  min-width: 250px;
}

.search-input {
  width: 100%;
  padding: 0.75rem 1rem 0.75rem 2.5rem;
  background: rgba(0, 0, 0, 0.25);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  color: var(--text-primary);
  font-family: var(--font-sans);
  font-size: 0.9rem;
  outline: none;
  transition: var(--transition-smooth);
}

.search-input:focus {
  border-color: var(--primary-glow);
  box-shadow: 0 0 15px rgba(139, 92, 246, 0.15);
  background: rgba(0, 0, 0, 0.4);
}

.search-wrapper::before {
  content: '🔍';
  position: absolute;
  left: 0.85rem;
  top: 50%;
  transform: translateY(-50%);
  font-size: 0.9rem;
  opacity: 0.6;
}

.filter-selects {
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.filter-select {
  padding: 0.75rem 1rem;
  background: rgba(0, 0, 0, 0.25);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  color: var(--text-primary);
  font-family: var(--font-sans);
  font-size: 0.9rem;
  outline: none;
  cursor: pointer;
  transition: var(--transition-smooth);
}

.filter-select:focus {
  border-color: var(--primary-glow);
  background: rgba(0, 0, 0, 0.4);
}

.filter-select option {
  background: #0f0d1e;
  color: var(--text-primary);
}

.stats-summary {
  font-size: 0.85rem;
  color: var(--text-secondary);
  margin-left: auto;
  font-weight: 500;
}

/* Glassmorphic Table Container */
.table-wrapper {
  background: var(--panel-bg);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid var(--border-color);
  border-radius: 20px;
  overflow: auto;
  box-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.3);
  flex: 1; /* Stretch to fill remaining height */
  position: relative;
}

table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
}

thead {
  position: sticky;
  top: 0;
  z-index: 10;
  background: rgba(18, 13, 38, 0.95);
  backdrop-filter: blur(8px);
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.3);
}

th {
  padding: 1rem 1.25rem;
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-secondary);
  border-bottom: 1px solid var(--border-color);
  cursor: pointer;
  user-select: none;
  transition: var(--transition-fast);
}

th:hover {
  color: var(--text-primary);
  background: rgba(255, 255, 255, 0.03);
}

th.sorted-asc::after {
  content: ' ▴';
}

th.sorted-desc::after {
  content: ' ▾';
}

/* Render optimization using multiple tbodies and content-visibility */
tbody {
  /* OPTIMIZATION: Skipping layout and paint when off-screen for non-first rows. 
     We will apply a class .deferred to sub-sections of rows. */
}

tbody.deferred {
  content-visibility: auto;
  /* Estimated height for 50 rows (~52px per row) */
  contain-intrinsic-size: auto none auto 2600px;
}

tr {
  border-bottom: 1px solid rgba(255, 255, 255, 0.03);
  transition: var(--transition-fast);
}

tr:hover {
  background: var(--panel-bg-hover);
}

td {
  padding: 0.9rem 1.25rem;
  font-size: 0.9rem;
  color: var(--text-primary);
}

.col-rank {
  font-family: var(--font-display);
  font-weight: 700;
  color: var(--secondary);
  text-align: center;
  width: 60px;
}

.col-title {
  font-weight: 600;
  color: #fff;
  max-width: 250px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.col-year {
  color: var(--text-secondary);
  width: 80px;
}

.col-genre {
  font-size: 0.8rem;
  width: 180px;
}

.genre-tag {
  display: inline-block;
  padding: 0.2rem 0.5rem;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: 6px;
  margin: 0.1rem;
}

.col-director {
  color: var(--text-secondary);
  max-width: 150px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.col-rating {
  font-family: var(--font-display);
  font-weight: 700;
  width: 80px;
}

.rating-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  background: rgba(245, 158, 11, 0.1);
  color: #f59e0b;
  padding: 0.25rem 0.5rem;
  border-radius: 8px;
  font-size: 0.85rem;
  border: 1px solid rgba(245, 158, 11, 0.2);
}

.col-revenue {
  text-align: right;
  font-family: var(--font-display);
  font-weight: 600;
  color: #34d399;
  width: 120px;
}

/* Chat Assistant Panel (Right Column) */
.assistant-section {
  display: flex;
  flex-direction: column;
  background: var(--panel-bg);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--border-color);
  border-radius: 24px;
  box-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.4);
  height: 100%; /* Stretch to take grid height */
  overflow: hidden;
}

.assistant-header {
  padding: 1.25rem;
  border-bottom: 1px solid var(--border-color);
  background: rgba(20, 15, 45, 0.5);
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.assistant-avatar {
  width: 38px;
  height: 38px;
  background: linear-gradient(135deg, var(--accent), var(--primary));
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.2rem;
  box-shadow: 0 0 15px rgba(236, 72, 153, 0.4);
}

.assistant-info h2 {
  font-family: var(--font-display);
  font-size: 1.1rem;
  font-weight: 700;
}

.assistant-info p {
  font-size: 0.75rem;
  color: var(--text-secondary);
}

/* Chat Message Log */
.chat-log {
  flex: 1;
  padding: 1.25rem;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 1rem;
  background: rgba(8, 7, 16, 0.2);
}

.message {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  max-width: 85%;
  animation: fadeIn 0.3s ease;
}

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

.message.user {
  align-self: flex-end;
}

.message.ai {
  align-self: flex-start;
}

.message-bubble {
  padding: 0.85rem 1.1rem;
  border-radius: 18px;
  font-size: 0.9rem;
  line-height: 1.45;
  word-break: break-word;
}

.message.user .message-bubble {
  background: linear-gradient(135deg, var(--primary), #6d28d9);
  color: white;
  border-bottom-right-radius: 4px;
  box-shadow: 0 4px 15px rgba(139, 92, 246, 0.25);
}

.message.ai .message-bubble {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border-color);
  color: var(--text-primary);
  border-bottom-left-radius: 4px;
}

.message.ai.error .message-bubble {
  background: rgba(239, 68, 68, 0.1);
  border-color: rgba(239, 68, 68, 0.2);
  color: #fca5a5;
}

.message-time {
  font-size: 0.7rem;
  color: var(--text-muted);
  align-self: flex-end;
}

.message.ai .message-time {
  align-self: flex-start;
}

/* Loading indicator inside chat */
.loading-bubble {
  display: flex;
  gap: 4px;
  align-items: center;
  justify-content: center;
  padding: 10px 15px;
}

.dot {
  width: 6px;
  height: 6px;
  background-color: var(--text-secondary);
  border-radius: 50%;
  animation: bounce 1.4s infinite ease-in-out both;
}

.dot:nth-child(1) { animation-delay: -0.32s; }
.dot:nth-child(2) { animation-delay: -0.16s; }

@keyframes bounce {
  0%, 80%, 100% { transform: scale(0); }
  40% { transform: scale(1); }
}

/* Chat Input Bar */
.chat-input-area {
  padding: 1.25rem;
  border-top: 1px solid var(--border-color);
  background: rgba(20, 15, 45, 0.3);
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.presets-container {
  display: flex;
  gap: 0.5rem;
  overflow-x: auto;
  padding-bottom: 0.25rem;
}

.presets-container::-webkit-scrollbar {
  height: 4px;
}

.preset-btn {
  white-space: nowrap;
  padding: 0.4rem 0.8rem;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  color: var(--text-secondary);
  font-size: 0.75rem;
  cursor: pointer;
  transition: var(--transition-fast);
}

.preset-btn:hover {
  background: rgba(139, 92, 246, 0.1);
  color: var(--text-primary);
  border-color: rgba(139, 92, 246, 0.3);
}

.input-row {
  display: flex;
  gap: 0.75rem;
  position: relative;
}

.chat-input {
  flex: 1;
  padding: 0.85rem 1.1rem;
  background: rgba(0, 0, 0, 0.3);
  border: 1px solid var(--border-color);
  border-radius: 14px;
  color: white;
  font-family: var(--font-sans);
  font-size: 0.9rem;
  outline: none;
  transition: var(--transition-smooth);
  resize: none;
  height: 46px;
  max-height: 120px;
}

.chat-input:focus {
  border-color: var(--border-color-glow);
  box-shadow: 0 0 15px rgba(139, 92, 246, 0.15);
  background: rgba(0, 0, 0, 0.55);
}

.send-btn {
  width: 46px;
  height: 46px;
  background: linear-gradient(135deg, var(--primary), var(--secondary));
  border: none;
  border-radius: 14px;
  color: white;
  font-size: 1.1rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 15px rgba(6, 182, 212, 0.2);
  transition: var(--transition-smooth);
}

.send-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(6, 182, 212, 0.35);
  background: linear-gradient(135deg, #a78bfa, #22d3ee);
}

.send-btn:active {
  transform: translateY(0);
}

/* Empty UI/Placeholder */
.empty-table-msg {
  text-align: center;
  padding: 3rem;
  color: var(--text-secondary);
  font-size: 1rem;
}

/* Scroll Indicators or Tooltips */
.movie-count-badge {
  background: linear-gradient(135deg, rgba(139, 92, 246, 0.15), rgba(6, 182, 212, 0.15));
  border: 1px solid rgba(139, 92, 246, 0.25);
  color: var(--text-primary);
  padding: 0.25rem 0.75rem;
  border-radius: 8px;
  font-size: 0.85rem;
  font-weight: 600;
}

/* AI Info Modal / Instruction Alert */
.info-alert {
  background: linear-gradient(to right, rgba(139, 92, 246, 0.08), rgba(6, 182, 212, 0.08));
  border: 1px solid rgba(139, 92, 246, 0.2);
  border-radius: 12px;
  padding: 0.85rem 1rem;
  font-size: 0.8rem;
  line-height: 1.4;
  color: var(--text-secondary);
}

.info-alert a {
  color: var(--secondary);
  text-decoration: none;
  font-weight: 600;
}

.info-alert a:hover {
  text-decoration: underline;
}
