@import url('https://fonts.googleapis.com/css2?family=Material+Symbols+Outlined:wght@400;500&display=swap');

:root {
    --bg1: #050816;
    --bg2: #0b1024;
    --accent: #2e52d3;
    --accent2: #4f7dff;
    --panel: rgba(9, 12, 32, 0.85);
    --panel-border: rgba(46, 82, 211, 0.55);
    --panel-glow: rgba(46, 82, 211, 0.25);
    --text: #e5e7eb;
    --muted: #9ca3af;
}

.material-symbols-outlined {
    font-variation-settings:
        "FILL" 0,
        "wght" 400,
        "GRAD" 0,
        "opsz" 24;
    font-size: 24px;
}

.emaa-ahu-chat {
    font-family: 'Rajdhani', system-ui, -apple-system, Segoe UI, Roboto, Helvetica, Arial, sans-serif;
}

/* Panel + glassmorphism – cloned from AHU */
.panel {
    position: fixed;
    z-index: 1000001;
    background: var(--panel);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid var(--panel-border);
    border-radius: 2px;
}

.panel__noise {
    position: absolute;
    inset: 0;
    opacity: 0.20;
    pointer-events: none;
    mix-blend-mode: overlay;
    background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noiseFilter'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='1.5' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noiseFilter)'/%3E%3C/svg%3E");
}

.panel__content {
    position: relative;
    padding: 32px;
    background: var(--panel);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid var(--panel-border);
    border-radius: 2px;
    height: 100%;
    box-sizing: border-box;
}

/* Right-side slide-in panel – exact geometry of .app--challenge .panel--chat */
.emaa-panel-chat {
    top: 32px;
    right: 32px;
    width: 360px;
    height: calc(100% - 64px);
    transform: translateX(calc(100% + 40px));
    transition: transform 0.3s ease, opacity 0.3s ease;
    opacity: 0;
    pointer-events: none;
}

.emaa-panel-chat.is-open {
    transform: translateX(0);
    z-index: 1000002;
    opacity: 1;
    pointer-events: auto;
}

.chat-panel {
    height: 100%;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.chat-header {
    border-bottom: 1px solid rgba(46, 82, 211, 0.45);
    padding-bottom: 12px;
}

.chat-header__top {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 12px;
}

.chat-kicker {
    margin: 0 0 6px;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.14em;
    color: var(--accent);
}

.chat-title {
    margin: 0 0 6px;
    font-size: 16px;
    font-weight: 600;
    color: var(--text);
    line-height: 1.4;
}

.chat-meta {
    margin: 0;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.12em;
    color: var(--muted);
}

.chat-close {
    flex-shrink: 0;
    width: 28px;
    height: 28px;
    padding: 0;
    border: 1px solid rgba(46, 82, 211, 0.6);
    background: rgba(6, 10, 32, 0.65);
    color: var(--text);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 2px;
    transition: background-color 0.2s ease, border-color 0.2s ease, box-shadow 0.2s ease;
}

.chat-close:hover,
.chat-close:focus-visible {
    background: rgba(46, 82, 211, 0.25);
    border-color: rgba(79, 125, 255, 0.9);
    box-shadow: 0 0 16px rgba(46, 82, 211, 0.6);
    outline: none;
}

.chat-close svg {
    width: 16px;
    height: 16px;
}

.chat-messages {
    flex: 1;
    overflow: auto;
    display: flex;
    flex-direction: column;
    gap: 10px;
    padding-right: 6px;
}

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

.chat-messages::-webkit-scrollbar-track {
    background: rgba(8, 13, 23, 0.3);
    border-radius: 4px;
}

.chat-messages::-webkit-scrollbar-thumb {
    background: rgba(156, 163, 175, 0.5);
    border-radius: 4px;
}

.chat-messages::-webkit-scrollbar-thumb:hover {
    background: rgba(156, 163, 175, 0.7);
}

.chat-messages {
    scrollbar-width: thin;
    scrollbar-color: rgba(156, 163, 175, 0.5) rgba(8, 13, 23, 0.3);
}

.chat-bubble {
    max-width: 100%;
    padding: 10px 12px;
    border-radius: 2px;
    border: 1px solid rgba(156, 163, 175, 0.35);
    background: rgba(8, 13, 23, 0.65);
    font-size: 13px;
    line-height: 1.6;
    color: var(--text);
}

.chat-bubble--user {
    align-self: flex-end;
    border-color: rgba(79, 125, 255, 0.75);
    background: rgba(46, 82, 211, 0.22);
    color: var(--text);
}

.chat-bubble--assistant {
    align-self: flex-start;
}

.chat-message {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 6px;
}

.chat-message--user {
    align-items: flex-end;
}

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

.chat-input input {
    flex: 1 !important;
    padding: 10px 12px !important;
    border-radius: 2px !important;
    border: 1px solid rgba(79, 125, 255, 0.55) !important;
    background: rgba(7, 11, 32, 0.9) !important;
    color: var(--text) !important;
    font-family: inherit !important;
    font-size: 13px !important;
}

.chat-input input::placeholder {
    color: #9ca3af;
    opacity: 1;
}

.chat-input input:focus-visible {
    outline: 2px solid rgba(79, 125, 255, 0.9);
    outline-offset: 2px;
}

.chat-send {
    padding: 10px 16px;
    border: 1px solid rgba(79, 125, 255, 0.85);
    background: var(--accent);
    color: #edf2ff;
    font-family: inherit;
    font-weight: 600;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.12em;
    cursor: pointer;
    transition: box-shadow .2s ease, transform .05s ease;
}

.chat-send:hover {
    box-shadow: 0 0 22px rgba(79, 125, 255, 0.75);
}

.chat-send:disabled {
    opacity: 0.55;
    cursor: not-allowed;
    box-shadow: none;
}

/* HUD help icon – cloned from AHU .hud + .help-icon */
.hud {
    position: fixed;
    right: 64px;
    bottom: 55px;
    display: flex;
    flex-direction: row;
    align-items: flex-end;
    gap: 12px;
    z-index: 999999;
    pointer-events: none;
}

@media only screen and (max-width: 800px) {
    .hud {
        right: 20px;
        bottom: 20px;
    }
}

.hud-icons {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.help-icon {
    width: 55px;
    height: 55px;
    border-radius: 0;
    background: radial-gradient(circle at 30% 0, #2f52d4, #2e52d3);
    color: #ffffff;
    display: flex;
    align-items: center;
    justify-content: center;
    pointer-events: auto;
    cursor: pointer;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}



.help-icon:hover,
.help-icon:focus-visible {
    transform: translateY(-2px);
    outline: none;
}

.help-icon:active {
    transform: translateY(0);
}

.emaa-help-icon-img {
    width: 26px;
    height: 26px;
    object-fit: contain;
}

@media (max-width: 980px) {
    .emaa-panel-chat {
        left: 0;
        right: 0;
        top: 0;
        /* کمی بالاتر از نوار ناوبری/فوتر موبایل */
        bottom: 20px;
        width: 100%;
        height: auto;
        border-radius: 0;
        transform: translateY(100%);
        opacity: 0;
        pointer-events: none;
    }

    .emaa-panel-chat.is-open {
        transform: translateY(0);
        opacity: 1;
        pointer-events: auto;
    }

    .panel__content {
        border-radius: 0;
        padding: 20px 16px;
    }
}

/* Actions under assistant messages */
.message-actions {
    display: flex;
    gap: 8px;
    margin-top: 10px;
    padding-top: 10px;
    border-top: 1px solid rgba(148, 163, 184, 0.35);
}

.action-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 6px 12px;
    border-radius: 0px;
    font-size: 11px;
    font-weight: 600;
    text-decoration: none;
    cursor: pointer;
    transition: all 0.2s ease;
    border: 1px solid transparent;
}

.email-btn {
    background: rgba(15, 23, 42, 0.85);
    color: #e5e7eb;
    border-color: rgba(148, 163, 184, 0.55);
}

.email-btn:hover {
    background: rgba(30, 64, 175, 0.65);
    border-color: rgba(129, 140, 248, 0.9);
}

.whatsapp-btn {
    background: #22c55e;
    color: #ecfdf3;
    border-color: #16a34a;
}

.whatsapp-btn:hover {
    background: #16a34a;
    border-color: #22c55e;
    color: #ecfdf3;
}