/* --- Base Reset & Fonts --- */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    font-family: 'Vazirmatn', -apple-system, BlinkMacSystemFont, sans-serif;
}

:root {
    --primary-teal: #0d9488;
    --primary-dark: #0f766e;
    --primary-light: #ccfbf1;
    --accent-gold: #d97706;
    --bg-light: #f8fafc;
    --card-bg: #ffffff;
    --text-main: #1e293b;
    --text-muted: #64748b;
    --chat-user-bg: #0d9488;
    --chat-bot-bg: #f1f5f9;
    --border-color: #e2e8f0;
    --radius-lg: 16px;
    --radius-md: 10px;
    --shadow-sm: 0 2px 8px rgba(0,0,0,0.05);
    --shadow-md: 0 4px 16px rgba(0,0,0,0.08);
}

body {
    background-color: var(--bg-light);
    color: var(--text-main);
    direction: rtl;
    line-height: 1.6;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

body.modal-open {
    overflow: hidden;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 16px;
}

/* --- Hero & Clinic Info --- */
.hero-section {
    background: linear-gradient(135deg, #0f766e 0%, #115e59 100%);
    color: white;
    padding: 32px 0 48px;
    border-bottom-left-radius: 32px;
    border-bottom-right-radius: 32px;
    box-shadow: var(--shadow-md);
}

.clinic-info-grid {
    display: grid;
    grid-template-columns: 1.2fr 0.8fr;
    gap: 32px;
    align-items: center;
}

.badge {
    display: inline-block;
    background: rgba(255, 255, 255, 0.15);
    backdrop-filter: blur(8px);
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 0.85rem;
    margin-bottom: 12px;
}

.clinic-text h1 {
    font-size: 1.8rem;
    font-weight: 800;
    margin-bottom: 12px;
    color: #ffffff;
}

.clinic-text .description {
    font-size: 0.95rem;
    color: #e6fffa;
    margin-bottom: 24px;
}

.info-cards {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.info-card {
    display: flex;
    align-items: center;
    gap: 12px;
    background: rgba(255, 255, 255, 0.1);
    padding: 10px 14px;
    border-radius: var(--radius-md);
    font-size: 0.88rem;
}

.info-card .icon {
    font-size: 1.3rem;
}

.info-card strong {
    display: block;
    color: #ffffff;
    font-size: 0.82rem;
}

.info-card span {
    color: #ccfbf1;
}

.map-link-btn {
    display: inline;
    margin: 0;
    padding: 0;
    color: #ffffff;
    background: transparent;
    border: none;
    font-size: 0.82rem;
    cursor: pointer;
    white-space: nowrap;
}

.map-link-btn:hover {
    color: #ccfbf1;
    border-bottom-color: #ccfbf1;
}

/* --- Carousel --- */
.carousel-container {
    position: relative;
    width: 100%;
    height: 260px;
    border-radius: var(--radius-lg);
    overflow: hidden;
    box-shadow: var(--shadow-md);
}

.carousel-slide {
    display: none;
    width: 100%;
    height: 100%;
    position: relative;
}

.carousel-slide.active {
    display: block;
}

.carousel-slide img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.carousel-slide .caption {
    position: absolute;
    bottom: 0;
    width: 100%;
    background: rgba(0, 0, 0, 0.65);
    color: white;
    padding: 8px 12px;
    font-size: 0.85rem;
    text-align: center;
    backdrop-filter: blur(4px);
}

.carousel-prev,
.carousel-next {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    background: rgba(0, 0, 0, 0.4);
    color: white;
    border: none;
    padding: 8px 12px;
    cursor: pointer;
    border-radius: 50%;
    transition: 0.2s;
}

.carousel-prev:hover,
.carousel-next:hover {
    background: rgba(0, 0, 0, 0.8);
}

.carousel-prev {
    right: 10px;
}

.carousel-next {
    left: 10px;
}

.carousel-dots {
    position: absolute;
    bottom: 35px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    gap: 6px;
}

.dot {
    width: 8px;
    height: 8px;
    background: rgba(255, 255, 255, 0.5);
    border-radius: 50%;
    cursor: pointer;
}

.dot.active {
    background: white;
    width: 18px;
    border-radius: 10px;
}

/* --- Chatbot Main Section --- */
.chat-section {
    margin-top: -24px;
    margin-bottom: 40px;
    flex: 1;
}

.chat-wrapper {
    background: var(--card-bg);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-md);
    border: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    height: 600px;
    overflow: hidden;
    min-width: 0;
    width: 100%;
}

.chat-header {
    background: #ffffff;
    padding: 16px 20px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
    min-width: 0;
}

.assistant-info {
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 0;
}

.avatar-container {
    position: relative;
    display: inline-block;
    flex: 0 0 auto;
}

.avatar-img {
    width: 75px;
    height: 75px;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid #ffffff;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
    display: block;
}

.avatar {
    width: 44px;
    height: 44px;
    background: var(--primary-light);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
}

.status-online {
    width: 12px;
    height: 12px;
    background: #22c55e;
    border: 2px solid white;
    border-radius: 50%;
    position: absolute;
    bottom: 0;
    right: 0;
}

.assistant-info h2 {
    font-size: 1.05rem;
    font-weight: 700;
}

.status-text {
    font-size: 0.78rem;
    color: var(--text-muted);
}

.clear-btn {
    background: transparent;
    border: 1px solid var(--border-color);
    padding: 6px 12px;
    border-radius: var(--radius-md);
    font-size: 0.8rem;
    cursor: pointer;
    color: var(--text-muted);
    transition: 0.2s;
    flex: 0 0 auto;
}

.clear-btn:hover {
    background: #f1f5f9;
    color: var(--text-main);
}

/* --- Suggestions Bar --- */
.suggestions-bar {
    padding: 10px 16px;
    background: #f8fafc;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    gap: 8px;
    overflow-x: auto;
    white-space: nowrap;
}

.suggestions-bar span {
    font-size: 0.78rem;
    color: var(--text-muted);
}

.chip {
    background: #ffffff;
    border: 1px solid var(--border-color);
    padding: 5px 12px;
    border-radius: 16px;
    font-size: 0.8rem;
    cursor: pointer;
    transition: 0.2s;
    color: var(--primary-dark);
    flex: 0 0 auto;
}

.chip:hover {
    background: var(--primary-light);
    border-color: var(--primary-teal);
}

/* --- Chat Messages --- */
.chat-messages {
    flex: 1;
    padding: 20px;
    overflow-y: auto;
    overflow-x: hidden;
    display: flex;
    flex-direction: column;
    gap: 16px;
    background: #fafafa;
    min-width: 0;
}

.message {
    max-width: 78%;
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.message.user {
    align-self: flex-start;
}

.message.assistant {
    align-self: flex-end;
}

.message-content {
    padding: 12px 16px;
    border-radius: 18px;
    font-size: 0.92rem;
    line-height: 1.5;
    white-space: pre-wrap;
    overflow-wrap: anywhere;
    word-break: break-word;
    min-width: 0;
}

.message.user .message-content {
    background: var(--chat-user-bg);
    color: white;
    border-bottom-right-radius: 4px;
}

.message.assistant .message-content {
    background: var(--chat-bot-bg);
    color: var(--text-main);
    border: 1px solid var(--border-color);
    border-bottom-left-radius: 4px;
}

.message-time {
    font-size: 0.7rem;
    color: var(--text-muted);
    margin-top: 4px;
    align-self: flex-end;
}

/* --- Typing Indicator --- */
.typing-indicator {
    display: none;
    align-items: center;
    gap: 8px;
    padding: 8px 20px;
    background: #fafafa;
}

.typing-indicator.active {
    display: flex;
}

.avatar-small {
    width: 32px;
    height: 32px;
    background: var(--primary-light);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.8rem;
}

.dots {
    display: flex;
    gap: 4px;
}

.dots span {
    width: 6px;
    height: 6px;
    background: var(--primary-teal);
    border-radius: 50%;
    animation: bounce 1.4s infinite ease-in-out both;
}

.dots span:nth-child(1) {
    animation-delay: -0.32s;
}

.dots span:nth-child(2) {
    animation-delay: -0.16s;
}

@keyframes bounce {
    0%,
    80%,
    100% {
        transform: scale(0);
    }

    40% {
        transform: scale(1);
    }
}

.typing-text {
    font-size: 0.78rem;
    color: var(--text-muted);
}

/* --- Input Area --- */
.chat-input-area {
    padding: 12px 16px;
    background: #ffffff;
    border-top: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 0;
}

.chat-input-area textarea {
    flex: 1;
    border: 1px solid var(--border-color);
    border-radius: 20px;
    padding: 10px 16px;
    font-size: 0.9rem;
    outline: none;
    resize: none;
    max-height: 100px;
    transition: 0.2s;
    min-width: 0;
    overflow-wrap: anywhere;
}

.chat-input-area textarea:focus {
    border-color: var(--primary-teal);
    box-shadow: 0 0 0 3px rgba(13, 148, 136, 0.15);
}

.send-btn {
    background: var(--primary-teal);
    color: white;
    border: none;
    width: 42px;
    height: 42px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: 0.2s;
    flex: 0 0 auto;
}

.send-btn:hover {
    background: var(--primary-dark);
}

.send-btn:disabled {
    cursor: not-allowed;
    opacity: 0.65;
}

/* --- Map Modal --- */
.map-modal {
    position: fixed;
    inset: 0;
    z-index: 1000;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 20px;
    background: rgba(15, 23, 42, 0.7);
}

.map-modal.active {
    display: flex;
}

.map-modal-content {
    width: min(760px, 100%);
    overflow: hidden;
    background: #ffffff;
    border-radius: var(--radius-lg);
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.3);
}

.map-modal-header {
    padding: 14px 18px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid var(--border-color);
}

.map-modal-header h2 {
    font-size: 1rem;
    color: var(--text-main);
}

.map-close-btn {
    width: 34px;
    height: 34px;
    border: none;
    border-radius: 50%;
    background: #f1f5f9;
    color: var(--text-main);
    font-size: 1.55rem;
    line-height: 1;
    cursor: pointer;
    transition: 0.2s;
}

.map-close-btn:hover {
    background: #e2e8f0;
}

.map-modal iframe {
    width: 100%;
    height: min(65vh, 480px);
    display: block;
    border: 0;
}

/* --- Footer --- */
.footer {
    background: #0f172a;
    color: #94a3b8;
    padding: 20px 0;
    font-size: 0.82rem;
    text-align: center;
    margin-top: auto;
}

.footer-content {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.developer-credit {
    color: #64748b;
    font-size: 0.75rem;
}

/* --- Responsive Adjustments --- */
@media (max-width: 868px) {
    .clinic-info-grid {
        grid-template-columns: 1fr;
    }

    .carousel-container {
        height: 200px;
    }

    .chat-wrapper {
        height: 520px;
    }
}

/*
   اصلاح قطعی نوار پیشنهادها:
   - عنوان «پیشنهادها» در یک ردیف مستقل قرار می‌گیرد.
   - دکمه‌ها با flex-wrap به ردیف بعد می‌روند.
   - در هر ردیف دو دکمه قرار می‌گیرد.
   - تا عرض 768px فعال است تا موبایل‌های بزرگ‌تر هم پوشش داده شوند.
*/
@media (max-width: 768px) {
    .suggestions-bar {
        width: 100%;
        max-width: 100%;
        min-width: 0;
        box-sizing: border-box;

        display: flex;
        flex-direction: row;
        flex-wrap: wrap;

        align-items: center;
        gap: 6px;
        padding: 8px 10px;

        overflow-x: hidden;
        overflow-y: visible;
        white-space: normal;
    }

    .suggestions-bar > span {
        flex: 0 0 100%;
        width: 100%;
        min-width: 0;

        font-size: 0.72rem;
        line-height: 1.4;
        color: var(--text-muted);
        white-space: normal;
    }

    .suggestions-bar > .chip {
        flex: 1 1 calc(50% - 3px);
        width: calc(50% - 3px);
        min-width: 0;
        max-width: calc(50% - 3px);
        box-sizing: border-box;

        padding: 6px 6px;
        font-size: 0.72rem;
        line-height: 1.4;
        text-align: center;

        white-space: normal;
        overflow-wrap: anywhere;
        word-break: break-word;
    }
}

@media (max-width: 480px) {
    .map-modal {
        padding: 12px;
    }

    .map-modal iframe {
        height: 60vh;
    }

    html,
    body {
        width: 100%;
        max-width: 100%;
        overflow-x: hidden;
    }

    .container {
        width: 100%;
        max-width: 100%;
        padding-left: 12px;
        padding-right: 12px;
    }

    .hero-section {
        padding: 20px 0 32px;
        border-bottom-left-radius: 22px;
        border-bottom-right-radius: 22px;
    }

    .clinic-info-grid {
        gap: 20px;
    }

    .clinic-text {
        min-width: 0;
    }

    .clinic-text h1 {
        font-size: 1.3rem;
        line-height: 1.5;
        overflow-wrap: anywhere;
    }

    .clinic-text .description {
        font-size: 0.84rem;
        line-height: 1.9;
        overflow-wrap: anywhere;
    }

    .info-card {
        min-width: 0;
        padding: 9px 10px;
        font-size: 0.78rem;
    }

    .contact-split {
        grid-template-columns: 1fr !important;
        gap: 8px !important;
    }

    .carousel-container {
        width: 100%;
        max-width: 100%;
        height: 180px;
        min-width: 0;
        overflow: hidden;
    }

    .chat-wrapper {
        width: 100%;
        max-width: 100%;
        min-width: 0;
        height: clamp(390px, 62dvh, 480px);
        border-radius: 12px;
        overflow: hidden;
    }

    .chat-header {
        padding: 10px 12px;
        gap: 8px;
        min-width: 0;
    }

    .assistant-info {
        min-width: 0;
        flex: 1 1 auto;
    }

    .assistant-info > div:last-child {
        min-width: 0;
    }

    .assistant-info h2,
    .status-text {
        min-width: 0;
        max-width: 100%;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    .avatar-img {
        width: 52px;
        height: 52px;
        flex: 0 0 52px;
    }

    .clear-btn {
        flex: 0 0 auto;
        white-space: nowrap;
        font-size: 0.72rem;
        padding-left: 7px;
        padding-right: 7px;
    }

    .chat-messages {
        min-width: 0;
        overflow-x: hidden;
    }

    .message {
        max-width: 88%;
        min-width: 0;
    }

    .message-content {
        max-width: 100%;
        min-width: 0;
        font-size: 0.84rem;
        line-height: 1.8;
        overflow-wrap: anywhere;
        word-break: break-word;
    }

    .chat-input-area {
        min-width: 0;
        padding: 10px 12px;
    }

    .chat-input-area textarea {
        min-width: 0;
        max-width: 100%;
        font-size: 0.84rem;
        line-height: 1.7;
        overflow-wrap: anywhere;
    }

    .footer {
        max-width: 100%;
        font-size: 0.72rem;
        line-height: 1.7;
        overflow-wrap: anywhere;
    }
}

.instagram-card {
    cursor: pointer;
    transition:
        transform 0.2s ease,
        border-color 0.2s ease,
        box-shadow 0.2s ease;
}

.instagram-card:hover {
    transform: translateY(-2px);
    border-color: #e1306c;
    box-shadow: 0 6px 18px rgba(225, 48, 108, 0.14);
}

.instagram-card .instagram-icon {
    color: #e1306c;
}

.instagram-card:focus-visible {
    outline: 3px solid rgba(225, 48, 108, 0.3);
    outline-offset: 3px;
}
