/**
 * 다다 AI — 전역 플로팅 채팅 위젯 (우하단)
 */

.dada-ai-fab .sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

.dada-ai-fab {
    position: fixed;
    right: max(1.25rem, env(safe-area-inset-right, 0px));
    left: auto;
    bottom: max(1.25rem, env(safe-area-inset-bottom, 0px));
    z-index: 9999;
    width: 3.75rem;
    height: 3.75rem;
    border: none;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: #fff;
    background: linear-gradient(145deg, #00aeef 0%, #004a99 100%);
    box-shadow:
        0 8px 24px rgba(0, 74, 153, 0.4),
        0 0 0 4px rgba(255, 255, 255, 0.4);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    -webkit-tap-highlight-color: transparent;
}

.dada-ai-fab:hover {
    transform: scale(1.06);
    box-shadow:
        0 12px 32px rgba(0, 74, 153, 0.48),
        0 0 0 5px rgba(255, 255, 255, 0.5);
}

.dada-ai-fab:active {
    transform: scale(0.96);
}

.dada-ai-fab svg {
    width: 1.6rem;
    height: 1.6rem;
}

.dada-ai-panel {
    position: fixed;
    right: max(1.25rem, env(safe-area-inset-right, 0px));
    left: auto;
    bottom: calc(max(1.25rem, env(safe-area-inset-bottom, 0px)) + 4.75rem);
    z-index: 9998;
    width: min(24rem, calc(100vw - 2.5rem));
    height: min(36rem, calc(100vh - 7rem));
    max-height: calc(100dvh - 7rem);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    border-radius: 1.25rem;
    background: #fff;
    border: 1px solid #e8eef5;
    box-shadow: 0 20px 48px rgba(0, 74, 153, 0.18);
    opacity: 0;
    visibility: hidden;
    transform: translateY(12px) scale(0.98);
    transition:
        opacity 0.25s ease,
        transform 0.25s ease,
        visibility 0.25s;
}

.dada-ai-panel.is-open {
    opacity: 1;
    visibility: visible;
    transform: translateY(0) scale(1);
}

.dada-ai-panel__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
    padding: 0.9rem 1.1rem;
    background: linear-gradient(135deg, #004a99 0%, #0077cc 55%, #00aeef 100%);
    color: #fff;
}

.dada-ai-panel__title {
    margin: 0;
    font-size: 1.05rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 0.45rem;
}

.dada-ai-panel__title svg {
    width: 1.15rem;
    height: 1.15rem;
}

.dada-ai-panel__close {
    width: 2rem;
    height: 2rem;
    border: none;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.16);
    color: #fff;
    font-size: 1.25rem;
    line-height: 1;
    cursor: pointer;
}

.dada-ai-panel__close:hover {
    background: rgba(255, 255, 255, 0.28);
}

.dada-ai-panel__messages {
    flex: 1;
    overflow-y: auto;
    padding: 1rem;
    background: #f4f9fc;
    -webkit-overflow-scrolling: touch;
}

.dada-ai-welcome {
    text-align: center;
    padding: 1.25rem 0.5rem 0.5rem;
    color: #5b6b7c;
}

.dada-ai-welcome h4 {
    margin: 0 0 0.5rem;
    color: #004a99;
    font-size: 1.05rem;
}

.dada-ai-welcome p {
    margin: 0.35rem 0;
    font-size: 0.82rem;
    line-height: 1.55;
}

.dada-ai-welcome a {
    color: #0077cc;
    font-weight: 600;
    text-decoration: none;
}

.dada-ai-welcome a:hover {
    color: #00aeef;
    text-decoration: underline;
}

.dada-ai-suggestions {
    display: flex;
    flex-direction: column;
    gap: 0.45rem;
    margin-top: 1rem;
    text-align: left;
}

.dada-ai-suggestion {
    width: 100%;
    border: 1px solid #d5e8f4;
    background: #fff;
    color: #004a99;
    border-radius: 0.85rem;
    padding: 0.55rem 0.75rem;
    font-size: 0.8rem;
    line-height: 1.4;
    text-align: left;
    cursor: pointer;
}

.dada-ai-suggestion:hover {
    border-color: #00aeef;
    background: #e8f6fc;
}

.dada-ai-message {
    display: flex;
    margin-bottom: 0.85rem;
}

.dada-ai-message--user {
    justify-content: flex-end;
}

.dada-ai-message--assistant {
    justify-content: flex-start;
}

.dada-ai-message__bubble {
    max-width: 85%;
    padding: 0.65rem 0.9rem;
    border-radius: 1rem;
    font-size: 0.875rem;
    line-height: 1.55;
    word-break: break-word;
}

.dada-ai-message--user .dada-ai-message__bubble {
    background: linear-gradient(135deg, #004a99, #0077cc);
    color: #fff;
    border-bottom-right-radius: 0.25rem;
}

.dada-ai-message--assistant .dada-ai-message__bubble {
    background: #fff;
    color: #1f2d3d;
    border: 1px solid #e3edf4;
    border-bottom-left-radius: 0.25rem;
}

.dada-ai-message__bubble strong {
    font-weight: 700;
    color: #004a99;
}

.dada-ai-message--user .dada-ai-message__bubble strong {
    color: #fff;
}

.dada-ai-message__bubble em {
    font-style: italic;
}

.dada-ai-md-h {
    margin: 0.35rem 0 0.4rem;
    font-size: 0.92rem;
    font-weight: 700;
    color: #004a99;
    line-height: 1.4;
}

.dada-ai-md-list {
    margin: 0.4rem 0 0.5rem;
    padding-left: 1.25rem;
}

.dada-ai-md-list li {
    margin: 0.2rem 0;
}

.dada-ai-md-code {
    font-family: ui-monospace, Consolas, monospace;
    font-size: 0.8em;
    padding: 0.1em 0.35em;
    border-radius: 0.3rem;
    background: #eef6fb;
    color: #004a99;
}

.dada-ai-md-link {
    color: #0077cc;
    font-weight: 600;
    text-decoration: underline;
}

.dada-ai-citation {
    font-weight: 600;
    color: #0077cc;
    text-decoration: none;
    white-space: nowrap;
}

.dada-ai-citation:hover,
.dada-ai-citation:focus-visible {
    color: #00aeef;
    text-decoration: underline;
}

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

@keyframes dada-ai-dots {
    0%,
    20% {
        content: '';
    }
    40% {
        content: '.';
    }
    60% {
        content: '..';
    }
    80%,
    100% {
        content: '…';
    }
}

.dada-ai-panel__input {
    display: flex;
    flex-direction: row;
    flex-wrap: nowrap;
    align-items: center;
    gap: 0.5rem;
    padding: 0.75rem;
    border-top: 1px solid #e8eef5;
    background: #fff;
    flex-shrink: 0;
}

.dada-ai-panel__input input {
    flex: 1 1 0;
    min-width: 0;
    width: auto;
    padding: 0.65rem 0.9rem;
    border: 1px solid #d7e3ee;
    border-radius: 999px;
    font: inherit;
    font-size: 1rem;
    color: #1f2d3d;
    background: #f7fbfe;
}

.dada-ai-panel__input input:focus {
    outline: 2px solid rgba(0, 174, 239, 0.35);
    border-color: #00aeef;
}

.dada-ai-send {
    flex: 0 0 auto;
    width: 2.75rem;
    height: 2.75rem;
    border: none;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: #fff;
    background: #00aeef;
}

.dada-ai-send svg {
    width: 1.05rem;
    height: 1.05rem;
}

.dada-ai-send:hover:not(:disabled) {
    background: #0077cc;
}

.dada-ai-send:disabled,
.dada-ai-panel__input input:disabled {
    opacity: 0.55;
    cursor: not-allowed;
}

@media (max-width: 480px) {
    .dada-ai-fab {
        right: max(0.75rem, env(safe-area-inset-right, 0px));
        bottom: max(1rem, env(safe-area-inset-bottom, 0px));
    }

    .dada-ai-panel {
        left: max(0.75rem, env(safe-area-inset-left, 0px));
        right: max(0.75rem, env(safe-area-inset-right, 0px));
        width: auto;
        height: min(32rem, calc(100dvh - 6.5rem));
        bottom: calc(max(1rem, env(safe-area-inset-bottom, 0px)) + 4.5rem);
    }
}
