/* ===== RESET & BASE ===== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
    --primary: #162A4D;
    --primary-light: #1e3a6b;
    --accent: #f07a1f;
    --accent-hover: #e06810;
    --accent-glow: rgba(240, 122, 31, 0.25);
    --bg: #0f1117;
    --bg-card: #181b24;
    --bg-surface: #1f2230;
    --bg-input: #13151c;
    --bg-chat: #111318;
    --text: #e4e6ed;
    --text-muted: #8b8fa5;
    --text-heading: #ffffff;
    --border: #2a2d3a;
    --border-focus: #f07a1f;
    --success: #22c55e;
    --user-bubble: #f07a1f;
    --user-bubble-text: #ffffff;
    --ai-bubble: #1f2230;
    --ai-bubble-text: #e4e6ed;
    --radius: 14px;
    --radius-lg: 20px;
    --font: 'Inter', system-ui, -apple-system, sans-serif;
    --shadow: 0 8px 32px rgba(0, 0, 0, 0.35);
    --shadow-lg: 0 16px 48px rgba(0, 0, 0, 0.5);
    --transition: 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

body {
    background: var(--bg);
    font-family: var(--font);
    color: var(--text);
    line-height: 1.6;
    min-height: 100vh;
    padding: 24px 16px;
    -webkit-font-smoothing: antialiased;
}

/* ===== CONTAINER ===== */
.container {
    max-width: 820px;
    margin: 0 auto;
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    border: 1px solid var(--border);
    box-shadow: var(--shadow-lg);
    overflow: hidden;
    animation: fadeUp 0.6s ease-out;
}

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

/* ===== HEADER ===== */
header {
    text-align: center;
    padding: 40px 28px 30px;
    background: linear-gradient(145deg, #0d1424, #162A4D 50%, #1e3a6b);
    position: relative;
    overflow: hidden;
}

header::before {
    content: '';
    position: absolute;
    top: -60%;
    left: -20%;
    width: 140%;
    height: 140%;
    background: radial-gradient(ellipse at 60% 20%, rgba(240, 122, 31, 0.12) 0%, transparent 60%);
    pointer-events: none;
}

.header-badge {
    display: inline-block;
    background: rgba(240, 122, 31, 0.15);
    color: var(--accent);
    font-size: 13px;
    font-weight: 600;
    padding: 6px 16px;
    border-radius: 100px;
    border: 1px solid rgba(240, 122, 31, 0.3);
    margin-bottom: 14px;
    letter-spacing: 0.5px;
}

header h1 {
    font-size: clamp(1.6rem, 5vw, 2.2rem);
    font-weight: 800;
    color: var(--text-heading);
    line-height: 1.2;
    margin-bottom: 8px;
    letter-spacing: -0.5px;
}

.header-subtitle {
    color: rgba(255, 255, 255, 0.55);
    font-size: 14px;
    font-weight: 400;
}

/* ===== CHAT CONTAINER ===== */
.chat-container {
    display: flex;
    flex-direction: column;
    height: 520px;
    position: relative;
    border-bottom: 1px solid var(--border);
}

/* ===== CHAT HISTORY ===== */
.chat-history {
    flex: 1;
    overflow-y: auto;
    padding: 24px 20px;
    background: var(--bg-chat);
    display: flex;
    flex-direction: column;
    gap: 20px;
    scroll-behavior: smooth;
}

/* Custom scrollbar */
.chat-history::-webkit-scrollbar {
    width: 6px;
}
.chat-history::-webkit-scrollbar-track {
    background: transparent;
}
.chat-history::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 3px;
}
.chat-history::-webkit-scrollbar-thumb:hover {
    background: var(--text-muted);
}

/* ===== MESSAGE BUBBLES ===== */
.message {
    display: flex;
    gap: 10px;
    max-width: 85%;
    animation: messageIn 0.3s ease-out;
}

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

/* AI messages: left-aligned */
.ai-message {
    align-self: flex-start;
}

/* User messages: right-aligned, reversed layout */
.user-message {
    align-self: flex-end;
    flex-direction: row-reverse;
}

.message-avatar {
    width: 34px;
    height: 34px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    flex-shrink: 0;
    background: var(--bg-surface);
    border: 1px solid var(--border);
}

.message-avatar.small {
    width: 28px;
    height: 28px;
    font-size: 14px;
}

.user-message .message-avatar {
    background: rgba(240, 122, 31, 0.15);
    border-color: rgba(240, 122, 31, 0.3);
}

.message-content {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

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

.message-bubble {
    padding: 12px 16px;
    border-radius: 14px;
    font-size: 14px;
    line-height: 1.65;
    white-space: pre-wrap;
    word-wrap: break-word;
}

/* AI bubble styling */
.ai-message .message-bubble {
    background: var(--ai-bubble);
    color: var(--ai-bubble-text);
    border: 1px solid var(--border);
    border-bottom-left-radius: 4px;
}

/* User bubble styling */
.user-message .message-bubble {
    background: linear-gradient(135deg, var(--user-bubble), var(--accent-hover));
    color: var(--user-bubble-text);
    border-bottom-right-radius: 4px;
}

.message-time {
    font-size: 11px;
    color: var(--text-muted);
    opacity: 0.6;
    padding: 0 4px;
}

/* ===== TYPING INDICATOR ===== */
.typing-indicator {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 0 20px 16px;
    position: absolute;
    bottom: 80px;
    left: 0;
}

.typing-dots {
    display: flex;
    gap: 4px;
    padding: 10px 16px;
    background: var(--ai-bubble);
    border: 1px solid var(--border);
    border-radius: 14px;
    border-bottom-left-radius: 4px;
}

.typing-dots span {
    width: 7px;
    height: 7px;
    background: var(--text-muted);
    border-radius: 50%;
    animation: typingBounce 1.4s ease-in-out infinite;
}

.typing-dots span:nth-child(2) { animation-delay: 0.2s; }
.typing-dots span:nth-child(3) { animation-delay: 0.4s; }

@keyframes typingBounce {
    0%, 60%, 100% { transform: translateY(0); opacity: 0.4; }
    30% { transform: translateY(-5px); opacity: 1; }
}

/* ===== CHAT INPUT AREA ===== */
.chat-input-area {
    padding: 16px 20px 12px;
    background: var(--bg-card);
    border-top: 1px solid var(--border);
}

.input-wrapper {
    display: flex;
    align-items: flex-end;
    gap: 10px;
    background: var(--bg-input);
    border: 1.5px solid var(--border);
    border-radius: 14px;
    padding: 6px 6px 6px 16px;
    transition: border-color var(--transition), box-shadow var(--transition);
}

.input-wrapper:focus-within {
    border-color: var(--border-focus);
    box-shadow: 0 0 0 3px var(--accent-glow);
}

.input-wrapper textarea {
    flex: 1;
    border: none;
    background: transparent;
    color: var(--text);
    font-family: var(--font);
    font-size: 14px;
    line-height: 1.5;
    padding: 10px 0;
    resize: none;
    max-height: 120px;
    overflow-y: auto;
}

.input-wrapper textarea::placeholder {
    color: var(--text-muted);
}

.input-wrapper textarea:focus {
    outline: none;
}

#sendBtn {
    width: 40px;
    height: 40px;
    min-width: 40px;
    border: none;
    border-radius: 10px;
    background: linear-gradient(135deg, var(--accent), var(--accent-hover));
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform var(--transition), box-shadow var(--transition), opacity var(--transition);
}

#sendBtn:hover:not(:disabled) {
    transform: scale(1.05);
    box-shadow: 0 4px 16px var(--accent-glow);
}

#sendBtn:active:not(:disabled) {
    transform: scale(0.95);
}

#sendBtn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.input-hint {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 6px 4px 0;
}

#charCount {
    font-size: 11px;
    color: var(--text-muted);
    opacity: 0.6;
}

.hint-shortcut {
    font-size: 11px;
    color: var(--text-muted);
    opacity: 0.5;
}

/* ===== HIDDEN ===== */
.hidden { display: none !important; }

/* ===== TOAST ===== */
.toast {
    position: fixed;
    bottom: 32px;
    left: 50%;
    transform: translateX(-50%) translateY(100px);
    background: var(--bg-surface);
    color: var(--text);
    border: 1px solid var(--border);
    padding: 12px 24px;
    border-radius: 10px;
    font-family: var(--font);
    font-size: 14px;
    font-weight: 500;
    box-shadow: var(--shadow);
    z-index: 9999;
    opacity: 0;
    pointer-events: none;
    transition: transform 0.4s cubic-bezier(0.4, 0, 0.2, 1), opacity 0.4s ease;
}

.toast.show {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
    pointer-events: auto;
}

/* ===== COPY BUTTON INSIDE BUBBLES ===== */
.copy-msg-btn {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    margin-top: 8px;
    background: rgba(255, 255, 255, 0.06);
    color: var(--text-muted);
    border: 1px solid var(--border);
    padding: 5px 10px;
    font-family: var(--font);
    font-size: 11px;
    font-weight: 500;
    border-radius: 6px;
    cursor: pointer;
    transition: all var(--transition);
}

.copy-msg-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    color: var(--accent);
    border-color: var(--accent);
}

/* ===== SEO CONTENT ===== */
.seo-content {
    padding: 40px 28px;
    border-top: 1px solid var(--border);
}

.seo-content h2 {
    font-size: 22px;
    font-weight: 700;
    color: var(--text-heading);
    margin-bottom: 16px;
}

.seo-content h3 {
    font-size: 17px;
    font-weight: 600;
    color: var(--text-heading);
    margin-top: 28px;
    margin-bottom: 10px;
}

.seo-content p {
    color: var(--text-muted);
    font-size: 15px;
    margin-bottom: 12px;
    line-height: 1.7;
}

.seo-content ul, .seo-content ol {
    padding-left: 20px;
    margin-bottom: 14px;
}

.seo-content li {
    color: var(--text-muted);
    font-size: 15px;
    margin-bottom: 8px;
    line-height: 1.6;
}

.seo-content strong {
    color: var(--text);
}

/* ===== FOOTER ===== */
footer {
    text-align: center;
    padding: 24px 28px;
    border-top: 1px solid var(--border);
}

.footer-links {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 6px;
    margin-bottom: 10px;
}

.footer-links a {
    color: var(--text-muted);
    text-decoration: none;
    font-size: 13px;
    font-weight: 500;
    padding: 4px 8px;
    border-radius: 6px;
    transition: color var(--transition), background var(--transition);
}

.footer-links a:hover {
    color: var(--accent);
    background: rgba(240, 122, 31, 0.08);
}

.footer-divider {
    color: var(--border);
    font-size: 14px;
}

.footer-copy {
    color: var(--text-muted);
    font-size: 12px;
    opacity: 0.6;
}

/* ===== RESPONSIVE ===== */
@media (max-width: 640px) {
    body { padding: 12px 8px; }
    header { padding: 32px 20px 24px; }
    .chat-container { height: 450px; }
    .chat-history { padding: 16px 12px; }
    .message { max-width: 90%; }
    .chat-input-area { padding: 12px; }
    .seo-content { padding: 28px 18px; }
    .input-hint { flex-direction: column; align-items: flex-start; gap: 2px; }
    .hint-shortcut { display: none; }
}
