/* ARIA Chat Widget Styles - Ported from FloatingAriaChat.vue */

/* Container */
.floating-aria-container {
    position: fixed;
    bottom: 30px;
    right: 30px;
    z-index: 9999;
    pointer-events: auto;
    font-family: 'Inter', system-ui, -apple-system, sans-serif;
}

/* Chat Bubble */
.aria-chat-bubble {
    width: 68px;
    height: 68px;
    background: linear-gradient(135deg, #1e3a5f 0%, #2a4066 50%, #4a7caf 100%);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow:
        0 8px 32px rgba(30, 58, 95, 0.4),
        0 0 20px rgba(74, 124, 175, 0.3),
        inset 0 2px 4px rgba(255, 255, 255, 0.1);
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    border: 3px solid rgba(255, 255, 255, 0.2);
    animation: breathe 4s ease-in-out infinite;
}

/* Entrance Animation */
.aria-chat-bubble.entrance-animation {
    animation:
        entranceBounce 0.8s cubic-bezier(0.68, -0.55, 0.265, 1.55),
        breathe 4s ease-in-out 0.8s infinite;
}

@keyframes entranceBounce {
    0% {
        opacity: 0;
        transform: scale(0) translateY(50px);
    }

    60% {
        transform: scale(1.15) translateY(-10px);
    }

    80% {
        transform: scale(0.95) translateY(5px);
    }

    100% {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

@keyframes breathe {

    0%,
    100% {
        box-shadow:
            0 8px 32px rgba(30, 58, 95, 0.4),
            0 0 20px rgba(74, 124, 175, 0.3),
            inset 0 2px 4px rgba(255, 255, 255, 0.1);
    }

    50% {
        box-shadow:
            0 12px 40px rgba(30, 58, 95, 0.5),
            0 0 40px rgba(74, 124, 175, 0.5),
            inset 0 2px 4px rgba(255, 255, 255, 0.15);
    }
}

.aria-chat-bubble:hover {
    transform: scale(1.12);
    box-shadow:
        0 16px 48px rgba(30, 58, 95, 0.5),
        0 0 50px rgba(74, 124, 175, 0.6),
        inset 0 2px 4px rgba(255, 255, 255, 0.2);
}

.aria-chat-bubble:hover .bubble-ring {
    animation-duration: 2s;
    border-color: rgba(255, 255, 255, 0.4);
}

.aria-chat-bubble:hover .aria-icon {
    animation: iconFloat 1s ease-in-out infinite;
}

@keyframes iconFloat {

    0%,
    100% {
        transform: translateY(0);
    }

    50% {
        transform: translateY(-3px);
    }
}

.aria-chat-bubble.pulse {
    animation:
        pulse 2s infinite,
        breathe 4s ease-in-out infinite;
}

@keyframes pulse {

    0%,
    100% {
        box-shadow:
            0 8px 32px rgba(30, 58, 95, 0.4),
            0 0 20px rgba(74, 124, 175, 0.3);
    }

    50% {
        box-shadow:
            0 8px 32px rgba(30, 58, 95, 0.6),
            0 0 40px rgba(74, 124, 175, 0.7);
    }
}

/* Bubble Elements */
.bubble-ring {
    position: absolute;
    width: 82px;
    height: 82px;
    border: 2px dashed rgba(255, 255, 255, 0.2);
    border-radius: 50%;
    animation: rotateRing 8s linear infinite;
    pointer-events: none;
}

@keyframes rotateRing {
    from {
        transform: rotate(0deg);
    }

    to {
        transform: rotate(360deg);
    }
}

.bubble-ripple {
    position: absolute;
    width: 68px;
    height: 68px;
    border: 2px solid rgba(74, 124, 175, 0.4);
    border-radius: 50%;
    animation: ripple 3s ease-out infinite;
    pointer-events: none;
}

.bubble-ripple.ripple-2 {
    animation-delay: 1.5s;
}

@keyframes ripple {
    0% {
        transform: scale(1);
        opacity: 0.6;
    }

    100% {
        transform: scale(2);
        opacity: 0;
    }
}

.bubble-icon {
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1;
}

.aria-icon {
    width: 36px;
    height: 36px;
    filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.3));
    display: block;
    margin: 0 auto;
}

.icon-orbit {
    animation: orbitPulse 3s ease-in-out infinite;
    transform-origin: center;
}

@keyframes orbitPulse {

    0%,
    100% {
        stroke-opacity: 0.3;
    }

    50% {
        stroke-opacity: 0.6;
    }
}

.icon-letter {
    animation: letterGlow 2s ease-in-out infinite;
}

@keyframes letterGlow {

    0%,
    100% {
        fill-opacity: 0.95;
    }

    50% {
        fill-opacity: 1;
    }
}

.node {
    animation: nodePulse 2s ease-in-out infinite;
}

.node-left {
    animation-delay: 0.3s;
}

.node-right {
    animation-delay: 0.6s;
}

@keyframes nodePulse {

    0%,
    100% {
        r: 1.5;
        fill-opacity: 0.7;
    }

    50% {
        r: 2;
        fill-opacity: 1;
    }
}

.node-top {
    animation: topNodePulse 1.5s ease-in-out infinite;
}

@keyframes topNodePulse {

    0%,
    100% {
        r: 2;
        fill-opacity: 0.9;
    }

    50% {
        r: 2.5;
        fill-opacity: 1;
    }
}

.neural-line {
    animation: lineFlicker 3s ease-in-out infinite;
}

@keyframes lineFlicker {

    0%,
    100% {
        stroke-opacity: 0.4;
    }

    50% {
        stroke-opacity: 0.8;
    }
}

.pulse-dot {
    animation: statusPulse 2s ease-in-out infinite;
}

@keyframes statusPulse {

    0%,
    100% {
        r: 3;
        fill: #22c55e;
        filter: drop-shadow(0 0 2px #22c55e);
    }

    50% {
        r: 3.5;
        fill: #4ade80;
        filter: drop-shadow(0 0 6px #22c55e);
    }
}

.bubble-notification {
    position: absolute;
    top: -5px;
    right: -5px;
    background: linear-gradient(135deg, #ef4444 0%, #dc2626 100%);
    color: white;
    border-radius: 50%;
    width: 22px;
    height: 22px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.75rem;
    font-weight: 700;
    box-shadow: 0 2px 8px rgba(239, 68, 68, 0.5);
    border: 2px solid white;
    z-index: 2;
    animation: notificationBounce 0.5s ease-out;
}

@keyframes notificationBounce {
    0% {
        transform: scale(0);
    }

    60% {
        transform: scale(1.2);
    }

    100% {
        transform: scale(1);
    }
}

/* Chat Window */
.aria-chat-window {
    position: absolute;
    bottom: 80px;
    right: 0;
    left: auto;
    width: 350px;
    max-width: calc(100vw - 60px);
    height: 500px;
    background: var(--bg-card, white);
    border-radius: 16px;
    box-shadow: var(--shadow-lg, 0 12px 40px rgba(0, 0, 0, 0.15));
    display: flex;
    flex-direction: column;
    overflow: hidden;
    z-index: 10000;
    border: none;
    transform: none;
    transition: width 0.3s ease, height 0.3s ease;
    opacity: 0;
    pointer-events: none;
    visibility: hidden;
}

.aria-chat-window.open {
    opacity: 1;
    pointer-events: auto;
    visibility: visible;
}

.aria-chat-window.expanded {
    width: 600px;
    height: 700px;
    max-width: calc(100vw - 320px);
    max-height: calc(100vh - 120px);
}

/* Hide expand button on mobile */
.expand-btn {
    display: none;
}

@media (min-width: 769px) {
    .expand-btn {
        display: flex;
    }
}

.chat-header {
    background: linear-gradient(135deg, #1e3a5f 0%, #2a4066 50%, #4a7caf 100%);
    color: white;
    padding: 1rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.chat-title {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-weight: 600;
}

.header-aria-icon {
    width: 24px;
    height: 24px;
    filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.2));
}

.header-pulse-dot {
    animation: headerPulse 2s ease-in-out infinite;
}

@keyframes headerPulse {

    0%,
    100% {
        fill: #22c55e;
    }

    50% {
        fill: #4ade80;
    }
}

.status-indicator {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    margin-left: 0.5rem;
}

.status-indicator.online {
    background: #22c55e;
}

.chat-controls {
    display: flex;
    gap: 0.5rem;
}

.control-btn {
    background: rgba(255, 255, 255, 0.2);
    border: none;
    color: white;
    width: 28px;
    height: 28px;
    border-radius: 6px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
}

.control-btn:hover {
    background: rgba(255, 255, 255, 0.3);
}

.chat-messages {
    flex: 1;
    padding: 1rem;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 1rem;
    background: var(--bg-secondary, #f8fafc);
}

.welcome-message {
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
}

.message {
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
}

.message.user {
    flex-direction: row-reverse;
}

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

.aria-avatar {
    background: linear-gradient(135deg, #1e3a5f 0%, #2a4066 50%, #4a7caf 100%);
    color: white;
    box-shadow: 0 2px 8px rgba(30, 58, 95, 0.3);
}

.avatar-aria-icon {
    width: 20px;
    height: 20px;
    filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.2));
}

.user-avatar {
    background: var(--bg-tertiary, #e5e7eb);
    color: var(--text-secondary, #6b7280);
}

.message-content {
    max-width: 70%;
    background: var(--bg-card, white);
    color: var(--text-primary, #333);
    padding: 0.75rem 1rem;
    border-radius: 12px;
    box-shadow: var(--shadow-sm, 0 2px 8px rgba(0, 0, 0, 0.1));
}

.message.user .message-content {
    background: linear-gradient(135deg, #4a7cbf 0%, #2563eb 100%);
    color: white;
}

.message.user .message-text,
.message.user .message-text * {
    color: white !important;
}

.message-text {
    line-height: 1.6;
    margin-bottom: 0.5rem;
}

/* Markdown Styles */
.message-text p {
    margin: 0 0 0.75rem 0;
}

.message-text p:last-child {
    margin-bottom: 0;
}

.message-text ul,
.message-text ol {
    margin: 0.5rem 0;
    padding-left: 1.25rem;
}

.message-text li {
    margin-bottom: 0.35rem;
}

.message-text li:last-child {
    margin-bottom: 0;
}

.message-text strong {
    font-weight: 600;
}

.message-text code {
    background: rgba(0, 0, 0, 0.1);
    padding: 0.125rem 0.375rem;
    border-radius: 4px;
    font-family: monospace;
    font-size: 0.875em;
}

.message.user .message-text code {
    background: rgba(255, 255, 255, 0.2);
}

.message-text pre {
    background: rgba(0, 0, 0, 0.05);
    padding: 0.75rem;
    border-radius: 6px;
    overflow-x: auto;
    margin: 0.5rem 0;
}

.message-text blockquote {
    border-left: 3px solid var(--text-secondary, #64748b);
    margin: 0.5rem 0;
    padding-left: 0.75rem;
    color: var(--text-secondary, #64748b);
}

.message-text h1,
.message-text h2,
.message-text h3,
.message-text h4 {
    margin: 0.75rem 0 0.5rem 0;
    font-weight: 600;
    line-height: 1.3;
}

.message-text h1 {
    font-size: 1.25rem;
}

.message-text h2 {
    font-size: 1.125rem;
}

.message-text h3 {
    font-size: 1rem;
}

.message-text h4 {
    font-size: 0.9375rem;
}

.message-text a {
    color: var(--color-primary, #2563eb);
    text-decoration: underline;
}

.message.user .message-text a {
    color: rgba(255, 255, 255, 0.9);
}

.message-time {
    font-size: 0.75rem;
    opacity: 0.6;
}

.quick-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-top: 1rem;
}

.quick-action-btn,
.suggestion-btn {
    background: rgba(74, 124, 191, 0.1);
    border: 1px solid rgba(74, 124, 191, 0.3);
    color: #4a7cbf;
    padding: 0.5rem 0.75rem;
    border-radius: 20px;
    font-size: 0.8rem;
    cursor: pointer;
    transition: all 0.2s;
}

.quick-action-btn:hover,
.suggestion-btn:hover {
    background: rgba(74, 124, 191, 0.2);
    border-color: rgba(74, 124, 191, 0.5);
}

.message-suggestions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.25rem;
    margin-top: 0.75rem;
}

.typing-indicator {
    display: flex;
    gap: 0.25rem;
    padding: 0.5rem 0;
}

.typing-indicator span {
    width: 6px;
    height: 6px;
    background: #4a7cbf;
    border-radius: 50%;
    animation: typing 1.4s infinite ease-in-out;
}

.typing-indicator span:nth-child(2) {
    animation-delay: 0.2s;
}

.typing-indicator span:nth-child(3) {
    animation-delay: 0.4s;
}

@keyframes typing {

    0%,
    60%,
    100% {
        transform: translateY(0);
        opacity: 0.4;
    }

    30% {
        transform: translateY(-4px);
        opacity: 1;
    }
}

.chat-input {
    padding: 1rem;
    background: var(--bg-card, white);
    border-top: 1px solid var(--border-primary, #e5e7eb);
}

.input-container {
    display: flex;
    gap: 0.5rem;
    align-items: center;
}

.message-input {
    flex: 1;
    padding: 0.75rem 1rem;
    border: 1px solid var(--border-input, #e5e7eb);
    border-radius: 25px;
    outline: none;
    font-size: 0.9rem;
    transition: border-color 0.2s;
    background: var(--bg-input, white);
    color: var(--text-primary, #333);
}

.message-input:focus {
    border-color: #4a7cbf;
}

.message-input:disabled {
    background: var(--bg-tertiary, #f3f4f6);
    cursor: not-allowed;
}

.send-btn {
    width: 40px;
    height: 40px;
    background: linear-gradient(135deg, #4a7cbf 0%, #2563eb 100%);
    border: none;
    border-radius: 50%;
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.send-btn:hover:not(:disabled) {
    transform: scale(1.05);
}

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

/* Mobile Responsive */
@media (max-width: 768px) {
    .floating-aria-container {
        bottom: 20px;
        right: 20px;
        /* width: 56px; height: 56px; - handled by children */
    }

    .aria-chat-bubble {
        width: 56px;
        height: 56px;
    }

    .bubble-icon {
        font-size: 1.3rem;
    }

    .message-content {
        max-width: 80%;
        font-size: 0.9rem;
    }

    .quick-action-btn,
    .suggestion-btn {
        font-size: 0.75rem;
        padding: 0.4rem 0.6rem;
    }

    .chat-messages {
        padding: 0.75rem;
        overscroll-behavior: contain;
        -webkit-overflow-scrolling: touch;
    }
}

@media (max-width: 480px) {

    /* Hide floating bubble on mobile - ARIA is in bottom nav instead */
    .floating-aria-container {
        display: none !important;
    }

    /* When chat is triggered from bottom nav, show fullscreen */
    .aria-chat-window.open {
        display: flex !important;
    }

    .aria-chat-window {
        position: fixed;
        top: env(safe-area-inset-top, 8px);
        bottom: env(safe-area-inset-bottom, 8px);
        left: env(safe-area-inset-left, 8px);
        right: env(safe-area-inset-right, 8px);
        width: auto !important;
        height: auto !important;
        max-width: none !important;
        max-height: none !important;
        transform: none;
        border-radius: 16px;
        display: flex;
        flex-direction: column;
        box-shadow: 0 4px 25px rgba(0, 0, 0, 0.25);
        touch-action: none;
        overflow: hidden;
    }

    .chat-messages {
        flex: 1;
        min-height: 0;
        overflow-y: auto;
        overscroll-behavior: contain;
        -webkit-overflow-scrolling: touch;
        touch-action: pan-y;
        padding-bottom: 10px;
    }

    .chat-input {
        flex-shrink: 0;
        background: var(--bg-card, white);
        border-top: 1px solid var(--border-primary, #e5e7eb);
        z-index: 10;
        padding: 0.75rem;
        padding-bottom: calc(0.75rem + env(safe-area-inset-bottom, 0px));
    }

    .input-container {
        background: transparent;
    }

    .message-input {
        border: 1px solid var(--border-input, #d1d5db);
        background: var(--bg-input, #f9fafb);
    }

    .chat-header {
        padding: 0.75rem 1rem;
        padding-top: calc(0.75rem + env(safe-area-inset-top, 0px));
    }
}

@media (max-width: 768px) and (min-width: 481px) {
    .aria-chat-window {
        position: fixed;
        top: 16px;
        bottom: 16px;
        left: 16px;
        right: 16px;
        width: calc(100vw - 32px) !important;
        max-width: none !important;
        height: auto;
        max-height: none;
    }
}

/* Scrollbar styling */
.chat-messages::-webkit-scrollbar {
    width: 4px;
}

.chat-messages::-webkit-scrollbar-track {
    background: #f1f5f9;
}

.chat-messages::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 2px;
}

.chat-messages::-webkit-scrollbar-thumb:hover {
    background: #94a3b8;
}