/* ===== FLUENT CHAT - moderno + tech (Samsung Galaxy AI vibes) ===== */

.fchat {
    display: flex;
    flex-direction: column;
    width: 100%;
    height: 100%;
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.85) 0%, rgba(248, 249, 252, 0.92) 100%);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-radius: 16px;
    border: 1px solid rgba(229, 231, 235, 0.7);
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.06);
    overflow: hidden;
    font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
    color: #1F2937;
}

/* ===== Header ===== */
.fchat-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 14px 18px;
    background: rgba(255, 255, 255, 0.6);
    border-bottom: 1px solid rgba(229, 231, 235, 0.6);
    flex-shrink: 0;
}

.fchat-identity {
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 0;
}

.fchat-identity-text {
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
}

.fchat-name {
    font-size: 1rem;
    font-weight: 600;
    color: #1F2937;
    letter-spacing: 0.2px;
}

.fchat-status {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 0.75rem;
    color: #6B7280;
}

.fchat-status.is-thinking {
    color: #003E91;
}

.fchat-status-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: linear-gradient(135deg, #003E91, #7F569F, #EC4899);
    background-size: 200% 200%;
    animation: fchatStatusPulse 1.4s ease-in-out infinite, fchatStatusShimmer 3s linear infinite;
}

@keyframes fchatStatusPulse {
    0%, 100% { transform: scale(0.7); opacity: 0.6; }
    50%      { transform: scale(1);   opacity: 1;   }
}

@keyframes fchatStatusShimmer {
    0%   { background-position: 0% 0%; }
    100% { background-position: 200% 200%; }
}

.fchat-header-actions {
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.fchat-icon-btn {
    width: 34px;
    height: 34px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: none;
    background: transparent;
    color: #6B7280;
    border-radius: 50%;
    cursor: pointer;
    transition: background-color 0.15s ease, color 0.15s ease, transform 0.15s ease;
    font-size: 0.95rem;
}

.fchat-icon-btn:hover:not(:disabled) {
    background: rgba(0, 62, 145, 0.08);
    color: #003E91;
}

.fchat-icon-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

/* ===== Avatar (bot/user) con anillo gradiente animado ===== */
.fchat-avatar {
    position: relative;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    font-weight: 600;
    font-size: 0.95rem;
    user-select: none;
}

.fchat-avatar-sm {
    width: 32px;
    height: 32px;
    font-size: 0.8125rem;
}

.fchat-avatar-bot {
    background: linear-gradient(135deg, #003E91 0%, #7F569F 60%, #EC4899 100%);
    color: #FFFFFF;
    box-shadow: 0 2px 8px rgba(127, 86, 159, 0.35);
}

.fchat-avatar-bot i {
    font-size: 1.1rem;
}

.fchat-avatar-sm.fchat-avatar-bot i {
    font-size: 0.85rem;
}

.fchat-avatar-bot.is-active::before {
    content: '';
    position: absolute;
    inset: -3px;
    border-radius: 50%;
    background: conic-gradient(from 0deg, #003E91, #7F569F, #EC4899, #003E91);
    z-index: -1;
    animation: fchatRotateRing 2.4s linear infinite;
    filter: blur(2px);
    opacity: 0.85;
}

@keyframes fchatRotateRing {
    to { transform: rotate(360deg); }
}

.fchat-avatar-user {
    background: linear-gradient(135deg, #E5F1FF 0%, #BFDBFE 100%);
    color: #003E91;
    border: 1px solid rgba(0, 62, 145, 0.18);
}

/* Avatar como imagen real (foto del perfil) */
.fchat-avatar-img {
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    color: transparent;
    background-color: #F3F4F6;
}

/* ===== Stream / mensajes ===== */
.fchat-stream {
    flex: 1;
    overflow-y: auto;
    padding: 24px 20px;
    scroll-behavior: smooth;
}

.fchat-stream::-webkit-scrollbar { width: 8px; }
.fchat-stream::-webkit-scrollbar-track { background: transparent; }
.fchat-stream::-webkit-scrollbar-thumb {
    background: rgba(0, 0, 0, 0.12);
    border-radius: 4px;
}
.fchat-stream::-webkit-scrollbar-thumb:hover { background: rgba(0, 0, 0, 0.25); }

.fchat-banner {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 10px;
    text-align: center;
    height: 100%;
    padding: 24px;
}

.fchat-banner-orb {
    width: 88px;
    height: 88px;
    border-radius: 50%;
    background: conic-gradient(from 0deg, #003E91, #7F569F, #EC4899, #003E91);
    box-shadow: 0 8px 28px rgba(127, 86, 159, 0.45);
    animation: fchatBannerOrb 6s linear infinite;
    margin-bottom: 8px;
    position: relative;
}

.fchat-banner-orb::after {
    content: '';
    position: absolute;
    inset: 8px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.4);
    backdrop-filter: blur(6px);
}

@keyframes fchatBannerOrb {
    to { transform: rotate(360deg); }
}

.fchat-banner-title {
    margin: 0;
    font-size: 1.5rem;
    font-weight: 700;
    color: #1F2937;
    background: linear-gradient(135deg, #003E91, #7F569F, #EC4899);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.fchat-banner-subtitle {
    margin: 0;
    color: #6B7280;
    font-size: 0.9375rem;
}

/* Mensajes */
.fchat-msg {
    display: flex;
    align-items: flex-end;
    gap: 10px;
    margin-bottom: 16px;
    animation: fchatFadeIn 0.25s ease-out;
}

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

.fchat-msg-user {
    flex-direction: row-reverse;
}

.fchat-bubble {
    position: relative;
    max-width: 78%;
    padding: 12px 16px;
    border-radius: 16px;
    line-height: 1.55;
    font-size: 0.9375rem;
    word-wrap: break-word;
}

.fchat-msg-user .fchat-bubble {
    background: linear-gradient(135deg, #003E91 0%, #1755B5 100%);
    color: #FFFFFF;
    border-bottom-right-radius: 4px;
    box-shadow: 0 2px 10px rgba(0, 62, 145, 0.25);
}

.fchat-msg-assistant .fchat-bubble {
    background: rgba(255, 255, 255, 0.95);
    color: #1F2937;
    border: 1px solid rgba(229, 231, 235, 0.8);
    border-bottom-left-radius: 4px;
    box-shadow: 0 1px 6px rgba(0, 0, 0, 0.04);
}

.fchat-user-text {
    white-space: pre-wrap;
}

/* Cursor parpadeante en streaming */
.fchat-msg.is-streaming .fchat-assistant-content::after {
    content: '▊';
    display: inline-block;
    margin-left: 2px;
    color: #7F569F;
    animation: fchatCursorBlink 0.85s steps(1) infinite;
    font-weight: 400;
}

@keyframes fchatCursorBlink {
    50% { opacity: 0; }
}

/* Markdown styling dentro del asistente */
.fchat-assistant-content :first-child { margin-top: 0; }
.fchat-assistant-content :last-child  { margin-bottom: 0; }
.fchat-assistant-content p { margin: 0 0 8px 0; }
.fchat-assistant-content ul,
.fchat-assistant-content ol { margin: 0 0 8px 0; padding-left: 22px; }
.fchat-assistant-content li { margin-bottom: 3px; }
.fchat-assistant-content code {
    background: rgba(0, 62, 145, 0.08);
    color: #003E91;
    padding: 1px 6px;
    border-radius: 4px;
    font-family: 'Cascadia Code', 'Fira Code', Consolas, monospace;
    font-size: 0.85em;
}
.fchat-assistant-content pre {
    background: #1F2937;
    color: #E5E7EB;
    padding: 12px;
    border-radius: 8px;
    overflow-x: auto;
    margin: 8px 0;
}
.fchat-assistant-content pre code {
    background: transparent;
    color: inherit;
    padding: 0;
}
.fchat-assistant-content table {
    border-collapse: collapse;
    width: 100%;
    margin: 8px 0;
    font-size: 0.875em;
}
.fchat-assistant-content table th,
.fchat-assistant-content table td {
    border: 1px solid rgba(0, 0, 0, 0.08);
    padding: 6px 10px;
    text-align: left;
}
.fchat-assistant-content table th {
    background: rgba(0, 62, 145, 0.05);
    font-weight: 600;
}
.fchat-assistant-content a {
    color: #003E91;
    text-decoration: underline;
}
.fchat-assistant-content blockquote {
    border-left: 3px solid #7F569F;
    padding-left: 12px;
    margin: 8px 0;
    color: #4B5563;
}

/* ===== Animacion "rombitos" Samsung Galaxy AI ===== */
.fchat-thinking {
    position: relative;
    display: inline-flex;
    align-items: center;
    gap: 10px;
    padding: 6px 12px;
    isolation: isolate;
}

/* Aura/niebla iridiscente que pulsa detras de los rombos */
.fchat-thinking::before {
    content: '';
    position: absolute;
    inset: -4px -8px;
    background: radial-gradient(ellipse at center,
        rgba(168, 85, 247, 0.18) 0%,
        rgba(99, 102, 241, 0.12) 40%,
        transparent 75%);
    border-radius: 50%;
    z-index: -1;
    animation: fchatThinkingMist 3.2s ease-in-out infinite;
    pointer-events: none;
}

@keyframes fchatThinkingMist {
    0%, 100% { opacity: 0.55; transform: scale(0.92); }
    50%      { opacity: 1;    transform: scale(1.08); }
}

/* Cada rombo: fondo con gradiente iridiscente que se mueve constantemente */
.fchat-rhombus {
    width: 16px;
    height: 16px;
    border-radius: 3px;
    background: linear-gradient(135deg,
        #003E91 0%,
        #4F46E5 22%,
        #A855F7 45%,
        #EC4899 68%,
        #F59E0B 88%,
        #003E91 100%);
    background-size: 600% 600%;
    transform: rotate(45deg) scale(0.3);
    opacity: 0;
    animation: fchatRhombusBeat 1.6s cubic-bezier(0.4, 0, 0.6, 1) infinite,
               fchatRhombusShine 4.5s linear infinite;
    will-change: transform, opacity, filter;
}

.fchat-rhombus:nth-child(1) { animation-delay: 0s,    0s;   }
.fchat-rhombus:nth-child(2) { animation-delay: 0.16s, 0.7s; }
.fchat-rhombus:nth-child(3) { animation-delay: 0.32s, 1.4s; }
.fchat-rhombus:nth-child(4) { animation-delay: 0.48s, 2.1s; }
.fchat-rhombus:nth-child(5) { animation-delay: 0.64s, 2.8s; }

@keyframes fchatRhombusBeat {
    0% {
        transform: rotate(45deg) scale(0.3) translateY(0);
        opacity: 0;
        filter: drop-shadow(0 0 0 rgba(168, 85, 247, 0)) blur(0.5px);
    }
    25% {
        transform: rotate(180deg) scale(1.1) translateY(-2px);
        opacity: 1;
        filter: drop-shadow(0 0 8px rgba(168, 85, 247, 0.7)) blur(0);
    }
    55% {
        transform: rotate(315deg) scale(1.25) translateY(-1px);
        opacity: 0.95;
        filter: drop-shadow(0 0 12px rgba(236, 72, 153, 0.6)) blur(0);
    }
    85% {
        transform: rotate(405deg) scale(0.6) translateY(1px);
        opacity: 0.4;
        filter: drop-shadow(0 0 4px rgba(99, 102, 241, 0.4)) blur(0.3px);
    }
    100% {
        transform: rotate(495deg) scale(0.3) translateY(0);
        opacity: 0;
        filter: drop-shadow(0 0 0 rgba(168, 85, 247, 0)) blur(0.5px);
    }
}

@keyframes fchatRhombusShine {
    0%   { background-position: 0% 0%; }
    100% { background-position: 600% 600%; }
}

.fchat-thinking-text {
    margin-left: 4px;
    color: #6B7280;
    font-size: 0.875rem;
    font-style: italic;
    background: linear-gradient(90deg,
        #6B7280 0%,
        #4F46E5 25%,
        #A855F7 45%,
        #EC4899 65%,
        #F59E0B 85%,
        #6B7280 100%);
    background-size: 250% auto;
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    animation: fchatThinkingTextShimmer 2.8s linear infinite;
    letter-spacing: 0.2px;
}

@keyframes fchatThinkingTextShimmer {
    0%   { background-position: 250% center; }
    100% { background-position: -250% center; }
}

/* ===== Tool calls (chips) ===== */
.fchat-toolcalls {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 8px;
}

.fchat-toolcall-chip {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 3px 9px;
    background: rgba(0, 62, 145, 0.08);
    color: #003E91;
    border: 1px solid rgba(0, 62, 145, 0.15);
    border-radius: 12px;
    font-size: 0.75rem;
    font-weight: 500;
}

.fchat-toolcall-chip i { font-size: 0.7rem; }

/* ===== Boton copiar (visible en hover) ===== */
.fchat-copy-btn {
    position: absolute;
    bottom: -10px;
    right: 8px;
    width: 24px;
    height: 24px;
    border: 1px solid rgba(0, 0, 0, 0.08);
    background: #FFFFFF;
    border-radius: 50%;
    color: #6B7280;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 0.7rem;
    opacity: 0;
    transition: opacity 0.15s ease, color 0.15s ease, background-color 0.15s ease;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
}

.fchat-msg-assistant:hover .fchat-copy-btn { opacity: 1; }

.fchat-copy-btn:hover {
    color: #003E91;
    background: #F0F7FF;
}

/* ===== Input area ===== */
.fchat-input-area {
    flex-shrink: 0;
    padding: 14px 18px 18px 18px;
    background: rgba(255, 255, 255, 0.5);
    border-top: 1px solid rgba(229, 231, 235, 0.6);
}

.fchat-input-shell {
    display: flex;
    align-items: flex-end;
    gap: 8px;
    padding: 6px 8px 6px 14px;
    background: #FFFFFF;
    border: 1px solid rgba(229, 231, 235, 0.9);
    border-radius: 22px;
    transition: border-color 0.18s ease, box-shadow 0.18s ease;
}

.fchat-input-shell:focus-within {
    border-color: #003E91;
    box-shadow: 0 0 0 3px rgba(0, 62, 145, 0.1);
}

.fchat-input-shell.is-listening {
    border-color: #EC4899;
    box-shadow: 0 0 0 3px rgba(236, 72, 153, 0.15);
}

.fchat-input {
    flex: 1;
    border: none;
    outline: none;
    background: transparent;
    resize: none;
    font-family: inherit;
    font-size: 0.9375rem;
    color: #1F2937;
    line-height: 1.5;
    padding: 8px 0;
    max-height: 160px;
    overflow-y: auto;
}

.fchat-input::placeholder {
    color: #9CA3AF;
}

.fchat-input:disabled {
    background: transparent;
    color: #9CA3AF;
    cursor: not-allowed;
}

.fchat-input-actions {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    flex-shrink: 0;
}

.fchat-mic-btn,
.fchat-send-btn {
    width: 38px;
    height: 38px;
    border: none;
    border-radius: 50%;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.12s ease, background-color 0.15s ease, box-shadow 0.15s ease;
    font-size: 0.95rem;
}

.fchat-mic-btn {
    background: rgba(0, 62, 145, 0.08);
    color: #003E91;
}

.fchat-mic-btn:hover:not(:disabled) {
    background: rgba(0, 62, 145, 0.15);
    transform: scale(1.05);
}

.fchat-mic-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.fchat-mic-btn.is-recording {
    background: linear-gradient(135deg, #EC4899, #BE185D);
    color: #FFFFFF;
    animation: fchatMicPulse 1.4s ease-in-out infinite;
}

@keyframes fchatMicPulse {
    0%, 100% { box-shadow: 0 0 0 0 rgba(236, 72, 153, 0.4); }
    50%      { box-shadow: 0 0 0 8px rgba(236, 72, 153, 0); }
}

.fchat-send-btn {
    background: linear-gradient(135deg, #003E91 0%, #1755B5 100%);
    color: #FFFFFF;
    box-shadow: 0 2px 8px rgba(0, 62, 145, 0.3);
}

.fchat-send-btn:hover:not(:disabled) {
    transform: scale(1.06);
    box-shadow: 0 3px 12px rgba(0, 62, 145, 0.4);
}

.fchat-send-btn:disabled {
    background: #E5E7EB;
    color: #9CA3AF;
    box-shadow: none;
    cursor: not-allowed;
}

.fchat-stop-btn {
    background: linear-gradient(135deg, #DC2626 0%, #991B1B 100%);
    box-shadow: 0 2px 8px rgba(220, 38, 38, 0.3);
}

.fchat-stop-btn:hover {
    transform: scale(1.06);
    box-shadow: 0 3px 12px rgba(220, 38, 38, 0.4);
}

/* ===== Responsive ===== */
@media (max-width: 768px) {
    .fchat-bubble { max-width: 86%; font-size: 0.9rem; }
    .fchat-stream { padding: 16px 12px; }
    .fchat-input-area { padding: 10px 12px 14px 12px; }
}
