:root {
  /* Indicar al navegador que soportamos ambos modos */
  color-scheme: light dark;
  
  --color-white:#fff;
  --color-black:#000;
  --color-gray-50:#f8fafc;
  --color-gray-100:#f1f5f9;
  --color-gray-200:#e2e8f0;
  --color-gray-300:#cbd5e1;
  --color-gray-400:#94a3b8;
  --color-gray-500:#64748b;
  --color-gray-600:#475569;
  --color-gray-700:#334155;
  --color-gray-800:#1e293b;
  --color-gray-900:#0f172a;
  
  --color-blue-300:#93c5fd;
  --color-blue-400:#60a5fa;
  --color-blue-500:#3b82f6;
  --color-blue-600:#2563eb;
  --color-blue-700:#1d4ed8;
  
  --color-purple-300:#c4b5fd;
  --color-purple-400:#a78bfa;
  --color-purple-500:#8b5cf6;
  --color-purple-600:#7c3aed;
  --color-purple-700:#6d28d9;
  
  --color-pink-300:#f9a8d4;
  --color-pink-400:#f472b6;
  --color-pink-500:#ec4899;
  --color-pink-600:#db2777;
  
  --color-green-300:#86efac;
  --color-green-400:#4ade80;
  --color-green-500:#22c55e;
  --color-green-600:#16a34a;
  
  --color-orange-300:#fdba74;
  --color-orange-400:#fb923c;
  --color-orange-500:#f97316;
  --color-orange-600:#ea580c;
  
  --color-red-400:#f87171;
  --color-red-500:#ef4444;
  --color-red-600:#dc2626;
  
  --color-cream-50:var(--color-gray-50);
  --color-cream-100:var(--color-white);
  --color-slate-500:var(--color-gray-500);
  --color-brown-600:var(--color-purple-600);
  --color-charcoal-700:var(--color-gray-800);
  --color-charcoal-800:var(--color-gray-900);
  --color-slate-900:var(--color-gray-900);
  --color-teal-300:var(--color-blue-300);
  --color-teal-400:var(--color-blue-400);
  --color-teal-500:var(--color-blue-500);
  --color-teal-600:var(--color-blue-600);
  --color-teal-700:var(--color-blue-700);
  --color-teal-800:var(--color-blue-700);

  --color-brown-600-rgb:124,58,237;
  --color-teal-500-rgb:59,130,246;
  --color-slate-900-rgb:15,23,42;
  --color-slate-500-rgb:100,116,139;
  --color-red-500-rgb:239,68,68;
  --color-red-400-rgb:248,113,113;
  --color-orange-500-rgb:249,115,22;
  --color-orange-400-rgb:251,146,60;
  --color-blue-500-rgb:59,130,246;
  --color-purple-500-rgb:139,92,246;
  --color-pink-500-rgb:236,72,153;
  --color-green-500-rgb:34,197,94;

  --color-bg-1:rgba(59,130,246,.15);
  --color-bg-2:rgba(250,204,21,.15);
  --color-bg-3:rgba(34,197,94,.15);
  --color-bg-4:rgba(239,68,68,.15);
  --color-bg-5:rgba(139,92,246,.15);
  --color-bg-6:rgba(249,115,22,.15);
  --color-bg-7:rgba(236,72,153,.15);
  --color-bg-8:rgba(6,182,212,.15);

  --color-background:#fff;
  --color-surface:#fafbfc;
  --color-text:var(--color-gray-900);
  --color-text-secondary:var(--color-gray-600);
  --color-primary:var(--color-blue-500);
  --color-primary-hover:var(--color-blue-600);
  --color-primary-active:var(--color-blue-700);
  --color-secondary:rgba(var(--color-purple-500-rgb),.15);
  --color-secondary-hover:rgba(var(--color-purple-500-rgb),.25);
  --color-secondary-active:rgba(var(--color-purple-500-rgb),.35);
  --color-border:rgba(var(--color-gray-300),.8);
  --color-btn-primary-text:#fff;
  --color-card-border:rgba(var(--color-blue-500-rgb),.2);
  --color-card-border-inner:rgba(var(--color-gray-300),.5);
  --color-error:var(--color-red-500);
  --color-success:var(--color-green-500);
  --color-warning:var(--color-orange-500);
  --color-info:var(--color-blue-500);
  --color-focus-ring:rgba(var(--color-blue-500-rgb),.5);
  --color-select-caret:rgba(var(--color-gray-900),.8);

  --focus-ring:0 0 0 4px var(--color-focus-ring);
  --focus-outline:3px solid var(--color-primary);
  --status-bg-opacity:.2;
  --status-border-opacity:.4;
  --select-caret-light:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%23134252' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
  --select-caret-dark:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%23f5f5f5' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");

  --color-success-rgb:34,197,94;
  --color-error-rgb:239,68,68;
  --color-warning-rgb:249,115,22;
  --color-info-rgb:59,130,246;

  --font-family-base:"FKGroteskNeue","Geist","Inter",-apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,sans-serif;
  --font-family-mono:"Berkeley Mono",ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;
  --font-size-xs:11px;
  --font-size-sm:12px;
  --font-size-base:14px;
  --font-size-md:14px;
  --font-size-lg:16px;
  --font-size-xl:18px;
  --font-size-2xl:20px;
  --font-size-3xl:24px;
  --font-size-4xl:30px;
  --font-weight-normal:400;
  --font-weight-medium:500;
  --font-weight-semibold:550;
  --font-weight-bold:600;
  --line-height-tight:1.2;
  --line-height-normal:1.5;
  --letter-spacing-tight:-.01em;

  --space-0:0;
  --space-1:1px;
  --space-2:2px;
  --space-4:4px;
  --space-6:6px;
  --space-8:8px;
  --space-10:10px;
  --space-12:12px;
  --space-16:16px;
  --space-20:20px;
  --space-24:24px;
  --space-32:32px;

  --radius-sm:6px;
  --radius-base:8px;
  --radius-md:10px;
  --radius-lg:12px;
  --radius-full:9999px;

  --shadow-xs:0 1px 2px rgba(0,0,0,.02);
  --shadow-sm:0 1px 3px rgba(0,0,0,.04),0 1px 2px rgba(0,0,0,.02);
  --shadow-md:0 4px 6px -1px rgba(0,0,0,.04),0 2px 4px -1px rgba(0,0,0,.02);
  --shadow-lg:0 10px 15px -3px rgba(0,0,0,.04),0 4px 6px -2px rgba(0,0,0,.02);
  --shadow-inset-sm:inset 0 1px 0 rgba(255,255,255,.15),inset 0 -1px 0 rgba(0,0,0,.03);

  --duration-fast:150ms;
  --duration-normal:250ms;
  --ease-standard:cubic-bezier(.16,1,.3,1);
  --container-sm:640px;
  --container-md:768px;
  --container-lg:1024px;
  --container-xl:1280px;
}

@media (prefers-color-scheme:dark){
  :root{
    --color-gray-400-rgb:119,124,124;
    --color-teal-300-rgb:50,184,198;
    --color-gray-300-rgb:167,169,169;
    --color-gray-200-rgb:245,245,245;
    --color-bg-1:rgb(216, 214, 202);
    --color-bg-2:rgb(246, 250, 21);
    --color-bg-3:rgba(34,197,94,.25);
    --color-bg-4:rgba(239,68,68,.25);
    --color-bg-5:rgba(139,92,246,.25);
    --color-bg-6:rgba(249,115,22,.25);
    --color-bg-7:rgba(236,72,153,.25);
    --color-bg-8:rgba(6,182,212,.25);
    --color-background:#0f172a;
    --color-surface:#fff;
    --color-text:#000;
    --color-text-secondary:#0f5349;
    --color-primary:var(--color-blue-400);
    --color-primary-hover:var(--color-blue-300);
    --color-primary-active:var(--color-blue-500);
    --color-secondary:rgba(var(--color-purple-500-rgb),.25);
    --color-secondary-hover:rgba(var(--color-purple-500-rgb),.35);
    --color-secondary-active:rgba(var(--color-purple-500-rgb),.45);
    --color-border:rgba(148,163,184,.3);
    --color-error:var(--color-red-400);
    --color-success:var(--color-green-400);
    --color-warning:var(--color-orange-400);
    --color-info: var(--color-blue-400);
    --color-focus-ring: rgba(var(--color-blue-500-rgb), 0.5);
    --color-btn-primary-text: #0f172a;
    --color-card-border: rgba(var(--color-blue-500-rgb), 0.3);
    --color-card-border-inner: rgba(148, 163, 184, 0.2);
    --shadow-inset-sm: inset 0 1px 0 rgba(255, 255, 255, 0.1),
      inset 0 -1px 0 rgba(0, 0, 0, 0.15);
    --button-border-secondary: rgba(var(--color-gray-400-rgb), 0.2);
    --color-border-secondary: rgba(var(--color-gray-400-rgb), 0.2);
    --color-select-caret: rgba(var(--color-gray-200-rgb), 0.8);

    /* Common style patterns - updated for dark mode */
    --focus-ring: 0 0 0 3px var(--color-focus-ring);
    --focus-outline: 2px solid var(--color-primary);
    --status-bg-opacity: 0.15;
    --status-border-opacity: 0.25;
    --select-caret-light: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%23134252' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
    --select-caret-dark: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%23f5f5f5' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");

    /* RGB versions for dark mode */
    --color-success-rgb: var(--color-teal-300-rgb);
    --color-error-rgb: var(--color-red-400-rgb);
    --color-warning-rgb: var(--color-orange-400-rgb);
    --color-info-rgb: var(--color-gray-300-rgb);
  }
}

[data-color-scheme="dark"]{
  --color-gray-400-rgb:119,124,124;
  --color-teal-300-rgb:50,184,198;
  --color-gray-300-rgb:167,169,169;
  --color-gray-200-rgb:245,245,245;
  --color-bg-1:rgba(29,78,216,.15);
  --color-bg-2:rgba(180,83,9,.15);
  --color-bg-3:rgba(21,128,61,.15);
  --color-bg-4:rgba(185,28,28,.15);
  --color-bg-5:rgba(107,33,168,.15);
  --color-bg-6:rgba(194,65,12,.15);
  --color-bg-7:rgba(190,24,93,.15);
  --color-bg-8:rgba(8,145,178,.15);
  --color-background:var(--color-charcoal-700);
  --color-surface:var(--color-charcoal-800);
  --color-text:var(--color-gray-200);
  --color-text-secondary:rgba(var(--color-gray-300-rgb),.7);
  --color-primary:var(--color-teal-300);
  --color-primary-hover:var(--color-teal-400);
  --color-primary-active:var(--color-teal-800);
  --color-secondary:rgba(var(--color-gray-400-rgb),.15);
  --color-secondary-hover:rgba(var(--color-gray-400-rgb),.25);
  --color-secondary-active:rgba(var(--color-gray-400-rgb),.3);
  --color-border:rgba(var(--color-gray-400-rgb),.3);
  --color-error:var(--color-red-400);
  --color-success:var(--color-teal-300);
  --color-warning:var(--color-orange-400);
  --color-info:var(--color-gray-300);
  --color-focus-ring:rgba(var(--color-teal-300-rgb),.4);
  --color-btn-primary-text:var(--color-slate-900);
  --color-card-border:rgba(var(--color-gray-400-rgb),.15);
  --color-card-border-inner:rgba(var(--color-gray-400-rgb),.15);
  --shadow-inset-sm:inset 0 1px 0 rgba(255,255,255,.1),inset 0 -1px 0 rgba(0,0,0,.15);
  --color-border-secondary:rgba(var(--color-gray-400-rgb),.2);
  --color-select-caret:rgba(var(--color-gray-200-rgb),.8);
  --focus-ring:0 0 0 3px var(--color-focus-ring);
  --focus-outline:2px solid var(--color-primary);
  --status-bg-opacity:.15;
  --status-border-opacity:.25;
  --select-caret-light: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%23134252' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
  --select-caret-dark: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%23f5f5f5' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");

  /* RGB versions for dark mode */
  --color-success-rgb: var(--color-teal-300-rgb);
  --color-error-rgb: var(--color-red-400-rgb);
  --color-warning-rgb: var(--color-orange-400-rgb);
  --color-info-rgb: var(--color-gray-300-rgb);
}

[data-color-scheme="light"]{
  --color-brown-600-rgb:94,82,64;
  --color-teal-500-rgb:33,128,141;
  --color-slate-900-rgb:19,52,59;
  --color-background:var(--color-cream-50);
  --color-surface:var(--color-cream-100);
  --color-text:var(--color-slate-900);
  --color-text-secondary:var(--color-slate-500);
  --color-primary:var(--color-teal-500);
  --color-primary-hover:var(--color-teal-600);
  --color-primary-active:var(--color-teal-700);
  --color-secondary:rgba(var(--color-brown-600-rgb),.12);
  --color-secondary-hover:rgba(var(--color-brown-600-rgb),.2);
  --color-secondary-active:rgba(var(--color-brown-600-rgb),.25);
  --color-border:rgba(var(--color-brown-600-rgb),.2);
  --color-btn-primary-text:var(--color-cream-50);
  --color-card-border:rgba(var(--color-brown-600-rgb),.12);
  --color-card-border-inner:rgba(var(--color-brown-600-rgb),.12);
  --color-error:var(--color-red-500);
  --color-success:var(--color-teal-500);
  --color-warning:var(--color-orange-500);
  --color-info:var(--color-slate-500);
  --color-focus-ring:rgba(var(--color-teal-500-rgb),.4);
  --color-success-rgb:var(--color-teal-500-rgb);
  --color-error-rgb:var(--color-red-500-rgb);
  --color-warning-rgb:var(--color-orange-500-rgb);
  --color-info-rgb:var(--color-slate-500-rgb);
}

html{
  font-size:var(--font-size-base);
  font-family:var(--font-family-base);
  line-height:var(--line-height-normal);
  color:var(--color-text);
  background-color:var(--color-background);
  -webkit-font-smoothing:antialiased;
  box-sizing:border-box
}
body{
  margin:0;
  padding:0
}

*,
*::before,
*::after {
  box-sizing: inherit;
}

h1,h2,h3,h4,h5,h6{
  margin:0;
  font-weight:var(--font-weight-semibold);
  line-height:var(--line-height-tight);
  color:var(--color-text);
  letter-spacing:var(--letter-spacing-tight)
}

h1{font-size:var(--font-size-4xl)}
h2{font-size:var(--font-size-3xl)}
h3{font-size:var(--font-size-2xl)}
h4{font-size:var(--font-size-xl)}
h5{font-size:var(--font-size-lg)}
h6{font-size:var(--font-size-md)}

p{margin:0 0 var(--space-16) 0}
a{color:var(--color-primary);text-decoration:none;transition:color var(--duration-fast) var(--ease-standard)}
a:hover{color:var(--color-primary-hover)}

code,
pre {
  font-family: var(--font-family-mono);
  font-size: calc(var(--font-size-base) * 0.95);
  background-color: var(--color-secondary);
  border-radius: var(--radius-sm);
}

code {
  padding: var(--space-1) var(--space-4);
}

pre {
  padding: var(--space-16);
  margin: var(--space-16) 0;
  overflow: auto;
  border: 1px solid var(--color-border);
}

pre code {
  background: none;
  padding: 0;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-8) var(--space-16);
  border-radius: var(--radius-base);
  font-size: var(--font-size-base);
  font-weight: 500;
  line-height: 1.5;
  cursor: pointer;
  transition: all var(--duration-normal) var(--ease-standard);
  border: none;
  text-decoration: none;
  position: relative;
}

.btn:focus-visible {
  outline: none;
  box-shadow: var(--focus-ring);
}

.btn--primary {
  background: linear-gradient(135deg, var(--color-primary) 0%, var(--color-primary-hover) 100%);
  color: var(--color-btn-primary-text);
  box-shadow: 0 4px 15px rgba(var(--color-blue-500-rgb), 0.3);
  border: 1px solid rgba(255, 255, 255, 0.2);
}

.btn--primary:hover {
  background: linear-gradient(135deg, var(--color-primary-hover) 0%, var(--color-primary-active) 100%);
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(var(--color-blue-500-rgb), 0.4);
}

.btn--primary:active {
  background: var(--color-primary-active);
  transform: translateY(0);
  box-shadow: 0 2px 10px rgba(var(--color-blue-500-rgb), 0.3);
}

.btn--danger {
  background: linear-gradient(135deg, var(--color-red-500) 0%, var(--color-red-600) 100%);
  color: white;
  box-shadow: 0 4px 15px rgba(var(--color-red-500-rgb), 0.3);
}

.btn--danger:hover {
  background: linear-gradient(135deg, var(--color-red-600) 0%, #b91c1c 100%);
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(var(--color-red-500-rgb), 0.4);
}

.btn--danger:active {
  background: var(--color-red-600);
  transform: translateY(0);
  box-shadow: 0 2px 10px rgba(var(--color-red-500-rgb), 0.3);
}

.btn--secondary {
  background: var(--color-secondary);
  color: var(--color-text);
  border: 2px solid rgba(var(--color-purple-500-rgb), 0.3);
  box-shadow: 0 2px 10px rgba(var(--color-purple-500-rgb), 0.1);
}

.btn--secondary:hover {
  background: var(--color-secondary-hover);
  border-color: rgba(var(--color-purple-500-rgb), 0.5);
  transform: translateY(-1px);
  box-shadow: 0 4px 15px rgba(var(--color-purple-500-rgb), 0.2);
}

.btn--secondary:active {
  background: var(--color-secondary-active);
  transform: translateY(0);
  box-shadow: 0 2px 8px rgba(var(--color-purple-500-rgb), 0.15);
}

.admin-rooms-list {
  max-height: 400px;
  overflow-y: auto;
  padding: 0;
}

.room-item {
  border: 1px solid #ddd;
  border-radius: 8px;
  padding: 15px;
  margin-bottom: 15px;
  background: #fff;
  transition: all 0.2s ease;
}

.room-item.room-active {
  border-left: 4px solid #28a745;
  background: #f8fff9;
}

.room-item.room-inactive {
  border-left: 4px solid #dc3545;
  background: #fff8f8;
  opacity: 0.8;
}

.room-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
  padding-bottom: 8px;
  border-bottom: 1px solid #eee;
}

.room-header h4 {
  margin: 0;
  font-size: 1.2em;
  font-weight: bold;
  color: #333;
}

.room-status {
  font-size: 0.9em;
  font-weight: 500;
  padding: 4px 8px;
  border-radius: 4px;
  background: #f0f0f0;
}

.room-info {
  margin-bottom: 15px;
}

.room-info p {
  margin: 5px 0;
  font-size: 0.9em;
  color: #555;
}

.room-info strong {
  color: #333;
  font-weight: 600;
}

.room-actions {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  margin-top: 10px;
}

.btn--sm {
  padding: 6px 12px;
  font-size: 0.85em;
  min-height: auto;
}

.no-rooms {
  text-align: center;
  padding: 40px 20px;
  color: #666;
  font-style: italic;
}

/* Responsive para modal admin */
@media (max-width: 480px) {
  .room-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
  }
  
  .room-actions {
    justify-content: center;
  }
  
  .admin-rooms-list {
    max-height: 300px;
  }
}

.btn--outline {
  background: transparent;
  border: 1px solid var(--color-border);
  color: rgba(210, 227, 228, 1);
}

.btn--outline:hover {
  background: var(--color-secondary);
}

.btn--sm {
  padding: var(--space-4) var(--space-12);
  font-size: var(--font-size-sm);
  border-radius: var(--radius-sm);
}

.btn--lg {
  padding: var(--space-10) var(--space-20);
  font-size: var(--font-size-lg);
  border-radius: var(--radius-md);
}

.btn--full-width {
  width: 100%;
}

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

/* Form elements */
.form-control {
  display: block;
  width: 100%;
  padding: var(--space-8) var(--space-12);
  font-size: var(--font-size-md);
  line-height: 1.5;
  color: var(--color-text);
  background-color: var(--color-surface);
  border: 2px solid var(--color-border);
  border-radius: var(--radius-base);
  transition: all var(--duration-fast) var(--ease-standard);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
}

textarea.form-control {
  font-family: var(--font-family-base);
  font-size: var(--font-size-base);
}

select.form-control {
  padding: var(--space-8) var(--space-12);
  -webkit-appearance: none;
  -moz-appearance: none;
  appearance: none;
  background-image: var(--select-caret-light);
  background-repeat: no-repeat;
  background-position: right var(--space-12) center;
  background-size: 16px;
  padding-right: var(--space-32);
}

/* Add a dark mode specific caret */
@media (prefers-color-scheme: dark) {
  select.form-control {
    background-image: var(--select-caret-dark);
  }
}

/* Also handle data-color-scheme */
[data-color-scheme="dark"] select.form-control {
  background-image: var(--select-caret-dark);
}

[data-color-scheme="light"] select.form-control {
  background-image: var(--select-caret-light);
}

.form-control:focus {
  border-color: var(--color-primary);
  outline: none;
  box-shadow: 0 0 0 4px rgba(var(--color-blue-500-rgb), 0.2), 0 4px 12px rgba(var(--color-blue-500-rgb), 0.15);
  transform: translateY(-1px);
}

.form-label {
  display: block;
  margin-bottom: var(--space-8);
  font-weight: var(--font-weight-medium);
  font-size: var(--font-size-sm);
}

.form-group {
  margin-bottom: var(--space-16);
}

/* Card component */
.card {
  background-color: var(--color-surface);
  border-radius: var(--radius-lg);
  border: 2px solid var(--color-card-border);
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.05);
  overflow: hidden;
  transition: all var(--duration-normal) var(--ease-standard);
  position: relative;
}

.card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: linear-gradient(90deg, var(--color-blue-500) 0%, var(--color-purple-500) 50%, var(--color-pink-500) 100%);
}

.card:hover {
  box-shadow: 0 8px 25px rgba(0, 0, 0, 0.1);
  transform: translateY(-4px);
  border-color: rgba(var(--color-blue-500-rgb), 0.4);
}

.card__body {
  padding: var(--space-16);
}

.card__header,
.card__footer {
  padding: var(--space-16);
  border-bottom: 1px solid var(--color-card-border-inner);
}

/* Status indicators - simplified with CSS variables */
.status {
  display: inline-flex;
  align-items: center;
  padding: var(--space-6) var(--space-12);
  border-radius: var(--radius-full);
  font-weight: var(--font-weight-medium);
  font-size: var(--font-size-sm);
}

.status--success {
  background-color: rgba(
    var(--color-success-rgb, 33, 128, 141),
    var(--status-bg-opacity)
  );
  color: var(--color-success);
  border: 1px solid
    rgba(var(--color-success-rgb, 33, 128, 141), var(--status-border-opacity));
}

.status--error {
  background-color: rgba(
    var(--color-error-rgb, 192, 21, 47),
    var(--status-bg-opacity)
  );
  color: var(--color-error);
  border: 1px solid
    rgba(var(--color-error-rgb, 192, 21, 47), var(--status-border-opacity));
}

.status--warning {
  background-color: rgba(
    var(--color-warning-rgb, 168, 75, 47),
    var(--status-bg-opacity)
  );
  color: var(--color-warning);
  border: 1px solid
    rgba(var(--color-warning-rgb, 168, 75, 47), var(--status-border-opacity));
}

.status--info {
  background-color: rgba(
    var(--color-info-rgb, 98, 108, 113),
    var(--status-bg-opacity)
  );
  color: var(--color-info);
  border: 1px solid
    rgba(var(--color-info-rgb, 98, 108, 113), var(--status-border-opacity));
}

/* Container layout */
.container {
  width: 100%;
  margin-right: auto;
  margin-left: auto;
  padding-right: var(--space-16);
  padding-left: var(--space-16);
}

@media (min-width: 640px) {
  .container {
    max-width: var(--container-sm);
  }
}
@media (min-width: 768px) {
  .container {
    max-width: var(--container-md);
  }
}
@media (min-width: 1024px) {
  .container {
    max-width: var(--container-lg);
  }
}
@media (min-width: 1280px) {
  .container {
    max-width: var(--container-xl);
  }
}

/* Utility classes */
.flex {
  display: flex;
}
.flex-col {
  flex-direction: column;
}
.items-center {
  align-items: center;
}
.justify-center {
  justify-content: center;
}
.justify-between {
  justify-content: space-between;
}
.gap-4 {
  gap: var(--space-4);
}
.gap-8 {
  gap: var(--space-8);
}
.gap-16 {
  gap: var(--space-16);
}

.m-0 {
  margin: 0;
}
.mt-8 {
  margin-top: var(--space-8);
}
.mb-8 {
  margin-bottom: var(--space-8);
}
.mx-8 {
  margin-left: var(--space-8);
  margin-right: var(--space-8);
}
.my-8 {
  margin-top: var(--space-8);
  margin-bottom: var(--space-8);
}

.p-0 {
  padding: 0;
}
.py-8 {
  padding-top: var(--space-8);
  padding-bottom: var(--space-8);
}
.px-8 {
  padding-left: var(--space-8);
  padding-right: var(--space-8);
}
.py-16 {
  padding-top: var(--space-16);
  padding-bottom: var(--space-16);
}
.px-16 {
  padding-left: var(--space-16);
  padding-right: var(--space-16);
}

.block {
  display: block;
}
.hidden {
  display: none;
}

/* Accessibility */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border-width: 0;
}

:focus-visible {
  outline: var(--focus-outline);
  outline-offset: 2px;
}

/* Dark mode specifics */
[data-color-scheme="dark"] .btn--outline {
  border: 1px solid var(--color-border-secondary);
}

@font-face {
  font-family: 'FKGroteskNeue';
  src: url('https://r2cdn.perplexity.ai/fonts/FKGroteskNeue.woff2')
    format('woff2');
}

/* END PERPLEXITY DESIGN SYSTEM */
/* Estilos específicos para la aplicación de chat anónimo */

/* Layouts de pantalla */
.screen {
  display: none;
  height: 100vh;
  height: 100svh; /* Small viewport height */
  height: 100dvh; /* Dynamic viewport height - preferred */
  width: 100%;
  overflow: hidden;
  /* Estructura flexbox para mejor manejo del layout */
  flex-direction: column;
}

.screen.active {
  display: flex; /* Cambiar de block a flex para activar flexbox */
}

/* Pantalla de bienvenida */
.welcome-content {
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  min-height: 100svh; /* Small viewport height */
  min-height: 100dvh; /* Dynamic viewport height - preferred */
  padding: var(--space-24);
  text-align: center;
  background: linear-gradient(135deg, 
    rgba(var(--color-blue-500-rgb), 0.05) 0%, 
    rgba(var(--color-purple-500-rgb), 0.05) 50%, 
    rgba(var(--color-pink-500-rgb), 0.05) 100%);
  position: relative;
}

.welcome-content::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: radial-gradient(circle at 20% 80%, rgba(var(--color-blue-500-rgb), 0.1) 0%, transparent 50%),
              radial-gradient(circle at 80% 20%, rgba(var(--color-purple-500-rgb), 0.1) 0%, transparent 50%),
              radial-gradient(circle at 40% 40%, rgba(var(--color-pink-500-rgb), 0.05) 0%, transparent 50%);
  pointer-events: none;
}

.logo h1 {
  font-size: var(--font-size-4xl);
  margin-bottom: var(--space-16);
  background: linear-gradient(135deg, var(--color-blue-500) 0%, var(--color-purple-500) 50%, var(--color-pink-500) 100%);
  background-clip: text;
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  font-weight: var(--font-weight-bold);
}

.logo p {
  font-size: var(--font-size-lg);
  color: var(--color-text-secondary);
  margin-bottom: var(--space-32);
}

.welcome-actions {
  width: 100%;
  max-width: 320px;
}

.divider {
  text-align: center;
  margin: var(--space-20) 0;
  color: var(--color-text-secondary);
  font-size: var(--font-size-sm);
}

.privacy-notice {
  margin-top: var(--space-32);
  color: var(--color-text-secondary);
}

/* Headers de pantalla */
.screen-header {
  display: flex;
  align-items: center;
  padding: var(--space-16);
  border-bottom: 1px solid var(--color-border);
  background: var(--color-surface);
  position: sticky;
  top: 0;
  z-index: 10;
}

.btn-back {
  background: none;
  border: none;
  color: var(--color-primary);
  font-size: var(--font-size-lg);
  cursor: pointer;
  padding: var(--space-8);
  margin-right: var(--space-16);
  border-radius: var(--radius-base);
  min-width: 48px;
  min-height: 48px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.btn-back:hover {
  background: var(--color-secondary);
}

.screen-header h2 {
  font-size: var(--font-size-xl);
  margin: 0;
}

/* Formularios */
.form {
  padding: var(--space-24);
  max-width: 480px;
  margin: 0 auto;
}

.form-help {
  color: var(--color-text-secondary);
  font-size: var(--font-size-sm);
  margin-top: var(--space-4);
}

.message-input {
  resize: vertical;
  min-height: 100px;
  font-family: var(--font-family-base);
  overflow-y: auto;
  line-height: 1.4;
}

/* Chat específico */
/* Header antiguo eliminado - información movida a barra inferior */

/* Barra inferior dentro del scroll - al final del contenido */
.chat-bottom-bar {
  flex-shrink: 0; /* No permitir que se comprima */
  background: rgba(255, 255, 255, 0.95);
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
  border-top: 1px solid var(--color-border);
  border-bottom: 1px solid var(--color-border);
  padding: var(--space-8) var(--space-16);
  display: flex;
  justify-content: space-between;
  align-items: center;
  height: 40px;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
  margin-top: auto; /* Empujar al final del contenido */
  margin-bottom: var(--space-16); /* Espacio antes del padding */
  min-width: 0; /* Permitir shrinking */
  overflow-x: auto; /* Permitir scroll horizontal si es necesario */
  overflow-y: hidden; /* Eliminar scroll vertical */
  -webkit-overflow-scrolling: touch; /* Smooth scroll en iOS */
  position: static; /* Parte del flujo normal - hace scroll */
  z-index: 1; /* Bajo z-index - dentro del scroll */
}

[data-color-scheme="dark"] .chat-bottom-bar {
  background: rgba(31, 41, 55, 0.95);
}

/* Mejora de visibilidad de botones SOLO en modo claro */
[data-color-scheme="light"] .chat-bottom-bar .btn--xs {
  border: 1px solid rgba(0, 0, 0, 0.1);
  background: rgba(255, 255, 255, 0.8);
  color: #333333;
}

[data-color-scheme="light"] .chat-bottom-bar .btn--xs:hover {
  background: rgba(255, 255, 255, 1);
  border-color: rgba(0, 0, 0, 0.2);
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
  color: #222222;
}

.chat-info-compact {
  display: flex;
  align-items: center;
  gap: var(--space-12);
  font-size: var(--font-size-xs);
  flex-shrink: 1; /* Puede reducirse */
  min-width: 0; /* Permite truncar texto */
  overflow: hidden; /* Evita overflow */
}

.room-code-compact {
  color: var(--color-primary);
  font-family: var(--font-family-mono);
  font-weight: var(--font-weight-semibold);
  cursor: pointer;
  padding: var(--space-2) var(--space-4);
  border-radius: var(--radius-sm);
  background: var(--color-bg-1);
}

.room-code-compact:hover {
  background: var(--color-bg-2);
}

.connection-status-compact {
  display: flex;
  align-items: center;
  gap: var(--space-4);
}

.counter-compact {
  font-size: var(--font-size-xs);
  color: var(--color-text-secondary);
}

.chat-actions-compact {
  display: flex;
  gap: var(--space-4);
  flex-shrink: 0; /* Los botones no se reducen */
  align-items: center;
}

.btn--xs {
  font-size: var(--font-size-xs);
  padding: var(--space-2) var(--space-6);
  min-height: 28px;
  height: 28px;
  line-height: 1;
}

.chat-container {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden; /* El scroll lo manejará chat-messages */
  padding-top: var(--space-16);
  padding-bottom: 0; /* Eliminar padding fijo que causa problemas */
}

.chat-messages {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  display: flex;
  flex-direction: column;
  -webkit-overflow-scrolling: touch; /* Smooth scrolling en iOS */
  scroll-behavior: smooth;
  /* Espacio solo para el input fijo - la barra hace scroll */
  padding-bottom: 80px; /* Solo espacio para el input (56px + margen) */
}

/* Contenedor para los mensajes reales */
.messages-container {
  flex: 1 1 auto;
  padding: var(--space-16);
  display: flex;
  flex-direction: column;
  gap: var(--space-16);
}

/* Mensajes */
.message {
  background: var(--color-surface);
  border: 2px solid var(--color-card-border);
  border-radius: var(--radius-lg);
  padding: var(--space-16);
  position: relative;
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.05);
  transition: all var(--duration-normal) var(--ease-standard);
}

.message:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.08);
}

.message.creator-message {
  background: rgba(213,227,226,1);
  border-color: var(--color-success);
  border-width: 2px;
}

[data-color-scheme="dark"] .message.creator-message {
  background: rgba(46, 64, 58, 1);
}

.message.creator-message .message-header {
  color: rgba(114, 134, 28, 1);
  font-weight: var(--font-weight-semibold);
}

.message-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: var(--space-8);
  font-size: var(--font-size-sm);
  color: var(--color-text-secondary);
}

.message-author {
  font-weight: var(--font-weight-medium);
}

.message-time {
  font-size: var(--font-size-xs);
}

.message-content {
  font-size: var(--font-size-base);
  line-height: var(--line-height-normal);
  margin-bottom: var(--space-12);
  word-wrap: break-word;
}

.message-actions {
  display: flex;
  gap: var(--space-8);
  align-items: center;
}

.vote-btn {
  background: var(--color-surface);
  border: 2px solid var(--color-border);
  border-radius: var(--radius-full);
  padding: var(--space-4) var(--space-8);
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: var(--space-4);
  font-size: var(--font-size-sm);
  min-width: 48px;
  min-height: 32px;
  transition: all var(--duration-fast) var(--ease-standard);
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.05);
}

.vote-btn:hover {
  background: var(--color-secondary);
  transform: translateY(-1px);
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.1);
}

.vote-btn.voted-like {
  background: linear-gradient(135deg, var(--color-bg-3) 0%, rgba(var(--color-green-500-rgb), 0.2) 100%);
  border-color: var(--color-success);
  color: var(--color-success);
  font-weight: var(--font-weight-semibold);
  box-shadow: 0 2px 10px rgba(var(--color-green-500-rgb), 0.2);
}

.vote-btn.voted-dislike {
  background: linear-gradient(135deg, var(--color-bg-4) 0%, rgba(var(--color-red-500-rgb), 0.2) 100%);
  border-color: var(--color-error);
  color: var(--color-error);
  font-weight: var(--font-weight-semibold);
  box-shadow: 0 2px 10px rgba(var(--color-red-500-rgb), 0.2);
}

.vote-count {
  font-weight: var(--font-weight-medium);
}


.message-deleted {
  background: rgba(0, 0, 0, 0.02);
  border-color: rgba(0, 0, 0, 0.1);
  opacity: 0.7;
  position: relative;
}

[data-color-scheme="dark"] .message-deleted {
  background: rgba(255, 255, 255, 0.03);
  border-color: rgba(255, 255, 255, 0.1);
}

.message-deleted .message-header {
  opacity: 0.8;
}

.deleted-message-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: var(--space-16);
  background: rgba(0, 0, 0, 0.02);
  border-radius: var(--radius-md);
  border: 1px dashed rgba(0, 0, 0, 0.2);
  margin: var(--space-8) 0;
}

[data-color-scheme="dark"] .deleted-message-content {
  background: rgba(255, 255, 255, 0.03);
  border-color: rgba(255, 255, 255, 0.2);
}

.deleted-icon {
  font-size: 1.5em;
  margin-bottom: var(--space-4);
  opacity: 0.6;
}

.deleted-text {
  font-style: italic;
  color: var(--color-text-secondary);
  font-size: var(--font-size-sm);
  margin-bottom: var(--space-4);
}

.deleted-time {
  font-size: var(--font-size-xs);
  color: var(--color-text-tertiary);
  opacity: 0.8;
}

/* Modo claro - mejorar visibilidad de texto en mensajes borrados */
[data-color-scheme="light"] .message-deleted {
  color: white;
}

[data-color-scheme="light"] .message-deleted .deleted-text {
  color: white;
}

[data-color-scheme="light"] .message-deleted .deleted-time {
  color: white;
}

[data-color-scheme="light"] .message-deleted .deleted-icon {
  color: white;
}

[data-color-scheme="light"] .message-deleted .message-author {
  color: white;
}

[data-color-scheme="light"] .message-deleted .message-time {
  color: white;
}


.admin-delete-btn {
  background: linear-gradient(135deg, #fee2e2 0%, #fecaca 100%);
  border: 2px solid #f87171;
  color: #dc2626;
  border-radius: var(--radius-full);
  padding: var(--space-2) var(--space-6);
  cursor: pointer;
  font-size: var(--font-size-xs);
  min-width: 32px;
  min-height: 28px;
  transition: all var(--duration-fast) var(--ease-standard);
  box-shadow: 0 2px 6px rgba(220, 38, 38, 0.15);
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.admin-delete-btn:hover {
  background: linear-gradient(135deg, #fecaca 0%, #f87171 100%);
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(220, 38, 38, 0.25);
}

.admin-delete-btn:active {
  transform: translateY(0);
  box-shadow: 0 2px 6px rgba(220, 38, 38, 0.15);
}

.admin-restore-btn {
  background: linear-gradient(135deg, #dbeafe 0%, #bfdbfe 100%);
  border: 2px solid #60a5fa;
  color: #2563eb;
  border-radius: var(--radius-full);
  padding: var(--space-4) var(--space-8);
  cursor: pointer;
  font-size: var(--font-size-xs);
  min-width: 80px;
  min-height: 32px;
  transition: all var(--duration-fast) var(--ease-standard);
  box-shadow: 0 2px 6px rgba(37, 99, 235, 0.15);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
}

.admin-restore-btn:hover {
  background: linear-gradient(135deg, #bfdbfe 0%, #93c5fd 100%);
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(37, 99, 235, 0.25);
}

.admin-restore-btn:active {
  transform: translateY(0);
  box-shadow: 0 2px 6px rgba(37, 99, 235, 0.15);
}

.deleted-actions {
  justify-content: center;
  margin-top: var(--space-8);
}

/* Dark mode para botones admin */
[data-color-scheme="dark"] .admin-delete-btn {
  background: linear-gradient(135deg, rgba(220, 38, 38, 0.15) 0%, rgba(248, 113, 113, 0.15) 100%);
  border-color: rgba(248, 113, 113, 0.6);
  color: #f87171;
}

[data-color-scheme="dark"] .admin-delete-btn:hover {
  background: linear-gradient(135deg, rgba(248, 113, 113, 0.2) 0%, rgba(220, 38, 38, 0.2) 100%);
  border-color: #f87171;
}

[data-color-scheme="dark"] .admin-restore-btn {
  background: linear-gradient(135deg, rgba(37, 99, 235, 0.15) 0%, rgba(96, 165, 250, 0.15) 100%);
  border-color: rgba(96, 165, 250, 0.6);
  color: #60a5fa;
}

[data-color-scheme="dark"] .admin-restore-btn:hover {
  background: linear-gradient(135deg, rgba(96, 165, 250, 0.2) 0%, rgba(37, 99, 235, 0.2) 100%);
  border-color: #60a5fa;
}

/* Input del chat - Estilo WhatsApp */
.chat-input-container {
  position: fixed;
  bottom: 0; /* Directamente sobre el teclado virtual */
  left: 0;
  right: 0;
  background: var(--color-surface);
  border-top: 1px solid var(--color-border);
  padding: var(--space-8);
  padding-bottom: calc(var(--space-8) + env(safe-area-inset-bottom));
  z-index: 30 !important; /* INPUT siempre encima */
  height: auto;
  min-height: 56px;
}

.input-group {
  display: flex;
  gap: var(--space-8);
  align-items: flex-end;
}

/* Nuevo estilo WhatsApp */
.input-group.whatsapp-style {
  display: flex;
  gap: var(--space-8);
  align-items: center;
  max-width: 100%;
}

.input-group .form-control {
  flex: 1;
  border-radius: var(--radius-lg);
}

.send-btn {
  min-width: 60px;
  height: 48px;
  border-radius: var(--radius-lg);
  flex-shrink: 0;
}

.action-buttons-group {
  display: flex;
  gap: var(--space-8);
  align-items: center;
}

.btn-attachment-inline {
  height: 48px;
  border-radius: var(--radius-lg);
  font-weight: var(--font-weight-medium);
  white-space: nowrap;
  display: flex;
  align-items: center;
  gap: var(--space-4);
}

.character-count {
  display: block;
  text-align: right;
  margin-top: var(--space-4);
  color: var(--color-text-secondary);
  font-size: var(--font-size-xs);
}

.character-count.warning {
  color: var(--color-warning);
}

.character-count.error {
  color: var(--color-error);
}

/* Ocultar visualmente pero mantener accesible */
.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;
}

/* Botones circulares estilo WhatsApp */
.btn-circle {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  cursor: pointer;
  transition: all 0.2s ease;
  flex-shrink: 0;
  padding: 0;
}

.btn-circle.btn-attachment {
  background: transparent;
  color: var(--color-text-secondary);
}

.btn-circle.btn-attachment:hover {
  background: var(--color-bg-hover);
}

.btn-circle.btn-send {
  background: var(--color-primary);
  color: white;
}

.btn-circle.btn-send:hover:not(:disabled) {
  background: var(--color-primary-hover);
  transform: scale(1.05);
}

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

/* Input estilo WhatsApp */
.whatsapp-style .message-input-wrapper {
  flex: 1;
  display: flex;
  align-items: center;
  background: var(--color-bg);
  border: 1px solid var(--color-border);
  border-radius: 24px;
  padding: 0 var(--space-12);
  min-height: 40px;
}

.whatsapp-style .message-input {
  border: none;
  background: transparent;
  padding: var(--space-8) 0;
  min-height: 24px;
  max-height: 100px;
  line-height: 1.4;
  resize: none;
  overflow-y: auto;
}

.whatsapp-style .message-input:focus {
  outline: none;
  box-shadow: none;
}

/* Evitar que los SVGs capturen eventos de click */
.btn-circle svg {
  pointer-events: none;
}

.btn-circle svg * {
  pointer-events: none;
}

/* Asegurar layout horizontal en whatsapp-style */
.whatsapp-style .message-input-wrapper {
  width: auto !important;
  flex: 1;
  max-width: calc(100% - 100px); /* Espacio para los 2 botones */
}

/* Acciones del chat - Integradas en barra inferior */
/* .chat-actions eliminado - ahora parte de .chat-bottom-bar */

/* Modales */
.modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: var(--space-16);
}

.modal.hidden {
  display: none;
}

.modal-content {
  background: var(--color-surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  width: 100%;
  max-width: 400px;
  max-height: 90vh;
  overflow-y: auto;
}

.modal-header {
  padding: var(--space-20);
  border-bottom: 1px solid var(--color-border);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.modal-header h3 {
  margin: 0;
  font-size: var(--font-size-xl);
}

.btn-close {
  background: none;
  border: none;
  font-size: var(--font-size-2xl);
  cursor: pointer;
  color: var(--color-text-secondary);
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-base);
}

.btn-close:hover {
  background: var(--color-secondary);
}

.modal-body {
  padding: var(--space-20);
}

.modal-footer {
  padding: var(--space-20);
  border-top: 1px solid var(--color-border);
  display: flex;
  gap: var(--space-12);
}

.room-code-display {
  display: flex;
  align-items: center;
  gap: var(--space-12);
  margin: var(--space-16) 0;
  padding: var(--space-16);
  background: linear-gradient(135deg, var(--color-bg-1) 0%, var(--color-bg-5) 100%);
  border-radius: var(--radius-lg);
  border: 2px solid rgba(var(--color-blue-500-rgb), 0.3);
  box-shadow: 0 4px 15px rgba(var(--color-blue-500-rgb), 0.1);
}

.room-code-display code {
  flex: 1;
  font-size: var(--font-size-xl);
  font-weight: var(--font-weight-bold);
  background: none;
  padding: 0;
  background: linear-gradient(135deg, var(--color-blue-500) 0%, var(--color-purple-500) 100%);
  background-clip: text;
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

/* Toast */
.toast {
  position: fixed;
  bottom: calc(var(--space-20) + env(safe-area-inset-bottom));
  left: 50%;
  transform: translateX(-50%);
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: var(--space-12) var(--space-20);
  box-shadow: var(--shadow-lg);
  z-index: 1001;
  max-width: 90%;
  text-align: center;
  transition: all var(--duration-normal) var(--ease-standard);
}

.toast.hidden {
  opacity: 0;
  transform: translateX(-50%) translateY(20px);
  pointer-events: none;
}

.toast.success {
  background: linear-gradient(135deg, var(--color-bg-3) 0%, rgba(var(--color-green-500-rgb), 0.2) 100%);
  border: 2px solid var(--color-success);
  color: var(--color-green-600);
  box-shadow: 0 8px 25px rgba(var(--color-green-500-rgb), 0.2);
}

.toast.error {
  background: linear-gradient(135deg, var(--color-bg-4) 0%, rgba(var(--color-red-500-rgb), 0.2) 100%);
  border: 2px solid var(--color-error);
  color: var(--color-red-600);
  box-shadow: 0 8px 25px rgba(var(--color-red-500-rgb), 0.2);
}

/* Estados de carga y vacío */
.loading {
  text-align: center;
  padding: var(--space-32);
  color: var(--color-text-secondary);
}

.empty-state {
  text-align: center;
  padding: var(--space-32);
}

.empty-state h3 {
  color: var(--color-text-secondary);
  margin-bottom: var(--space-16);
}

.empty-state p {
  color: var(--color-text-secondary);
  font-size: var(--font-size-sm);
}

/* Animaciones */
@keyframes slideInUp {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes pulse {
  0%, 100% {
    transform: scale(1);
  }
  50% {
    transform: scale(1.05);
  }
}

@keyframes messageHighlight {
  0% {
    background-color: var(--color-bg-3);
    transform: scale(1.02);
  }
  100% {
    background-color: transparent;
    transform: scale(1);
  }
}

@keyframes realtimeIndicator {
  0%, 100% {
    opacity: 1;
    transform: scale(1);
  }
  50% {
    opacity: 0.5;
    transform: scale(0.8);
  }
}

.message {
  animation: slideInUp var(--duration-normal) var(--ease-standard);
}

.vote-btn:active {
  animation: pulse var(--duration-fast) var(--ease-standard);
}

/* Mensajes en tiempo real */
.realtime-message {
  animation: slideInUp var(--duration-normal) var(--ease-standard);
}

.message-highlight {
  animation: messageHighlight 2s var(--ease-standard);
}

.realtime-indicator {
  animation: realtimeIndicator 1s var(--ease-standard) infinite;
  color: var(--color-success);
  font-size: var(--font-size-xs);
  margin-left: var(--space-8);
}

/* Indicador de estado de conexión */
.connection-status {
  display: inline-flex;
  align-items: center;
  gap: var(--space-4);
  font-size: var(--font-size-xs);
  color: var(--color-text-secondary);
  padding: var(--space-4) var(--space-8);
  border-radius: var(--radius-full);
  background: var(--color-secondary);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
  font-weight: var(--font-weight-medium);
}

.connection-status.online {
  color: var(--color-green-600);
  background: linear-gradient(135deg, var(--color-bg-3) 0%, rgba(var(--color-green-500-rgb), 0.2) 100%);
  border: 1px solid rgba(var(--color-green-500-rgb), 0.3);
}

.connection-status.offline {
  color: var(--color-red-600);
  background: linear-gradient(135deg, var(--color-bg-4) 0%, rgba(var(--color-red-500-rgb), 0.2) 100%);
  border: 1px solid rgba(var(--color-red-500-rgb), 0.3);
}

.connection-indicator {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: currentColor;
}

.connection-status.online .connection-indicator {
  animation: pulse 2s var(--ease-standard) infinite;
}


/* Estados de mensaje */
.message-state-indicator {
  position: sticky;
  bottom: 0;
  background: rgba(var(--color-teal-500-rgb), 0.1);
  color: var(--color-teal-600);
  padding: 0.5rem 1rem;
  margin: 0.25rem 0;
  border-radius: 1rem;
  font-size: 0.75rem;
  font-weight: 500;
  text-align: center;
  border: 1px solid rgba(var(--color-teal-500-rgb), 0.2);
  animation: messageStateSlide 0.3s ease-out;
  z-index: 10;
}

.message-state-indicator.error {
  background: rgba(var(--color-red-400-rgb), 0.1);
  color: var(--color-red-500);
  border-color: rgba(var(--color-red-400-rgb), 0.2);
}

/* Typing indicator */
.typing-indicator {
  position: sticky;
  bottom: 0;
  background: rgba(var(--color-slate-500-rgb), 0.05);
  padding: 0.75rem 1rem;
  margin: 0.5rem 0;
  border-radius: 1rem;
  animation: typingSlide 0.3s ease-out;
  z-index: 5;
}

.typing-content {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.8rem;
  color: var(--color-slate-500);
  font-style: italic;
}

.typing-dots {
  display: flex;
  gap: 0.2rem;
}

.typing-dots .dot {
  width: 4px;
  height: 4px;
  background: var(--color-slate-400);
  border-radius: 50%;
  animation: typingBounce 1.4s infinite ease-in-out;
}

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

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

.typing-dots .dot:nth-child(3) {
  animation-delay: 0s;
}

/* Enhanced message states */
.message.sending {
  opacity: 0.6;
  transform: scale(0.98);
}

.message.sent {
  opacity: 1;
  transform: scale(1);
  transition: all var(--duration-normal) var(--ease-standard);
}

.message.delivered::after {
  content: "✓";
  position: absolute;
  bottom: 0.25rem;
  right: 0.5rem;
  font-size: 0.7rem;
  color: var(--color-teal-500);
  opacity: 0.7;
}

.message.error {
  border-left: 3px solid var(--color-red-400);
  background: rgba(var(--color-red-400-rgb), 0.05);
}

/* Enhanced connection status */
.connection-status.reconnecting {
  background: rgba(var(--color-orange-400-rgb), 0.1);
  color: var(--color-orange-500);
  border-color: rgba(var(--color-orange-400-rgb), 0.3);
}

.connection-status.reconnecting .connection-indicator {
  color: var(--color-orange-500);
  animation: pulse 2s infinite;
}

/* Nuevas animaciones */
@keyframes messageStateSlide {
  0% {
    opacity: 0;
    transform: translateY(10px) scale(0.95);
  }
  100% {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

@keyframes typingSlide {
  0% {
    opacity: 0;
    transform: translateY(10px);
  }
  100% {
    opacity: 1;
    transform: translateY(0);
  }
}

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

/* Responsive breakpoints */

/* Mobile small screens */
@media (max-width: 480px) {
  .chat-container {
    padding-bottom: 0; /* Eliminar padding que causa problemas con flexbox */
  }
  
  /* FORZAR VISIBILIDAD de la barra de botones en móviles */
  .chat-bottom-bar {
    display: flex !important;
    min-height: 40px !important;
    flex-shrink: 0 !important;
    position: relative !important;
    z-index: 15 !important; /* Consistente - DEBAJO del input */
    margin-bottom: 0 !important; /* Sin margen que la oculte */
  }
  
  /* Asegurar layout horizontal en móviles */
  .input-group.whatsapp-style {
    display: flex !important;
    flex-direction: row !important;
    flex-wrap: nowrap !important;
    align-items: center;
  }
  
  .whatsapp-style .btn-circle {
    width: 36px;  /* Botones más pequeños en móvil */
    height: 36px;
    flex-shrink: 0;
  }
  
  .whatsapp-style .message-input-wrapper {
    flex: 1 1 auto;
    min-width: 0; /* Permitir que se encoja */
    max-width: none;
  }
  
  /* Espacio solo para input en móviles */
  .chat-messages {
    padding-bottom: 70px; /* Solo input - barra dentro del scroll */
  }
  
  .chat-bottom-bar {
    padding: var(--space-6) var(--space-8); /* Menos padding en móviles */
    height: 36px; /* Altura reducida */
    flex-wrap: nowrap; /* No permitir wrap */
    overflow-x: auto; /* Permitir scroll horizontal */
    overflow-y: hidden; /* Eliminar scroll vertical */
    -webkit-overflow-scrolling: touch; /* Smooth scroll en iOS */
    /* Siempre visible - no afectada por scroll */
  }
  
  .chat-info-compact {
    gap: var(--space-8); /* Menos espacio entre elementos */
    flex-shrink: 0; /* No reducir tamaño */
    min-width: 0; /* Permitir texto truncado */
  }
  
  .chat-actions-compact {
    gap: var(--space-2); /* Botones más juntos */
    flex-shrink: 0; /* No reducir para mantener todos los botones visibles */
    flex-wrap: nowrap; /* Mantener en una línea */
    min-width: max-content; /* Ancho mínimo para mostrar todos los botones */
  }
  
  .btn--xs {
    padding: var(--space-1) var(--space-4); /* Padding más pequeño */
    font-size: 11px; /* Texto más pequeño */
    min-height: 24px;
    height: 24px;
  }
  
  .room-code-compact {
    font-size: 11px; /* Código más pequeño */
    padding: var(--space-1) var(--space-2);
  }
  
  .counter-compact {
    font-size: 10px; /* Contador más pequeño */
  }
  
  .chat-input-container {
    padding: var(--space-12);
    padding-bottom: calc(var(--space-12) + env(safe-area-inset-bottom, 12px));
  }
  
  .chat-messages {
    padding: var(--space-12);
    gap: var(--space-12);
  }
  
  .welcome-content {
    padding: var(--space-16);
  }
  
  .form {
    padding: var(--space-16);
  }
  
  .modal-content {
    margin: var(--space-8);
    max-height: calc(100vh - var(--space-16));
  }
  
  /* Mejorar tamaños de botones para touch */
  .btn {
    min-height: 48px;
    padding: var(--space-12) var(--space-20);
  }
  
  .vote-btn {
    min-height: 44px;
    min-width: 64px;
    padding: var(--space-8) var(--space-12);
  }
}

@media (min-width: 768px) {
  .welcome-content {
    padding: var(--space-32);
  }
  
  .welcome-actions {
    max-width: 400px;
  }
  
  .form {
    padding: var(--space-32);
  }
  
  .chat-messages {
    padding: var(--space-24);
  }
  
  .chat-input-container {
    padding: var(--space-24);
  }
  
  .modal-content {
    max-width: 500px;
  }
}

@media (min-width: 1024px) {
  .chat-container {
    max-width: 800px;
    margin: 0 auto;
  }
  
  .chat-input-container {
    max-width: 800px;
    margin: 0 auto;
    position: relative;
    border-top: none;
  }
  
  .chat-bottom-bar {
    margin-top: auto; /* Mantener al final */
    padding: var(--space-16);
    margin-bottom: var(--space-16);
  }
}

/* Accesibilidad y estados focus */
.btn:focus-visible,
.form-control:focus-visible,
.vote-btn:focus-visible {
  outline: var(--focus-outline);
  outline-offset: 2px;
}

/* Estados disabled mejorados */
.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  pointer-events: none;
}

/* Mejoras para touch */
@media (hover: none) and (pointer: coarse) {
  .btn {
    min-height: 48px;
  }
  
  .vote-btn {
    min-height: 44px;
    min-width: 60px;
  }
  
  .btn-back {
    min-width: 48px;
    min-height: 48px;
  }
}

/* Dark mode específico para elementos custom */
@media (prefers-color-scheme: dark) {
  .limit-counter {
    background: var(--color-bg-1);
  }
}

[data-color-scheme="dark"] .limit-counter {
  background: var(--color-bg-1);
}

/* Mejoras para teclado virtual en móviles */
@media (max-height: 600px) and (max-width: 480px) {
  .chat-container {
    padding-bottom: 0; /* Eliminar padding que causa problemas con flexbox */
  }
  
  /* Espacio mínimo cuando el teclado está visible */
  .chat-messages {
    padding-bottom: 60px; /* Mínimo para input */
  }
  
  .chat-bottom-bar {
    padding: var(--space-4) var(--space-6); /* Padding mínimo */
    height: auto !important; /* Altura automática, no fija */
    min-height: 36px !important; /* Altura mínima visible */
    margin-bottom: 0 !important; /* SIN margen que la oculte */
    overflow-x: auto; /* Permitir scroll horizontal */
    overflow-y: hidden; /* Eliminar scroll vertical */
    flex-shrink: 0 !important; /* NUNCA colapsar */
    display: flex !important; /* SIEMPRE visible */
  }
  
  .chat-actions-compact {
    gap: var(--space-1); /* Gap mínimo entre botones */
  }
  
  .btn--xs {
    padding: var(--space-1) var(--space-3); /* Padding mínimo */
    font-size: 10px; /* Texto mínimo */
    min-height: 22px;
    height: 22px;
  }
  
  /* Ocultar texto en botones si es necesario, solo mostrar iconos */
  .btn--xs {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }
  
  .welcome-content {
    min-height: 100vh; /* Usar viewport fijo en pantallas muy pequeñas */
    justify-content: flex-start;
    padding-top: var(--space-32);
  }
}

/* Pantallas extra pequeñas - optimización extrema */
@media (max-width: 320px) {
  .chat-bottom-bar {
    padding: var(--space-2) var(--space-4);
    height: 28px;
    font-size: 9px;
    overflow-x: auto; /* Permitir scroll horizontal */
    overflow-y: hidden; /* Eliminar scroll vertical */
  }
  
  .chat-info-compact {
    gap: var(--space-4);
  }
  
  .room-code-compact {
    font-size: 9px;
    padding: 1px 2px;
  }
  
  .counter-compact {
    font-size: 8px;
  }
  
  .chat-actions-compact {
    gap: 1px;
  }
  
  .btn--xs {
    padding: 1px 3px;
    font-size: 9px;
    min-height: 20px;
    height: 20px;
  }
  
  /* En pantallas muy pequeñas, priorizar iconos sobre texto */
  .btn--xs:not(#leaveRoomBtn) {
    font-size: 12px; /* Solo iconos más grandes */
  }
}

/* =====================================================
   ESTILOS PARA SISTEMA DE PDFs
   ===================================================== */

/* Botón de adjuntar PDF en input */
.message-input-wrapper {
  position: relative;
  flex: 1;
  display: flex;
  align-items: flex-end;
}

.input-actions {
  position: absolute;
  right: var(--space-8);
  bottom: var(--space-8);
  z-index: 2;
}

.btn-attachment {
  background: var(--color-primary);
  color: white;
  border: none;
  border-radius: 50%;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  cursor: pointer;
  transition: all var(--transition-base);
  box-shadow: var(--shadow-sm);
}

.btn-attachment:hover {
  background: var(--color-primary-hover);
  transform: translateY(-1px);
  box-shadow: var(--shadow-md);
}

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

/* Barra de progreso de subida */
.pdf-upload-progress {
  position: absolute;
  top: -50px;
  left: 0;
  right: 0;
  background: var(--color-bg-card);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: var(--space-12);
  z-index: 10;
  animation: slideDown 0.3s ease-out;
}

.progress-bar {
  width: 100%;
  height: 8px;
  background: var(--color-bg-1);
  border-radius: var(--radius-sm);
  overflow: hidden;
  margin-bottom: var(--space-8);
}

.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--color-primary), var(--color-secondary));
  transition: width 0.3s ease;
  border-radius: var(--radius-sm);
}

.progress-text {
  font-size: 0.85rem;
  color: var(--color-text-2);
  text-align: center;
  font-weight: 500;
}

/* Sección de archivos adjuntos */
.attachments-section {
  flex-shrink: 0; /* No permitir que se comprima */
  background: var(--color-bg-card);
  border-top: 1px solid var(--color-border);
  transition: all var(--transition-base);
  overflow: hidden;
  margin-top: auto; /* Empujar hacia abajo junto con bottom-bar */
}

.attachments-section.hidden {
  max-height: 0;
  border-top: none;
  padding: 0;
  margin: 0;
}

.attachments-section:not(.hidden) {
  max-height: 300px;
  margin-bottom: var(--space-16);
}

.attachments-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-12) var(--space-16);
  border-bottom: 1px solid var(--color-border);
  background: var(--color-bg-1);
}

.attachments-header h4 {
  margin: 0;
  font-size: 0.9rem;
  font-weight: 600;
  color: rgba (150,201,202,1);
}


.attachments-list {
  max-height: 240px;
  overflow-y: auto;
  padding: var(--space-8);
  padding-bottom: 80px; /* Espacio extra para scroll completo - último PDF visible */
}

/* Componente individual de PDF */
.pdf-attachment {
  display: flex;
  align-items: center;
  gap: var(--space-12);
  padding: var(--space-12);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  background: var(--color-bg-card);
  margin-bottom: var(--space-8);
  transition: all var(--transition-base);
}

.pdf-attachment:hover {
  border-color: var(--color-primary);
  box-shadow: var(--shadow-sm);
  transform: translateY(-1px);
}

.pdf-attachment:last-child {
  margin-bottom: 0;
}

.pdf-icon {
  font-size: 1.5rem;
  flex-shrink: 0;
}

.pdf-info {
  flex: 1;
  min-width: 0;
}

.pdf-name {
  font-weight: 600;
  color: var(--color-text-1);
  font-size: 0.9rem;
  margin-bottom: var(--space-4);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.pdf-meta {
  font-size: 0.8rem;
  color: var(--color-text-2);
  display: flex;
  gap: var(--space-8);
  align-items: center;
}

.pdf-actions {
  display: flex;
  gap: var(--space-4);
  flex-shrink: 0;
}

.btn-pdf-preview,
.btn-pdf-download {
  background: transparent;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all var(--transition-base);
  font-size: 0.9rem;
}

.btn-pdf-preview:hover {
  background: var(--color-primary);
  border-color: var(--color-primary);
  color: white;
}

.btn-pdf-download:hover {
  background: var(--color-success);
  border-color: var(--color-success);
  color: white;
}

/* Modal de Password para acceso IA */
.ai-password-modal .modal-content {
  max-width: 480px;
  width: 90%;
}

.ai-password-content {
  text-align: center;
}

.ai-password-body {
  padding: 2rem;
}

.ai-password-description {
  margin-bottom: 1.5rem;
  color: var(--color-text-secondary);
  font-size: 0.95rem;
  line-height: 1.5;
}

.password-input-group {
  margin: 1.5rem 0;
  position: relative;
}

.password-input {
  width: 100%;
  padding: 1rem;
  font-size: 1.1rem;
  text-align: center;
  letter-spacing: 0.2em;
  border: 2px solid var(--color-border);
  border-radius: var(--border-radius);
  background: var(--color-white);
  transition: all 0.3s ease;
  font-family: 'Courier New', monospace;
  font-weight: 600;
}

.password-input:focus {
  outline: none;
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
  transform: scale(1.02);
}

.password-feedback {
  margin-top: 0.75rem;
  min-height: 20px;
  font-size: 0.9rem;
  font-weight: 500;
}

.password-feedback.success {
  color: var(--color-success);
}

.password-feedback.error {
  color: var(--color-danger);
}

.password-feedback.loading {
  color: var(--color-info);
  animation: pulse 1.5s ease-in-out infinite alternate;
}

@keyframes pulse {
  0% { opacity: 0.6; }
  100% { opacity: 1; }
}

.password-actions {
  display: flex;
  gap: 1rem;
  justify-content: center;
  margin-top: 2rem;
}

.password-actions .btn {
  min-width: 120px;
  padding: 0.75rem 1.5rem;
  font-weight: 600;
}

/* Animación para el modal de password */
.ai-password-modal.show {
  animation: fadeIn 0.3s ease;
}

.ai-password-modal.show .modal-content {
  animation: slideInDown 0.3s ease;
}

@keyframes slideInDown {
  from {
    opacity: 0;
    transform: translate(-50%, -60%) scale(0.95);
  }
  to {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1);
  }
}

/* Responsive para modal de password */
@media (max-width: 768px) {
  .ai-password-modal .modal-content {
    max-width: 95%;
    margin: 1rem;
  }
  
  .password-actions {
    flex-direction: column;
  }
  
  .password-actions .btn {
    width: 100%;
  }
}

/* Modo oscuro para modal de password */
[data-color-scheme="dark"] .ai-password-modal .modal-content {
  background: var(--color-dark-card);
  border: 1px solid var(--color-dark-border);
}

[data-color-scheme="dark"] .password-input {
  background: var(--color-dark-bg);
  border-color: var(--color-dark-border);
  color: var(--color-dark-text);
}

[data-color-scheme="dark"] .password-input:focus {
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.2);
}

[data-color-scheme="dark"] .ai-password-description {
  color: var(--color-dark-text-secondary);
}

/* Modal de preview PDF */
.pdf-modal .modal-content {
  max-width: 90vw;
  max-height: 90vh;
  width: 1000px;
}

.pdf-modal-content {
  display: flex;
  flex-direction: column;
}

.pdf-modal-body {
  flex: 1;
  padding: 0;
  display: flex;
  min-height: 600px;
}

#pdfPreviewFrame {
  width: 100%;
  height: 100%;
  min-height: 600px;
  border: none;
  border-radius: 0 0 var(--radius-md) var(--radius-md);
}

/* PDF en mensajes de chat */
.message-pdf {
  margin-top: var(--space-8);
  padding: var(--space-12);
  background: var(--color-bg-1);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
}

.message-pdf .pdf-attachment {
  margin-bottom: 0;
  border: none;
  padding: 0;
  background: transparent;
}

.message-pdf .pdf-attachment:hover {
  transform: none;
  box-shadow: none;
  border-color: transparent;
}

/* Responsive para PDFs */
@media (max-width: 768px) {
  .pdf-modal .modal-content {
    width: 95vw;
    height: 95vh;
    max-width: none;
    max-height: none;
    border-radius: var(--radius-lg);
  }
  
  .pdf-modal-body {
    min-height: 70vh;
  }
  
  #pdfPreviewFrame {
    min-height: 70vh;
  }
  
  .pdf-attachment {
    padding: var(--space-8);
    gap: var(--space-8);
  }
  
  .pdf-name {
    font-size: 0.85rem;
  }
  
  .pdf-meta {
    font-size: 0.75rem;
    flex-direction: column;
    align-items: flex-start;
    gap: var(--space-2);
  }
  
  .btn-pdf-preview,
  .btn-pdf-download {
    width: 36px;
    height: 36px;
    font-size: 1rem;
  }
}

@media (max-width: 480px) {
  .input-group {
    flex-direction: column;
    gap: var(--space-8);
    align-items: stretch;
  }
  
  .message-input-wrapper {
    order: 1;
    width: auto; /* Cambiado de 100% para evitar wrap */
    flex: 1;
  }
  
  .message-input {
    width: 100%;
    min-height: 120px;
    max-height: 200px;
    padding: var(--space-12);
    font-size: 16px;
    line-height: 1.4;
    overflow-y: auto;
    resize: none;
    box-sizing: border-box;
  }
  
  .action-buttons-group {
    order: 2;
    display: flex;
    gap: var(--space-8);
    width: 100%;
  }
  
  .btn-attachment-inline {
    flex: 0 0 auto;
    padding: var(--space-8) var(--space-12);
  }
  
  .send-btn {
    flex: 1;
    margin-top: 0;
  }
  
  .attachments-list {
    max-height: 180px; /* Reducir de 200px para mejor aprovechamiento */
    padding: var(--space-4); /* Reducir padding del contenedor */
    padding-bottom: 80px; /* Preservar espacio para scroll completo en móviles */
  }
  
  .pdf-attachment {
    flex-direction: column;
    align-items: flex-start;
    gap: var(--space-4); /* Reducir de var(--space-8) para elementos más compactos */
    padding: var(--space-8) var(--space-12); /* Reducir padding vertical */
    min-height: unset; /* Remover altura mínima */
  }
  
  .pdf-info {
    width: 100%;
    gap: var(--space-2); /* Reducir espaciado interno */
  }
  
  .pdf-actions {
    align-self: flex-end;
    margin-top: var(--space-2); /* Reducir margen superior */
  }
  
  .pdf-info {
    width: 100%;
  }
  
  .pdf-actions {
    align-self: flex-end;
  }
}

/* Animaciones para PDFs */
@keyframes slideDown {
  from {
    opacity: 0;
    transform: translateY(-10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes fadeInScale {
  from {
    opacity: 0;
    transform: scale(0.95);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

.pdf-attachment {
  animation: fadeInScale 0.3s ease-out;
}

/* Estados de loading para PDFs */
.pdf-loading {
  opacity: 0.6;
  pointer-events: none;
}

.pdf-loading::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  width: 20px;
  height: 20px;
  border: 2px solid var(--color-border);
  border-top: 2px solid var(--color-primary);
  border-radius: 50%;
  animation: spin 1s linear infinite;
  transform: translate(-50%, -50%);
}

@keyframes spin {
  0% { transform: translate(-50%, -50%) rotate(0deg); }
  100% { transform: translate(-50%, -50%) rotate(360deg); }
}

/* Dark mode para PDFs */
@media (prefers-color-scheme: dark) {
  .pdf-attachment {
    background: var(--color-bg-2);
    border-color: var(--color-border-dark);
  }
  
  .attachments-section {
    background: var(--color-bg-2);
    border-color: var(--color-border-dark);
  }
  
  .attachments-header {
    background: var(--color-bg-1);
    border-color: var(--color-border-dark);
  }
}

[data-color-scheme="dark"] .pdf-attachment {
  background: var(--color-bg-2);
  border-color: var(--color-border-dark);
}

[data-color-scheme="dark"] .attachments-section {
  background: var(--color-bg-2);
  border-color: var(--color-border-dark);
}

[data-color-scheme="dark"] .attachments-header {
  background: var(--color-bg-1);
  border-color: var(--color-border-dark);
}


/* Modal IA específico */
.ai-modal .modal-content {
  max-width: 800px;
  width: 90%;
}

.ai-modal-body {
  max-height: 70vh;
  overflow-y: auto;
}

/* Grid de opciones de análisis */
.ai-options-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 1rem;
  margin: 1.5rem 0;
}

.ai-option-btn {
  background: var(--color-white);
  border: 2px solid var(--color-border);
  border-radius: var(--border-radius);
  padding: 1.5rem;
  cursor: pointer;
  transition: all 0.3s ease;
  text-align: center;
  position: relative;
  overflow: hidden;
}

.ai-option-btn::before {
  content: '';
  position: absolute;
  top: 0;
  left: -100%;
  width: 100%;
  height: 100%;
  background: linear-gradient(
    90deg,
    transparent,
    rgba(59, 130, 246, 0.1),
    transparent
  );
  transition: left 0.5s ease;
}

.ai-option-btn:hover::before {
  left: 100%;
}

.ai-option-btn:hover {
  border-color: var(--color-blue-500);
  transform: translateY(-2px);
  box-shadow: 0 8px 25px rgba(59, 130, 246, 0.15);
}

.ai-option-btn:active {
  transform: translateY(0);
  box-shadow: 0 4px 15px rgba(59, 130, 246, 0.2);
}

.ai-option-icon {
  font-size: 2rem;
  margin-bottom: 0.5rem;
}

.ai-option-title {
  font-weight: 600;
  font-size: 1.1rem;
  margin-bottom: 0.5rem;
  color: var(--color-text-primary);
}

.ai-option-desc {
  font-size: 0.875rem;
  color: var(--color-text-secondary);
  line-height: 1.4;
}

/* Contenedor de resultados */
.ai-analysis-result {
  margin-top: 2rem;
  border-top: 2px solid var(--color-border);
  padding-top: 1.5rem;
}

.ai-placeholder {
  text-align: center;
  padding: 2rem;
  color: var(--color-text-secondary);
  font-style: italic;
}

.ai-result {
  background: linear-gradient(135deg, var(--color-gray-50), var(--color-white));
  border-radius: var(--border-radius);
  padding: 1.5rem;
  border: 1px solid var(--color-border);
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.05);
}

.ai-result-header {
  margin-bottom: 1rem;
}

.ai-result h4 {
  margin: 0 0 0.5rem 0;
  color: var(--color-blue-600);
  font-size: 1.25rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.ai-room-info {
  background: var(--color-gray-100);
  padding: 0.5rem 0.75rem;
  border-radius: var(--border-radius-sm);
  border-left: 3px solid var(--color-blue-500);
}

.ai-room-info small {
  color: var(--color-text-secondary);
  font-size: 0.8rem;
}

.ai-room-info strong {
  color: var(--color-blue-700);
  font-weight: 600;
}

.ai-result-content {
  line-height: 1.6;
  color: var(--color-text-primary);
}

.ai-result-content p {
  margin: 0 0 1rem 0;
}

.ai-result-content strong {
  color: var(--color-blue-700);
  font-weight: 600;
}

.ai-result-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 1.5rem;
  padding-top: 1rem;
  border-top: 1px solid var(--color-border);
}

.ai-result-footer small {
  color: var(--color-text-secondary);
  font-size: 0.8rem;
}

/* Estados de loading para IA */
.ai-loading {
  text-align: center;
  padding: 2rem;
}

.loading-spinner {
  width: 40px;
  height: 40px;
  border: 4px solid var(--color-border);
  border-top: 4px solid var(--color-blue-500);
  border-radius: 50%;
  animation: ai-spin 1s linear infinite;
  margin: 0 auto 1rem auto;
}

.loading-detail {
  color: var(--color-text-secondary);
  font-size: 0.9rem;
  margin-top: 0.5rem;
}

@keyframes ai-spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

/* Estados de error */
.ai-error {
  background: linear-gradient(135deg, rgba(239, 68, 68, 0.1), rgba(239, 68, 68, 0.05));
  border: 1px solid var(--color-red-400);
  border-radius: var(--border-radius);
  padding: 1.5rem;
  text-align: center;
}

.ai-error h4 {
  color: var(--color-red-500);
  margin: 0 0 0.5rem 0;
}

.ai-error p {
  color: var(--color-text-primary);
  margin: 0;
}

/* Responsive para móvil */
@media (max-width: 768px) {
  .ai-modal .modal-content {
    width: 95%;
    max-height: 90vh;
  }
  
  .ai-options-grid {
    grid-template-columns: 1fr;
    gap: 0.75rem;
  }
  
  .ai-option-btn {
    padding: 1rem;
  }
  
  .ai-option-title {
    font-size: 1rem;
  }
  
  .ai-result-footer {
    flex-direction: column;
    gap: 1rem;
    align-items: stretch;
  }
  
  .ai-result-footer .btn {
    width: 100%;
  }
}

/* Dark mode para componentes IA */
@media (prefers-color-scheme: dark) {
  .ai-option-btn {
    background: var(--color-bg-2);
    border-color: var(--color-border-dark);
    color: var(--color-text-primary);
  }
  
  .ai-option-btn:hover {
    border-color: var(--color-blue-400);
    box-shadow: 0 8px 25px rgba(96, 165, 250, 0.15);
  }
  
  .ai-result {
    background: linear-gradient(135deg, var(--color-bg-2), var(--color-bg-1));
    border-color: var(--color-border-dark);
  }
  
  .ai-error {
    background: linear-gradient(135deg, rgba(248, 113, 113, 0.1), rgba(248, 113, 113, 0.05));
    border-color: var(--color-red-400);
  }
}

[data-color-scheme="dark"] .ai-option-btn {
  background: var(--color-bg-2);
  border-color: var(--color-border-dark);
  color: var(--color-text-primary);
}

[data-color-scheme="dark"] .ai-option-btn:hover {
  border-color: var(--color-blue-400);
  box-shadow: 0 8px 25px rgba(96, 165, 250, 0.15);
}

[data-color-scheme="dark"] .ai-result {
  background: linear-gradient(135deg, var(--color-bg-2), var(--color-bg-1));
  border-color: var(--color-border-dark);
}

[data-color-scheme="dark"] .ai-error {
  background: linear-gradient(135deg, rgba(248, 113, 113, 0.1), rgba(248, 113, 113, 0.05));
  border-color: var(--color-red-400);
}

/* =============================================================
   IA INLINE QUERIES - Estilos para consultas IA desde chat
============================================================= */

/* Indicador de procesamiento IA */
.ai-query-indicator {
  margin: 1rem 0;
  padding: 1rem;
  background: linear-gradient(135deg, var(--color-blue-500), var(--color-purple-500));
  border-radius: 12px;
  box-shadow: 0 4px 20px rgba(59, 130, 246, 0.3);
  animation: ai-pulse 2s ease-in-out infinite;
}

.ai-processing {
  display: flex;
  align-items: center;
  gap: 1rem;
  color: var(--color-white);
}

.ai-spinner {
  width: 24px;
  height: 24px;
  border: 3px solid rgba(255, 255, 255, 0.3);
  border-top: 3px solid var(--color-white);
  border-radius: 50%;
  animation: ai-spin 1s linear infinite;
}

.ai-processing-text {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.ai-processing-text strong {
  font-size: 1rem;
  font-weight: 600;
}

.ai-processing-text small {
  font-size: 0.875rem;
  opacity: 0.9;
}

/* Mensajes IA en el chat */
.ai-message {
  background: linear-gradient(135deg, rgb(238, 237, 239), rgb(180, 182, 185));
  border: 2px solid transparent;
  border-image: linear-gradient(135deg, var(--color-purple-400), var(--color-blue-400)) 1;
  border-radius: 16px;
  margin: 1.5rem 0;
  padding: 1.5rem;
  position: relative;
  animation: ai-slideIn 0.5s ease-out;
}

.ai-message::before {
  content: '🤖';
  position: absolute;
  top: -12px;
  left: 20px;
  background: linear-gradient(135deg, var(--color-purple-500), var(--color-blue-500));
  color: var(--color-white);
  padding: 0.5rem;
  border-radius: 50%;
  font-size: 1rem;
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 10px rgba(139, 92, 246, 0.3);
}

.ai-header {
  margin-bottom: 1rem;
  display: flex;
  align-items: center;
  gap: 1rem;
}

.ai-author {
  background: linear-gradient(135deg, var(--color-purple-500), var(--color-blue-500));
  background-clip: text;
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  font-weight: 700;
  font-size: 1.1rem;
}

.ai-indicator {
  background: linear-gradient(135deg, var(--color-purple-400), var(--color-blue-400));
  color: var(--color-white);
  padding: 0.25rem 0.5rem;
  border-radius: 6px;
  font-size: 0.75rem;
  font-weight: 600;
}

.ai-content {
  margin: 1rem 0;
  line-height: 1.6;
  color: var(--color-text-primary);
}

.ai-paragraph {
  margin: 1rem 0;
}

.ai-number {
  color: var(--color-purple-600);
  font-weight: 700;
}

.ai-metadata {
  background: rgba(139, 92, 246, 0.1);
  border: 1px solid rgba(139, 92, 246, 0.2);
  border-radius: 8px;
  padding: 0.75rem;
  margin: 1rem 0;
  font-family: 'Courier New', monospace;
}

.ai-metadata small {
  color: var(--color-text-secondary);
  line-height: 1.4;
}

.ai-actions {
  display: flex;
  gap: 0.75rem;
  margin-top: 1rem;
  padding-top: 1rem;
  border-top: 1px solid rgba(139, 92, 246, 0.2);
}

.ai-action-btn {
  background: linear-gradient(135deg, var(--color-purple-500), var(--color-blue-500));
  color: var(--color-white);
  border: none;
  padding: 0.5rem 1rem;
  border-radius: 6px;
  font-size: 0.875rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.3s ease;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.ai-action-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(139, 92, 246, 0.3);
}

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

/* Efecto de highlight para mensajes IA nuevos */
.ai-message-highlight {
  animation: ai-highlight 3s ease-out;
}

/* Animaciones */
@keyframes ai-pulse {
  0%, 100% {
    opacity: 1;
    transform: scale(1);
  }
  50% {
    opacity: 0.9;
    transform: scale(1.02);
  }
}

@keyframes ai-spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

@keyframes ai-slideIn {
  0% {
    opacity: 0;
    transform: translateY(20px);
  }
  100% {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes ai-highlight {
  0% {
    box-shadow: 0 0 0 0 rgba(139, 92, 246, 0.7);
  }
  70% {
    box-shadow: 0 0 0 10px rgba(139, 92, 246, 0);
  }
  100% {
    box-shadow: 0 0 0 0 rgba(139, 92, 246, 0);
  }
}

/* Dark mode para elementos IA inline */
[data-color-scheme="dark"] .ai-message {
  background: linear-gradient(135deg, rgba(139, 92, 246, 0.15), rgba(59, 130, 246, 0.15));
}

[data-color-scheme="dark"] .ai-metadata {
  background: rgba(139, 92, 246, 0.15);
  border-color: rgba(139, 92, 246, 0.3);
}

[data-color-scheme="dark"] .ai-actions {
  border-top-color: rgba(139, 92, 246, 0.3);
}

/* Optimizaciones específicas para teclado virtual en dispositivos móviles */
@media (max-width: 768px) {
  /* Prevenir que el viewport cambie cuando aparece el teclado */
  .screen {
    height: 100vh;
    height: 100dvh; /* Dynamic viewport height para móviles modernos */
  }
  
  /* Con sticky position, no necesitamos manejar transforms */
  .chat-input-container {
    /* Sticky position maneja automáticamente el posicionamiento */
  }
  
  /* Ajustar el contenedor de mensajes cuando el teclado está visible */
  .chat-messages {
    /* Usar toda la altura disponible */
    flex: 1;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch; /* Smooth scrolling en iOS */
    scroll-behavior: smooth;
  }
  
  /* Prevenir zoom no deseado en iOS cuando se enfoca el input */
  .message-input,
  .form-control {
    font-size: 16px !important; /* iOS no hace zoom con 16px o más */
  }
  
  /* Mejorar la experiencia cuando el teclado está visible */
  body.keyboard-visible .chat-messages {
    /* Añadir un pequeño padding cuando el teclado está activo */
    padding-bottom: var(--space-20);
  }
}

/* Responsive para móviles */
@media (max-width: 480px) {
  .ai-message {
    margin: 1rem 0;
    padding: 1rem;
  }
  
  .ai-processing {
    flex-direction: column;
    text-align: center;
    gap: 0.75rem;
  }
  
  .ai-actions {
    flex-direction: column;
    gap: 0.5rem;
  }
  
  .ai-action-btn {
    justify-content: center;
  }
}

/* ==================== SISTEMA DE EDICIÓN DE MENSAJES ==================== */

.edit-btn {
  opacity: 0;
  margin-left: 8px;
  transition: opacity 0.2s;
  cursor: pointer;
  background: none;
  border: none;
  font-size: 14px;
  padding: 4px 8px;
  border-radius: 4px;
}

.message:hover .edit-btn {
  opacity: 0.7;
}

.edit-btn:hover {
  opacity: 1 !important;
  background: rgba(var(--color-blue-500-rgb), 0.1);
}

.edit-btn:disabled {
  cursor: not-allowed;
  opacity: 0.3 !important;
}

/* Modo edición */
.message.editing {
  background: var(--color-bg-1);
  border: 1px solid rgba(var(--color-blue-500-rgb), 0.3);
  box-shadow: 0 0 10px rgba(var(--color-blue-500-rgb), 0.1);
}

.edit-textarea {
  width: 100%;
  min-height: 60px;
  padding: 8px 12px;
  border: 1px solid var(--color-border);
  border-radius: 8px;
  resize: vertical;
  font-family: inherit;
  font-size: 14px;
  line-height: 1.5;
  background: var(--color-background);
  color: white;
  transition: border-color 0.2s;
}

.edit-textarea:focus {
  outline: none;
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px rgba(var(--color-blue-500-rgb), 0.1);
}

.edit-controls {
  display: flex;
  gap: 8px;
  margin-top: 8px;
  align-items: center;
}

.save-edit,
.cancel-edit {
  padding: 6px 12px;
  border: none;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
}

.save-edit {
  background: var(--color-primary);
  color: white;
}

.save-edit:hover:not(:disabled) {
  background: var(--color-primary-hover);
  transform: translateY(-1px);
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.save-edit:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.cancel-edit {
  background: var(--color-gray-300); /* Fondo más oscuro para mejor contraste */
  color: var(--color-gray-800); /* Texto más oscuro */
}

.cancel-edit:hover {
  background: var(--color-gray-400); /* Más contraste en hover */
}

.char-count {
  margin-left: auto;
  font-size: 12px;
  color: var(--color-text-secondary);
}

/* Indicador de editado */
.edited-indicator {
  font-size: 0.8em;
  color: var(--color-gray-500);
  font-style: italic;
  margin-left: 4px;
}

/* Animación de actualización */
@keyframes messageUpdate {
  0% {
    background: rgba(var(--color-blue-500-rgb), 0.2);
  }
  100% {
    background: transparent;
  }
}

.message-updated {
  animation: messageUpdate 1s ease-out;
}

/* Dark mode para edición */
[data-theme="dark"] .edit-textarea {
  background: var(--color-gray-800);
  color: var(--color-gray-100);
  border-color: var(--color-gray-600);
}

[data-theme="dark"] .edit-textarea:focus {
  border-color: var(--color-primary);
}

[data-theme="dark"] .cancel-edit {
  background: var(--color-gray-700);
  color: var(--color-gray-100);
}

[data-theme="dark"] .cancel-edit:hover {
  background: var(--color-gray-600);
}

/* Estilos dark mode para sistema actual [data-color-scheme] */
[data-color-scheme="dark"] .cancel-edit {
  background: var(--color-gray-600);
  color: var(--color-gray-100);
}

[data-color-scheme="dark"] .cancel-edit:hover {
  background: var(--color-gray-500);
}

[data-theme="dark"] .message.editing {
  background: rgba(var(--color-blue-500-rgb), 0.05);
}

/* Responsive para móvil */
@media (max-width: 480px) {
  .edit-controls {
    flex-wrap: wrap;
  }
  
  .char-count {
    width: 100%;
    text-align: right;
    margin-top: 4px;
  }
  
  .edit-textarea {
    font-size: 16px; /* Prevenir zoom en iOS */
  }
  
  /* Botón de editar siempre visible en móviles */
  .edit-btn {
    opacity: 0.8 !important; /* Siempre visible en móviles */
    min-width: 44px;
    min-height: 44px; /* Área táctil recomendada */
    padding: 8px;
  }
}

/* Dispositivos táctiles sin hover preciso */
@media (hover: none) and (pointer: coarse) {
  .edit-btn {
    opacity: 0.8 !important; /* Visible en dispositivos táctiles */
    min-width: 44px;
    min-height: 44px; /* Área táctil recomendada según Material Design */
  }
}

/* ==================== iOS SAFARI FIXES ESPECÍFICOS ==================== */
/* NOTA: Estos estilos SOLO se aplican cuando se detecta iOS Safari */
/* No afectan dispositivos Android ni otros navegadores */

/* Fixes para iOS Safari cuando se detecta */
.ios-safari .chat-input-container {
  /* Usar altura mínima segura para iOS */
  min-height: calc(56px + env(safe-area-inset-bottom, 0));
  
  /* Padding consistente para safe areas */
  padding-bottom: max(12px, env(safe-area-inset-bottom, 12px));
}

/* Ajustes cuando el teclado está visible en iOS */
.ios-safari.ios-keyboard-visible .chat-input-container {
  /* Cambiar temporalmente a absolute para iOS */
  position: absolute !important;
  width: 100%;
  left: 0;
  right: 0;
  
  /* Se calcula dinámicamente en JavaScript */
  /* top y bottom se establecen via JS */
}

/* Barra superior en iOS cuando hay teclado */
.ios-safari.ios-keyboard-visible .chat-bottom-bar {
  /* Cambiar temporalmente a absolute */
  position: absolute !important;
  width: 100%;
  left: 0;
  right: 0;
  z-index: 100;
  
  /* Se calcula dinámicamente en JavaScript */
}

/* Ajustar mensajes cuando el teclado está visible en iOS */
.ios-safari.ios-keyboard-visible .chat-messages {
  /* Reducir altura disponible cuando el teclado está visible */
  max-height: calc(100vh - 120px);
  
  /* Mantener scroll suave */
  -webkit-overflow-scrolling: touch;
  overflow-y: auto;
}

/* Viewport units más seguros para iOS */
.ios-safari .screen {
  /* Usar small viewport height en iOS */
  height: 100vh;
  height: -webkit-fill-available;
  min-height: 100vh;
  min-height: -webkit-fill-available;
}

/* Prevenir problemas de posicionamiento en iOS Safari */
.ios-safari .chat-container {
  /* Contenedor con altura flexible */
  min-height: 100vh;
  min-height: -webkit-fill-available;
  display: flex;
  flex-direction: column;
}

/* Mejorar transiciones en iOS */
.ios-safari * {
  /* Deshabilitar transiciones problemáticas durante cambios de teclado */
  -webkit-transition-property: none !important;
  transition-property: none !important;
}

/* Re-habilitar transiciones selectivamente */
.ios-safari .btn,
.ios-safari .modal,
.ios-safari .toast {
  -webkit-transition-property: all !important;
  transition-property: all !important;
}

/* Media query específica para iPhones con notch/dynamic island */
@supports (padding-top: env(safe-area-inset-top)) {
  .ios-safari .chat-bottom-bar {
    /* Padding extra para dispositivos con notch */
    padding-top: env(safe-area-inset-top, 0);
  }
  
  .ios-safari .chat-input-container {
    /* Asegurar espacio para home indicator */
    padding-bottom: calc(12px + env(safe-area-inset-bottom, 0));
  }
}

/* Fixes adicionales para iOS 16.4+ */
@supports (interactive-widget: resizes-visual) {
  .ios-safari .chat-input-container {
    /* Comportamiento mejorado en iOS modernos */
    position: fixed !important;
  }
}

/* Barra duplicada en scroll - Solo visible en móviles */
.chat-bottom-bar-scroll {
  display: none; /* Oculta por defecto en desktop */
  margin-top: var(--space-24);
  margin-bottom: var(--space-12);
}

/* Barra superior fija en móviles */
@media (max-width: 768px) {
  /* Barra duplicada visible solo en móviles */
  .chat-bottom-bar-scroll {
    display: flex !important;
    background: rgba(255, 255, 255, 0.95);
    -webkit-backdrop-filter: blur(10px);
    backdrop-filter: blur(10px);
    border: 1px solid var(--color-border);
    border-radius: var(--border-radius-md);
    padding: var(--space-8) var(--space-16);
    justify-content: space-between;
    align-items: center;
    margin: var(--space-16);
    margin-top: var(--space-24);
    margin-bottom: var(--space-16);
    position: relative; /* Parte del flujo del scroll */
    flex-shrink: 0;
  }
  
  /* Tema oscuro para barra duplicada */
  [data-color-scheme="dark"] .chat-bottom-bar-scroll {
    background: rgba(31, 41, 55, 0.95);
  }
  
  /* Botones en barra duplicada */
  [data-color-scheme="light"] .chat-bottom-bar-scroll .btn--xs {
    border: 1px solid rgba(0, 0, 0, 0.1);
    background: rgba(255, 255, 255, 0.8);
    color: #333333;
  }
  
  [data-color-scheme="light"] .chat-bottom-bar-scroll .btn--xs:hover {
    background: rgba(255, 255, 255, 1);
    border-color: rgba(0, 0, 0, 0.2);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    color: #222222;
  }
  
  /* Barra original fija en top */
  .chat-bottom-bar:not(.chat-bottom-bar-scroll) {
    position: fixed !important;
    top: 0 !important;
    bottom: auto !important;
    left: 0;
    right: 0;
    z-index: 100;
    background: var(--color-bg-card);
    border-bottom: 1px solid var(--color-border);
    border-top: none;
  }
  
  /* Input SIEMPRE arriba, independiente del teclado */
  .chat-input-container {
    position: fixed !important;
    top: 40px !important; /* Debajo de chat-bottom-bar */
    bottom: auto !important; /* NO usar bottom */
    left: 0;
    right: 0;
    z-index: 99;
    background: var(--color-surface);
    border-bottom: 1px solid var(--color-border);
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    /* Prevenir cualquier movimiento */
    transform: none !important;
    transition: none !important;
  }
  
  /* Mensajes con posición fija */
  .chat-messages {
    position: fixed;
    top: 130px; /* Debajo de ambas barras superiores */
    bottom: 0;
    left: 0;
    right: 0;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    padding: var(--space-12);
  }
  
  /* Contenedor principal sin interferir */
  .chat-container {
    height: 100vh;
    overflow: hidden; /* Solo chat-messages debe tener scroll */
  }
  
  /* Desactivar comportamientos especiales de iOS */
  .ios-keyboard-visible .chat-input-container {
    position: fixed !important;
    top: 40px !important;
    bottom: auto !important;
    transform: none !important;
  }
  
  /* Asegurar que el body no se mueva */
  body.keyboard-visible {
    overflow: hidden;
    position: fixed;
    width: 100%;
  }
}

/* Fallbacks explícitos para elementos problemáticos - mismos colores */
.chat-messages {
  /* Fallback al mismo color de fondo blanco */
  background-color: var(--color-background, #fff);
}

.attachments-list,
#attachmentsList {
  /* Fallback al mismo color surface */
  background-color: var(--color-surface, #fafbfc);
}

.message-list,
#messagesContainer {
  /* Fallback al mismo color de fondo */
  background-color: var(--color-background, #fff);
}

/* Forzar colores en elementos que pueden fallar en algunos navegadores */
.chat-container {
  background-color: var(--color-background, #fff);
}

.modal-content {
  background-color: var(--color-surface, #fafbfc);
}

/* Regla de compatibilidad para navegadores que no soportan variables CSS */
@supports not (--css: variables) {
  /* Colores hardcodeados idénticos a los actuales para fallback */
  body {
    background-color: #fff !important;
    color: #0f172a !important;
  }
  
  .chat-messages,
  .message-list,
  #messagesContainer {
    background-color: #fff !important;
  }
  
  .attachments-list,
  #attachmentsList,
  .modal-content,
  .message {
    background-color: #fafbfc !important;
  }
  
  .chat-bottom-bar {
    background-color: rgba(255, 255, 255, 0.95) !important;
  }
  
  /* Botones con colores explícitos */
  .btn--primary {
    background: #3b82f6 !important;
    color: #fff !important;
  }
  
  .btn--primary:hover {
    background: #2563eb !important;
  }
}