/* ==============================================
   도란도란 펫 아지트 - AI 챗봇 UI (Premium v2)
   ==============================================
   Reference: Enterprise-grade RAG 챗봇 UI
   ============================================== */

/* ------ Google Fonts ------ */
@import url('https://fonts.googleapis.com/css2?family=Noto+Sans+KR:wght@400;500;600;700&display=swap');

/* ------ Design Tokens ------ */
:root {
    --ac-font: 'Noto Sans KR', -apple-system, BlinkMacSystemFont, sans-serif;
    --ac-primary: #2D2D2D;
    --ac-primary-dark: #1A1A1A;
    --ac-accent: #4A90D9;
    --ac-accent-light: #E8F0FE;
    --ac-green: #0D9488;
    --ac-green-light: #ECFDF5;
    --ac-green-badge: #10B981;
    --ac-white: #FFFFFF;
    --ac-bg: #F7F8FA;
    --ac-border: #E5E7EB;
    --ac-border-light: #F0F1F3;
    --ac-text: #1F2937;
    --ac-text-secondary: #6B7280;
    --ac-text-light: #9CA3AF;
    --ac-user-bubble: #1E293B;
    --ac-shadow-sm: 0 1px 3px rgba(0,0,0,0.08);
    --ac-shadow-md: 0 4px 24px rgba(0,0,0,0.12);
    --ac-shadow-lg: 0 12px 48px rgba(0,0,0,0.16);
    --ac-radius: 14px;
    --ac-width: 400px;
    --ac-height: 600px;
}

/* ------ 플로팅 아이콘 버튼 (FAB) ------ */
.ac-fab {
    position: fixed;
    bottom: 24px;
    right: 24px;
    width: 58px;
    height: 58px;
    border-radius: 50%;
    background: linear-gradient(135deg, #FF6B6B, #FF8E53);
    border: none;
    cursor: pointer;
    box-shadow: 0 4px 16px rgba(255, 107, 107, 0.4);
    z-index: 9998;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}
.ac-fab:hover {
    transform: scale(1.08);
    background: linear-gradient(135deg, #FF8E53, #FF6B6B);
    box-shadow: 0 6px 24px rgba(255, 107, 107, 0.5);
}
.ac-fab-inner {
    position: relative;
    width: 32px;
    height: 32px;
}
.ac-fab-inner img,
.ac-fab-inner svg {
    width: 100%;
    height: 100%;
}
.ac-fab-badge {
    position: absolute;
    top: -4px;
    right: -6px;
    width: 12px;
    height: 12px;
    background: #4ADE80;
    border-radius: 50%;
    border: 2px solid #fff;
    animation: ac-pulse 2s infinite;
}
@keyframes ac-pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

/* ------ 챗봇 모달 ------ */
.ac-modal {
    position: fixed;
    bottom: 92px;
    right: 24px;
    width: var(--ac-width);
    height: var(--ac-height);
    background: var(--ac-white);
    border-radius: var(--ac-radius);
    box-shadow: var(--ac-shadow-lg);
    z-index: 9999;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    opacity: 0;
    transform: translateY(16px) scale(0.96);
    pointer-events: none;
    transition: all 0.35s cubic-bezier(0.4, 0, 0.2, 1);
    font-family: var(--ac-font);
    border: 1px solid var(--ac-border);
}
.ac-modal.open {
    opacity: 1;
    transform: translateY(0) scale(1);
    pointer-events: all;
}

/* ------ 헤더 (엷은 초록) ------ */
.ac-header {
    background: linear-gradient(135deg, #ECFDF5, #D1FAE5);
    color: #065F46;
    padding: 14px 16px;
    display: flex;
    align-items: center;
    gap: 10px;
    flex-shrink: 0;
    border-bottom: 1px solid #A7F3D0;
}
.ac-header-avatar {
    width: 38px;
    height: 38px;
    background: rgba(16, 185, 129, 0.15);
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    flex-shrink: 0;
}
.ac-header-info {
    flex: 1;
    min-width: 0;
}
.ac-header-title {
    font-size: 14px;
    font-weight: 700;
    margin: 0;
    letter-spacing: -0.3px;
    color: #065F46;
}
.ac-header-status {
    display: flex;
    align-items: center;
    gap: 5px;
    margin-top: 2px;
}
.ac-status-dot {
    width: 7px;
    height: 7px;
    background: var(--ac-green-badge);
    border-radius: 50%;
    flex-shrink: 0;
}
.ac-header-status span {
    font-size: 10.5px;
    color: #047857;
    font-weight: 400;
}
.ac-close-btn {
    background: rgba(5, 150, 105, 0.12);
    border: none;
    color: #065F46;
    width: 30px;
    height: 30px;
    border-radius: 8px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    transition: all 0.2s;
    flex-shrink: 0;
}
.ac-close-btn:hover {
    background: rgba(255,255,255,0.2);
    color: #fff;
}

/* ------ 탭 네비게이션 ------ */
.ac-tabs {
    display: flex;
    border-bottom: 1px solid var(--ac-border);
    background: var(--ac-white);
    flex-shrink: 0;
}
.ac-tab {
    flex: 1;
    padding: 10px 0;
    text-align: center;
    font-size: 13px;
    font-weight: 600;
    color: var(--ac-text-light);
    background: none;
    border: none;
    cursor: pointer;
    position: relative;
    transition: color 0.2s;
    font-family: var(--ac-font);
}
.ac-tab:hover {
    color: var(--ac-text-secondary);
}
.ac-tab.active {
    color: var(--ac-text);
}
.ac-tab.active::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 20%;
    width: 60%;
    height: 2px;
    background: var(--ac-text);
    border-radius: 2px;
}

/* ------ 탭 콘텐츠 ------ */
.ac-tab-content {
    display: none;
    flex: 1;
    flex-direction: column;
    overflow: hidden;
}
.ac-tab-content.active {
    display: flex;
}

/* ------ 메시지 영역 ------ */
.ac-messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    background: var(--ac-bg);
    display: flex;
    flex-direction: column;
    gap: 14px;
}
.ac-messages::-webkit-scrollbar { width: 4px; }
.ac-messages::-webkit-scrollbar-track { background: transparent; }
.ac-messages::-webkit-scrollbar-thumb {
    background: var(--ac-border);
    border-radius: 4px;
}

/* ------ 말풍선 공통 ------ */
.ac-msg {
    max-width: 88%;
    font-size: 13px;
    line-height: 1.7;
    word-break: break-word;
    animation: ac-msg-in 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    font-family: var(--ac-font);
}
@keyframes ac-msg-in {
    from { opacity: 0; transform: translateY(6px); }
    to { opacity: 1; transform: translateY(0); }
}

/* 사용자 말풍선 (카카오톡 스타일 옐로우) */
.ac-msg.user {
    align-self: flex-end;
    background: #FEE500;
    color: #3C1E1E;
    padding: 11px 16px;
    border-radius: 14px 14px 4px 14px;
    font-weight: 400;
    box-shadow: 0 1px 3px rgba(254, 229, 0, 0.3);
}

/* AI 말풍선 */
.ac-msg.bot {
    align-self: flex-start;
    background: var(--ac-white);
    color: var(--ac-text);
    padding: 14px 16px;
    border-radius: 14px 14px 14px 4px;
    border: 1px solid var(--ac-border-light);
    box-shadow: var(--ac-shadow-sm);
}
.ac-msg.bot b,
.ac-msg.bot strong {
    font-weight: 600;
    color: var(--ac-primary);
}

/* 봇 말풍선 리스트 스타일 */
.ac-msg.bot ol,
.ac-msg.bot ul {
    margin: 8px 0;
    padding-left: 24px;
}
.ac-msg.bot ol.ac-list {
    list-style: none;
    padding-left: 0;
    counter-reset: ac-counter;
}
.ac-msg.bot ol.ac-list > li {
    counter-increment: ac-counter;
    margin-bottom: 12px;
    padding: 10px 12px;
    background: #f8fdf8;
    border-radius: 8px;
    border-left: 3px solid var(--ac-accent, #4CAF50);
}
.ac-msg.bot ol.ac-list > li::before {
    content: counter(ac-counter) ". ";
    font-weight: 700;
    color: var(--ac-accent, #4CAF50);
}
.ac-msg.bot ol.ac-list > li b {
    color: var(--ac-primary, #2D2D2D);
}
.ac-msg.bot li {
    margin-bottom: 6px;
}
.ac-msg.bot .ac-detail {
    padding-left: 16px;
    margin-top: 3px;
    font-size: 12.5px;
    color: #555;
    line-height: 1.6;
}

/* AI 일반 지식 안내 */
.ac-general-notice {
    margin-top: 10px;
    padding: 8px 10px;
    background: #fff8e1;
    border-radius: 6px;
    font-size: 11.5px;
    color: #8d6e00;
    line-height: 1.5;
    border-left: 3px solid #ffa726;
}
.ac-general-notice b {
    color: #e65100;
}

/* 공공데이터 안내 문구 */
.ac-data-notice {
    margin-top: 8px;
    padding: 8px 10px;
    background: #f0f7ff;
    border-radius: 6px;
    font-size: 11.5px;
    color: #556;
    line-height: 1.6;
    border-left: 3px solid #4a90d9;
}
.ac-data-notice b {
    color: #2c5282;
}
.ac-db-link {
    color: #2c5282;
    text-decoration: underline;
    text-decoration-style: dotted;
    cursor: pointer;
}
.ac-db-link:hover {
    color: #1a365d;
    text-decoration-style: solid;
}

/* 출처 뱃지 */
.ac-sources {
    margin-top: 10px;
    padding-top: 10px;
    border-top: 1px solid var(--ac-border-light);
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 4px;
}
.ac-sources-label {
    font-size: 11px;
    color: var(--ac-green);
    font-weight: 600;
    margin-right: 2px;
    cursor: pointer;
}
.ac-sources-label:hover {
    text-decoration: underline;
}
.ac-sources-link {
    color: #4a90d9;
    font-size: 12px;
}
.ac-sources-link:hover {
    color: #2c5282;
}

/* 데이터 소스 팝업 모달 */
.ac-modal-overlay {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.4);
    z-index: 10001;
    display: flex;
    align-items: center;
    justify-content: center;
}
.ac-modal-content {
    background: #fff;
    border-radius: 12px;
    width: 340px;
    max-height: 70vh;
    box-shadow: 0 8px 30px rgba(0,0,0,0.2);
    overflow: hidden;
}
.ac-modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 14px 16px;
    background: linear-gradient(135deg, #e8f5e9, #f0f7ff);
    border-bottom: 1px solid #e0e0e0;
    font-size: 14px;
}
.ac-modal-close {
    font-size: 22px;
    cursor: pointer;
    color: #999;
    line-height: 1;
}
.ac-modal-close:hover {
    color: #333;
}
.ac-modal-body {
    padding: 12px 16px;
    overflow-y: auto;
    max-height: calc(70vh - 50px);
    font-size: 12.5px;
}
.ac-ds-section {
    margin-top: 10px;
    margin-bottom: 6px;
    padding-bottom: 4px;
    border-bottom: 1px solid #eee;
    font-size: 13px;
}
.ac-ds-section:first-child {
    margin-top: 0;
}
.ac-ds-item {
    padding: 4px 0 4px 12px;
    color: #555;
    position: relative;
}
.ac-ds-item::before {
    content: "•";
    position: absolute;
    left: 0;
    color: #4CAF50;
}
.ac-ds-total {
    margin-top: 12px;
    padding: 8px 10px;
    background: #f8fdf8;
    border-radius: 6px;
    text-align: center;
    font-size: 12px;
    color: #4CAF50;
}
.ac-source-tag {
    display: inline-flex;
    align-items: center;
    gap: 3px;
    background: var(--ac-green-light);
    color: var(--ac-green);
    padding: 3px 9px;
    border-radius: 6px;
    font-size: 10.5px;
    font-weight: 500;
}
.ac-source-tag::before {
    content: '';
    width: 5px;
    height: 5px;
    background: var(--ac-green-badge);
    border-radius: 50%;
    flex-shrink: 0;
}

/* ------ 예시 질문 ------ */
.ac-suggestions {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-top: 10px;
}
.ac-suggest-btn {
    background: var(--ac-bg);
    border: 1px solid var(--ac-border);
    border-radius: 10px;
    padding: 9px 14px;
    font-size: 12.5px;
    color: var(--ac-text);
    cursor: pointer;
    text-align: left;
    transition: all 0.2s;
    font-family: var(--ac-font);
    font-weight: 400;
}
.ac-suggest-btn:hover {
    background: var(--ac-accent-light);
    border-color: var(--ac-accent);
    color: var(--ac-accent);
}

/* ------ 타이핑 인디케이터 ------ */
.ac-typing {
    align-self: flex-start;
    display: flex;
    align-items: center;
    gap: 5px;
    padding: 12px 18px;
    background: var(--ac-white);
    border-radius: 14px 14px 14px 4px;
    border: 1px solid var(--ac-border-light);
    box-shadow: var(--ac-shadow-sm);
}
.ac-typing-dot {
    width: 7px;
    height: 7px;
    background: var(--ac-text-light);
    border-radius: 50%;
    animation: ac-bounce 1.4s ease-in-out infinite;
}
.ac-typing-dot:nth-child(2) { animation-delay: 0.15s; }
.ac-typing-dot:nth-child(3) { animation-delay: 0.3s; }
@keyframes ac-bounce {
    0%, 80%, 100% { transform: scale(0.6); opacity: 0.3; }
    40% { transform: scale(1); opacity: 1; }
}

/* ------ 입력 영역 ------ */
.ac-input-area {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 14px;
    background: var(--ac-green-light);
    border-top: 1px solid #D1FAE5;
    flex-shrink: 0;
}
.ac-input {
    flex: 1;
    border: 1px solid var(--ac-border);
    border-radius: 22px;
    padding: 10px 16px;
    font-size: 13px;
    outline: none;
    background: var(--ac-bg);
    transition: all 0.2s;
    font-family: var(--ac-font);
    color: var(--ac-text);
}
.ac-input:focus {
    border-color: var(--ac-accent);
    background: var(--ac-white);
    box-shadow: 0 0 0 3px rgba(74, 144, 217, 0.08);
}
.ac-input::placeholder {
    color: var(--ac-text-light);
    font-size: 12.5px;
}
.ac-send-btn {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    background: #34D399;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    flex-shrink: 0;
    box-shadow: 0 2px 6px rgba(52, 211, 153, 0.25);
}
.ac-send-btn:hover {
    background: #6EE7B7;
    transform: scale(1.05);
}
.ac-send-btn:active {
    transform: scale(0.94);
}
.ac-send-btn:disabled {
    background: #D1D5DB;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}
.ac-send-btn svg {
    width: 16px;
    height: 16px;
    fill: #fff;
}

/* ------ News 탭 콘텐츠 ------ */
.ac-news-panel {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    background: var(--ac-bg);
}
.ac-news-item {
    background: var(--ac-white);
    border: 1px solid var(--ac-border-light);
    border-radius: 10px;
    padding: 14px 16px;
    margin-bottom: 10px;
    transition: box-shadow 0.2s;
}
.ac-news-item:hover {
    box-shadow: var(--ac-shadow-sm);
}
.ac-news-title {
    font-size: 13px;
    font-weight: 600;
    color: var(--ac-text);
    margin: 0 0 4px;
}
.ac-news-desc {
    font-size: 11.5px;
    color: var(--ac-text-secondary);
    margin: 0;
    line-height: 1.5;
}
.ac-news-tag {
    display: inline-block;
    margin-top: 8px;
    font-size: 10px;
    font-weight: 600;
    color: var(--ac-green);
    background: var(--ac-green-light);
    padding: 2px 8px;
    border-radius: 4px;
}

/* ------ 모바일 반응형 ------ */
@media (max-width: 480px) {
    .ac-modal {
        bottom: 0;
        right: 0;
        left: 0;
        width: 100%;
        height: 100vh;
        height: 100dvh;
        border-radius: 0;
        border: none;
    }
    .ac-fab {
        bottom: 16px;
        right: 16px;
        width: 52px;
        height: 52px;
    }
}
