/**
 * Home Chat Assistant Styles
 * Three-color organic bubble design (Green, Orange, Purple)
 * for mysa digital homepage
 */

/* ===================================
   Floating Chat Button (Bottom-Left)
   =================================== */

.home-chat-button {
    position: fixed;
    bottom: 24px;
    left: 24px;
    width: 72px;
    height: 72px;
    border-radius: 50%;
    border: none;
    cursor: pointer;
    z-index: 999;
    background: transparent;
    box-shadow: none;
    transition: transform 0.3s ease;
    overflow: visible;
    padding: 0;
}

/* Speech Bubble Tooltip */
.home-chat-tooltip {
    position: absolute;
    left: 80px;
    bottom: 50%;
    transform: translateY(50%) scale(0);
    background: white;
    padding: 12px 16px;
    border-radius: 12px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
    white-space: nowrap;
    font-size: 14px;
    font-weight: 500;
    color: #1f2937;
    opacity: 0;
    pointer-events: none;
    transition: all 0.4s cubic-bezier(0.68, -0.55, 0.265, 1.55);
    z-index: 1000;
}

.home-chat-tooltip::before {
    content: '';
    position: absolute;
    right: 100%;
    top: 50%;
    transform: translateY(-50%);
    border: 8px solid transparent;
    border-right-color: white;
}

.home-chat-tooltip.show {
    transform: translateY(50%) scale(1);
    opacity: 1;
    animation: tooltipBounce 0.6s ease-out;
}

@keyframes tooltipBounce {
    0% {
        transform: translateY(50%) scale(0);
    }
    50% {
        transform: translateY(50%) scale(1.1);
    }
    100% {
        transform: translateY(50%) scale(1);
    }
}

.home-chat-button:hover {
    transform: scale(1.1);
}

.home-chat-button:active {
    transform: scale(1.05);
}

/* Three Organic Bubble Shapes */
.home-chat-button .bubble-container {
    position: relative;
    width: 100%;
    height: 100%;
    border-radius: 50%;
    overflow: hidden;
}

.home-chat-button .bubble-shape {
    position: absolute;
    border-radius: 58% 42% 48% 52% / 62% 45% 55% 38%;
    opacity: 0.85;
    mix-blend-mode: normal;
}

/* Shape 1 - Green (ScratchBoard) */
.home-chat-button .bubble-shape-1 {
    width: 32px;
    height: 32px;
    background: linear-gradient(135deg, #60993E 0%, #4A7A2F 100%);
    top: 8px;
    left: 6px;
    animation: gentle-float-1 13s ease-in-out infinite;
}

/* Shape 2 - Orange (BuzzBoard) */
.home-chat-button .bubble-shape-2 {
    width: 36px;
    height: 36px;
    background: linear-gradient(135deg, #E96C09 0%, #D15F08 100%);
    top: 18px;
    right: 8px;
    animation: gentle-float-2 14s ease-in-out infinite 0.5s;
    border-radius: 48% 52% 58% 42% / 45% 62% 38% 55%;
}

/* Shape 3 - Purple (Pondera) */
.home-chat-button .bubble-shape-3 {
    width: 28px;
    height: 28px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    bottom: 10px;
    left: 18px;
    animation: gentle-float-3 15s ease-in-out infinite 1s;
    border-radius: 62% 38% 42% 58% / 48% 55% 45% 52%;
}

/* Floating Animations */
@keyframes gentle-float-1 {
    0%, 100% {
        transform: translate(0, 0) rotate(0deg);
        border-radius: 58% 42% 48% 52% / 62% 45% 55% 38%;
    }
    25% {
        transform: translate(3px, -4px) rotate(5deg);
        border-radius: 48% 52% 58% 42% / 55% 62% 38% 45%;
    }
    50% {
        transform: translate(-2px, -6px) rotate(-3deg);
        border-radius: 42% 58% 52% 48% / 48% 55% 45% 62%;
    }
    75% {
        transform: translate(-4px, -2px) rotate(-7deg);
        border-radius: 52% 48% 42% 58% / 62% 38% 55% 45%;
    }
}

@keyframes gentle-float-2 {
    0%, 100% {
        transform: translate(0, 0) rotate(0deg);
        border-radius: 48% 52% 58% 42% / 45% 62% 38% 55%;
    }
    25% {
        transform: translate(-3px, 5px) rotate(-6deg);
        border-radius: 58% 42% 48% 52% / 62% 38% 55% 45%;
    }
    50% {
        transform: translate(4px, 3px) rotate(4deg);
        border-radius: 42% 58% 52% 48% / 38% 55% 62% 45%;
    }
    75% {
        transform: translate(2px, -3px) rotate(8deg);
        border-radius: 52% 48% 42% 58% / 55% 45% 38% 62%;
    }
}

@keyframes gentle-float-3 {
    0%, 100% {
        transform: translate(0, 0) rotate(0deg);
        border-radius: 62% 38% 42% 58% / 48% 55% 45% 52%;
    }
    25% {
        transform: translate(4px, 3px) rotate(-4deg);
        border-radius: 42% 58% 62% 38% / 55% 45% 52% 48%;
    }
    50% {
        transform: translate(-3px, 5px) rotate(6deg);
        border-radius: 38% 62% 58% 42% / 45% 52% 48% 55%;
    }
    75% {
        transform: translate(3px, -4px) rotate(-5deg);
        border-radius: 58% 42% 38% 62% / 52% 48% 55% 45%;
    }
}

/* ===================================
   Modal Overlay
   =================================== */

.home-chat-modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 5000;
    display: none;
    align-items: center;
    justify-content: center;
    animation: fadeIn 0.2s ease-out;
}

.home-chat-modal.active {
    display: flex;
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

/* ===================================
   Modal Container
   =================================== */

.home-chat-container {
    background: #ffffff;
    width: 600px;
    max-width: 90vw;
    height: 80vh;
    max-height: 700px;
    border-radius: 16px;
    display: flex;
    flex-direction: column;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    animation: slideUp 0.3s ease-out;
    overflow: hidden;
}

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

/* ===================================
   Modal Header
   =================================== */

.home-chat-header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 40%, #E96C09 70%, #60993E 100%);
    color: white;
    padding: 20px 24px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-shrink: 0;
}

.home-chat-header-content h2 {
    margin: 0 0 4px 0;
    font-size: 24px;
    font-weight: 600;
}

.home-chat-header-content p {
    margin: 0;
    font-size: 14px;
    opacity: 0.9;
}

.home-chat-close {
    background: rgba(255, 255, 255, 0.2);
    border: none;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s ease;
    color: white;
    font-size: 24px;
    line-height: 1;
}

.home-chat-close:hover {
    background: rgba(255, 255, 255, 0.3);
}

/* ===================================
   Tabs
   =================================== */

.home-chat-tabs {
    display: flex;
    background: #f3f4f6;
    border-bottom: 1px solid #e5e7eb;
    flex-shrink: 0;
}

.home-chat-tab {
    flex: 1;
    padding: 12px 16px;
    background: transparent;
    border: none;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    color: #6b7280;
    transition: all 0.2s ease;
    position: relative;
}

.home-chat-tab:hover {
    background: rgba(0, 0, 0, 0.02);
    color: #374151;
}

.home-chat-tab.active {
    color: #667eea;
    background: #ffffff;
}

.home-chat-tab.active::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 2px;
    background: linear-gradient(90deg, #667eea 0%, #E96C09 50%, #60993E 100%);
}

/* ===================================
   Tab Content Areas
   =================================== */

.home-chat-tab-content {
    display: none;
    flex: 1;
    overflow: hidden;
    flex-direction: column;
}

.home-chat-tab-content.active {
    display: flex;
}

/* ===================================
   Chat Body (Messages)
   =================================== */

.home-chat-body {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.home-chat-message {
    display: flex;
    gap: 12px;
    animation: messageSlide 0.3s ease-out;
    max-width: 85%;
}

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

.home-chat-message.user {
    align-self: flex-end;
    flex-direction: row-reverse;
}

.home-chat-message.assistant {
    align-self: flex-start;
}

.home-chat-message-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    position: relative;
}

.home-chat-message.user .home-chat-message-avatar {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
}

.home-chat-message.assistant .home-chat-message-avatar {
    background: #F9F6EE; /* mysa cream */
    color: #6b7280;
    overflow: visible;
}

/* Three-bubble avatar for AI */
.ai-avatar-bubble {
    position: absolute;
    border-radius: 58% 42% 48% 52% / 62% 45% 55% 38%;
    opacity: 0.9;
}

.ai-avatar-bubble-1 {
    width: 12px;
    height: 12px;
    background: linear-gradient(135deg, #60993E 0%, #4A7A2F 100%);
    top: 4px;
    left: 3px;
}

.ai-avatar-bubble-2 {
    width: 14px;
    height: 14px;
    background: linear-gradient(135deg, #E96C09 0%, #D15F08 100%);
    top: 10px;
    right: 4px;
    border-radius: 48% 52% 58% 42% / 45% 62% 38% 55%;
}

.ai-avatar-bubble-3 {
    width: 10px;
    height: 10px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    bottom: 6px;
    left: 10px;
    border-radius: 62% 38% 42% 58% / 48% 55% 45% 52%;
}

.home-chat-message-content {
    background: #f3f4f6;
    padding: 12px 16px;
    border-radius: 16px;
    line-height: 1.5;
    font-size: 15px;
    color: #1f2937;
}

.home-chat-message.user .home-chat-message-content {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
}

.home-chat-message-content p {
    margin: 0 0 8px 0;
}

.home-chat-message-content p:last-child {
    margin-bottom: 0;
}

.home-chat-message-content strong {
    font-weight: 600;
}

.home-chat-message-content a {
    color: inherit;
    text-decoration: underline;
    font-weight: 500;
}

.home-chat-message.user .home-chat-message-content a {
    color: white;
}

/* Typing Indicator */
.home-chat-typing {
    display: flex;
    gap: 4px;
    padding: 12px 16px;
}

.home-chat-typing-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #9ca3af;
    animation: typing 1.4s ease-in-out infinite;
}

.home-chat-typing-dot:nth-child(1) {
    animation-delay: 0s;
}

.home-chat-typing-dot:nth-child(2) {
    animation-delay: 0.2s;
}

.home-chat-typing-dot:nth-child(3) {
    animation-delay: 0.4s;
}

@keyframes typing {
    0%, 60%, 100% {
        transform: translateY(0);
        opacity: 0.7;
    }
    30% {
        transform: translateY(-10px);
        opacity: 1;
    }
}

/* ===================================
   Chat Footer (Input Area)
   =================================== */

.home-chat-footer {
    padding: 16px 20px;
    border-top: 1px solid #e5e7eb;
    flex-shrink: 0;
    background: #ffffff;
}

.home-chat-input-wrapper {
    display: flex;
    gap: 12px;
    align-items: flex-end;
}

.home-chat-input {
    flex: 1;
    padding: 12px 16px;
    border: 1px solid #d1d5db;
    border-radius: 24px;
    font-size: 15px;
    font-family: inherit;
    resize: none;
    min-height: 48px;
    max-height: 120px;
    line-height: 1.5;
    transition: border-color 0.2s ease;
}

.home-chat-input:focus {
    outline: none;
    border-color: #667eea;
}

.home-chat-input::placeholder {
    color: #9ca3af;
}

.home-chat-send {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    border: none;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    font-size: 20px;
}

.home-chat-send:hover:not(:disabled) {
    transform: scale(1.05);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
}

.home-chat-send:active:not(:disabled) {
    transform: scale(0.95);
}

.home-chat-send:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.home-chat-disclaimer {
    margin-top: 8px;
    font-size: 12px;
    color: #6b7280;
    text-align: center;
}

/* Transcript Button */
.home-chat-transcript-btn {
    margin-top: 12px;
    width: 100%;
    padding: 10px;
    background: transparent;
    border: 1px solid #d1d5db;
    border-radius: 8px;
    font-size: 13px;
    color: #6b7280;
    cursor: pointer;
    transition: all 0.2s ease;
}

.home-chat-transcript-btn:hover {
    background: #f9fafb;
    border-color: #667eea;
    color: #667eea;
}

/* ===================================
   Message Form Tab
   =================================== */

.home-chat-form-container {
    padding: 24px;
    overflow-y: auto;
}

.home-chat-form-container h3 {
    margin: 0 0 8px 0;
    font-size: 20px;
    font-weight: 600;
    color: #1f2937;
}

.home-chat-form-container p {
    margin: 0 0 24px 0;
    color: #6b7280;
    font-size: 14px;
}

.home-chat-form-group {
    margin-bottom: 20px;
}

.home-chat-form-label {
    display: block;
    margin-bottom: 6px;
    font-size: 14px;
    font-weight: 500;
    color: #374151;
}

.home-chat-form-input,
.home-chat-form-textarea {
    width: 100%;
    padding: 12px 16px;
    border: 1px solid #d1d5db;
    border-radius: 8px;
    font-size: 15px;
    font-family: inherit;
    transition: border-color 0.2s ease;
}

.home-chat-form-input:focus,
.home-chat-form-textarea:focus {
    outline: none;
    border-color: #667eea;
}

.home-chat-form-textarea {
    resize: vertical;
    min-height: 120px;
}

.home-chat-form-submit {
    width: 100%;
    padding: 14px 24px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.home-chat-form-submit:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
}

.home-chat-form-submit:active:not(:disabled) {
    transform: translateY(0);
}

.home-chat-form-submit:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.home-chat-form-status {
    margin-top: 16px;
    padding: 12px;
    border-radius: 8px;
    font-size: 14px;
    text-align: center;
    display: none;
}

.home-chat-form-status.success {
    display: block;
    background: #d1fae5;
    color: #065f46;
}

.home-chat-form-status.error {
    display: block;
    background: #fee2e2;
    color: #991b1b;
}

/* Budget Exceeded Notice */
.home-chat-budget-notice {
    padding: 16px;
    background: #fef3c7;
    border-left: 4px solid #f59e0b;
    margin: 16px 20px;
    border-radius: 4px;
    font-size: 14px;
    color: #92400e;
}

.home-chat-budget-notice strong {
    display: block;
    margin-bottom: 4px;
    color: #78350f;
}

/* ===================================
   Responsive Design (Mobile)
   =================================== */

@media (max-width: 640px) {
    .home-chat-button {
        width: 56px;
        height: 56px;
        bottom: 16px;
        left: 16px;
    }

    .home-chat-button .bubble-shape-1 {
        width: 24px;
        height: 24px;
        top: 6px;
        left: 4px;
    }

    .home-chat-button .bubble-shape-2 {
        width: 28px;
        height: 28px;
        top: 14px;
        right: 6px;
    }

    .home-chat-button .bubble-shape-3 {
        width: 20px;
        height: 20px;
        bottom: 8px;
        left: 14px;
    }

    .home-chat-tooltip {
        left: 64px;
        font-size: 13px;
        padding: 10px 14px;
    }

    .home-chat-tooltip::before {
        border-width: 6px;
    }

    .home-chat-container {
        width: 100%;
        height: 100%;
        max-width: 100%;
        max-height: 100%;
        border-radius: 0;
    }

    .home-chat-header {
        padding: 16px 20px;
    }

    .home-chat-header-content h2 {
        font-size: 20px;
    }

    .home-chat-body {
        padding: 16px;
    }

    .home-chat-message {
        max-width: 90%;
    }

    .home-chat-footer {
        padding: 12px 16px;
    }

    .home-chat-form-container {
        padding: 20px;
    }
}

/* ===================================
   Dark Mode Support
   =================================== */

@media (prefers-color-scheme: dark) {
    .home-chat-tooltip {
        background: #374151;
        color: #f9fafb;
    }

    .home-chat-tooltip::before {
        border-right-color: #374151;
    }

    .home-chat-container {
        background: #1f2937;
        color: #f9fafb;
    }

    .home-chat-tabs {
        background: #111827;
        border-bottom-color: #374151;
    }

    .home-chat-tab {
        color: #9ca3af;
    }

    .home-chat-tab:hover {
        background: rgba(255, 255, 255, 0.05);
        color: #d1d5db;
    }

    .home-chat-tab.active {
        background: #1f2937;
        color: #a78bfa;
    }

    .home-chat-body {
        background: #1f2937;
    }

    .home-chat-message.assistant .home-chat-message-avatar {
        background: #1C2541; /* mysa navy in dark mode */
        color: #9ca3af;
    }

    .home-chat-message.assistant .home-chat-message-content {
        background: #374151;
        color: #f9fafb;
    }

    .home-chat-footer {
        background: #1f2937;
        border-top-color: #374151;
    }

    .home-chat-input {
        background: #374151;
        border-color: #4b5563;
        color: #f9fafb;
    }

    .home-chat-input::placeholder {
        color: #6b7280;
    }

    .home-chat-input:focus {
        border-color: #a78bfa;
    }

    .home-chat-disclaimer {
        color: #9ca3af;
    }

    .home-chat-transcript-btn {
        border-color: #4b5563;
        color: #9ca3af;
        background: transparent;
    }

    .home-chat-transcript-btn:hover {
        background: #374151;
        border-color: #a78bfa;
        color: #a78bfa;
    }

    .home-chat-form-container {
        background: #1f2937;
    }

    .home-chat-form-container h3 {
        color: #f9fafb;
    }

    .home-chat-form-container p {
        color: #9ca3af;
    }

    .home-chat-form-label {
        color: #d1d5db;
    }

    .home-chat-form-input,
    .home-chat-form-textarea {
        background: #374151;
        border-color: #4b5563;
        color: #f9fafb;
    }

    .home-chat-form-input:focus,
    .home-chat-form-textarea:focus {
        border-color: #a78bfa;
    }
}

/* ===================================
   Accessibility
   =================================== */

.home-chat-button:focus-visible,
.home-chat-close:focus-visible,
.home-chat-tab:focus-visible,
.home-chat-send:focus-visible,
.home-chat-transcript-btn:focus-visible,
.home-chat-form-submit:focus-visible {
    outline: 2px solid #667eea;
    outline-offset: 2px;
}

/* Scroll behavior */
.home-chat-body {
    scroll-behavior: smooth;
}

/* Custom scrollbar */
.home-chat-body::-webkit-scrollbar {
    width: 8px;
}

.home-chat-body::-webkit-scrollbar-track {
    background: transparent;
}

.home-chat-body::-webkit-scrollbar-thumb {
    background: #d1d5db;
    border-radius: 4px;
}

.home-chat-body::-webkit-scrollbar-thumb:hover {
    background: #9ca3af;
}

@media (prefers-color-scheme: dark) {
    .home-chat-body::-webkit-scrollbar-thumb {
        background: #4b5563;
    }

    .home-chat-body::-webkit-scrollbar-thumb:hover {
        background: #6b7280;
    }
}
