/* ==========================================================
   DESIGN TOKENS
   ========================================================== */

:root {
    /* Layout */
    --layout-margin: 20px;
    --sidebar-width: 280px;

    /* Brand */
    --color-brand: #240046;
    --color-brand-light: #4c3f91;
    --color-brand-strong: #240046;
    --color-brand-gradient: linear-gradient(180deg, #5e60ce 0%, #6930c3 100%);

    /* Surfaces */
    --color-white: #ffffff;
    --color-light-purple: #ede9fe;
    --color-surface: #ffffff;
    --color-surface-alt: #f4f5f8;

    /* Borders */
    --color-border: #e5e7eb;

    /* Neutrals */
    --color-grey-100: #f3f4f6;
    --color-grey-300: #d1d5db;
    --color-grey-600: #6b7280;

    --text-grey: #9ca3af;
    --text-purple: #6d5bd0;

    /* Sidebar */
    --sidebar-active-bg: #240046;

    /* Status */
    --color-danger: #e2747d;
    --color-danger-light: #fbe9eb;

    --color-warning: #c58b00;
    --color-warning-light: #fff4d6;
}

/* ==========================================================
   BASE
   ========================================================== */

body {
    font-family: Arial, sans-serif;
    margin: 0;
    background-color: var(--color-white);
}

/* ==========================================================
   APP SHELL LAYOUT
   ========================================================== */

.app-shell {
    min-height: 100vh;
    background: var(--color-white);
    position: relative;
}

/* Left background band */
.app-shell::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    width: calc(var(--layout-margin) + var(--sidebar-width));
    height: 100vh;
    background: #c2b8f2;
    z-index: -1;
}

.app-layout {
    display: flex;
    min-height: calc(100vh - 40px);
    margin: var(--layout-margin);
    background: var(--color-white);
    border-radius: 24px;
    overflow: hidden;
}

/* ==========================================================
   LOGIN
   ========================================================== */

.login-body {
    background-color: #f4f7fc;
    display: flex;
    justify-content: center;
    align-items: center;
    height: 100vh;
}
.login-container {
    background-color: white;
    padding: 30px;
    border-radius: 8px;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
    width: 100%;
    max-width: 400px;
    text-align: center;
}
.login-container h2 {
    margin-bottom: 20px;
    font-size: 28px;
}
.login-container img {
    width: 150px;
    margin-bottom: 20px;
}
.login-container form {
    display: flex;
    flex-direction: column;
}
.login-container input {
    padding: 10px;
    margin: 10px 0;
    border: 1px solid #ccc;
    border-radius: 4px;
    font-size: 16px;
}
.login-button {
    padding: 12px;
    background-color: #4caf50;
    color: white;
    border: none;
    border-radius: 4px;
    font-size: 16px;
    cursor: pointer;
    transition: background-color 0.3s;
}
.login-button:hover {
    background-color: #45a049;
}
.resend-code-button {
    background: none;
    border: 0;
    padding: 0;
    margin: 14px;
    font: inherit;
    font-size: 12px;
    text-decoration: underline;
    cursor: pointer;
}
.resend-code-button:disabled {
    cursor: default;
}
.login-error-message {
    color: red;
    font-size: 14px;
    margin-top: 10px;
}
.copyright-message {
    font-size: 10px;
    margin-top: 10px;
}

/* ==========================================================
   SIDEBAR
   ========================================================== */

.app-sidebar {
    width: var(--sidebar-width);
    flex-shrink: 0;
    box-sizing: border-box;
}

.sidebar-inner {
    height: 100%;
}

.sidebar-logo {
    width: 180px;
}

.sidebar-title {
    font-size: 1rem;
    font-weight: 600;
    margin-top: 0.5rem;
}

/* Section headings */
.sidebar-section {
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-purple);
    margin-bottom: 0.5rem;
}

/* Nav links */
.sidebar-nav .nav-link {
    color: var(--text-grey);
    font-weight: 500;
    border-radius: 999px;
    padding: 0.6rem 1rem;
    margin-bottom: 0.4rem;
    transition: background 0.2s ease;
}

/* Hover = light purple pill, text stays grey */
.sidebar-nav .nav-link:hover {
    background: rgba(109, 91, 208, 0.15);
    color: var(--text-grey);
}

/* Active pill */
.sidebar-nav .nav-link.active {
    background: var(--sidebar-active-bg);
    color: var(--color-white);
}

/* Sub items */
.sidebar-sub .nav-link {
    padding-left: 1.75rem;
    font-size: 0.9rem;
}

/* ==========================================================
   MAIN REGION
   ========================================================== */

.app-main {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
    background: var(--color-light-purple);
}

.app-content {
    flex: 1;
    padding: 2rem;
    overflow-y: auto;
}

/* ==========================================================
   TOP BAR
   ========================================================== */

.app-top-bar {
    background: var(--color-brand-strong);
    color: var(--color-white);
    padding: 2.5rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

/* Avatar */
.user-avatar {
    width: 42px;
    height: 42px;
    border-radius: 50%;
    object-fit: cover;
    transition: opacity 0.2s ease;
}

.user-avatar:hover {
    opacity: 0.85;
}

/* Notifications */
.notification-dropdown-menu {
    min-width: 360px;
    max-width: 420px;
    max-height: 70vh;
    overflow-y: auto;
}

.notification-unread {
    background-color: var(--bs-light);
}

.notification-unread-indicator {
    width: 0.75rem;
    flex: 0 0 0.75rem;
    color: var(--color-brand-light);
    font-size: 0.75rem;
}

/* ==========================================================
   BUTTONS
   ========================================================== */

.btn-pill {
    border-radius: 999px;
}

/* Primary */
.btn-primary {
    background-color: var(--color-brand-light);
    border-color: var(--color-brand-light);
    color: var(--color-white);
}

.btn-primary:hover {
    background-color: var(--color-brand);
    border-color: var(--color-brand);
}

/* Outline Primary */
.btn-outline-primary {
    border: 1px solid var(--color-brand-light);
    color: var(--color-brand-light);
    background: var(--color-white);
}

.btn-outline-primary:hover {
    background: var(--color-brand-light);
    color: var(--color-white);
}

/* Secondary */
.btn-secondary {
    background-color: var(--color-white);
    border: 1px solid var(--color-brand);
    color: var(--color-brand);
}

.btn-secondary:hover {
    background-color: var(--color-light-purple);
}

/* Danger */
.btn-danger {
    background-color: var(--color-danger);
    border-color: var(--color-danger);
    color: var(--color-white);
}

.btn-danger:hover {
    background-color: #b63640;
}

/* Outline Danger */
.btn-outline-danger {
    border: 1px solid var(--color-danger);
    color: var(--color-danger);
    background: var(--color-white);
}

.btn-outline-danger:hover {
    background: var(--color-danger);
    color: var(--color-white);
}

/* Warning */
.btn-warning {
    background-color: var(--color-warning);
    border-color: var(--color-warning);
    color: var(--color-white);
}

.btn-warning:hover {
    background-color: #a87400;
}

/* Close */
.btn-close {
    filter: grayscale(100%);
    opacity: 0.6;
}

.btn-close:hover {
    opacity: 1;
}

/* Small size refinement */
.btn-sm {
    padding: 0.35rem 0.8rem;
    font-size: 0.8rem;
}

/* ==========================================================
   TABLES
   ========================================================== */

.ds-table {
    border-collapse: collapse;
    width: 100%;
    background: transparent;
}

.ds-table thead th {
    text-transform: uppercase;
    font-size: 0.75rem;
    letter-spacing: 0.05em;
    font-weight: 600;
    color: var(--color-grey-600);
    padding: 1rem 0.5rem;
    border-bottom: 2px solid #d6d2f7;
}

.ds-table tbody td {
    padding: 1.1rem 0.5rem;
    font-size: 0.95rem;
    border-bottom: 1px solid #e4e0fa;
    vertical-align: middle;
}

.ds-table tbody tr:last-child td {
    border-bottom: none;
}

.ds-table tbody tr:hover {
    background: rgba(36, 0, 70, 0.03);
}

/* Clickable rows */
.tr-clickable {
    cursor: pointer;
    transition: background-color 0.15s ease;
}

.tr-clickable:hover td {
    background-color: var(--color-light-purple);
}

/* Action column */
.ds-actions {
    display: flex;
    gap: 0.5rem;
    justify-content: left;
}

/* Table column widths */
.th-10-column {
    width: 10%;
}
.th-15-column {
    width: 15%;
}
.th-20-column {
    width: 20%;
}
.th-25-column {
    width: 25%;
}
.th-30-column {
    width: 30%;
}
.th-35-column {
    width: 35%;
}
.th-40-column {
    width: 40%;
}
.th-50-column {
    width: 50%;
}
.th-60-column {
    width: 60%;
}
.th-70-column {
    width: 70%;
}
.th-75-column {
    width: 75%;
}
.th-80-column {
    width: 80%;
}
.th-90-column {
    width: 90%;
}

/* ==========================================================
   CATALOG CARD GRID
   ========================================================== */

.ds-card-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: 1.5rem;
}

.ds-card {
    background: var(--color-white);
    border-radius: 18px;
    padding: 1.75rem;
    text-decoration: none;
    color: inherit;
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.05);
    transition: all 0.2s ease;
}

.ds-card h5 {
    margin-bottom: 0.5rem;
    font-weight: 600;
    color: var(--color-brand-strong);
}

.ds-card p {
    margin: 0;
    font-size: 0.9rem;
    color: var(--color-grey-600);
}

.ds-card:hover {
    transform: translateY(-3px);
    box-shadow: 0 14px 30px rgba(0, 0, 0, 0.08);
}

/* ==========================================================
   UTILITIES
   ========================================================== */

.align-center {
    text-align: center;
}
.align-right {
    text-align: right;
}

.w-95 {
    width: 95%;
}

.visually-hidden {
    position: absolute !important;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* ==========================================================
   OFFER GENERATOR — LAYOUT
   ========================================================== */

.og-layout {
    display: grid;
    grid-template-columns: 320px minmax(0, 1fr);
    gap: 32px;
    align-items: stretch;
}

@media (max-width: 1100px) {
    .og-layout {
        grid-template-columns: 1fr;
    }
}

/* ==========================================================
   OFFER GENERATOR — PANELS
   ========================================================== */

.og-left {
    background: #fff;
    border-radius: 24px;
    padding: 32px;
    min-height: calc(100vh - 160px);
    box-shadow: 0 12px 32px rgba(48, 18, 78, 0.06);
}

.og-right {
    display: flex;
    flex-direction: column;
    gap: 32px;
    min-width: 0;
}

.og-panel {
    background: #fff;
    border-radius: 24px;
    padding: 32px 40px;
    box-shadow: 0 12px 32px rgba(48, 18, 78, 0.06);
    box-sizing: border-box;
}

.og-notes-panel {
    flex: 0 0 auto;
}

.og-question-area {
    flex: 1 1 auto;
    min-width: 0;
}

.og-notes-panel textarea {
    resize: vertical;
}

/* ==========================================================
   OFFER GENERATOR — PROGRESS
   ========================================================== */

.questionnaire-progress {
    margin-bottom: 0.5rem;
}

.questionnaire-progress-header {
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 0.25rem;
    font-size: 0.875rem;
}

.questionnaire-progress-title {
    font-weight: 700;
    color: #333;
}

.questionnaire-progress-percent {
    font-weight: 700;
    color: #333;
    text-align: center;
}

.questionnaire-progress-label {
    font-weight: 700;
    color: #333;
    text-align: right;
}

.questionnaire-progress-track {
    width: 100%;
    height: 0.65rem;
    overflow: hidden;
    background: #e9ecef;
    border: 1px solid var(--color-brand);
    border-radius: 999px;
    box-sizing: border-box;
}

.questionnaire-progress-bar {
    height: 100%;
    width: 0;
    background: var(--color-brand);
    border-radius: 999px;
    transition: width 0.2s ease;
}

/* ==========================================================
   QUESTION PANEL
   ========================================================== */

.og-question-title {
    font-size: 1.5rem;
    font-weight: 600;
    color: var(--color-brand-strong);
    margin-bottom: 0.4rem;
}

.og-question-help {
    font-size: 0.9rem;
    color: #666;
    margin-bottom: 1rem;
    line-height: 1.4;
}

.og-answer-area {
    margin-bottom: 2rem;
}

.og-actions {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.og-input {
    width: 100%;
    padding: 0.9rem 1rem;
    border-radius: 14px;
    border: 1px solid var(--color-border);
    font-size: 1rem;
    transition:
        border 0.2s ease,
        box-shadow 0.2s ease;
}

.og-input:focus {
    outline: none;
    border-color: var(--color-brand-light);
    box-shadow: 0 0 0 3px rgba(109, 91, 208, 0.15);
}

.og-bool-options {
    display: flex;
    gap: 1rem;
}

.og-bool-btn {
    flex: 1;
    padding: 1rem;
    border-radius: 16px;
    border: 2px solid var(--color-border);
    background: var(--color-white);
    text-align: center;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
}

.og-bool-btn:hover {
    border-color: var(--color-brand-light);
}

.og-bool-btn.active {
    background: var(--color-light-purple);
    border-color: var(--color-brand-light);
    color: var(--color-brand-strong);
}

.og-choice-grid {
    display: grid;
    gap: 1rem;
}

.og-choice {
    padding: 1.2rem 1.5rem;
    border-radius: 18px;
    border: 2px solid var(--color-border);
    cursor: pointer;
    transition: all 0.2s ease;
    font-weight: 500;
}

.og-choice:hover {
    border-color: var(--color-brand-light);
    background: var(--color-light-purple);
}

.og-choice.active {
    border-color: var(--color-brand);
    background: var(--color-light-purple);
}

.og-session-sections {
    margin-top: 1.5rem;
}

.og-section-title {
    font-weight: 600;
    margin-bottom: 0.75rem;
}

.og-section-divider {
    margin: 2rem 0;
}

.og-questionnaire-card {
    background: #ffffff;
    border: 1px solid #e3e3e3;
    border-radius: 12px;
    padding: 1rem;
    transition: all 0.15s ease;
}

.og-questionnaire-card:hover {
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.06);
}

/* ==========================================================
   MODE SELECTOR
   ========================================================== */

.og-mode-buttons {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
}

.og-mode-btn {
    background: #eee;
    border: 2px solid transparent;
    border-radius: 14px;
    padding: 0.6rem 1rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.15s ease;
}

.og-mode-btn:hover {
    background: #e4e4e4;
}

.og-mode-btn.active {
    background: var(--color-brand-soft);
    border-color: var(--color-brand);
}

/* ==========================================================
   AI PANEL
   ========================================================== */

.ai-chat {
    display: flex;
    flex-direction: column;
    height: 500px;
}

.ai-chat-history {
    flex-grow: 1;
    overflow-y: auto;
    padding: 1rem;
    border: 1px solid #ddd;
    background: #fafafa;
}

.ai-message {
    margin-bottom: 0.75rem;
    line-height: 1.4;
}

.ai-assistant {
    color: #333;
}

.ai-user {
    font-weight: 600;
}

.ai-input-row {
    display: flex;
    gap: 0.5rem;
    margin-top: 1rem;
}

.ai-input-row input {
    flex-grow: 1;
    padding: 0.5rem;
}

.ai-thinking span::after {
    content: '';
    animation: ai-thinking-dots 1.2s steps(4, end) infinite;
}

@keyframes ai-thinking-dots {
    0% {
        content: '';
    }

    25% {
        content: '.';
    }

    50% {
        content: '..';
    }

    75%,
    100% {
        content: '...';
    }
}

/* ==========================================================
   SUMMARY PANEL
   ========================================================== */

.og-summary-title {
    font-size: 1rem;
    font-weight: 600;
    color: var(--color-brand-strong);
    margin-bottom: 1.5rem;
}

.og-summary-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.6rem 0;
    border-bottom: 1px solid rgba(0, 0, 0, 0.06);
}

.og-summary-content {
    display: flex;
    flex-direction: column;
}

.og-summary-actions {
    margin-left: 1rem;
}

.og-summary-question {
    font-size: 0.85rem;
    color: var(--color-grey-600);
    margin-bottom: 0.25rem;
}

.og-summary-answer {
    font-weight: 500;
    color: var(--color-brand-strong);
}

/* ==========================================================
   OFFER GENERATOR — SOLUTION CARDS
   ========================================================== */

.offering-card .card {
    border-radius: 14px;
    border: 1px solid var(--color-border);
    transition:
        box-shadow 0.2s ease,
        transform 0.2s ease;
}

.offering-card .card:hover {
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.06);
    transform: translateY(-2px);
}

/* ==========================================================
   OFFER GENERATOR LANDING
   ========================================================== */

.og-landing {
    display: flex;
    flex-direction: column;
    gap: 2rem;
}

.og-context-panel {
    background: var(--color-white);
    padding: 2rem;
    border-radius: 24px;
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.05);
}

.og-questionnaire-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: 1.5rem;
}

/* ==========================================================
   UNIFIED OFFERING TABLE
   ========================================================== */

.og-offering-table th {
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--color-grey-600);
    border-bottom: 2px solid #e4e0fa;
}

.og-offering-table td {
    vertical-align: middle;
}

/* Category separator row */
.og-category-row td {
    background: transparent;
    padding-top: 2rem;
    padding-bottom: 0.75rem;
    border-top: 1px solid var(--color-border);
    border-bottom: none;
}

/* Remove hover effect from category rows */
.og-category-row:hover td {
    background: transparent !important;
}

/* Normal row hover */
.og-offering-table tbody tr:not(.og-category-row):not(.og-total-row):hover {
    background: rgba(36, 0, 70, 0.03);
}

.og-offering-table input {
    text-align: center;
}

.og-checkbox {
    appearance: none;
    -webkit-appearance: none;
    width: 22px;
    height: 22px;
    border: 2px solid var(--color-brand-strong);
    border-radius: 6px;
    cursor: pointer;
    position: relative;
    transition: all 0.2s ease;
}

.og-checkbox:checked {
    background-color: var(--color-brand-strong);
    border-color: var(--color-brand-strong);
}

.og-checkbox:checked::after {
    content: '✓';
    position: absolute;
    color: white;
    font-size: 14px;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -55%);
}

.og-checkbox:focus {
    outline: 2px solid var(--color-brand-strong);
    outline-offset: 2px;
}

/* ==========================================================
   WORKFLOW — OFFER PARTIAL SOLUTION
   ========================================================== */

.offer-partial-solution {
    padding-bottom: 2rem;
}

.offer-partial-solution .offer-context-panel {
    margin-bottom: 0 !important;
}

.offer-partial-solution .offer-context-panel + .og-layout {
    margin-top: 32px;
}

.offer-partial-solution .offer-context-panel-title {
    margin-bottom: 1.5rem;
}

.offer-partial-solution .offer-context-grid {
    display: grid !important;
    gap: 2rem;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) !important;
    width: 100%;
}

.offer-partial-solution .offer-context-block {
    grid-column: auto !important;
    min-width: 0;
}

.offer-partial-solution .offer-context-heading {
    margin-bottom: 0.75rem;
}

.offer-partial-solution .offer-context-title {
    color: var(--color-brand-strong);
    font-weight: 700;
    margin-bottom: 0.75rem;
}

.offer-partial-solution .offer-contact-list {
    display: grid;
    gap: 0.35rem;
    margin: 0;
}

.offer-partial-solution .offer-contact-row {
    display: grid;
    grid-template-columns: 5rem minmax(0, 1fr);
    gap: 0.75rem;
}

.offer-partial-solution .offer-contact-row dt {
    color: var(--color-grey-600);
    font-size: 0.85rem;
    font-weight: 600;
}

.offer-partial-solution .offer-contact-row dd {
    margin: 0;
    min-width: 0;
    overflow-wrap: anywhere;
}

.offer-partial-solution .offer-selection-row td {
    border-top: 0;
    padding-top: 0.25rem;
}

.offer-partial-solution .offer-readonly-before-selection td {
    border-bottom-width: 0;
}

.offer-partial-solution .offer-product-picker-button {
    background: var(--bs-body-bg);
    cursor: pointer;
    min-height: 2.375rem;
    text-align: left;
}

.offer-partial-solution .offer-product-picker-button span:first-child {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.offer-partial-solution .offer-product-dropdown {
    left: 0;
    max-height: 18rem;
    max-width: 100%;
    min-width: 0;
    overflow-x: hidden;
    overflow-y: auto;
    right: 0;
    white-space: normal;
    width: 100%;
    z-index: 1040;
}

.offer-partial-solution .offer-product-dropdown .dropdown-item {
    max-width: 100%;
    min-width: 0;
    overflow-wrap: anywhere;
    text-align: left;
    white-space: normal;
    width: 100%;
}

.offer-partial-solution .offer-selected-detail {
    margin-top: 0.65rem;
}

.offer-partial-solution .offer-qty-input {
    max-width: 5.5rem;
}

.offer-partial-solution .og-offering-table {
    table-layout: fixed;
    width: 100%;
}

.offer-partial-solution .og-offering-table th,
.offer-partial-solution .og-offering-table td {
    min-width: 0;
}

.offer-partial-solution .offer-product-picker {
    max-width: 100%;
    min-width: 0;
    width: 100%;
}

.offer-partial-solution .offer-product-picker-button {
    max-width: 100%;
    min-width: 0;
    overflow: hidden;
    width: 100%;
}

/* ==========================================================
   QUESTIONNAIRE BUILDER
   ========================================================== */

.question-table {
    table-layout: fixed;
    width: 100%;
}

.question-col {
    white-space: normal;
    word-break: break-word;
}

.expanded-inner {
    width: 95%;
    background: #f8f9fa;
    border-radius: 6px;
    border: 1px solid #e3e6ea;
}

.sort-arrow-btn {
    border: none;
    background: none;
    padding: 2px 6px;
    cursor: pointer;
    line-height: 1;
}

.sort-arrow-btn:hover {
    background: #e9ecef;
    border-radius: 4px;
}

.q-section {
    margin-top: 1.5rem;
}

.q-tabs {
    display: flex;
    gap: 0.5rem;
    margin-bottom: -1px;
}

.q-tab {
    padding: 0.4rem 0.9rem;
    font-size: 0.9rem;
    border: 1px solid #ccc;
    border-bottom: none;
    background: #f5f5f5;
    cursor: pointer;
    border-radius: 6px 6px 0 0;
}

.q-tab.active {
    background: white;
    font-weight: 600;
    border-color: #ccc;
}

.q-section-body {
    background: white;
    border: 1px solid #ccc;
    border-radius: 0 6px 6px 6px;
    padding: 1rem;
}

/* Question builder flow diagram */
.question-flow-diagram {
    width: 100%;
    overflow: auto;
    background: #fafafa;
    min-height: 600px;
}

.diagram-toolbar {
    position: sticky;
    top: 0;
    z-index: 20;
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 0.75rem;
    background: #fafafa;
    border-bottom: 1px solid #eee;
}

.diagram-wrapper {
    display: block;
    position: relative !important;
    width: 100%;
    min-height: 600px;
    overflow: visible;
}

.diagram-legend {
    display: inline-flex;
    width: fit-content;
    align-items: center;
    gap: 0.75rem;
    background: white;
    border: 1px solid #ddd;
    border-radius: 6px;
    padding: 0.5rem 0.75rem;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.08);
    font-size: 0.85rem;
    z-index: 20;
}

.legend-item {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
}

.legend-item + .legend-item {
    margin-top: 0;
}

.legend-colour {
    width: 12px;
    height: 12px;
    border-radius: 2px;
    display: inline-block;
    flex: 0 0 auto;
}

.legend-label {
    white-space: nowrap;
}

.node {
    position: absolute !important;
    z-index: 2;
    width: 260px;
    cursor: pointer;
}

.node-box {
    width: 260px;
    min-height: 90px;
    height: 100%;
    padding: 10px;
    background: white;
    border: 2px solid #ccc;
    border-radius: 10px;
    box-shadow: 0 3px 6px rgba(0, 0, 0, 0.08);
    box-sizing: border-box;

    display: flex;
    flex-direction: column;
    justify-content: center;
    text-align: center;

    white-space: normal;
    overflow-wrap: break-word;
    word-break: normal;
}

.node-box strong {
    display: block;
    line-height: 1.3;
}

.node-box .text-muted {
    margin-top: 0.35rem;
    line-height: 1.2;
    overflow-wrap: break-word;
}

.node.selected .node-box {
    border: 2px solid #000;
    box-shadow: 0 0 10px rgba(0, 0, 0, 0.25);
}

.node.faded {
    opacity: 0.2;
}

.edges-layer {
    position: absolute;
    top: 0;
    left: 0;
    pointer-events: none;
    overflow: visible;
    z-index: 1;
}

.edge-label {
    font-size: 12px;
    fill: #222;
    font-weight: 500;
}

.edge-label-box {
    width: 100%;
    height: 100%;
    background: white;
    border: 2px solid #ccc;
    border-radius: 8px;
    padding: 6px 10px;
    font-size: 12px;
    line-height: 1.3;
    text-align: center;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.1);
    box-sizing: border-box;

    white-space: normal;
    overflow-wrap: break-word;
    word-break: normal;
}

.edge-label-box > div {
    margin-bottom: 0.2rem;
}

.edge-label-box > div:last-child {
    margin-bottom: 0;
}

.edge-label-box strong {
    font-weight: 600;
}

.question-flow-diagram {
    width: 100%;
    background: #fafafa;
}

.diagram-toolbar {
    position: sticky;
    top: 0;
    z-index: 20;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: 0.75rem;
    background: #fafafa;
    border-bottom: 1px solid #eee;
    flex-wrap: wrap;
}

.diagram-wrapper {
    position: relative;
    width: 100%;
    min-height: 600px;
    overflow: auto;
    background: #fafafa;
}

.diagram-canvas {
    position: relative;
}

.diagram-content {
    position: relative;
}

.diagram-zoom-controls {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    background: #fff;
    border: 1px solid #ddd;
    border-radius: 6px;
    padding: 0.4rem 0.5rem;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.08);
}

.diagram-zoom-value {
    min-width: 52px;
    text-align: center;
    font-size: 0.9rem;
    font-weight: 600;
}

/* ==========================================================
   SUPPORT TICKET AI
   ========================================================== */

.ai-comment {
    background-color: var(--color-light-purple);
}

.ai-messages-container {
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
}

.ai-message-text {
    white-space: pre-wrap;
}

/* Create with AI page */
.ai-ticket-create-card {
    height: 75vh;
}

.ai-ticket-create-body {
    flex: 1 1 auto;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

/* Update page AI chatbox */
.ai-chatbox {
    position: fixed;
    right: 1rem;
    bottom: 0;
    width: 470px;
    height: 50vh;
    min-width: 320px;
    min-height: 280px;
    max-width: 90vw;
    max-height: 85vh;
    z-index: 1050;
}

.ai-chatbox-card {
    height: 100%;
    display: flex;
    flex-direction: column;
}

.ai-chatbox-body {
    flex: 1 1 auto;
    min-height: 0;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.ai-new-message-input {
    flex-shrink: 0;
}

/* Collapsed state */
.ai-chatbox.collapsed {
    width: 470px !important;
    height: auto !important;
    min-height: 0;
}

.ai-chatbox.collapsed .ai-chatbox-card {
    height: auto;
}

.ai-chatbox.collapsed .ai-chatbox-header {
    margin-bottom: 0 !important;
}

.ai-chatbox.collapsed .ai-chatbox-body {
    display: none;
}

.ai-chatbox.collapsed .resize-handle {
    display: none;
}

/* Resize handles */
.resize-handle {
    position: absolute;
    z-index: 10;
}

.resize-top {
    top: 0;
    left: 0;
    width: 100%;
    height: 8px;
    cursor: ns-resize;
}

.resize-left {
    top: 0;
    left: 0;
    width: 8px;
    height: 100%;
    cursor: ew-resize;
}

.resize-corner {
    top: 0;
    left: 0;
    width: 16px;
    height: 16px;
    cursor: nwse-resize;
}

.ai-chatbox.resizing {
    user-select: none;
}
