/* ==========================================
   CSS Variables & Root Styles
   ========================================== */
:root {
    --brand-green-dark: #1b4332;
    --brand-green-mid: #2d6a4f;
    --brand-green-light: #40916c;
    --brand-green-lighter: #52b788;
    --brand-green-soft: #74c69d;
    --text-dark: #081c15;
    --text-light: #d8f3dc;
    --white: #ffffff;
    --shadow-sm: 0 2px 8px rgba(27, 67, 50, 0.1);
    --shadow-md: 0 4px 16px rgba(27, 67, 50, 0.15);
    --shadow-lg: 0 8px 32px rgba(27, 67, 50, 0.2);
    --radius: 16px;
    --radius-sm: 8px;
    --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

/* ==========================================
   Body Background Gradient
   ========================================== */
body {
    font-family: "Cairo", "Segoe UI", Tahoma, sans-serif;
}

/* ==========================================
   Chat Button (Floating)
   ========================================== */
.chat-button {
    position: fixed;
    bottom: 24px;
    left: 24px;
    width: 70px;
    height: 70px;
    background: linear-gradient(
        135deg,
        var(--brand-green-mid),
        var(--brand-green-light)
    );
    border: none;
    border-radius: 50%;
    cursor: pointer;
    box-shadow: var(--shadow-lg);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    transition: var(--transition);
    /* Removed bounce animation */
}

[dir="rtl"] .chat-button {
    right: auto;
    left: 24px;
}

.chat-button:hover {
    transform: scale(1.1);
    box-shadow: 0 12px 40px rgba(27, 67, 50, 0.3);
}

.chat-button svg {
    width: 46px;
    height: 46px;
}

.chat-button .notification-badge {
    position: absolute;
    top: -4px;
    right: -4px;
    background: #ef4444;
    color: var(--white);
    border-radius: 50%;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: 700;
    animation: pulse 2s infinite;
}

[dir="rtl"] .chat-button .notification-badge {
    right: auto;
    left: -4px;
}

/* ==========================================
   Chat Window
   ========================================== */
.chat-window {
    position: fixed;
    bottom: 100px;
    left: 24px;
    width: 420px;
    max-width: calc(100vw - 48px);
    height: 600px;
    max-height: calc(100vh - 140px);
    background: var(--white);
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    display: none;
    flex-direction: column;
    overflow: hidden;
    z-index: 9998;
    animation: slideUp 0.3s ease-out;
}

.chat-window.active {
    display: flex;
}

/* ==========================================
   Chat Header
   ========================================== */
.chat-header {
    background: linear-gradient(
        135deg,
        var(--brand-green-dark),
        var(--brand-green-mid)
    );
    color: var(--white);
    padding: 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    box-shadow: var(--shadow-sm);
}

.chat-header-left {
    display: flex;
    align-items: center;
    gap: 12px;
}

.chat-avatar {
    width: 44px;
    height: 44px;
    background: linear-gradient(
        135deg,
        var(--brand-green-lighter),
        var(--brand-green-soft)
    );
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    font-weight: 700;
    color: var(--text-dark);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}

.chat-avatar svg {
    width: 28px;
    height: 28px;
    fill: var(--text-dark);
}

.chat-header-info h3 {
    font-size: 18px;
    margin: 0 0 4px 0;
    font-weight: 700;
}

.chat-status {
    font-size: 13px;
    opacity: 0.9;
    display: flex;
    align-items: center;
    gap: 6px;
}

.status-dot {
    width: 8px;
    height: 8px;
    background: #10b981;
    border-radius: 50%;
    display: inline-block;
    animation: pulse 2s infinite;
}

.chat-header-actions {
    display: flex;
    align-items: center;
    gap: 8px;
}

.chat-action-btn {
    background: transparent;
    border: none;
    color: var(--white);
    cursor: pointer;
    padding: 0;
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: var(--transition);
    opacity: 0.9;
}

.chat-action-btn:hover {
    background: rgba(255, 255, 255, 0.2);
    opacity: 1;
    transform: scale(1.05);
}

.chat-action-btn svg {
    width: 20px;
    height: 20px;
    fill: currentColor;
}

.chat-close {
    background: transparent;
    border: none;
    color: var(--white);
    font-size: 28px;
    cursor: pointer;
    padding: 0;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: var(--transition);
}

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

/* ==========================================
   Chat Messages Area
   ========================================== */
.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    background: linear-gradient(to bottom, #f0fdf4, #ffffff);
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.chat-messages::-webkit-scrollbar {
    width: 6px;
}

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

.chat-messages::-webkit-scrollbar-thumb {
    background: var(--brand-green-light);
    border-radius: 3px;
}

/* ==========================================
   Message Bubbles
   ========================================== */
.message {
    display: flex;
    gap: 8px;
    animation: fadeIn 0.3s ease-out;
    align-items: flex-end;
}

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

[dir="rtl"] .message {
    flex-direction: row-reverse;
}

[dir="rtl"] .message.user-message {
    flex-direction: row;
}

.message-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: linear-gradient(
        135deg,
        var(--brand-green-lighter),
        var(--brand-green-soft)
    );
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    color: var(--text-dark);
    font-weight: 600;
    flex-shrink: 0;
}

.user-message .message-avatar {
    background: linear-gradient(135deg, #3b82f6, #60a5fa);
    color: var(--white);
}

.message-content {
    max-width: 88%;
    padding: 12px 16px;
    border-radius: var(--radius-sm);
    line-height: 1.7;
    word-wrap: break-word;
}

.bot-message .message-content {
    background: var(--white);
    color: var(--text-dark);
    box-shadow: var(--shadow-sm);
    max-width: 92%;
}

.user-message .message-content {
    background: linear-gradient(
        135deg,
        var(--brand-green-mid),
        var(--brand-green-light)
    );
    color: var(--white);
    max-width: 80%;
}

/* ==========================================
   Rest Card (Chalet Card)
   ========================================== */
.rest-card {
    background: var(--white);
    border-radius: var(--radius);
    overflow: hidden;
    box-shadow: var(--shadow-md);
    transition: var(--transition);
    margin-top: 8px;
    max-width: 100%;
}

.rest-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-lg);
}

.rest-card-image {
    position: relative;
    width: 100%;
    height: 180px;
    overflow: hidden;
    background: linear-gradient(135deg, #e5e7eb, #f3f4f6);
}

.rest-card-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: var(--transition);
}

.rest-card:hover .rest-card-image img {
    transform: scale(1.05);
}

.rest-card-discount-badge {
    position: absolute;
    top: 12px;
    right: 12px;
    background: linear-gradient(135deg, #ef4444, #dc2626);
    color: var(--white);
    padding: 6px 12px;
    border-radius: 20px;
    font-weight: 700;
    font-size: 13px;
    box-shadow: var(--shadow-md);
    animation: pulse 2s infinite;
}

[dir="rtl"] .rest-card-discount-badge {
    right: auto;
    left: 12px;
}

.rest-card-content {
    padding: 16px;
}

.rest-card-code {
    display: inline-block;
    background: linear-gradient(
        135deg,
        var(--brand-green-lighter),
        var(--brand-green-soft)
    );
    color: var(--text-dark);
    padding: 4px 10px;
    border-radius: 12px;
    font-size: 11px;
    font-weight: 700;
    margin-bottom: 8px;
    letter-spacing: 0.5px;
}

.rest-card-title {
    font-size: 16px;
    font-weight: 700;
    color: var(--text-dark);
    margin-bottom: 12px;
}

/* ==========================================
   Rest Card Features (NEW)
   ========================================== */
.rest-card-features {
    display: flex;
    justify-content: space-around;
    padding: 12px 0;
    margin: 12px 0;
    border-top: 1px solid #e5e7eb;
    border-bottom: 1px solid #e5e7eb;
    gap: 8px;
    flex-wrap: wrap;
}

.feature-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    min-width: 50px;
}

.feature-icon {
    font-size: 18px;
}

.feature-value {
    font-size: 15px;
    font-weight: 700;
    color: var(--brand-green-dark);
}

.feature-label {
    font-size: 10px;
    color: #6b7280;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

/* ==========================================
   Rest Card Prices
   ========================================== */
.rest-card-prices {
    margin: 12px 0;
}

.price-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 0;
}

.price-label {
    font-size: 13px;
    color: #6b7280;
    font-weight: 500;
}

.price-values {
    display: flex;
    align-items: center;
    gap: 8px;
}

.price-before {
    font-size: 13px;
    color: #9ca3af;
    text-decoration: line-through;
}

.price-after {
    font-size: 16px;
    font-weight: 700;
    color: var(--brand-green-dark);
}

.price-currency {
    font-size: 13px;
    color: var(--brand-green-mid);
    font-weight: 600;
}

.rest-card-discount-text {
    background: linear-gradient(135deg, #fef3c7, #fde68a);
    color: #92400e;
    padding: 8px 12px;
    border-radius: var(--radius-sm);
    font-size: 13px;
    font-weight: 600;
    text-align: center;
    margin: 12px 0;
}

.rest-card-button {
    width: 100%;
    background: linear-gradient(
        135deg,
        var(--brand-green-mid),
        var(--brand-green-light)
    );
    color: var(--white);
    border: none;
    padding: 12px;
    border-radius: var(--radius-sm);
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    box-shadow: var(--shadow-sm);
}

.rest-card-button:hover {
    background: linear-gradient(
        135deg,
        var(--brand-green-light),
        var(--brand-green-lighter)
    );
    box-shadow: var(--shadow-md);
    transform: translateY(-2px);
}

/* ==========================================
   Typing Indicator
   ========================================== */
.typing-indicator {
    display: flex;
    gap: 8px;
    align-items: flex-end;
    animation: fadeIn 0.3s ease-out;
}

/* Arabic locale: typing indicator on the LEFT */
.locale-ar .typing-indicator {
    align-self: flex-start;
    flex-direction: row;
}

/* English locale: typing indicator on the RIGHT */
.locale-en .typing-indicator {
    align-self: flex-end;
    flex-direction: row-reverse;
}

.typing-indicator .message-avatar {
    width: 32px;
    height: 32px;
}

.typing-dots {
    background: var(--white);
    padding: 12px 16px;
    border-radius: var(--radius-sm);
    display: flex;
    gap: 4px;
    box-shadow: var(--shadow-sm);
}

.typing-dots span {
    width: 8px;
    height: 8px;
    background: var(--brand-green-mid);
    border-radius: 50%;
    animation: typing 1.4s infinite;
}

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

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

/* ==========================================
   Chat Input Area
   ========================================== */
.chat-input {
    padding: 16px;
    background: var(--white);
    border-top: 1px solid #e5e7eb;
    display: flex;
    gap: 8px;
}

.chat-input input {
    flex: 1;
    padding: 12px 16px;
    border: 2px solid #e5e7eb;
    border-radius: 24px;
    font-size: 14px;
    outline: none;
    transition: var(--transition);
    font-family: "Cairo", "Segoe UI", sans-serif;
}

.chat-input input:focus {
    border-color: var(--brand-green-light);
}

.send-button {
    width: 44px;
    height: 44px;
    background: linear-gradient(
        135deg,
        var(--brand-green-mid),
        var(--brand-green-light)
    );
    color: var(--white);
    border: none;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
    box-shadow: var(--shadow-sm);
}

.send-button:hover:not(:disabled) {
    background: linear-gradient(
        135deg,
        var(--brand-green-light),
        var(--brand-green-lighter)
    );
    box-shadow: var(--shadow-md);
    transform: scale(1.05);
}

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

.send-button svg {
    width: 20px;
    height: 20px;
    fill: var(--white);
}

[dir="rtl"] .send-button svg {
    transform: scaleX(-1);
}

/* ==========================================
   Animations
   ========================================== */
@keyframes bounce {
    0%,
    100% {
        transform: translateY(0);
    }
    50% {
        transform: translateY(-8px);
    }
}

@keyframes pulse {
    0%,
    100% {
        opacity: 1;
        transform: scale(1);
    }
    50% {
        opacity: 0.8;
        transform: scale(0.95);
    }
}

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

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

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

/* ==========================================
   Responsive Design
   ========================================== */
@media (max-width: 480px) {
    .chat-window {
        width: 100%;
        height: 100vh;       /* fallback for older iOS */
        height: 100dvh;      /* dynamic viewport — shrinks when keyboard appears */
        max-width: 100vw;
        max-height: 100vh;
        max-height: 100dvh;
        bottom: 0;
        right: 0;
        left: 0;
        top: 0;
        border-radius: 0;
    }

    [dir="rtl"] .chat-window {
        left: 0;
        right: 0;
    }

    /* prevent iOS auto-zoom on input focus */
    .chat-input input {
        font-size: 16px;
    }

    .chat-phone-input,
    #chatPhoneInput,
    #chatOtpInput {
        font-size: 16px;
    }

    .chat-button {
        bottom: 16px;
        left: 16px;
        width: 60px;
        height: 60px;
    }

    [dir="rtl"] .chat-button {
        right: auto;
        left: 16px;
    }

    .rest-card-features {
        gap: 4px;
    }

    .feature-item {
        min-width: 45px;
    }

    .feature-icon {
        font-size: 16px;
    }

    .feature-value {
        font-size: 13px;
    }

    .feature-label {
        font-size: 9px;
    }
}

/* ==========================================
   Card Rating Styles (Compact & Professional)
   ========================================== */
.rest-card-rating {
    display: flex;
    align-items: center;
    gap: 6px;
    margin: 8px 0;
    padding: 4px 8px;
    background: linear-gradient(135deg, #fef3c7, #fde68a);
    border-radius: 6px;
    font-size: 11px;
}

.rating-stars {
    letter-spacing: 1px;
    font-size: 12px;
}

.rating-info {
    color: #92400e;
    font-weight: 600;
    font-size: 11px;
}

[dir="rtl"] .rest-card-rating {
    direction: rtl;
}

@media (min-width: 481px) and (max-width: 768px) {
    .chat-window {
        width: 380px;
        height: 550px;
    }
}

/* =====================================================
   Mahra AI — Marker Styles (Mobile-matched)
   ===================================================== */

/* CODE chip wrapper — column layout matching mobile */
.code-chip-wrap {
    display: inline-flex;
    flex-direction: column;
    gap: 5px;
    margin: 6px 0;
    width: fit-content;
    max-width: 100%;
}

/* Code badge — bordered box with code + copy icon */
.code-chip {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    background: #fff;
    border: 1.5px solid #b2dfdb;
    border-radius: 10px;
    padding: 8px 14px;
    cursor: pointer;
    font-size: 13.5px;
    transition: all .2s;
    width: fit-content;
}
.code-chip:hover  { background: #f1f8e9; border-color: #4caf50; }
.code-chip.copied { background: #e8f5e9; border-color: #2e7d32; }
.code-chip-copy-icon { font-size: 15px; }
.code-chip-code { font-weight: 700; color: #1b5e20; font-family: monospace; letter-spacing: 0.5px; }

/* Green CTA button below the code badge */
.code-chip-cta {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: #2d6a4f;
    color: #fff;
    border-radius: 10px;
    padding: 8px 16px;
    font-size: 12.5px;
    font-weight: 600;
    cursor: pointer;
    transition: background .2s;
    width: fit-content;
    font-family: "Cairo", "Segoe UI", sans-serif;
}
.code-chip-cta:hover { background: #1b4332; }

/* Contact chips */
.contact-chip {
    display: inline-flex; align-items: center; gap: 5px;
    background: #e3f2fd; border: 1px solid #90caf9; border-radius: 8px;
    padding: 4px 10px; font-size: 13px; color: #1565c0;
    text-decoration: none; font-weight: 600; margin: 3px 0;
}
.contact-chip:hover { background: #bbdefb; }

/* Text markers — lighter, more readable */
.txt-bold    { color: #2d6a4f; font-weight: 600; }
.txt-strike  { color: #999; text-decoration: line-through; font-weight: 400; }
.txt-warning { color: #c0392b; font-weight: 600; }

/* Phone verification block */
.chat-phone-block {
    background: #f1f8e9; border: 1.5px solid #aed581;
    border-radius: 12px; padding: 12px 14px; margin: 8px 0;
}
.chat-phone-label { font-size: 13px; font-weight: 600; color: #33691e; margin-bottom: 8px; }
.chat-phone-row   { display: flex; gap: 8px; align-items: center; }
.chat-phone-input {
    flex: 1; border: 1.5px solid #aed581; border-radius: 8px;
    padding: 7px 10px; font-size: 14px; outline: none;
}
.chat-phone-input:focus { border-color: #558b2f; }
.chat-phone-btn {
    background: #558b2f; color: #fff; border: none;
    border-radius: 8px; padding: 7px 14px; font-size: 13px;
    font-weight: 600; cursor: pointer; white-space: nowrap;
}
.chat-phone-btn:disabled { opacity: .6; cursor: default; }
.chat-phone-btn:hover:not(:disabled) { background: #33691e; }
.chat-phone-error { color: #c62828; font-size: 12px; margin-top: 6px; font-weight: 500; }

/* ==========================================
   Message Content — lighter typography
   ========================================== */
.message-content {
    font-size: 13.5px;
    line-height: 1.65;
}
.bot-message .message-content {
    font-weight: 400;
    color: #1a2e1a;
}
.bot-message .message-content strong,
.bot-message .message-content .txt-bold {
    font-weight: 600;
    font-size: 13.5px;
}

/* ==========================================
   Quick Suggestion Chips
   ========================================== */
.chat-suggestions {
    display: flex;
    gap: 7px;
    padding: 9px 14px;
    overflow-x: auto;
    background: #fafafa;
    border-top: 1px solid #eef0ee;
    scrollbar-width: none;
    flex-shrink: 0;
}
.chat-suggestions::-webkit-scrollbar { display: none; }

.chip {
    flex-shrink: 0;
    border: none;
    border-radius: 20px;
    padding: 6px 13px;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    font-family: "Cairo", "Segoe UI", sans-serif;
    transition: all 0.18s ease;
    white-space: nowrap;
    line-height: 1.4;
}
.chip:active { transform: scale(0.95); }

.chip-today   { background: #e0f2fe; color: #0369a1; border: 1px solid #bae6fd; }
.chip-today:hover   { background: #bae6fd; }

.chip-deals   { background: #fef3c7; color: #92400e; border: 1px solid #fde68a; }
.chip-deals:hover   { background: #fde68a; }

.chip-budget  { background: #d1fae5; color: #065f46; border: 1px solid #6ee7b7; }
.chip-budget:hover  { background: #a7f3d0; }

.chip-events  { background: #ede9fe; color: #5b21b6; border: 1px solid #c4b5fd; }
.chip-events:hover  { background: #ddd6fe; }

.chip-support { background: #f1f5f9; color: #475569; border: 1px solid #cbd5e1; }
.chip-support:hover { background: #e2e8f0; }

/* ==========================================
   Markdown Rendering — dividers & headers
   ========================================== */

/* Thin section divider (--- in AI response) */
.chat-hr {
    border: none;
    border-top: 1px solid #e2e8e2;
    margin: 6px 0;
}

/* Section header (## or ### in AI response) */
.chat-section-label {
    display: inline-block;
    font-size: 12px;
    font-weight: 700;
    color: #2d6a4f;
    background: #f0faf4;
    border-left: 3px solid #52b788;
    padding: 2px 8px 2px 6px;
    border-radius: 0 4px 4px 0;
    margin: 4px 0 2px;
}

[dir="rtl"] .chat-section-label {
    border-left: none;
    border-right: 3px solid #52b788;
    border-radius: 4px 0 0 4px;
    padding: 2px 6px 2px 8px;
}

/* br.chat-spacer = paragraph break — slightly more space than a normal <br> */
br.chat-spacer {
    display: block;
    content: '';
    margin-top: 4px;
}

/* ==========================================
   Contact Chips — phone & email buttons
   ========================================== */
.contact-chip {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 5px 12px;
    border-radius: 20px;
    font-size: 13px;
    font-weight: 600;
    text-decoration: none;
    margin: 3px 2px;
    transition: all 0.18s ease;
    cursor: pointer;
}

.phone-chip {
    background: #e8f5e9;
    color: #2e7d32;
    border: 1.5px solid #a5d6a7;
}
.phone-chip:hover { background: #c8e6c9; color: #1b5e20; }

.email-chip {
    background: #e3f2fd;
    color: #1565c0;
    border: 1.5px solid #90caf9;
}
.email-chip:hover { background: #bbdefb; color: #0d47a1; }
