* { margin: 0; padding: 0; box-sizing: border-box; }
body { font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif; background: #f0f0f5; height: 100vh; overflow: hidden; }

/* LOGIN */
.login-screen { display: flex; align-items: center; justify-content: center; height: 100vh; background: linear-gradient(135deg, #1a1a5e 0%, #5b2c85 100%); }
.login-box { background: white; border-radius: 20px; padding: 40px 30px; width: 90%; max-width: 380px; box-shadow: 0 20px 60px rgba(0,0,0,0.3); text-align: center; }
.login-logo { font-size: 28px; font-weight: 800; color: #242581; margin-bottom: 5px; }
.login-sub { font-size: 13px; color: #888; margin-bottom: 30px; }
.login-input { width: 100%; border: 2px solid #e0e0e0; border-radius: 12px; padding: 14px 18px; font-size: 15px; margin-bottom: 15px; outline: none; transition: border-color 0.3s; }
.login-input:focus { border-color: #5b2c85; }
.login-btn { width: 100%; padding: 14px; border: none; border-radius: 12px; background: linear-gradient(135deg, #242581, #5b2c85); color: white; font-size: 16px; font-weight: 600; cursor: pointer; transition: transform 0.2s; }
.login-btn:hover { transform: scale(1.02); }
.login-btn:disabled { opacity: 0.6; }
.login-error { color: #c62828; font-size: 13px; margin-top: 10px; min-height: 20px; }

/* SELECTOR CLIENTE */
.client-screen { display: flex; flex-direction: column; height: 100vh; background: #f0f0f5; }
.client-header { background: linear-gradient(135deg, #242581, #5b2c85); color: white; padding: 20px; text-align: center; }
.client-header h2 { font-size: 18px; margin-bottom: 4px; }
.client-header span { font-size: 13px; opacity: 0.8; }
.client-list { flex: 1; overflow-y: auto; padding: 15px; }
.client-item { background: white; border-radius: 12px; padding: 16px 20px; margin-bottom: 10px; box-shadow: 0 2px 8px rgba(0,0,0,0.08); cursor: pointer; display: flex; align-items: center; gap: 15px; transition: transform 0.2s; }
.client-item:hover { transform: scale(1.01); }
.client-item:active { transform: scale(0.98); }
.client-icon { width: 44px; height: 44px; border-radius: 10px; background: linear-gradient(135deg, #242581, #5b2c85); display: flex; align-items: center; justify-content: center; color: white; font-weight: 700; font-size: 16px; flex-shrink: 0; }
.client-info { flex: 1; }
.client-name { font-weight: 600; font-size: 15px; color: #333; }
.client-domain { font-size: 12px; color: #999; margin-top: 2px; }
.client-logout { padding: 15px; text-align: center; }
.client-logout a { color: #c62828; font-size: 14px; cursor: pointer; text-decoration: none; }
.client-search { margin: 15px 15px 0; }
.client-search input { width: 100%; padding: 12px 16px; border: 2px solid #e0e0e0; border-radius: 12px; font-size: 14px; outline: none; }
.client-search input:focus { border-color: #5b2c85; }

/* CHAT */
.chat-screen { display: flex; flex-direction: column; height: 100vh; }
.chat-header { background: linear-gradient(135deg, #242581, #5b2c85); color: white; padding: 12px 16px; display: flex; align-items: center; gap: 12px; flex-shrink: 0; }
.chat-back { background: none; border: none; color: white; font-size: 22px; cursor: pointer; padding: 4px 8px; }
.chat-header-info { flex: 1; }
.chat-header-title { font-size: 16px; font-weight: 600; }
.chat-header-client { font-size: 12px; opacity: 0.8; }
.chat-messages { flex: 1; overflow-y: auto; padding: 16px; display: flex; flex-direction: column; gap: 10px; background: #f0f0f5; }
.msg { max-width: 85%; padding: 12px 16px; border-radius: 16px; font-size: 14px; line-height: 1.5; word-wrap: break-word; animation: msgIn 0.3s ease; }
@keyframes msgIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }
.msg-user { align-self: flex-end; background: #242581; color: white; border-bottom-right-radius: 4px; }
.msg-bot { align-self: flex-start; background: white; color: #333; border-bottom-left-radius: 4px; box-shadow: 0 1px 4px rgba(0,0,0,0.08); }
.msg-bot b, .msg-bot strong { color: #242581; }
.msg-bot pre, .msg-bot code { font-family: "Courier New", monospace; font-size: 13px; white-space: pre; overflow-x: auto; }
.msg-bot .tabla-mono { font-family: "Courier New", monospace; font-size: 12px; line-height: 1.4; white-space: pre; display: block; background: #f8f8f8; padding: 8px 10px; border-radius: 8px; margin: 6px 0; overflow-x: auto; letter-spacing: 0; }
.msg-bot-wrap { align-self: flex-start; max-width: 85%; display: flex; flex-direction: column; gap: 4px; }
.btn-leer { align-self: flex-start; background: none; border: 1px solid #ccc; border-radius: 16px; padding: 3px 10px; font-size: 12px; color: #666; cursor: pointer; transition: all 0.2s; }
.btn-leer:hover { border-color: #242581; color: #242581; }
.btn-leer.leyendo { border-color: #c62828; color: #c62828; }
.btn-csv { align-self: flex-start; background: none; border: 1px solid #ccc; border-radius: 16px; padding: 3px 10px; font-size: 12px; color: #666; cursor: pointer; transition: all 0.2s; margin-left: 5px; }
.btn-csv:hover { border-color: #2E7D32; color: #2E7D32; }
.msg-error { align-self: center; background: #ffebee; color: #c62828; font-size: 13px; text-align: center; border-radius: 12px; }
.msg-typing { align-self: flex-start; background: white; color: #999; font-style: italic; box-shadow: 0 1px 4px rgba(0,0,0,0.08); }
.msg-voice-indicator { align-self: center; background: rgba(36,37,129,0.1); color: #242581; font-size: 13px; border-radius: 20px; padding: 6px 16px; }

/* INPUT AREA */
.chat-input-area { display: flex; gap: 8px; padding: 12px 16px; background: white; border-top: 1px solid #e8e8e8; align-items: center; flex-shrink: 0; }
.chat-input { flex: 1; border: 2px solid #e0e0e0; border-radius: 24px; padding: 12px 18px; font-size: 15px; outline: none; transition: border-color 0.3s; }
.chat-input:focus { border-color: #5b2c85; }
.btn-circle { width: 48px; height: 48px; border-radius: 50%; border: none; cursor: pointer; display: flex; align-items: center; justify-content: center; transition: transform 0.2s; flex-shrink: 0; }
.btn-send { background: linear-gradient(135deg, #242581, #5b2c85); color: white; font-size: 20px; }
.btn-mic { background: #f0f0f5; color: #242581; font-size: 22px; }
.btn-mic.recording { background: #c62828; color: white; animation: pulse 1s infinite; }
.btn-circle:hover { transform: scale(1.08); }
.btn-circle:disabled { opacity: 0.4; cursor: not-allowed; transform: none; }
@keyframes pulse { 0%, 100% { box-shadow: 0 0 0 0 rgba(198,40,40,0.4); } 50% { box-shadow: 0 0 0 12px rgba(198,40,40,0); } }

/* SPEAKING INDICATOR */
.speaking-bar { display: none; align-items: center; gap: 8px; padding: 8px 16px; background: rgba(36,37,129,0.05); border-top: 1px solid #e8e8e8; }
.speaking-bar.active { display: flex; }
.speaking-waves { display: flex; gap: 3px; align-items: center; }
.speaking-waves span { width: 4px; background: #242581; border-radius: 2px; animation: wave 0.8s infinite; }
.speaking-waves span:nth-child(1) { height: 12px; animation-delay: 0s; }
.speaking-waves span:nth-child(2) { height: 18px; animation-delay: 0.1s; }
.speaking-waves span:nth-child(3) { height: 14px; animation-delay: 0.2s; }
.speaking-waves span:nth-child(4) { height: 20px; animation-delay: 0.3s; }
.speaking-waves span:nth-child(5) { height: 10px; animation-delay: 0.4s; }
@keyframes wave { 0%, 100% { transform: scaleY(0.5); } 50% { transform: scaleY(1); } }
.speaking-text { font-size: 13px; color: #242581; flex: 1; }
.speaking-stop { background: none; border: 1px solid #c62828; color: #c62828; border-radius: 16px; padding: 4px 12px; font-size: 12px; cursor: pointer; }

/* DOTS */
.dots span { animation: dotPulse 1.4s infinite; font-size: 18px; }
.dots span:nth-child(2) { animation-delay: 0.2s; }
.dots span:nth-child(3) { animation-delay: 0.4s; }
@keyframes dotPulse { 0%,80%,100% { opacity: 0.3; } 40% { opacity: 1; } }

/* PUTO AMO MODE */
.puto-amo .msg-bot { background: white; color: #333; border: 1px solid #e0e0e0; }
.puto-amo .msg-bot b, .puto-amo .msg-bot strong { color: #CC0000; }
.puto-amo .msg-user { background: #CC0000; }
.puto-amo .chat-input { background: white; color: #333; border-color: #ccc; }
.puto-amo .chat-input:focus { border-color: #CC0000; }
.puto-amo .chat-input-area { background: #f5f5f5; border-color: #ddd; }

/* MODO OPERADOR - Terminal verde retro */
.modo-operador .chat-header { background: linear-gradient(135deg, #003300, #005500) !important; }
.modo-operador .chat-messages { background: #0a0a0a; }
.modo-operador .msg-bot { background: #1a1a1a; color: #33ff33; border: 1px solid #2a2a2a; font-family: "Courier New", monospace; }
.modo-operador .msg-bot b, .modo-operador .msg-bot strong { color: #66ff66; }
.modo-operador .msg-bot table { color: #33ff33; background: #1a1a1a; }
.modo-operador .msg-bot th { background: #003300; color: #33ff33; }
.modo-operador .msg-bot td { border-bottom-color: #1a3a1a; color: #33ff33; }
.modo-operador .msg-bot tr:nth-child(even) { background: #222222; }
.modo-operador .msg-bot tr:hover { background: #2a2a2a; }
.modo-operador .msg-bot pre, .modo-operador .msg-bot code { background: #111111; color: #33ff33; }
.modo-operador .msg-bot .tabla-mono { background: #111111; color: #33ff33; }
.modo-operador .msg-user { background: #005500; color: #33ff33; }
.modo-operador .chat-input { background: #0a0a0a; color: #33ff33; border-color: #1a3a1a; font-family: "Courier New", monospace; }
.modo-operador .chat-input::placeholder { color: #1a6a1a; }
.modo-operador .chat-input:focus { border-color: #33ff33; }
.modo-operador .chat-input-area { background: #050505; border-color: #1a3a1a; }
.modo-operador .btn-leer, .modo-operador .btn-csv { color: #33ff33; border-color: #1a3a1a; }
.modo-operador .btn-leer:hover, .modo-operador .btn-csv:hover { border-color: #33ff33; }
.modo-operador .msg-error { background: #1a0000; color: #ff3333; }
.modo-operador .msg-typing { background: #0d1a0d; color: #1a6a1a; }

/* STAR WARS CRAWL */
.sw-container { overflow: hidden; height: 400px; position: relative; background: #000; border-radius: 12px; display: flex; align-items: flex-start; justify-content: center; }
.sw-crawl { position: relative; width: 90%; text-align: center; font-family: "Franklin Gothic", "Arial Narrow", sans-serif; color: #FFD700; font-size: 17px; line-height: 1.8; font-weight: bold; letter-spacing: 2px; padding: 20px; animation: swCrawl 30s linear forwards; }
@keyframes swCrawl { 0% { margin-top: 400px; opacity: 1; } 10% { opacity: 1; } 90% { opacity: 1; } 100% { margin-top: -800px; opacity: 0; } }
.sw-title { color: #FFD700; font-size: 28px; text-align: center; font-family: "Franklin Gothic", "Arial Narrow", sans-serif; letter-spacing: 6px; margin-bottom: 20px; }

/* WAR GAMES TYPEWRITER */
.wargames-typing { font-family: "Courier New", monospace !important; }
.wg-cursor { animation: blink 0.7s infinite; font-weight: bold; }
@keyframes blink { 0%,50% { opacity: 1; } 51%,100% { opacity: 0; } }

/* HIDDEN */
.hidden { display: none !important; }

/* SAFE AREAS (mobile) */
@supports (padding-top: env(safe-area-inset-top)) {
    .chat-header { padding-top: calc(12px + env(safe-area-inset-top)); }
    .login-screen { padding-top: env(safe-area-inset-top); }
    .chat-input-area { padding-bottom: calc(12px + env(safe-area-inset-bottom)); }
}

/* MENU DESPLEGABLE */
.chat-menu { position: absolute; top: 100%; right: 0; background: white; border-radius: 8px; box-shadow: 0 4px 20px rgba(0,0,0,0.2); min-width: 220px; z-index: 100; overflow: hidden; }
.chat-menu.hidden { display: none; }
.chat-menu-item { padding: 12px 16px; cursor: pointer; font-size: 14px; color: #333; border-bottom: 1px solid #eee; transition: background 0.2s; }
.chat-menu-item:last-child { border-bottom: none; }
.chat-menu-item:hover { background: #f0f0f5; }
.puto-amo .chat-menu { background: #1a0000; border: 1px solid #550000; }
.puto-amo .chat-menu-item { color: #ff9999; border-color: #330000; }
.puto-amo .chat-menu-item:hover { background: #2a0000; }
.modo-operador .chat-menu { background: #0a0a0a; border: 1px solid #005500; }
.modo-operador .chat-menu-item { color: #33ff33; border-color: #003300; font-family: 'Courier New', monospace; }
.modo-operador .chat-menu-item:hover { background: #001a00; }
/* HISTORIAL DIAS */
.historial-dia { padding: 10px 16px; cursor: pointer; border-bottom: 1px solid #eee; font-size: 14px; }
.historial-dia:hover { background: #f0f0f5; }
.historial-dia .fecha { font-weight: bold; color: #242581; }
.historial-dia .count { color: #999; font-size: 12px; }
.chat-menu-separator { height: 1px; background: #ddd; margin: 4px 0; }
.puto-amo .chat-menu-separator { background: #550000; }
.modo-operador .chat-menu-separator { background: #005500; }
