:root {
    --ink-950: #0f172a;
    --ink-900: #172033;
    --ink-800: #243049;
    --ink-700: #40506f;
    --ink-500: #6b7893;
    --ink-300: #c8d2e2;
    --panel: rgba(255, 255, 255, 0.9);
    --panel-strong: #ffffff;
    --surface: #eef4ff;
    --surface-soft: #f8fbff;
    --line: rgba(64, 80, 111, 0.16);
    --brand: #1463ff;
    --brand-strong: #0f4fcc;
    --brand-soft: rgba(20, 99, 255, 0.1);
    --accent: #ffb703;
    --accent-soft: rgba(255, 183, 3, 0.14);
    --success: #1aa672;
    --danger: #d1495b;
    --danger-soft: rgba(209, 73, 91, 0.12);
    --shadow-lg: 0 24px 70px rgba(15, 23, 42, 0.16);
    --shadow-md: 0 16px 36px rgba(15, 23, 42, 0.1);
    --radius-xl: 28px;
    --radius-lg: 20px;
    --radius-md: 14px;
}

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

html,
body {
    min-height: 100%;
}

body {
    font-family: "IBM Plex Sans", "Segoe UI", sans-serif;
    color: var(--ink-900);
    background:
        radial-gradient(circle at top left, rgba(20, 99, 255, 0.14), transparent 32%),
        radial-gradient(circle at top right, rgba(255, 183, 3, 0.14), transparent 28%),
        linear-gradient(180deg, #f5f8ff 0%, #edf3ff 100%);
    padding: 28px;
}

body::before,
body::after {
    content: "";
    position: fixed;
    z-index: 0;
    inset: auto;
    pointer-events: none;
}

body::before {
    width: 240px;
    height: 240px;
    left: -70px;
    bottom: -60px;
    background: radial-gradient(circle, rgba(20, 99, 255, 0.16), transparent 70%);
}

body::after {
    width: 260px;
    height: 260px;
    right: -90px;
    top: -60px;
    background: radial-gradient(circle, rgba(255, 183, 3, 0.18), transparent 72%);
}

.chat-shell {
    position: relative;
    z-index: 1;
    max-width: 1320px;
    margin: 0 auto;
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: 24px;
}

.chat-container {
    min-height: calc(100vh - 56px);
    height: calc(100vh - 56px);
    background: var(--panel);
    border: 1px solid rgba(255, 255, 255, 0.7);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-lg);
    backdrop-filter: blur(18px);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.chat-header {
    display: flex;
    justify-content: space-between;
    gap: 18px;
    padding: 24px 28px 20px;
    border-bottom: 1px solid var(--line);
    background:
        linear-gradient(135deg, rgba(20, 99, 255, 0.08), transparent 35%),
        linear-gradient(180deg, rgba(255, 255, 255, 0.98), rgba(248, 251, 255, 0.94));
}

.bot-info {
    display: flex;
    align-items: center;
    gap: 16px;
    min-width: 0;
}

.bot-avatar {
    width: 58px;
    height: 58px;
    border-radius: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--brand-strong);
    background:
        linear-gradient(180deg, rgba(20, 99, 255, 0.12), rgba(20, 99, 255, 0.04)),
        var(--panel-strong);
    border: 1px solid rgba(20, 99, 255, 0.14);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.8);
}

.bot-avatar svg {
    width: 26px;
    height: 26px;
}

.eyebrow {
    font-family: "Pixelify Sans", sans-serif;
    font-size: 0.86rem;
    color: var(--brand-strong);
    letter-spacing: 0.03em;
    margin-bottom: 3px;
}

.chat-header h1 {
    font-size: 1.4rem;
    line-height: 1.1;
    font-weight: 700;
    color: var(--ink-950);
}

.status {
    margin-top: 5px;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-size: 0.85rem;
    color: var(--ink-700);
    font-weight: 500;
}

.status::before {
    content: "";
    width: 8px;
    height: 8px;
    border-radius: 999px;
    background: var(--success);
    box-shadow: 0 0 0 5px rgba(26, 166, 114, 0.12);
}

.header-actions {
    display: flex;
    align-items: flex-start;
    justify-content: flex-end;
    gap: 10px;
    flex-wrap: wrap;
    max-width: 520px;
}

.agents-link,
.profile-selector,
.menu-btn {
    min-height: 42px;
}

.agents-link {
    text-decoration: none;
    color: var(--ink-900);
    padding: 10px 14px;
    border-radius: 999px;
    border: 1px solid var(--line);
    background: rgba(255, 255, 255, 0.78);
    font-size: 0.84rem;
    font-weight: 600;
    transition: transform 0.2s ease, border-color 0.2s ease, background 0.2s ease;
}

.agents-link:hover {
    transform: translateY(-1px);
    border-color: rgba(20, 99, 255, 0.26);
    background: #ffffff;
}

.agents-pill {
    background: linear-gradient(180deg, rgba(255, 183, 3, 0.22), rgba(255, 183, 3, 0.1));
    border-color: rgba(255, 183, 3, 0.25);
}

.selector-group {
    display: flex;
    flex-direction: column;
    gap: 5px;
    min-width: 230px;
}

.selector-label {
    font-size: 0.72rem;
    font-weight: 700;
    color: var(--ink-500);
    text-transform: uppercase;
    letter-spacing: 0.06em;
}

.profile-selector {
    border: 1px solid var(--line);
    border-radius: 14px;
    background: rgba(255, 255, 255, 0.84);
    color: var(--ink-900);
    padding: 10px 14px;
    font-family: inherit;
    font-size: 0.9rem;
    font-weight: 500;
    min-width: 190px;
    outline: none;
}

.profile-selector:hover,
.profile-selector:focus {
    border-color: rgba(20, 99, 255, 0.34);
}

.entity-selector {
    min-width: 230px;
}

.menu-btn {
    width: 44px;
    border: 1px solid var(--line);
    border-radius: 14px;
    background: rgba(255, 255, 255, 0.8);
    color: var(--ink-700);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: transform 0.2s ease, border-color 0.2s ease, color 0.2s ease;
}

.menu-btn:hover {
    transform: translateY(-1px);
    color: var(--brand-strong);
    border-color: rgba(20, 99, 255, 0.28);
}

.menu-btn svg {
    width: 18px;
    height: 18px;
}

.context-strip {
    padding: 18px 28px 0;
}

.context-card {
    border-radius: var(--radius-lg);
    background:
        linear-gradient(135deg, rgba(20, 99, 255, 0.1), transparent 36%),
        linear-gradient(180deg, rgba(255, 255, 255, 0.98), rgba(248, 251, 255, 0.94));
    border: 1px solid rgba(20, 99, 255, 0.12);
    padding: 18px 18px 16px;
    box-shadow: var(--shadow-md);
}

.context-kicker {
    font-family: "Pixelify Sans", sans-serif;
    color: var(--brand-strong);
    font-size: 0.86rem;
    margin-bottom: 8px;
}

.context-badges {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.context-badge {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    min-height: 34px;
    padding: 7px 12px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.88);
    border: 1px solid rgba(64, 80, 111, 0.16);
    font-size: 0.84rem;
    font-weight: 600;
    color: var(--ink-800);
}

.context-badge-agent {
    background: linear-gradient(180deg, rgba(20, 99, 255, 0.14), rgba(20, 99, 255, 0.08));
    border-color: rgba(20, 99, 255, 0.16);
    color: var(--brand-strong);
}

.context-badge-case {
    background: rgba(255, 183, 3, 0.13);
    border-color: rgba(255, 183, 3, 0.22);
}

.context-copy {
    margin-top: 12px;
    color: var(--ink-700);
    line-height: 1.55;
    font-size: 0.93rem;
}

.profile-rules-copy {
    margin-top: 10px;
    color: var(--ink-500);
    line-height: 1.5;
    font-size: 0.86rem;
}

.session-toolbar {
    margin-top: 16px;
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 12px;
    align-items: end;
}

.session-field {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.session-field span {
    font-size: 0.74rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--ink-500);
}

.session-field input {
    min-height: 42px;
    width: 100%;
    border: 1px solid var(--line);
    border-radius: 14px;
    padding: 10px 14px;
    background: rgba(255, 255, 255, 0.92);
    font: inherit;
    color: var(--ink-950);
    outline: none;
}

.session-field textarea {
    min-height: 78px;
    width: 100%;
    border: 1px solid var(--line);
    border-radius: 14px;
    padding: 10px 14px;
    background: rgba(255, 255, 255, 0.92);
    font: inherit;
    color: var(--ink-950);
    outline: none;
    resize: vertical;
}

.session-field input:focus {
    border-color: rgba(20, 99, 255, 0.32);
    box-shadow: 0 0 0 4px rgba(20, 99, 255, 0.08);
}

.session-field textarea:focus {
    border-color: rgba(20, 99, 255, 0.32);
    box-shadow: 0 0 0 4px rgba(20, 99, 255, 0.08);
}

.session-field-wide {
    grid-column: 1 / -1;
}

.context-actions {
    margin-top: 14px;
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.context-actions-bottom {
    margin-top: 0;
    margin-bottom: 12px;
    justify-content: flex-end;
}

.context-action-btn {
    border: 1px solid var(--line);
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.86);
    color: var(--ink-900);
    padding: 9px 14px;
    font-family: inherit;
    font-size: 0.84rem;
    font-weight: 600;
    cursor: pointer;
    transition: transform 0.2s ease, border-color 0.2s ease, background 0.2s ease;
}

.context-action-btn:hover {
    transform: translateY(-1px);
    border-color: rgba(20, 99, 255, 0.26);
    background: #ffffff;
}

.context-action-btn-primary {
    background: linear-gradient(180deg, rgba(20, 99, 255, 0.14), rgba(20, 99, 255, 0.06));
    border-color: rgba(20, 99, 255, 0.25);
}

.context-action-btn-ghost {
    background: linear-gradient(180deg, rgba(15, 23, 42, 0.04), rgba(15, 23, 42, 0.02));
    border-color: rgba(64, 80, 111, 0.18);
    justify-self: end;
}

/* Minimalist modifications */
.context-card.minimal {
    padding: 12px 18px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.session-toolbar.minimalist-toolbar {
    margin-top: 0;
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: stretch;
}

.minimal-input {
    flex: 1;
    min-width: 140px;
    min-height: 36px;
    border: 1px solid var(--line);
    border-radius: 12px;
    padding: 6px 12px;
    background: rgba(255, 255, 255, 0.92);
    font: inherit;
    font-size: 0.85rem;
    color: var(--ink-950);
    outline: none;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.minimal-input:focus {
    border-color: rgba(20, 99, 255, 0.32);
    box-shadow: 0 0 0 3px rgba(20, 99, 255, 0.08);
}

.minimal-input.note-input {
    flex: 2;
    min-width: 200px;
}

.minimal-btn {
    min-height: 36px;
    padding: 4px 14px;
    border-radius: 12px;
    white-space: nowrap;
    display: flex;
    align-items: center;
}

.lock-btn {
    cursor: pointer;
    transition: background 0.2s, color 0.2s;
}
.lock-btn:hover {
    background: rgba(20,99,255,0.14) !important;
}
.lock-btn.locked {
    background: rgba(26, 166, 114, 0.12) !important;
    color: var(--success) !important;
}

.minimal-select {
    min-height: 32px;
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 2px 26px 2px 10px;
    background: rgba(255, 255, 255, 0.92);
    font: inherit;
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--ink-900);
    outline: none;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%2340506f' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 8px center;
    background-size: 12px;
    cursor: pointer;
    transition: border-color 0.2s;
}

.minimal-select:focus, .minimal-select:hover {
    border-color: rgba(20, 99, 255, 0.32);
}

.chat-messages {
    flex: 1;
    padding: 22px 28px 24px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 16px;
    background:
        linear-gradient(180deg, rgba(255, 255, 255, 0.26), transparent 30%),
        linear-gradient(180deg, #f7faff 0%, #f4f8ff 100%);
}

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

.chat-messages::-webkit-scrollbar-thumb {
    background: rgba(64, 80, 111, 0.18);
    border-radius: 999px;
}

.message {
    display: flex;
    max-width: 78%;
    animation: fadeIn 0.28s ease forwards;
}

.message.bot,
.message.bot-error {
    align-self: flex-start;
}

.message.user {
    align-self: flex-end;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(8px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.message-content {
    padding: 15px 18px;
    border-radius: 22px;
    font-size: 0.97rem;
    line-height: 1.55;
    white-space: pre-wrap;
    word-break: break-word;
    box-shadow: 0 10px 24px rgba(15, 23, 42, 0.06);
}

.message-content a {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    margin-top: 10px;
    padding: 8px 12px;
    border-radius: 999px;
    background: rgba(11, 96, 255, 0.1);
    border: 1px solid rgba(11, 96, 255, 0.18);
    color: #0b60ff;
    font-weight: 600;
    text-decoration: none;
}

.message-content a:hover {
    background: rgba(11, 96, 255, 0.16);
}

.message.bot .message-content {
    background: linear-gradient(180deg, #ffffff, #f5f8ff);
    border: 1px solid rgba(64, 80, 111, 0.12);
    border-bottom-left-radius: 8px;
    color: var(--ink-900);
}

.message.user .message-content {
    background: linear-gradient(180deg, var(--brand), var(--brand-strong));
    color: #ffffff;
    border-bottom-right-radius: 8px;
}

.message.bot-error .message-content {
    background: linear-gradient(180deg, rgba(209, 73, 91, 0.12), rgba(209, 73, 91, 0.08));
    border: 1px solid rgba(209, 73, 91, 0.18);
    color: #7d2230;
    border-bottom-left-radius: 8px;
}

.typing-indicator {
    padding: 14px 18px;
    border-radius: 20px;
    border-bottom-left-radius: 8px;
    background: linear-gradient(180deg, #ffffff, #f3f7ff);
    border: 1px solid rgba(64, 80, 111, 0.12);
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.typing-indicator span {
    width: 8px;
    height: 8px;
    border-radius: 999px;
    background: rgba(20, 99, 255, 0.45);
    animation: pulseDots 1.2s infinite ease-in-out;
}

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

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

.typing-indicator .loading-text {
    width: auto;
    height: auto;
    border-radius: 0;
    background: none;
    animation: none;
    font-size: 0.9rem;
    color: var(--ink-700);
    margin-left: 8px;
}

@keyframes pulseDots {
    0%,
    80%,
    100% {
        transform: scale(0.7);
        opacity: 0.5;
    }

    40% {
        transform: scale(1);
        opacity: 1;
    }
}

.chat-input-area {
    padding: 18px 28px 26px;
    border-top: 1px solid var(--line);
    background: rgba(255, 255, 255, 0.92);
}

.attachment-preview {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    margin-bottom: 12px;
    padding: 10px 14px;
    border-radius: 14px;
    background: var(--surface);
    border: 1px solid rgba(20, 99, 255, 0.12);
    color: var(--ink-800);
    font-size: 0.88rem;
}

.attachment-preview button {
    width: 28px;
    height: 28px;
    border: none;
    border-radius: 999px;
    background: rgba(15, 79, 204, 0.08);
    color: var(--brand-strong);
    cursor: pointer;
}

#chat-form {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 8px 8px 8px 16px;
    background: linear-gradient(180deg, #ffffff, #f5f8ff);
    border: 1px solid rgba(64, 80, 111, 0.14);
    border-radius: 24px;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.8);
}

#chat-form:focus-within {
    border-color: rgba(20, 99, 255, 0.3);
    box-shadow:
        inset 0 1px 0 rgba(255, 255, 255, 0.8),
        0 0 0 4px rgba(20, 99, 255, 0.08);
}

.attach-btn {
    width: 42px;
    height: 42px;
    border: none;
    border-radius: 14px;
    background: var(--surface);
    color: var(--ink-700);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: transform 0.2s ease, background 0.2s ease;
}

.attach-btn:hover {
    transform: translateY(-1px);
    background: #e7f0ff;
}

.attach-btn svg {
    width: 18px;
    height: 18px;
}

#message-input {
    flex: 1;
    border: none;
    background: transparent;
    color: var(--ink-950);
    font-size: 0.96rem;
    outline: none;
}

#message-input::placeholder {
    color: var(--ink-500);
}

#send-btn {
    width: 46px;
    height: 46px;
    border: none;
    border-radius: 16px;
    background: linear-gradient(180deg, var(--brand), var(--brand-strong));
    color: #ffffff;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: 0 12px 24px rgba(20, 99, 255, 0.24);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

#send-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 16px 28px rgba(20, 99, 255, 0.28);
}

#send-btn svg {
    width: 18px;
    height: 18px;
}

.side-panel {
    position: fixed;
    top: 26px;
    right: -420px;
    width: min(390px, calc(100vw - 22px));
    height: calc(100vh - 52px);
    background: rgba(255, 255, 255, 0.96);
    border-left: 1px solid var(--line);
    border-radius: 26px 0 0 26px;
    box-shadow: var(--shadow-lg);
    backdrop-filter: blur(20px);
    transition: right 0.28s ease;
    z-index: 20;
    display: flex;
    flex-direction: column;
}

.side-panel.open {
    right: 0;
}

.panel-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 14px;
    padding: 22px 22px 18px;
    border-bottom: 1px solid var(--line);
}

.panel-header h2 {
    font-size: 1.18rem;
    font-weight: 700;
    color: var(--ink-950);
}

.panel-content {
    flex: 1;
    overflow-y: auto;
    padding: 20px 22px 24px;
}

.ticket-list {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.ticket-item {
    border-radius: 16px;
    padding: 14px 15px;
    background: linear-gradient(180deg, #ffffff, #f6f9ff);
    border: 1px solid rgba(64, 80, 111, 0.12);
    cursor: pointer;
    transition: transform 0.2s ease, border-color 0.2s ease;
}

.ticket-item:hover {
    transform: translateY(-2px);
    border-color: rgba(20, 99, 255, 0.26);
}

.ticket-id {
    display: block;
    font-weight: 700;
    color: var(--brand-strong);
    margin-bottom: 4px;
}

.ticket-cat {
    font-size: 0.84rem;
    color: var(--ink-500);
}

.empty-msg {
    margin-top: 40px;
    text-align: center;
    color: var(--ink-500);
    font-size: 0.92rem;
}

.hidden {
    display: none !important;
}

@media (max-width: 1024px) {
    body {
        padding: 16px;
    }

    .chat-container {
        min-height: calc(100vh - 32px);
    }

    .chat-header {
        flex-direction: column;
        align-items: flex-start;
    }

    .header-actions {
        width: 100%;
        justify-content: flex-start;
    }

    .selector-group,
    .entity-selector,
    .profile-selector {
        min-width: 100%;
    }

    .session-toolbar {
        grid-template-columns: 1fr;
    }

    .session-field-wide {
        grid-column: auto;
    }

    .context-action-btn-ghost {
        justify-self: stretch;
    }
}

@media (max-width: 720px) {
    body {
        padding: 0;
    }

    .chat-container {
        min-height: 100vh;
        border-radius: 0;
    }

    .chat-header,
    .context-strip,
    .chat-messages,
    .chat-input-area {
        padding-left: 16px;
        padding-right: 16px;
    }

    .chat-header {
        padding-top: 18px;
    }

    .message {
        max-width: 92%;
    }

    .context-badges {
        gap: 8px;
    }

    .context-badge {
        width: 100%;
        justify-content: flex-start;
    }

    .context-actions-bottom {
        justify-content: stretch;
    }

    .context-action-btn {
        flex: 1;
        text-align: center;
    }

    .side-panel {
        top: 0;
        height: 100vh;
        border-radius: 0;
    }
}
