/* ==============================================================================
   Ahmed Hemdan & Partners - Smart AI Consultant Chat Widget (Styles)
   مكتب أحمد حمدان محمد وشركاه - المساعد الاستشاري الذكي
   Fully responsive, light/dark mode compliant, zero-CLS architecture
   ============================================================================== */

/* Floating Action Button (FAB) */
.hemdan-ai-fab {
    position: fixed;
    bottom: 24px;
    right: 24px;
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: linear-gradient(135deg, #0a192f 0%, #0f2342 50%, #c5a880 100%);
    border: 2px solid var(--gold-primary, #c5a880);
    box-shadow: 0 8px 25px rgba(10, 25, 47, 0.4), 0 0 15px rgba(197, 168, 128, 0.35);
    color: #ffffff;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.55rem;
    z-index: 1000;
    transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
    outline: none;
}

.hemdan-ai-fab:hover {
    transform: translateY(-4px) scale(1.05);
    box-shadow: 0 12px 30px rgba(10, 25, 47, 0.5), 0 0 25px rgba(197, 168, 128, 0.6);
}

.hemdan-ai-fab .fab-badge {
    position: absolute;
    top: -4px;
    left: -4px;
    background: #10b981;
    color: #ffffff;
    font-size: 0.68rem;
    font-weight: 800;
    padding: 2px 6px;
    border-radius: 10px;
    border: 2px solid #ffffff;
    letter-spacing: 0.5px;
    box-shadow: 0 2px 6px rgba(16, 185, 129, 0.4);
}

.hemdan-ai-fab-pulse {
    position: absolute;
    inset: -6px;
    border-radius: 50%;
    border: 2px solid var(--gold-primary, #c5a880);
    opacity: 0;
    animation: hemdanAiPulse 2.8s infinite;
    pointer-events: none;
}

@keyframes hemdanAiPulse {
    0% { transform: scale(0.9); opacity: 0.8; }
    50% { transform: scale(1.25); opacity: 0; }
    100% { transform: scale(1.3); opacity: 0; }
}

/* Tooltip Label */
.hemdan-ai-tooltip {
    position: fixed;
    bottom: 34px;
    right: 94px;
    background: var(--navy-deep, #0a192f);
    color: #ffffff;
    font-size: 0.85rem;
    font-weight: 700;
    padding: 8px 16px;
    border-radius: 20px;
    border: 1px solid var(--gold-border, rgba(197, 168, 128, 0.35));
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.25);
    pointer-events: none;
    white-space: nowrap;
    z-index: 999;
    transition: all 0.3s ease;
    opacity: 1;
    display: flex;
    align-items: center;
    gap: 6px;
    font-family: inherit;
}

.hemdan-ai-tooltip.hide {
    opacity: 0;
    transform: translateX(10px);
}

/* Chat Main Window */
.hemdan-ai-window {
    position: fixed;
    bottom: 96px;
    right: 24px;
    width: 390px;
    max-width: calc(100vw - 32px);
    height: 590px;
    max-height: calc(100vh - 120px);
    border-radius: 20px;
    background: var(--bg-white, #ffffff);
    color: var(--slate-dark, #1e293b);
    border: 1px solid var(--gold-border, rgba(197, 168, 128, 0.35));
    box-shadow: 0 20px 50px rgba(10, 25, 47, 0.25), 0 0 1px rgba(0, 0, 0, 0.1);
    z-index: 1000;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    opacity: 0;
    pointer-events: none;
    transform: scale(0.92) translateY(20px);
    transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
    font-family: inherit;
}

.hemdan-ai-window.open {
    opacity: 1;
    pointer-events: auto;
    transform: scale(1) translateY(0);
}

/* Chat Header */
.hemdan-ai-header {
    background: linear-gradient(135deg, #0a192f 0%, #0f2342 100%);
    color: #ffffff;
    padding: 14px 18px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 2px solid var(--gold-primary, #c5a880);
    flex-shrink: 0;
}

.hemdan-ai-header-info {
    display: flex;
    align-items: center;
    gap: 12px;
}

.hemdan-ai-avatar {
    width: 42px;
    height: 42px;
    border-radius: 50%;
    background: linear-gradient(135deg, #dfc7a5 0%, #c5a880 100%);
    color: #0a192f;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.25rem;
    position: relative;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

.hemdan-ai-avatar .status-dot {
    position: absolute;
    bottom: 1px;
    right: 1px;
    width: 11px;
    height: 11px;
    border-radius: 50%;
    background: #10b981;
    border: 2px solid #0a192f;
}

.hemdan-ai-header-titles h4 {
    margin: 0;
    font-size: 0.98rem;
    font-weight: 800;
    color: #ffffff;
    letter-spacing: -0.2px;
}

.hemdan-ai-header-titles p {
    margin: 2px 0 0;
    font-size: 0.76rem;
    color: var(--gold-light, #dfc7a5);
}

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

.hemdan-ai-btn-action {
    background: rgba(255, 255, 255, 0.1);
    border: none;
    color: #ffffff;
    width: 32px;
    height: 32px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 0.9rem;
    transition: all 0.2s;
}

.hemdan-ai-btn-action:hover {
    background: rgba(197, 168, 128, 0.25);
    color: var(--gold-light, #dfc7a5);
}

/* Chat Messages Container */
.hemdan-ai-messages {
    flex: 1;
    padding: 16px;
    overflow-y: auto;
    overflow-x: hidden;
    display: flex;
    flex-direction: column;
    gap: 12px;
    background: var(--bg-light, #f8fafc);
    font-size: 0.88rem;
    line-height: 1.6;
}

/* Message Bubble */
.hemdan-msg {
    display: flex;
    flex-direction: column;
    max-width: 88%;
    animation: hemdanMsgFade 0.25s ease-out;
}

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

.hemdan-msg.bot {
    align-self: flex-start;
}

.hemdan-msg.user {
    align-self: flex-end;
}

.hemdan-msg-bubble {
    padding: 12px 16px;
    border-radius: 16px;
    position: relative;
    word-break: break-word;
}

.hemdan-msg.bot .hemdan-msg-bubble {
    background: var(--bg-white, #ffffff);
    color: var(--slate-dark, #1e293b);
    border: 1px solid var(--slate-border, #e2e8f0);
    border-top-right-radius: 4px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
}

.hemdan-msg.user .hemdan-msg-bubble {
    background: linear-gradient(135deg, #0f2342 0%, #152c50 100%);
    color: #ffffff;
    border-top-left-radius: 4px;
    box-shadow: 0 4px 12px rgba(15, 35, 66, 0.2);
}

.hemdan-msg-time {
    font-size: 0.7rem;
    color: var(--slate-light, #94a3b8);
    margin-top: 4px;
    align-self: flex-start;
}

.hemdan-msg.user .hemdan-msg-time {
    align-self: flex-end;
}

/* Quick Suggestion Chips */
.hemdan-quick-chips {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-top: 8px;
}

.hemdan-chip {
    background: var(--bg-white, #ffffff);
    border: 1px solid var(--gold-border, rgba(197, 168, 128, 0.4));
    color: var(--navy-deep, #0a192f);
    padding: 8px 12px;
    border-radius: 12px;
    font-size: 0.82rem;
    font-weight: 600;
    cursor: pointer;
    text-align: right;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: all 0.2s ease;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.03);
    outline: none;
    font-family: inherit;
}

.hemdan-chip i {
    color: var(--gold-primary, #c5a880);
    font-size: 0.9rem;
}

.hemdan-chip:hover {
    background: var(--gold-subtle, rgba(197, 168, 128, 0.12));
    border-color: var(--gold-primary, #c5a880);
    transform: translateX(-4px);
}

/* Inline Booking Form Card inside Chat */
.hemdan-booking-card {
    background: var(--bg-white, #ffffff);
    border: 1px solid var(--gold-primary, #c5a880);
    border-radius: 14px;
    padding: 16px;
    margin-top: 8px;
    box-shadow: 0 6px 18px rgba(0, 0, 0, 0.06);
}

.hemdan-booking-card h5 {
    margin: 0 0 12px;
    font-size: 0.95rem;
    font-weight: 800;
    color: var(--navy-deep, #0a192f);
    display: flex;
    align-items: center;
    gap: 8px;
}

.hemdan-booking-card h5 i {
    color: var(--gold-primary, #c5a880);
}

.hemdan-bk-group {
    margin-bottom: 10px;
}

.hemdan-bk-group label {
    display: block;
    font-size: 0.78rem;
    font-weight: 700;
    margin-bottom: 4px;
    color: var(--slate-body, #475569);
}

.hemdan-bk-input {
    width: 100%;
    padding: 8px 12px;
    border-radius: 8px;
    border: 1px solid var(--slate-border, #cbd5e1);
    background: var(--bg-light, #f8fafc);
    color: var(--slate-dark, #1e293b);
    font-size: 0.84rem;
    outline: none;
    box-sizing: border-box;
    font-family: inherit;
    transition: border-color 0.2s;
}

.hemdan-bk-input:focus {
    border-color: var(--gold-primary, #c5a880);
    background: #ffffff;
}

.hemdan-bk-btn-submit {
    width: 100%;
    padding: 10px;
    border-radius: 10px;
    background: linear-gradient(135deg, #0a192f 0%, #0f2342 100%);
    color: #ffffff;
    border: 1px solid var(--gold-primary, #c5a880);
    font-weight: 700;
    font-size: 0.88rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    margin-top: 12px;
    transition: all 0.2s;
}

.hemdan-bk-btn-submit:hover {
    background: var(--gold-primary, #c5a880);
    color: #0a192f;
}

/* Booking Success State */
.hemdan-bk-success {
    background: rgba(16, 185, 129, 0.08);
    border: 1px solid #10b981;
    border-radius: 12px;
    padding: 14px;
    text-align: center;
}

.hemdan-bk-success i.check-icon {
    font-size: 2rem;
    color: #10b981;
    margin-bottom: 6px;
}

.hemdan-bk-wa-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: 100%;
    padding: 10px;
    border-radius: 10px;
    background: #25D366;
    color: #ffffff !important;
    font-weight: 800;
    font-size: 0.88rem;
    text-decoration: none;
    margin-top: 10px;
    box-shadow: 0 4px 12px rgba(37, 211, 102, 0.35);
    transition: transform 0.2s;
}

.hemdan-bk-wa-btn:hover {
    transform: scale(1.02);
}

/* Typing Indicator */
.hemdan-typing {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 8px 14px;
    background: var(--bg-white, #ffffff);
    border: 1px solid var(--slate-border, #e2e8f0);
    border-radius: 16px;
    align-self: flex-start;
}

.hemdan-typing span {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--gold-primary, #c5a880);
    animation: hemdanBounce 1.4s infinite ease-in-out both;
}

.hemdan-typing span:nth-child(1) { animation-delay: -0.32s; }
.hemdan-typing span:nth-child(2) { animation-delay: -0.16s; }

@keyframes hemdanBounce {
    0%, 80%, 100% { transform: scale(0); }
    40% { transform: scale(1); }
}

.typing-cursor {
    display: inline-block;
    width: 2px;
    height: 1em;
    background: var(--gold-primary, #c5a880);
    vertical-align: text-bottom;
    margin-right: 2px;
    animation: cursorBlink 0.8s infinite;
}

@keyframes cursorBlink {
    0%, 100% { opacity: 1; }
    50% { opacity: 0; }
}

/* Chat Footer / Quick Actions Bar */
.hemdan-ai-quick-bar {
    padding: 6px 14px;
    background: var(--bg-white, #ffffff);
    border-top: 1px solid var(--slate-border, #f1f5f9);
    display: flex;
    gap: 6px;
    overflow-x: auto;
    flex-shrink: 0;
}

.hemdan-quick-action-pill {
    padding: 4px 10px;
    border-radius: 12px;
    background: var(--bg-light, #f8fafc);
    border: 1px solid var(--slate-border, #e2e8f0);
    color: var(--slate-dark, #1e293b);
    font-size: 0.74rem;
    font-weight: 700;
    cursor: pointer;
    white-space: nowrap;
    display: inline-flex;
    align-items: center;
    gap: 5px;
    transition: all 0.15s;
}

.hemdan-quick-action-pill:hover {
    background: var(--gold-subtle, rgba(197, 168, 128, 0.12));
    border-color: var(--gold-primary, #c5a880);
    color: var(--navy-deep, #0a192f);
}

/* Chat Input Bar */
.hemdan-ai-footer {
    padding: 10px 14px;
    background: var(--bg-white, #ffffff);
    border-top: 1px solid var(--slate-border, #e2e8f0);
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
}

.hemdan-ai-input {
    flex: 1;
    border: 1px solid var(--slate-border, #cbd5e1);
    background: var(--bg-light, #f8fafc);
    color: var(--slate-dark, #1e293b);
    padding: 9px 14px;
    border-radius: 24px;
    font-size: 0.88rem;
    outline: none;
    resize: none;
    height: 40px;
    max-height: 90px;
    box-sizing: border-box;
    font-family: inherit;
    transition: border-color 0.2s;
    line-height: 1.4;
}

.hemdan-ai-input:focus {
    border-color: var(--gold-primary, #c5a880);
    background: #ffffff;
}

.hemdan-ai-btn-send {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: linear-gradient(135deg, #0a192f 0%, #0f2342 100%);
    border: 1px solid var(--gold-primary, #c5a880);
    color: var(--gold-light, #dfc7a5);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 0.95rem;
    outline: none;
    transition: all 0.2s;
    flex-shrink: 0;
}

.hemdan-ai-btn-send:hover {
    background: var(--gold-primary, #c5a880);
    color: #0a192f;
    transform: scale(1.05);
}

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

/* Dark Mode Overrides */
[data-theme="dark"] .hemdan-ai-window {
    background: #0a192f;
    color: #ffffff;
    border-color: rgba(197, 168, 128, 0.35);
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.6);
}

[data-theme="dark"] .hemdan-ai-messages {
    background: #060d19;
}

[data-theme="dark"] .hemdan-msg.bot .hemdan-msg-bubble {
    background: #0f2342;
    color: #ffffff;
    border-color: rgba(197, 168, 128, 0.2);
}

[data-theme="dark"] .hemdan-chip {
    background: #0f2342;
    color: #ffffff;
    border-color: rgba(197, 168, 128, 0.3);
}

[data-theme="dark"] .hemdan-chip:hover {
    background: rgba(197, 168, 128, 0.15);
}

[data-theme="dark"] .hemdan-booking-card {
    background: #0f2342;
    border-color: var(--gold-primary, #c5a880);
}

[data-theme="dark"] .hemdan-booking-card h5 {
    color: #ffffff;
}

[data-theme="dark"] .hemdan-bk-group label {
    color: #cbd5e1;
}

[data-theme="dark"] .hemdan-bk-input {
    background: #060d19;
    border-color: rgba(197, 168, 128, 0.3);
    color: #ffffff;
}

[data-theme="dark"] .hemdan-bk-input:focus {
    border-color: var(--gold-light, #dfc7a5);
    background: #0a192f;
}

[data-theme="dark"] .hemdan-typing {
    background: #0f2342;
    border-color: rgba(197, 168, 128, 0.2);
}

[data-theme="dark"] .hemdan-ai-quick-bar,
[data-theme="dark"] .hemdan-ai-footer {
    background: #0a192f;
    border-color: rgba(197, 168, 128, 0.2);
}

[data-theme="dark"] .hemdan-quick-action-pill {
    background: #0f2342;
    border-color: rgba(197, 168, 128, 0.25);
    color: #cbd5e1;
}

[data-theme="dark"] .hemdan-quick-action-pill:hover {
    background: rgba(197, 168, 128, 0.2);
    color: #ffffff;
}

[data-theme="dark"] .hemdan-ai-input {
    background: #060d19;
    border-color: rgba(197, 168, 128, 0.3);
    color: #ffffff;
}

[data-theme="dark"] .hemdan-ai-input:focus {
    background: #0f2342;
    border-color: var(--gold-light, #dfc7a5);
}

/* Mobile Responsiveness */
@media (max-width: 480px) {
    .hemdan-ai-fab {
        bottom: 20px;
        right: 18px;
        width: 54px;
        height: 54px;
        font-size: 1.4rem;
    }
    
    .hemdan-ai-tooltip {
        display: none !important;
    }

    .hemdan-ai-window {
        bottom: 84px;
        right: 12px;
        left: 12px;
        width: calc(100vw - 24px);
        height: calc(100vh - 100px);
        max-height: 580px;
        border-radius: 16px;
    }
}
