/* ── Wrapper & layout ── */
#sds-app {
    position: relative;
}

.sds-cp-search-wrapper {
    position: relative;
}

.sds-cp-search-wrapper.overlay {
    position: absolute;
    top: 0;
    left: 0;
    opacity: 0;
    width: 100%;
    height: 100%;
    max-height: calc(100vh - var(--header-height));
    transform: translate3d(0, 100%, 0) scale(0.85);
    padding: 0;
    transition: all 300ms ease-in-out;
    z-index: -100;
}

.sds-cp-search-wrapper.overlay.show {
    z-index: 100;
    opacity: 1;
    transform: translate3d(0, 0, 0) scale(1);
}

[id^="sds-cp-search-main-"] {
    width: 100%;
    height: 100%;
    /* padding: 1.25rem 1.25rem 4.375rem; */
    display: flex;
    flex-direction: column;
}

[id^="sds-cp-search-main-"] .sds-cp-search-container {
    flex: 1;
    min-height: 0;
    display: flex;
    flex-direction: column;
    gap: 0.625rem;
    background: #f8f9fa;
}

/* ── Header ── */
[id^="sds-cp-search-main-"] > .cp-page-header {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 1rem;
    flex-shrink: 0;
}

[id^="sds-cp-search-main-"] > .cp-page-header .cta-btn-back-to-cp {
    display: inline-flex;
    height: 2rem;
    padding: 0.375rem 0.75rem;
    justify-content: center;
    align-items: center;
    gap: 0.5rem;
    border-radius: 1.75rem;
    border: 1px solid var(--sds-grey-500, #B6BFBF);
    background: var(--sds-white, #FFF);
    box-shadow: 0px 2px 1px 0px rgba(0, 60, 70, 0.05), 0px 0px 1px 0px rgba(0, 60, 70, 0.05);
    cursor: pointer;
}

[id^="sds-cp-search-main-"] > .cp-page-header .cta-btn-back-to-cp svg {
    cursor: pointer;
}

[id^="sds-cp-search-main-"] > .cp-page-header .cp-page-title {
    color: var(--sds-primary-500, #0B9294);
    font-family: var(--sds-font-family, Arial, Helvetica, sans-serif);
    font-size: 1.125rem;
    font-style: normal;
    font-weight: 600;
    line-height: 1.5;
}

/* ── Results container ── */
[id^="sds-cp-search-main-"] #sds-cp-search-results-container {
    /* border-top: 1px solid var(--sds-primary-200, #B3D5D7); */
    margin-top: 1.5rem;
    flex: 1;
    min-height: 0;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    width: 100%;
    max-width: 820px;
    margin-left: auto;
    margin-right: auto;
}

/* ── Feed (message list) ── */
.sds-search-feed {
    flex: 1;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    box-sizing: border-box;
    padding: 0 24px;
    gap:24px;

}

/* ── Messages ── */
.sds-search-message {
    display: flex;
    width: 100%;
}

.sds-search-message--user {
    justify-content: flex-end;
    flex-direction: column;
    align-items: flex-end;
}

.sds-search-message--user .sds-search-message__bubble {
    background: var(--sds-primary);
    color: #fff;
    border-radius: 18px 18px 4px 18px;
    padding: 11px 18px;
    font-size: 13px;
    line-height: 1.55;
    max-width: 88%;
}

.sds-search-message__user-row {
    display: flex;
    align-items: flex-end;
    justify-content: flex-end;
    gap: 12px;
    max-width: 88%;
}

.sds-search-message__user-row .sds-search-message__bubble {
    max-width: none;
}

.sds-search-message--ai {
    gap: 10px;
    align-items: flex-start;
}

.sds-search-message__avatar-wrap {
    flex-shrink: 0;
}

.sds-search-message__avatar {
    width: 28px;
    height: 28px;
    flex-shrink: 0;
    border-radius: 6px;
    background: var(--sds-primary);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 13px;
    font-weight: 700;
    line-height: 1;
}

.sds-search-message__body {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.sds-search-message__meta {
    font-size: 12px;
    color: var(--sds-grey-500);
    display: flex;
    align-items: center;
    gap: 0;
    min-height: 28px;
}

.sds-search-message__meta-name {
    font-weight: 600;
    color: var(--sds-grey-800);
    margin-right: 8px;
}

.sds-search-message__time {
    font-size: 11px;
    font-weight: 400;
    line-height: 1;
    color: var(--sds-grey-500);
    white-space: nowrap;
}

.sds-search-message--user .sds-search-message__time {
    flex-shrink: 0;
}

/* ── AI prose box ── */
.sds-search-message__prose {
    background: #fff;
    border: 1px solid var(--sds-grey-400);
    border-radius: 14px;
    padding: 14px 16px;
    font-weight: 400;
    font-size: 14px;
    line-height: 22px;
    color: var(--sds-grey-900, #020303);
}

.sds-search-message__prose p { margin: 0 0 8px; }
.sds-search-message__prose p:last-child { margin-bottom: 0; }

.sds-search-message__prose ul {
    margin: 6px 0 8px;
    padding-left: 0;
    list-style: none;
}

.sds-search-message__prose ul li {
    padding: 2px 0 2px 14px;
    position: relative;
}

.sds-search-message__prose ul li::before {
    content: '•';
    position: absolute;
    left: 0;
    color: var(--sds-grey-500);
}

.sds-search-message__prose > .table-responsive {
    overflow-x: auto;
    border: 1px solid lightgray;
    border-radius: 10px;
    max-height: 400px;
}

.sds-search-message__prose > .table-responsive > table td {
    border-radius: 0 !important;
    padding: 0.3rem 0.3rem;
}

.sds-search-message__error {
    font-size: 13px;
    line-height: 1.5;
    color: #b91c1c;
    background: #fef2f2;
    border: 1px solid #fecaca;
    border-radius: 6px;
    padding: 8px 12px;
}

/* ── Dot loader ── */
.sds-search-dot-loader {
    display: flex;
    gap: 5px;
    align-items: center;
    border: 1px solid var(--sds-grey-400);
    border-radius: 14px;
    padding: 14px 16px;
    background: var(--sds-white, #fff);
}

.sds-search-dot-loader span {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--sds-primary);
    animation: sdsSearchLoaderBounce 1.2s infinite ease-in-out;
}

.sds-search-dot-loader span:nth-child(2) { animation-delay: 0.2s; }
.sds-search-dot-loader span:nth-child(3) { animation-delay: 0.4s; }

@keyframes sdsSearchLoaderBounce {
    0%, 80%, 100% { transform: translateY(0) scale(0.6); opacity: 0.4; }
    40%           { transform: translateY(-5px) scale(1); opacity: 1; }
}

/* ── Input area ── */
[id^="sds-cp-search-main-"] .sds-cp-search-form-wrapper {
    margin-top: auto;
    padding: 12px 4px 16px;
    width: 100%;
    max-width: 820px;
    margin-left: auto;
    margin-right: auto;
}

.sds-search-input-card {
    display: flex;
    flex-direction: column;
    border: 1px solid var(--sds-grey-500);
    border-radius: 18px;
    background: #fff;
    padding: 12px 10px 8px 18px;
    transition: border-color 0.15s;
}

.sds-search-input-card:focus-within {
    border-color: var(--sds-primary);
}

.sds-search-input-row {
    display: flex;
    align-items: flex-end;
    gap: 8px;
}

.sds-search-textarea {
    flex: 1;
    border: none;
    background: none;
    outline: none;
    font-size: 13px;
    font-family: inherit;
    color: var(--sds-grey-800);
    resize: none;
    min-height: 36px;
    max-height: 120px;
    line-height: 1.55;
    padding: 0;
    box-sizing: border-box;
}

.sds-search-textarea::placeholder { color: var(--sds-grey-400); }

.sds-search-input-hint {
    display: flex;
    justify-content: flex-end;
    padding: 5px 4px 0;
    font-size: 11px;
    color: var(--sds-grey-500);
}

.sds-search-send-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    padding: 0;
    background: var(--sds-primary);
    color: #fff;
    border: none;
    border-radius: 50%;
    cursor: pointer;
    flex-shrink: 0;
    transition: opacity 0.15s;
}

.sds-search-send-btn:hover { opacity: 0.88; }
.sds-search-send-btn:disabled { opacity: 0.4; cursor: not-allowed; }

/* ── Source results table wrapper ── */
[id^="sds-cp-search-main-"] .sds-cp-search.msg-src-wrapper {
    width: 100%;
    height: 100%;
    margin: 10px 0;
    overflow: auto;
}

[id^="sds-cp-search-main-"] .sds-cp-search .sds-datatable-container {
    box-shadow: none !important;
    border-radius: unset !important;
}

/* ── Context menu ── */
.sds-search-results-context-option {
    gap: 8px;
}

.sds-search-results-context-option .sds-search-results-option-icon {
    width: 20px;
    height: 20px;
}

.sds-search-results-context-option .sds-search-results-option-icon svg {
    width: 100%;
    height: 100%;
}

.sds-search-results-context-option .sds-search-results-option-text {
    font-family: var(--sds-font-family, Arial, Helvetica, sans-serif);
    font-size: 14px;
    color: var(--sds-black, #000);
}

.sds-search-result-popover-wrapper p {
    white-space: pre-line;
    font-size: 0.75rem;
}

.sds-cp-search-src-context-menu .dx-submenu {
    border-radius: 18px;
}

.sds-cp-search-src-context-menu .dx-submenu .dx-menu-items-container {
    padding: 16px 0;
}

.sds-cp-search-src-context-menu .dx-submenu .dx-menu-items-container .dx-menu-item {
    padding: 5px 15px;
}

.sds-cp-search-src-context-menu .dx-submenu .dx-menu-items-container .dx-menu-item-content {
    padding: 0;
}

.sds-cp-search-src-context-menu .dx-submenu .dx-menu-items-container .sds-search-results-option-text {
    margin-top: 2px;
}

/* ── Suggested cards grid ── */
.sds-search-cards-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
    min-width: 0;
}

.sds-search-card {
    background: #fff;
    border: 1px solid var(--sds-grey-400, #dde3e3);
    border-radius: 12px;
    padding: 12px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    cursor: pointer;
    transition: box-shadow 0.15s, border-color 0.15s;
    min-width: 0;
    overflow: hidden;
}

.sds-search-card:hover {
    border-color: var(--sds-primary);
    box-shadow: 0 2px 8px rgba(11, 146, 148, 0.1);
}

.sds-search-card__header {
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 0;
}

.sds-search-card__icon {
    width: 30px;
    height: 30px;
    border-radius: 7px;
    background: var(--sds-primary-50, #e6f4f4);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.sds-search-card__icon svg {
    width: 18px;
    height: 18px;
    color: var(--sds-primary, #0B9294);
    fill: var(--sds-primary, #0B9294);
}

.sds-search-card__title {
    flex: 1;
    font-size: 13px;
    font-weight: 600;
    color: var(--sds-grey-900, #020303);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    min-width: 0;
}

.sds-search-card__score {
    font-size: 11px;
    font-weight: 600;
    color: #15803d;
    background: #dcfce7;
    padding: 2px 8px;
    border-radius: 20px;
    flex-shrink: 0;
}

.sds-search-card__score.medium {
    color: #92400e;
    background: #fef3c7;
}

.sds-search-card__score.low {
    color: #991b1b;
    background: #fee2e2;
}

.sds-search-card__desc {
    font-size: 12px;
    color: var(--sds-grey-600, #6b7280);
    line-height: 1.5;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    overflow-wrap: anywhere;
    word-break: break-word;
}

.sds-search-card__tags {
    display: flex;
    flex-wrap: wrap;
    gap: 5px;
    margin-top: 2px;
}

.sds-search-card__tag {
    font-size: 10px;
    font-weight: 500;
    color: var(--sds-grey-700, #374151);
    background: var(--sds-grey-50, #f8f9fa);
    border: 1px solid var(--sds-grey-200, #e5e7eb);
    border-radius: 20px;
    padding: 0px 6px;
    line-height: 1.6;
}
