/* ═══════════════════════════════════════
   SmartAssistant.css — Smart Assistant Page Only
   ═══════════════════════════════════════ */

.smart-assistant-page {
    padding: 0;
    margin: 0;
    background: #f8fafc;
    width: 100%;
    /* ارتفاع ثابت: کل ارتفاع منهای نوار بالا (۴۸) و پدینگ کانتینر (۳۲) → بدون اسکرول صفحه */
    height: calc(100vh - 80px);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

/* ── Three Column Layout ── */
.three-column-layout {
    display: grid;
    grid-template-columns: 280px 1fr 340px;
    gap: 12px;
    flex: 1;
    min-height: 0;
    padding: 0 12px 12px 12px;
    overflow: hidden;
}

.column-left,
.column-middle,
.column-right {
    display: flex;
    flex-direction: column;
    overflow: hidden;
    min-height: 0;
}

/* ── Search field must NOT grow (base .search-field-wrapper sets flex:1) ── */
.smart-assistant-page .search-field-wrapper {
    flex: 0 0 auto !important;
    margin-bottom: 6px;
}

.smart-assistant-page .patient-list-container {
    flex: 1;
    min-height: 0;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

/* ── Patient Table (left column) ── */
.patient-table {
    height: 100%;
    min-width: 100%;
    display: flex;
    flex-direction: column;
}

    .patient-table .mud-table-container {
        flex: 1;
        overflow: auto !important;
        min-height: 80px;
    }

    .patient-table .mud-table-head {
        position: sticky;
        top: 0;
        z-index: 10;
        background: #f8fafc !important;
    }

        .patient-table .mud-table-head th {
            background: #f8fafc !important;
            font-weight: 600;
            color: #475569;
            padding: 4px 8px !important;
            font-size: 0.7rem !important;
            border-bottom: 2px solid #e2e8f0;
            text-transform: uppercase;
            letter-spacing: 0.3px;
        }

    .patient-table .mud-table-body td {
        padding: 3px 8px !important;
        font-size: 0.78rem !important;
        border-bottom: 1px solid #f1f5f9;
    }

    .patient-table .mud-table-body .mud-table-row {
        cursor: pointer;
        transition: all 0.15s ease;
    }

        .patient-table .mud-table-body .mud-table-row:hover {
            background: #f1f5f9;
        }

        .patient-table .mud-table-body .mud-table-row.selected {
            background: #dbeafe;
            border-right: 3px solid #3b82f6;
        }

/* ── Patient Actions Menu ── */
.patient-actions-menu {
    display: inline-flex;
}

    .patient-actions-menu .mud-icon-button {
        width: 24px !important;
        height: 24px !important;
        padding: 2px !important;
    }

.menu-item-text {
    font-size: 0.78rem;
    color: #1a2332;
}

/* ── Section Header Counts ── */
.section-header .patient-count {
    background: #1a2332;
    color: white;
    padding: 0px 10px;
    border-radius: 12px;
    font-size: 0.7rem;
    font-weight: 600;
    margin-right: auto;
    min-width: 20px;
    text-align: center;
    line-height: 20px;
}

.section-header .suggestions-count {
    background: #f59e0b;
    color: white;
    padding: 0px 10px;
    border-radius: 12px;
    font-size: 0.7rem;
    font-weight: 600;
    margin-right: auto;
    min-width: 20px;
    text-align: center;
    line-height: 20px;
}

/* ── Chat: Patient Banner ── */
.selected-patient-banner {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 6px 12px;
    background: linear-gradient(135deg, #1a2332, #2d3748);
    border-radius: 8px;
    margin-bottom: 6px;
    flex-shrink: 0;
    box-shadow: 0 2px 8px rgba(26, 35, 50, 0.2);
}

.no-patient-banner {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px;
    background: #f8fafc;
    border-radius: 8px;
    margin-bottom: 6px;
    color: #64748b;
    font-size: 0.78rem;
    flex-shrink: 0;
    border: 2px dashed #e2e8f0;
}

.avatar-text {
    color: white;
    font-size: 0.9rem;
    font-weight: 700;
}

.patient-info {
    color: white;
    flex: 1;
    min-width: 0;
}

.patient-details {
    display: flex;
    gap: 10px;
    font-size: 0.65rem;
    opacity: 0.85;
    flex-wrap: wrap;
    margin-top: 1px;
}

    .patient-details span {
        display: flex;
        align-items: center;
        gap: 3px;
    }

/* ── Chat Container ── */
.chat-container {
    flex: 1;
    overflow-y: auto;
    padding: 8px 10px;
    background: #f8fafc;
    border-radius: 8px;
    margin-bottom: 6px;
    min-height: 0;
}

    .chat-container::-webkit-scrollbar {
        width: 3px;
    }

    .chat-container::-webkit-scrollbar-thumb {
        background: #cbd5e1;
        border-radius: 10px;
    }

.chat-messages {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.chat-message {
    display: flex;
    gap: 6px;
    max-width: 88%;
}

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

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

.message-avatar {
    flex-shrink: 0;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.6rem;
}

.user-message .message-avatar {
    background: #1a2332;
    color: white;
}

.ai-message .message-avatar {
    background: #10b981;
    color: white;
}

.message-text {
    padding: 6px 10px;
    border-radius: 8px;
    font-size: 0.78rem;
    line-height: 1.5;
    white-space: pre-wrap;
    word-wrap: break-word;
}

.user-message .message-text {
    background: #1a2332;
    color: white;
    border-bottom-left-radius: 3px;
}

.ai-message .message-text {
    background: white;
    color: #1a2332;
    border-bottom-right-radius: 3px;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.06);
}

.message-time {
    font-size: 0.5rem;
    color: #94a3b8;
    padding: 0 4px;
}

/* ── Chat Input ── */
.chat-input-container {
    padding-top: 4px;
    border-top: 1px solid #e2e8f0;
    flex-shrink: 0;
}

.chat-input-wrapper {
    display: flex;
    gap: 6px;
}

.chat-input {
    flex: 1;
}

    .chat-input .mud-input-control {
        margin-bottom: 0 !important;
    }

        .chat-input .mud-input-control .mud-input {
            padding: 6px 10px !important;
            min-height: 32px !important;
            font-size: 0.78rem !important;
        }

/* ── AI Status ── */
.ai-status {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-right: auto;
    font-size: 0.65rem;
    color: #64748b;
}

.status-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    display: inline-block;
}

    .status-dot.online {
        background: #10b981;
        animation: pulse-dot 2s infinite;
    }

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

/* ── Suggestions (right column) ── */
.suggestions-container {
    height: 100%;
    display: flex;
    flex-direction: column;
    gap: 6px;
    overflow: hidden;
}

.suggestion-section {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 0;
}

    .suggestion-section.medications-section { flex: 1.2; }

.suggestion-header {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 4px 8px;
    background: #f8fafc;
    border-radius: 6px;
    flex-shrink: 0;
}

.suggestion-title {
    flex: 1;
    font-weight: 600;
    font-size: 0.7rem;
    color: #1a2332;
}

.suggestion-count {
    background: #e2e8f0;
    color: #475569;
    border-radius: 12px;
    padding: 0 8px;
    font-size: 0.55rem;
    font-weight: 600;
    line-height: 16px;
}

.suggestion-list {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 3px;
    overflow-y: auto;
    padding: 3px 2px 2px 2px;
}

    .suggestion-list::-webkit-scrollbar {
        width: 3px;
    }

    .suggestion-list::-webkit-scrollbar-thumb {
        background: #cbd5e1;
        border-radius: 10px;
    }

.suggestion-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 10px;
    border-radius: 10px;
    transition: all 0.2s ease;
    gap: 8px;
    border: 1px solid transparent;
}

    .suggestion-item:hover {
        transform: translateX(-2px);
        box-shadow: 0 3px 10px rgba(0, 0, 0, 0.08);
    }

.suggestion-item-content {
    flex: 1;
    min-width: 0;
}

.suggestion-item-header {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-wrap: wrap;
}

.medication-item {
    background: #f0fdf4;
    border-color: #bbf7d0;
    border-right: 3px solid #10b981;
}

.lab-item {
    background: #fffbeb;
    border-color: #fde68a;
    border-right: 3px solid #f59e0b;
}

.item-name {
    font-weight: 700;
    font-size: 0.8rem;
    color: #1a2332;
}

.item-dosage {
    font-size: 0.66rem;
    color: #047857;
    background: #ffffff;
    padding: 1px 8px;
    border-radius: 10px;
    font-weight: 600;
    border: 1px solid #d1fae5;
}

.item-reason {
    font-size: 0.68rem;
    color: #64748b;
    margin-top: 3px;
    line-height: 1.4;
}

.suggestion-actions {
    display: flex;
    align-items: center;
    gap: 2px;
    flex-shrink: 0;
}

.accept-btn .mud-icon-button,
.reject-btn .mud-icon-button {
    width: 22px !important;
    height: 22px !important;
    padding: 2px !important;
}

.accept-btn .mud-icon-button { color: #10b981 !important; }
.accept-btn .mud-icon-button:hover { color: #059669 !important; }
.reject-btn .mud-icon-button { color: #ef4444 !important; }
.reject-btn .mud-icon-button:hover { color: #dc2626 !important; }

.empty-suggestion {
    padding: 14px;
    text-align: center;
    color: #64748b;
    font-size: 0.75rem;
    background: #f8fafc;
    border-radius: 6px;
    border: 2px dashed #e2e8f0;
}

/* ── Responsive ── */
@media (max-width: 1400px) {
    .three-column-layout {
        grid-template-columns: 240px 1fr 300px;
    }
}

@media (max-width: 1200px) {
    .three-column-layout {
        grid-template-columns: 240px 1fr 280px;
        gap: 10px;
    }
}

@media (max-width: 992px) {
    .three-column-layout {
        grid-template-columns: 1fr;
        gap: 12px;
        overflow-y: auto;
        height: auto;
        flex: none;
        padding-bottom: 16px;
    }

    /* ارتفاع بیشتر در موبایل: چند پیشنهاد/چت/مریض دیده شود */
    .column-left,
    .column-right {
        min-height: 340px;
        max-height: 520px;
    }

    .column-middle {
        min-height: 420px;
        max-height: 600px;
    }

    .smart-assistant-page {
        height: auto;
        overflow-y: auto;
    }
}

@media (max-width: 768px) {
    .three-column-layout {
        padding: 0 8px 12px 8px;
        gap: 10px;
    }

    .column-left,
    .column-right {
        min-height: 320px;
        max-height: 480px;
    }

    .column-middle {
        min-height: 400px;
        max-height: 540px;
    }

    .selected-patient-banner {
        flex-direction: column;
        text-align: center;
        padding: 6px 10px;
    }

    .patient-details {
        justify-content: center;
        font-size: 0.6rem;
        gap: 6px;
    }

    .chat-message {
        max-width: 95%;
    }

    .message-text {
        font-size: 0.72rem;
        padding: 5px 8px;
    }
}

@media (max-width: 480px) {
    .column-left,
    .column-right {
        min-height: 300px;
        max-height: 460px;
    }

    .column-middle {
        min-height: 380px;
        max-height: 520px;
    }
}
