:root {
  /* Modern AI Theme Colors */
  --primary: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  --secondary: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
  --accent: linear-gradient(135deg, #4facfe 0%, #00f2fe 100%);
  --success: linear-gradient(135deg, #43e97b 0%, #38f9d7 100%);
  --bg: #0a0e27;
  --bg-glass: rgba(255, 255, 255, 0.05);
  --bg-card: rgba(255, 255, 255, 0.08);
  --border: rgba(255, 255, 255, 0.12);
  --text: #ffffff;
  --text-muted: #a0aec0;
  --shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
  --glow: 0 0 20px rgba(102, 126, 234, 0.3);
  
  /* Original Variables for Compatibility */
  --card: var(--bg-card);
  --line: var(--border);
  --muted: var(--text-muted);
  --ink: var(--text);
}

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

body {
  font-family: 'Cairo', 'Tahoma', Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  overflow-x: hidden;
  position: relative;
}

/* Background Effects */
body::before {
  content: '';
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: 
    radial-gradient(ellipse at 25% 25%, rgba(120, 119, 198, 0.15) 0%, transparent 50%),
    radial-gradient(ellipse at 75% 75%, rgba(255, 154, 158, 0.15) 0%, transparent 50%),
    radial-gradient(ellipse at 50% 100%, rgba(17, 24, 39, 0.8) 0%, transparent 50%);
  pointer-events: none;
  z-index: -1;
}

/* Floating Elements */
.floating-elements {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: -1;
}

.floating-element {
  position: absolute;
  background: linear-gradient(135deg, rgba(102, 126, 234, 0.1), rgba(118, 75, 162, 0.1));
  border-radius: 50%;
  animation: float 6s ease-in-out infinite;
}

.floating-element:nth-child(1) {
  width: 80px;
  height: 80px;
  top: 20%;
  left: 10%;
  animation-delay: 0s;
}

.floating-element:nth-child(2) {
  width: 120px;
  height: 120px;
  top: 60%;
  right: 15%;
  animation-delay: 2s;
}

.floating-element:nth-child(3) {
  width: 60px;
  height: 60px;
  bottom: 30%;
  left: 20%;
  animation-delay: 4s;
}

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

/* Header */
.header, .topbar {
  background: var(--bg-glass);
  backdrop-filter: blur(20px);
  border-bottom: 1px solid var(--border);
  padding: 1rem 0;
  position: sticky;
  top: 0;
  z-index: 100;
}

.header-content {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 2rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 1rem;
}

.logo, .brand {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  font-size: 1.5rem;
  font-weight: 700;
  background: var(--primary);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.logo-icon {
  width: 40px;
  height: 40px;
  background: var(--accent);
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.25rem;
  box-shadow: var(--glow);
}

.quality-selector, .actions {
  display: flex;
  gap: 0.5rem;
  align-items: center;
  flex-wrap: wrap;
}

.quality-btn, .seg {
  padding: 0.5rem 1rem;
  border: 1px solid var(--border);
  background: var(--bg-glass);
  backdrop-filter: blur(10px);
  border-radius: 25px;
  color: var(--text);
  cursor: pointer;
  transition: all 0.3s ease;
  font-size: 0.875rem;
  font-weight: 500;
}

.quality-btn:hover, .seg:hover {
  transform: translateY(-2px);
  box-shadow: var(--glow);
}

.quality-btn.active, .seg.active {
  background: var(--primary);
  border-color: transparent;
  box-shadow: var(--glow);
}

/* Container */
.container, .wrap {
  max-width: 1200px;
  margin: 0 auto;
  padding: 2rem;
  display: grid;
  gap: 2rem;
}

/* Cards */
.card {
  background: var(--bg-card);
  backdrop-filter: blur(20px);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 2rem;
  box-shadow: var(--shadow);
  transition: all 0.3s ease;
  position: relative;
  overflow: hidden;
}

.card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: var(--primary);
  border-radius: 20px 20px 0 0;
}

.card:hover {
  transform: translateY(-4px);
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.4);
}

.card-title {
  font-size: 1.5rem;
  font-weight: 700;
  margin-bottom: 1rem;
  background: var(--primary);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.card-icon {
  width: 42px;
  height: 42px;
  background: linear-gradient(135deg, #4facfe 0%, #00f2fe 100%);
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.25rem;
  color: white;
  box-shadow: 0 4px 15px rgba(79, 172, 254, 0.3);
  border: 1px solid rgba(255, 255, 255, 0.1);
}

/* Form Elements */
.form-group {
  margin-bottom: 1.5rem;
}

.form-label {
  display: block;
  margin-bottom: 0.5rem;
  font-weight: 600;
  color: var(--text);
}

.form-input, input.number, .select, .activities-select {
  width: 100%;
  padding: 1rem 1.25rem;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--bg-glass);
  backdrop-filter: blur(10px);
  color: var(--text);
  font-size: 1rem;
  transition: all 0.3s ease;
}

.form-input:focus, input.number:focus, .select:focus, .activities-select:focus {
  outline: none;
  border-color: #667eea;
  box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.file-upload {
  border: 2px dashed var(--border);
  border-radius: 12px;
  padding: 2rem;
  text-align: center;
  background: var(--bg-glass);
  transition: all 0.3s ease;
  cursor: pointer;
}

.file-upload:hover {
  border-color: #667eea;
  background: rgba(102, 126, 234, 0.05);
}

.file-upload-icon {
  width: 48px;
  height: 48px;
  background: var(--accent);
  border-radius: 12px;
  margin: 0 auto 1rem;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
}

/* Buttons */
.btn {
  padding: 0.875rem 2rem;
  border: none;
  border-radius: 12px;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.3s ease;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  justify-content: center;
  min-width: 120px;
}

.btn-primary, .btn.accent {
  background: var(--primary);
  color: white;
  box-shadow: var(--glow);
}

.btn-primary:hover, .btn.accent:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 25px rgba(102, 126, 234, 0.4);
}

.btn-secondary {
  background: var(--bg-glass);
  backdrop-filter: blur(10px);
  border: 1px solid var(--border);
  color: var(--text);
}

.btn-secondary:hover {
  background: var(--border);
  transform: translateY(-2px);
}

.btn-success {
  background: var(--success);
  color: white;
}

.btn-success:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 25px rgba(67, 233, 123, 0.4);
}

.btn.send {
  background: #22c55e;
  color: #062412;
  border-radius: 999px;
  padding: 10px 14px;
}

.btn.send:hover {
  filter: brightness(1.05);
}

/* Checkboxes */
.checkbox-group {
  display: grid;
  gap: 1rem;
  margin-top: 1rem;
}

.checkbox-item, .check {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem 1rem;
  background: var(--bg-glass);
  border: 1px solid var(--border);
  border-radius: 12px;
  transition: all 0.3s ease;
  cursor: pointer;
}

.checkbox-item:hover, .check:hover {
  background: rgba(102, 126, 234, 0.05);
  border-color: #667eea;
}

.checkbox-item input[type="checkbox"], .check input[type="checkbox"] {
  width: 18px;
  height: 18px;
  accent-color: #667eea;
}

/* Grid Layout */
.grid {
  display: grid;
  gap: 2rem;
}

.grid-2 {
  grid-template-columns: 1fr 1fr;
}

.grid-3 {
  grid-template-columns: 1fr 1fr 1fr;
}

.grid-4 {
  grid-template-columns: 1fr 1fr 1fr 1fr;
}

/* Results Section */
.result-card {
  background: var(--bg-card);
  border-radius: 16px;
  padding: 1.5rem;
  border: 1px solid var(--border);
  backdrop-filter: blur(20px);
}

.result-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 1rem;
  border-radius: 25px;
  font-size: 0.875rem;
  font-weight: 600;
  margin-bottom: 1rem;
}

.badge-success {
  background: var(--success);
  color: white;
}

.badge-info {
  background: var(--accent);
  color: white;
}

.badge {
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 6px 10px;
  font-size: 12px;
}

.badge.ok {
  background: #16381f;
  border-color: #1f6b2f;
}

.badge.warn {
  background: #3a2d14;
  border-color: #845316;
}

.badge.bad {
  background: #3a1b1b;
  border-color: #8a2727;
}

/* Meta Cards */
.meta-cards {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 16px;
  margin: 12px 0 20px;
}

.meta-card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 14px 16px;
  display: grid;
  grid-template-columns: 42px 1fr;
  grid-template-rows: auto auto;
  align-items: center;
  transition: transform .15s ease, box-shadow .2s ease, border-color .2s ease;
}

.meta-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 18px rgba(0,0,0,.28);
  border-color: #2a3a60;
}

.meta-icon {
  grid-row: 1 / span 2;
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  font-size: 20px;
  background: #101a33;
  border: 1px solid var(--line);
  color: #cfe3ff;
  border-radius: 12px;
  margin-inline-end: 12px;
}

.meta-label {
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 4px;
}

.meta-value {
  font-size: 17px;
  font-weight: 800;
  letter-spacing: .2px;
  color: var(--ink);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Chat Interface */
.chat-container {
  background: var(--bg-glass);
  border: 1px solid var(--border);
  border-radius: 16px;
  height: 400px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.chat-messages, .chat.whatsapp {
  flex: 1;
  padding: 1rem;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 1rem;
  background: #0b1527;
  border: 1px solid var(--line);
  border-radius: 14px;
  min-height: 220px;
  max-height: 360px;
}

.message, .msgrow {
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  max-width: 80%;
}

.message.user, .msgrow.me {
  align-self: flex-end;
  flex-direction: row-reverse;
  justify-content: flex-end;
}

.message-avatar, .avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.125rem;
  flex-shrink: 0;
}

.message-avatar.user, .avatar.me {
  background: var(--secondary);
}

.message-avatar.ai, .avatar.ai {
  background: var(--primary);
}

.message-content, .bubble {
  background: var(--bg-card);
  backdrop-filter: blur(15px);
  padding: 0.875rem 1.125rem;
  border-radius: 16px;
  border: 1px solid var(--border);
  line-height: 1.5;
  max-width: 70%;
  font-size: 15px;
  color: #eaf1ff;
  box-shadow: 0 1px 0 rgba(0,0,0,.08);
}

.message.user .message-content, .me .bubble {
  background: var(--primary);
  color: white;
}

.chat-input-container, .chat-input {
  padding: 1rem;
  border-top: 1px solid var(--border);
  display: flex;
  gap: 0.75rem;
  align-items: center;
  margin-top: 8px;
}

.chat-input input {
  flex: 1;
  padding: 0.75rem 1rem;
  border: 1px solid var(--border);
  border-radius: 25px;
  background: var(--bg-glass);
  backdrop-filter: blur(10px);
  color: var(--text);
  outline: none;
}

/* Tables */
.kv td {
  background: #0b1220;
  border: 1px solid var(--line);
  padding: 6px;
  border-radius: 6px;
}

.kv {
  border-collapse: separate;
  border-spacing: 6px 8px;
}

/* Activities Tool */
.activities-preview, .box {
  background: var(--bg-glass);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 1.5rem;
  margin-top: 1.5rem;
  min-height: 300px;
  white-space: pre-wrap;
  line-height: 1.7;
  font-family: 'Cairo', sans-serif;
  background: #0c1426;
  margin-bottom: 10px;
}

#actPreview b {
  color: #c7d2fe;
}

/* PDF Report Styles */
.report {
  width: 794px;
  min-height: 1123px;
  background: #ffffff;
  color: #0f172a;
  padding: 40px;
  position: relative;
  font-family: 'Tahoma', Arial, sans-serif;
}

.report .stamp {
  position: absolute;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) rotate(0deg);
  width: 180px;
  mix-blend-mode: normal;
  filter: none;
}

.r-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.r-title {
  font-size: 22px;
  font-weight: 800;
}

.r-badges {
  display: flex;
  gap: 8px;
  align-items: center;
}

.r-badge {
  border-radius: 999px;
  padding: 6px 10px;
  font-size: 12px;
  border: 1px solid #ddd;
}

.r-badge-mode {
  background: #e0f2fe;
  color: #0c4a6e;
  border-color: #bae6fd;
}

.r-badge-conf {
  background: #dcfce7;
  color: #14532d;
  border-color: #bbf7d0;
}

.r-line {
  height: 3px;
  background: linear-gradient(90deg, #22c55e, #0ea5e9);
  width: 100%;
  margin: 8px 0 18px;
  border-radius: 2px;
}

.r-section {
  margin: 14px 0;
}

.r-section-title {
  font-weight: 800;
  color: #0f172a;
  margin-bottom: 6px;
}

.r-summary {
  background: #f8fafc;
  border: 1px solid #e5e7eb;
  border-radius: 10px;
  padding: 10px;
  line-height: 1.8;
}

.r-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  border: 1px solid #e5e7eb;
  border-radius: 12px;
  overflow: hidden;
}

.r-table thead th {
  background: #0ea5e9;
  color: #fff;
  text-align: right;
  padding: 10px;
  font-size: 13px;
}

.r-table tbody td {
  background: #ffffff;
  padding: 10px;
  border-top: 1px solid #e5e7eb;
  font-size: 13px;
}

.r-table tbody tr:nth-child(even) td {
  background: #f8fafc;
}

/* Responsive Design */
@media (max-width: 1100px) {
  .meta-cards {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 768px) {
  .container, .wrap {
    padding: 1rem;
  }
  
  .grid-2,
  .grid-3,
  .grid-4 {
    grid-template-columns: 1fr;
  }
  
  .header-content {
    flex-direction: column;
    text-align: center;
  }
  
  .quality-selector, .actions {
    justify-content: center;
  }
  
  .meta-cards {
    grid-template-columns: 1fr;
  }
  
  .meta-card {
    grid-template-columns: 38px 1fr;
  }
  
  .meta-icon {
    width: 38px;
    height: 38px;
    font-size: 18px;
  }
  
  .meta-value {
    font-size: 16px;
  }
}

@media (max-width: 560px) {
  .meta-cards {
    grid-template-columns: 1fr;
  }
  
  .meta-card {
    grid-template-columns: 38px 1fr;
  }
  
  .meta-icon {
    width: 38px;
    height: 38px;
    font-size: 18px;
  }
  
  .meta-value {
    font-size: 16px;
  }
}

/* Loading Animation */
.loading {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 1rem;
}

.loading-dot {
  width: 8px;
  height: 8px;
  background: var(--primary);
  border-radius: 50%;
  animation: loading 1.4s ease-in-out infinite both;
}

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

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

/* File Upload Status */
.file-status {
  margin-top: 1rem;
  padding: 0.75rem 1rem;
  border-radius: 8px;
  font-size: 0.875rem;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.file-status.success {
  background: rgba(67, 233, 123, 0.15);
  color: #00d774;
  border: 1px solid rgba(67, 233, 123, 0.4);
}

.file-status.success svg {
  color: #00d774;
  filter: drop-shadow(0 0 4px rgba(0, 215, 116, 0.3));
}

.file-status.error {
  background: rgba(248, 113, 113, 0.1);
  color: #f87171;
  border: 1px solid rgba(248, 113, 113, 0.3);
}

/* Utility Classes */
.hidden { display: none !important; }
.text-center { text-align: center; }
.text-muted { color: var(--text-muted); }
.mb-2, .mt { margin-bottom: 1rem; }
.mt-2 { margin-top: 1rem; }
.muted { color: var(--muted); font-size: 12px; }
.hint { color: var(--muted); font-size: 12px; margin-top: 4px; }
.foot { padding: 12px; text-align: center; color: var(--muted); font-size: 12px; }
.start { justify-content: flex-start; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.full { grid-column: 1/-1; }
.spacer { width: 10px; }

/* Mode Display */
.mode {
  font-size: 22px;
  font-weight: 800;
  color: #c7d2fe;
}

/* Input File */
input[type=file] {
  width: 100%;
  border: 1px dashed var(--line);
  border-radius: 10px;
  background: #0b1220;
  color: #cbd5e1;
  padding: 10px;
}

/* Additional Chat Styles */
.meta {
  display: block;
  color: #9fb0c9;
  font-size: 11px;
  margin-top: 2px;
  text-align: left;
}

.me .meta {
  text-align: right;
}

/* Success Animation */
@keyframes success-pulse {
  0% { box-shadow: 0 0 0 0 rgba(67, 233, 123, 0.4); }
  70% { box-shadow: 0 0 0 10px rgba(67, 233, 123, 0); }
  100% { box-shadow: 0 0 0 0 rgba(67, 233, 123, 0); }
}

.success-animation {
  animation: success-pulse 1.5s ease-out;
}