/* ========================================
   FAREN AI LIVE CHAT — RESPONSIVE COMPONENT
   Clean, minimal, fully responsive
   ======================================== */

/* Container */
.chat-widget-container {
    position: fixed;
    bottom: 0;
    right: 0;
    z-index: 99999;
    font-family: 'DM Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    pointer-events: none;
}

.chat-widget-container > * {
    pointer-events: auto;
}

/* ── Chat Toggle Button ── */
.chat-icon-button {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: linear-gradient(135deg, #D4A574 0%, #b8834a 100%);
    color: #fff;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    box-shadow: 0 6px 24px rgba(212, 165, 116, 0.45), 0 2px 8px rgba(0,0,0,0.15);
    transition: all 0.3s cubic-bezier(.4,0,.2,1);
    margin: 1.25rem;
    position: relative;
    z-index: 100001;
}

.chat-icon-button:active {
    transform: scale(0.92);
}

@media (hover: hover) {
    .chat-icon-button:hover {
        transform: scale(1.1) rotate(-5deg);
        box-shadow: 0 10px 36px rgba(212, 165, 116, 0.55);
    }
}

/* Notification Badge */
.chat-badge {
    position: absolute;
    top: -4px;
    right: -4px;
    background: #ff4444;
    color: white;
    border-radius: 50%;
    width: 22px;
    height: 22px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 11px;
    font-weight: 700;
    border: 2px solid #fff;
    animation: badgePulse 2s ease-in-out infinite;
}

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

/* ── Chat Box ── */
.chat-box {
    position: fixed;
    bottom: 100px;
    right: 1.25rem;
    width: 380px;
    height: 440px;
    background: rgba(18, 15, 12, 0.97);
    backdrop-filter: blur(24px);
    -webkit-backdrop-filter: blur(24px);
    border: 1px solid rgba(212, 165, 116, 0.18);
    border-radius: 1.25rem;
    box-shadow:
        0 24px 80px rgba(0, 0, 0, 0.5),
        0 0 0 1px rgba(212, 165, 116, 0.08);
    display: flex;
    flex-direction: column;
    opacity: 0;
    visibility: hidden;
    transform: scale(0.85) translateY(30px);
    transition: all 0.35s cubic-bezier(.4,0,.2,1);
    z-index: 100000;
    overflow: hidden;
}

.chat-box.active {
    opacity: 1;
    visibility: visible;
    transform: scale(1) translateY(0);
}

/* ── Chat Header ── */
.chat-header {
    padding: 1rem 1.25rem;
    border-bottom: 1px solid rgba(212, 165, 116, 0.12);
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: linear-gradient(135deg, rgba(212, 165, 116, 0.1) 0%, rgba(140, 100, 60, 0.05) 100%);
    flex-shrink: 0;
}

.chat-header-info {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    min-width: 0;
}

.chat-header-avatar {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    background: linear-gradient(135deg, #D4A574 0%, #b8834a 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-size: 1rem;
    flex-shrink: 0;
    box-shadow: 0 2px 8px rgba(212, 165, 116, 0.3);
}

.chat-header-title {
    color: #f5f0eb;
    font-size: 0.95rem;
    font-weight: 700;
    margin: 0;
    letter-spacing: 0.01em;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.chat-header-subtitle {
    color: #8a8580;
    font-size: 0.72rem;
    font-weight: 500;
    margin: 0.15rem 0 0;
    letter-spacing: 0.02em;
}

.chat-close-btn {
    background: rgba(255,255,255,0.05);
    border: 1px solid rgba(255,255,255,0.08);
    color: #8a8580;
    font-size: 1.1rem;
    cursor: pointer;
    transition: all 0.25s ease;
    padding: 0;
    width: 34px;
    height: 34px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    flex-shrink: 0;
}

.chat-close-btn:active,
.chat-close-btn:hover {
    color: #D4A574;
    background: rgba(212, 165, 116, 0.12);
    border-color: rgba(212, 165, 116, 0.2);
}

/* ── Chat Messages ── */
.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 1rem 1.25rem;
    display: flex;
    flex-direction: column;
    gap: 0.65rem;
    background: rgba(255, 255, 255, 0.015);
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
}

/* Custom scrollbar */
.chat-messages::-webkit-scrollbar {
    width: 5px;
}

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

.chat-messages::-webkit-scrollbar-thumb {
    background: rgba(212, 165, 116, 0.25);
    border-radius: 10px;
}

.chat-messages::-webkit-scrollbar-thumb:hover {
    background: rgba(212, 165, 116, 0.45);
}

/* ── Chat Message Bubble ── */
.chat-message {
    display: flex;
    gap: 0.5rem;
    animation: msgSlideIn 0.35s ease forwards;
}

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

.chat-message.user {
    justify-content: flex-end;
}

.message-bubble {
    max-width: 80%;
    padding: 0.7rem 1rem;
    border-radius: 1rem;
    font-size: 0.84rem;
    line-height: 1.5;
    word-wrap: break-word;
    overflow-wrap: break-word;
}

.message-bubble.bot {
    background: rgba(212, 165, 116, 0.12);
    color: #e2ddd8;
    border-left: 3px solid #D4A574;
    border-radius: 0.25rem 1rem 1rem 1rem;
}

.message-bubble.user {
    background: linear-gradient(135deg, #D4A574 0%, #b8834a 100%);
    color: #1a1a1a;
    font-weight: 600;
    border-radius: 1rem 1rem 0.25rem 1rem;
}

.chat-timestamp {
    font-size: 0.65rem;
    color: #666;
    margin-top: 0.2rem;
    text-align: right;
}

.chat-message.user .chat-timestamp {
    text-align: right;
}

/* Typing Indicator */
.typing-indicator .message-bubble.bot span {
    display: inline-block;
    width: 7px;
    height: 7px;
    margin: 0 2px;
    background: #D4A574;
    border-radius: 50%;
    animation: typingBounce 1.2s ease-in-out infinite;
}

.typing-indicator .message-bubble.bot span:nth-child(2) {
    animation-delay: 0.15s;
}

.typing-indicator .message-bubble.bot span:nth-child(3) {
    animation-delay: 0.3s;
}

@keyframes typingBounce {
    0%, 60%, 100% { transform: translateY(0); opacity: 0.4; }
    30% { transform: translateY(-6px); opacity: 1; }
}

/* ── Chat Input Area ── */
.chat-input-area {
    padding: 0.85rem 1rem;
    border-top: 1px solid rgba(212, 165, 116, 0.1);
    display: flex;
    gap: 0.5rem;
    align-items: flex-end;
    background: rgba(255, 255, 255, 0.025);
    flex-shrink: 0;
}

.chat-input {
    flex: 1;
    padding: 0.65rem 0.9rem;
    border: 2px solid rgba(212, 165, 116, 0.15);
    background: rgba(255, 255, 255, 0.92);
    color: #1a1a1a;
    border-radius: 0.75rem;
    font-size: 0.88rem;
    font-family: inherit;
    transition: all 0.3s ease;
    min-height: 40px;
    max-height: 100px;
    resize: none;
    outline: none;
}

.chat-input:focus {
    border-color: #D4A574;
    box-shadow: 0 0 0 3px rgba(212, 165, 116, 0.12);
}

.chat-input::placeholder {
    color: #999;
}

.chat-send-btn {
    width: 40px;
    height: 40px;
    background: linear-gradient(135deg, #D4A574 0%, #b8834a 100%);
    color: #fff;
    border: none;
    border-radius: 0.75rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.95rem;
    transition: all 0.3s ease;
    flex-shrink: 0;
}

.chat-send-btn:active {
    transform: scale(0.92);
}

@media (hover: hover) {
    .chat-send-btn:hover {
        transform: scale(1.06);
        box-shadow: 0 4px 16px rgba(212, 165, 116, 0.4);
    }
}

/* =============================================
   RESPONSIVE BREAKPOINTS
   ============================================= */

/* ── Large Desktop (1200px+) ── */
@media (min-width: 1200px) {
    .chat-box {
        width: 400px;
        height: 470px;
    }
}

/* ── Desktop (769px – 1199px) ── */
@media (min-width: 769px) and (max-width: 1199px) {
    .chat-box {
        width: 380px;
        height: 440px;
        bottom: 95px;
    }
}

/* ── Tablet (481px – 768px) ── */
@media (min-width: 481px) and (max-width: 768px) {
    .chat-icon-button {
        width: 56px;
        height: 56px;
        font-size: 1.35rem;
        margin: 1rem;
    }

    .chat-box {
        width: 340px;
        height: 480px;
        bottom: 85px;
        right: 1rem;
    }

    .chat-header {
        padding: 0.85rem 1rem;
    }

    .chat-header-avatar {
        width: 34px;
        height: 34px;
        font-size: 0.9rem;
    }

    .chat-header-title {
        font-size: 0.9rem;
    }

    .chat-messages {
        padding: 0.85rem 1rem;
    }

    .message-bubble {
        max-width: 85%;
        font-size: 0.82rem;
    }

    .chat-input-area {
        padding: 0.75rem 0.85rem;
    }
}

/* ── Mobile (361px – 480px) ── */
@media (max-width: 480px) {
    .chat-icon-button {
        width: 52px;
        height: 52px;
        font-size: 1.25rem;
        margin: 0.75rem;
    }

    .chat-box {
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        width: 100% !important;
        height: 100% !important;
        max-width: 100vw;
        max-height: 100vh;
        border-radius: 0;
        border: none;
    }

    .chat-header {
        padding: 0.85rem 1rem;
        border-radius: 0;
        padding-top: max(0.85rem, env(safe-area-inset-top, 0.85rem));
    }

    .chat-header-avatar {
        width: 36px;
        height: 36px;
        font-size: 0.9rem;
    }

    .chat-header-title {
        font-size: 0.9rem;
    }

    .chat-header-subtitle {
        font-size: 0.68rem;
    }

    .chat-close-btn {
        width: 36px;
        height: 36px;
        font-size: 1.15rem;
    }

    .chat-messages {
        padding: 0.75rem;
        gap: 0.5rem;
    }

    .message-bubble {
        max-width: 88%;
        padding: 0.65rem 0.85rem;
        font-size: 0.82rem;
    }

    .chat-input-area {
        padding: 0.65rem 0.75rem;
        padding-bottom: max(0.65rem, env(safe-area-inset-bottom, 0.65rem));
    }

    .chat-input {
        padding: 0.6rem 0.8rem;
        font-size: 0.88rem;
        min-height: 42px;
    }

    .chat-send-btn {
        width: 42px;
        height: 42px;
    }
}

/* ── Extra Small Mobile (≤360px) ── */
@media (max-width: 360px) {
    .chat-icon-button {
        width: 48px;
        height: 48px;
        font-size: 1.15rem;
        margin: 0.6rem;
    }

    .chat-badge {
        width: 18px;
        height: 18px;
        font-size: 9px;
    }

    .chat-header {
        padding: 0.7rem 0.85rem;
    }

    .chat-header-avatar {
        width: 32px;
        height: 32px;
        font-size: 0.8rem;
    }

    .chat-header-title {
        font-size: 0.82rem;
    }

    .chat-header-subtitle {
        font-size: 0.62rem;
    }

    .chat-close-btn {
        width: 32px;
        height: 32px;
        font-size: 1rem;
    }

    .chat-messages {
        padding: 0.6rem;
    }

    .message-bubble {
        max-width: 92%;
        padding: 0.55rem 0.7rem;
        font-size: 0.78rem;
    }

    .chat-input-area {
        padding: 0.55rem 0.6rem;
    }

    .chat-input {
        padding: 0.55rem 0.7rem;
        font-size: 0.84rem;
        min-height: 38px;
    }

    .chat-send-btn {
        width: 38px;
        height: 38px;
        font-size: 0.85rem;
    }
}

/* ── Landscape orientation on small screens ── */
@media (max-height: 500px) and (orientation: landscape) {
    .chat-box {
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        width: 100% !important;
        height: 100% !important;
        border-radius: 0;
        border: none;
    }

    .chat-header {
        padding: 0.5rem 1rem;
    }

    .chat-header-avatar {
        width: 30px;
        height: 30px;
        font-size: 0.75rem;
    }

    .chat-messages {
        padding: 0.5rem 0.75rem;
        gap: 0.35rem;
    }

    .message-bubble {
        padding: 0.4rem 0.7rem;
        font-size: 0.78rem;
    }

    .chat-input-area {
        padding: 0.4rem 0.75rem;
    }

    .chat-input {
        min-height: 34px;
        padding: 0.4rem 0.7rem;
    }

    .chat-send-btn {
        width: 34px;
        height: 34px;
    }
}

/* ── Print: hide chat ── */
@media print {
    .chat-widget-container {
        display: none !important;
    }
}

/* ── Ensure widget stays visible ── */
.chat-widget-container {
    position: fixed !important;
    bottom: 0 !important;
    right: 0 !important;
}
