/* ============================================
   AWS Bedrock Chat - 디자인 개편 (기능 동일)
   ============================================ */

:root {
    /* 색상 토큰 */
    --bg-app: #0f1117;
    --bg-app-grad-1: #141829;
    --bg-app-grad-2: #0b0d14;
    --surface: #171a24;
    --surface-2: #1f2330;
    --surface-3: #262b3a;
    --border: #2a2f3e;
    --border-strong: #363c4e;

    --text: #e7eaf3;
    --text-muted: #9aa3b8;
    --text-faint: #6b7389;

    --accent: #6366f1;
    --accent-2: #8b5cf6;
    --accent-hover: #7c7ff5;
    --accent-soft: rgba(99, 102, 241, 0.14);

    --user-bubble-1: #6366f1;
    --user-bubble-2: #8b5cf6;
    --ai-bubble: #1f2330;

    --success: #22c55e;
    --danger: #f87171;
    --danger-bg: rgba(248, 113, 113, 0.12);

    --radius-sm: 10px;
    --radius: 16px;
    --radius-lg: 22px;
    --radius-pill: 999px;

    --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.25);
    --shadow: 0 18px 50px rgba(0, 0, 0, 0.45);

    --gradient-accent: linear-gradient(135deg, var(--accent) 0%, var(--accent-2) 100%);
}

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

html {
    scroll-behavior: smooth;
}

body {
    font-family: 'Pretendard', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Apple SD Gothic Neo', 'Noto Sans KR', sans-serif;
    color: var(--text);
    background:
        radial-gradient(1200px 600px at 80% -10%, rgba(139, 92, 246, 0.18), transparent 60%),
        radial-gradient(1000px 500px at -10% 0%, rgba(99, 102, 241, 0.16), transparent 55%),
        linear-gradient(160deg, var(--bg-app-grad-1) 0%, var(--bg-app) 50%, var(--bg-app-grad-2) 100%);
    background-attachment: fixed;
    min-height: 100vh;
    padding: 32px 20px;
    -webkit-font-smoothing: antialiased;
    text-rendering: optimizeLegibility;
}

/* ============================================
   컨테이너 / 헤더
   ============================================ */
.container {
    max-width: 1120px;
    margin: 0 auto;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
    overflow: hidden;
    backdrop-filter: blur(12px);
}

header {
    position: relative;
    background:
        radial-gradient(600px 220px at 20% 0%, rgba(255, 255, 255, 0.10), transparent 70%),
        var(--gradient-accent);
    color: #fff;
    padding: 36px 36px 34px;
    overflow: hidden;
}

header::after {
    content: "";
    position: absolute;
    inset: 0;
    background-image: radial-gradient(rgba(255, 255, 255, 0.12) 1px, transparent 1px);
    background-size: 22px 22px;
    opacity: 0.4;
    pointer-events: none;
}

/* 로고 + 타이틀 레이아웃 */
.header-brand {
    position: relative;
    z-index: 1;
    display: flex;
    align-items: center;
    gap: 22px;
    max-width: 760px;
    margin: 0 auto;
}

/* 로고 배지 - 그라데이션 위에서 로고가 또렷하게 보이도록 흰색 배경 */
.brand-logo {
    flex: 0 0 auto;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 96px;
    height: 96px;
    background: #fff;
    border-radius: 22px;
    box-shadow: 0 10px 28px rgba(0, 0, 0, 0.25);
    overflow: hidden;
}

/* 어떤 비율의 이미지든 배지 안에 깨지지 않게 맞춤 */
.brand-logo img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    padding: 12px;
}

.brand-text {
    min-width: 0;
}

header h1 {
    font-size: 2.3em;
    font-weight: 800;
    letter-spacing: -0.02em;
    margin-bottom: 8px;
    text-shadow: 0 2px 12px rgba(0, 0, 0, 0.2);
}

header p {
    opacity: 0.92;
    font-size: 1.02em;
    font-weight: 400;
}

/* ============================================
   탭
   ============================================ */
.tabs {
    display: flex;
    gap: 6px;
    padding: 12px 16px 0;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
}

.tab-button {
    flex: 1;
    padding: 14px 18px;
    background: transparent;
    border: none;
    border-radius: var(--radius-sm) var(--radius-sm) 0 0;
    cursor: pointer;
    font-size: 0.98em;
    font-weight: 600;
    color: var(--text-muted);
    transition: color 0.2s, background 0.2s;
    position: relative;
}

.tab-button::after {
    content: "";
    position: absolute;
    left: 16px;
    right: 16px;
    bottom: -1px;
    height: 3px;
    border-radius: 3px;
    background: var(--gradient-accent);
    transform: scaleX(0);
    transition: transform 0.25s ease;
}

.tab-button:hover {
    color: var(--text);
    background: var(--surface-2);
}

.tab-button.active {
    color: var(--text);
    background: var(--surface-2);
}

.tab-button.active::after {
    transform: scaleX(1);
}

.tab-content {
    display: none;
    padding: 32px;
    min-height: 520px;
    animation: fadeIn 0.3s ease;
}

.tab-content.active {
    display: block;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(6px); }
    to { opacity: 1; transform: translateY(0); }
}

/* ============================================
   채팅
   ============================================ */
.chat-container {
    display: flex;
    flex-direction: column;
    height: 620px;
}

.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 22px;
    background: var(--bg-app);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    margin-bottom: 18px;
    display: flex;
    flex-direction: column;
    gap: 14px;
}

/* 스크롤바 */
.chat-messages::-webkit-scrollbar,
.multimodal-response::-webkit-scrollbar,
.web-response::-webkit-scrollbar {
    width: 10px;
}
.chat-messages::-webkit-scrollbar-thumb,
.multimodal-response::-webkit-scrollbar-thumb,
.web-response::-webkit-scrollbar-thumb {
    background: var(--border-strong);
    border-radius: 10px;
}
.chat-messages::-webkit-scrollbar-track,
.multimodal-response::-webkit-scrollbar-track,
.web-response::-webkit-scrollbar-track {
    background: transparent;
}

.message {
    margin: 0;
    padding: 14px 18px;
    border-radius: 18px;
    max-width: 78%;
    word-wrap: break-word;
    box-shadow: var(--shadow-sm);
    animation: popIn 0.22s ease;
}

@keyframes popIn {
    from { opacity: 0; transform: translateY(8px) scale(0.98); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}

.message.user {
    align-self: flex-end;
    background: var(--gradient-accent);
    color: #fff;
    text-align: left;
    border-bottom-right-radius: 6px;
}

.message.assistant {
    align-self: flex-start;
    background: var(--ai-bubble);
    border: 1px solid var(--border);
    color: var(--text);
    border-bottom-left-radius: 6px;
}

.message.loading {
    align-self: flex-start;
    color: var(--text-muted);
    font-style: italic;
    background: var(--surface-2);
    border: 1px solid var(--border);
}

.message.error {
    align-self: flex-start;
    background: var(--danger-bg);
    color: var(--danger);
    border: 1px solid rgba(248, 113, 113, 0.3);
}

.message-header {
    font-weight: 700;
    margin-bottom: 6px;
    font-size: 0.82em;
    opacity: 0.85;
    letter-spacing: 0.01em;
}

.message-content {
    line-height: 1.65;
    font-size: 0.98em;
}

.usage-info {
    font-size: 0.8em;
    color: var(--text-muted);
    margin-top: 10px;
    padding-top: 8px;
    border-top: 1px solid var(--border);
}

.message.user .usage-info {
    color: rgba(255, 255, 255, 0.85);
    border-top-color: rgba(255, 255, 255, 0.25);
}

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

.chat-input-container input {
    flex: 1;
    padding: 14px 20px;
    background: var(--surface-2);
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-pill);
    font-size: 1em;
    color: var(--text);
    outline: none;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.chat-input-container input::placeholder {
    color: var(--text-faint);
}

.chat-input-container input:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 4px var(--accent-soft);
}

.chat-input-container button {
    padding: 14px 26px;
    background: var(--gradient-accent);
    color: #fff;
    border: none;
    border-radius: var(--radius-pill);
    cursor: pointer;
    font-weight: 700;
    font-size: 0.95em;
    transition: transform 0.12s, box-shadow 0.2s, filter 0.2s;
    box-shadow: 0 6px 18px rgba(99, 102, 241, 0.35);
}

.chat-input-container button:hover {
    filter: brightness(1.08);
    box-shadow: 0 8px 22px rgba(99, 102, 241, 0.45);
}

.chat-input-container button:active {
    transform: scale(0.97);
}

/* 두 번째 버튼(초기화)은 보조 스타일 */
.chat-input-container button#chat-clear-btn {
    background: var(--surface-2);
    color: var(--text-muted);
    border: 1px solid var(--border-strong);
    box-shadow: none;
}

.chat-input-container button#chat-clear-btn:hover {
    background: var(--surface-3);
    color: var(--text);
    filter: none;
}

/* ============================================
   멀티모달
   ============================================ */
.multimodal-container {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 22px;
}

.input-section {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.input-section textarea {
    padding: 14px 16px;
    background: var(--surface-2);
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-sm);
    font-size: 1em;
    font-family: inherit;
    color: var(--text);
    resize: vertical;
    outline: none;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.input-section textarea::placeholder {
    color: var(--text-faint);
}

.input-section textarea:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 4px var(--accent-soft);
}

.file-upload-section {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.file-label {
    padding: 16px;
    background: var(--surface-2);
    border: 1.5px dashed var(--border-strong);
    border-radius: var(--radius-sm);
    cursor: pointer;
    text-align: center;
    font-weight: 600;
    color: var(--accent-hover);
    transition: background 0.2s, border-color 0.2s, color 0.2s;
}

.file-label:hover {
    background: var(--accent-soft);
    border-color: var(--accent);
    color: var(--text);
}

.file-upload-section input[type="file"] {
    display: none;
}

.image-preview {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-top: 4px;
}

.image-preview-item {
    position: relative;
    width: 100px;
    height: 100px;
    border-radius: var(--radius-sm);
    overflow: hidden;
    border: 1px solid var(--border-strong);
}

.image-preview-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.image-preview-item .remove-btn {
    position: absolute;
    top: 5px;
    right: 5px;
    background: rgba(15, 17, 23, 0.75);
    color: #fff;
    border: 1px solid rgba(255, 255, 255, 0.25);
    border-radius: 50%;
    width: 24px;
    height: 24px;
    cursor: pointer;
    font-size: 15px;
    line-height: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
}

.image-preview-item .remove-btn:hover {
    background: var(--danger);
}

.button-group {
    display: flex;
    gap: 10px;
}

.button-group button {
    flex: 1;
    padding: 14px;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 1em;
    font-weight: 700;
    cursor: pointer;
    transition: transform 0.12s, filter 0.2s, background 0.2s;
}

.button-group button:first-child {
    background: var(--gradient-accent);
    color: #fff;
    box-shadow: 0 6px 18px rgba(99, 102, 241, 0.35);
}

.button-group button:first-child:hover {
    filter: brightness(1.08);
}

.button-group button:first-child:active {
    transform: scale(0.98);
}

.button-group button:last-child {
    background: var(--surface-2);
    color: var(--text-muted);
    border: 1px solid var(--border-strong);
}

.button-group button:last-child:hover {
    background: var(--surface-3);
    color: var(--text);
}

.multimodal-response {
    padding: 22px;
    background: var(--bg-app);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    max-height: 520px;
    overflow-y: auto;
    line-height: 1.7;
    color: var(--text);
}

/* ============================================
   웹 요약
   ============================================ */
.web-container {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.web-container .input-section {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.web-container input[type="url"] {
    padding: 14px 16px;
    background: var(--surface-2);
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-sm);
    font-size: 1em;
    color: var(--text);
    outline: none;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.web-container input[type="url"]::placeholder {
    color: var(--text-faint);
}

.web-container input[type="url"]:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 4px var(--accent-soft);
}

.web-container button {
    align-self: flex-start;
    padding: 14px 30px;
    background: var(--gradient-accent);
    color: #fff;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 1em;
    font-weight: 700;
    cursor: pointer;
    transition: transform 0.12s, filter 0.2s;
    box-shadow: 0 6px 18px rgba(99, 102, 241, 0.35);
}

.web-container button:hover {
    filter: brightness(1.08);
}

.web-container button:active {
    transform: scale(0.98);
}

.web-response {
    padding: 22px;
    background: var(--bg-app);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    line-height: 1.8;
    color: var(--text);
    min-height: 120px;
}

/* ============================================
   공통 상태
   ============================================ */
.loading {
    text-align: center;
    padding: 24px;
    color: var(--text-muted);
}

.error {
    background: var(--danger-bg);
    color: var(--danger);
    padding: 16px;
    border-radius: var(--radius-sm);
    border-left: 4px solid var(--danger);
}

/* ============================================
   푸터
   ============================================ */
footer {
    background: var(--surface);
    border-top: 1px solid var(--border);
    padding: 22px;
    text-align: center;
    color: var(--text-faint);
    font-size: 0.88em;
}

/* ============================================
   반응형
   ============================================ */
@media (max-width: 768px) {
    body {
        padding: 16px 12px;
    }

    .header-brand {
        flex-direction: column;
        text-align: center;
        gap: 16px;
    }

    .brand-logo {
        width: 80px;
        height: 80px;
    }

    .multimodal-container {
        grid-template-columns: 1fr;
    }

    .message {
        max-width: 90%;
    }

    header {
        padding: 32px 20px 28px;
    }

    header h1 {
        font-size: 1.9em;
    }

    .tab-content {
        padding: 20px;
    }

    .chat-input-container {
        flex-wrap: wrap;
    }

    .chat-input-container input {
        flex: 1 1 100%;
    }

    .chat-input-container button {
        flex: 1;
    }
}
