/* ╔═══════════════════════════════════════════════════════════════════╗
   ║  N Digital Hub AI Assistant — Stylesheet                            ║
   ║  WhatsApp-style multi-bubble replies, responsive, dark mode.         ║
   ╚═══════════════════════════════════════════════════════════════════╝ */

:root {
    /* Light theme (default) */
    --bg:            #f1f5f9;
    --bg-elev:       #ffffff;
    --bg-soft:       #f8fafc;
    --sidebar-bg:    #0f172a;
    --sidebar-text:  #e2e8f0;
    --sidebar-muted: #94a3b8;
    --text:          #0f172a;
    --text-muted:    #64748b;
    --border:        #e2e8f0;
    --accent:        #0ea5e9;
    --accent-dark:   #0284c7;
    --accent-soft:   #e0f2fe;
    --user-bubble:   #dcfce7;
    --user-bubble-text: #064e3b;
    --assistant-bubble: #ffffff;
    --assistant-bubble-text: #0f172a;
    --shadow-sm:     0 1px 2px rgba(15,23,42,0.06);
    --shadow-md:     0 4px 12px rgba(15,23,42,0.08);
    --shadow-lg:     0 10px 30px rgba(15,23,42,0.12);
    --radius:        14px;
    --radius-sm:     8px;
}

[data-theme="dark"] {
    --bg:            #0b1220;
    --bg-elev:       #111827;
    --bg-soft:       #0f172a;
    --sidebar-bg:    #050a14;
    --sidebar-text:  #e2e8f0;
    --sidebar-muted: #64748b;
    --text:          #f1f5f9;
    --text-muted:    #94a3b8;
    --border:        #1f2937;
    --accent:        #38bdf8;
    --accent-dark:   #0ea5e9;
    --accent-soft:   #0c4a6e;
    --user-bubble:   #064e3b;
    --user-bubble-text: #d1fae5;
    --assistant-bubble: #1e293b;
    --assistant-bubble-text: #f1f5f9;
    --shadow-sm:     0 1px 2px rgba(0,0,0,0.3);
    --shadow-md:     0 4px 12px rgba(0,0,0,0.4);
    --shadow-lg:     0 10px 30px rgba(0,0,0,0.5);
}

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

html, body {
    height: 100%;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    background: var(--bg);
    color: var(--text);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    overflow: hidden;
}

button {
    font-family: inherit;
    cursor: pointer;
    border: none;
    background: none;
    color: inherit;
}

textarea, input {
    font-family: inherit;
    color: inherit;
}

/* ═══════════════ LAYOUT ═══════════════ */
.app {
    display: flex;
    height: 100vh;
    height: 100dvh;
    width: 100vw;
    overflow: hidden;
}

/* ═══════════════ SIDEBAR ═══════════════ */
.sidebar {
    width: 280px;
    flex-shrink: 0;
    background: var(--sidebar-bg);
    color: var(--sidebar-text);
    display: flex;
    flex-direction: column;
    transition: transform 0.25s ease;
    z-index: 30;
}

.sidebar-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 18px;
    border-bottom: 1px solid rgba(255,255,255,0.06);
}

.brand {
    display: flex;
    align-items: center;
    gap: 10px;
}

.brand-logo {
    width: 36px;
    height: 36px;
    border-radius: 10px;
    background: linear-gradient(135deg, #0ea5e9, #0284c7);
    color: white;
    font-weight: 800;
    font-size: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 8px rgba(14,165,233,0.4);
}

.brand-name {
    font-weight: 700;
    font-size: 15px;
    line-height: 1.2;
}

.brand-sub {
    font-size: 11px;
    color: var(--sidebar-muted);
    text-transform: uppercase;
    letter-spacing: 0.06em;
}

.icon-btn {
    width: 34px;
    height: 34px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    color: var(--sidebar-text);
    transition: background 0.15s;
}
.icon-btn:hover { background: rgba(255,255,255,0.08); }

.new-chat-btn {
    margin: 12px 14px;
    padding: 12px 14px;
    border-radius: 10px;
    background: var(--accent);
    color: white;
    font-weight: 600;
    font-size: 14px;
    display: flex;
    align-items: center;
    gap: 10px;
    transition: background 0.15s, transform 0.1s;
    box-shadow: 0 2px 8px rgba(14,165,233,0.3);
}
.new-chat-btn:hover { background: var(--accent-dark); }
.new-chat-btn:active { transform: scale(0.98); }
.new-chat-btn .plus { font-size: 20px; font-weight: 300; }

.conversation-list {
    flex: 1;
    overflow-y: auto;
    padding: 4px 8px 8px;
}

.conv-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    border-radius: 8px;
    cursor: pointer;
    color: var(--sidebar-text);
    font-size: 13.5px;
    transition: background 0.15s;
    position: relative;
    margin-bottom: 2px;
}
.conv-item:hover { background: rgba(255,255,255,0.06); }
.conv-item.active { background: rgba(14,165,233,0.18); }
.conv-item .conv-title {
    flex: 1;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.conv-item .conv-del {
    opacity: 0;
    background: rgba(239,68,68,0.15);
    color: #fca5a5;
    width: 26px;
    height: 26px;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    transition: opacity 0.15s;
}
.conv-item:hover .conv-del { opacity: 1; }
.conv-item .conv-del:hover { background: rgba(239,68,68,0.3); }

.sidebar-footer {
    padding: 12px 14px;
    border-top: 1px solid rgba(255,255,255,0.06);
}

.founder-card {
    background: rgba(255,255,255,0.04);
    border-radius: 10px;
    padding: 10px 12px;
    margin-bottom: 8px;
}

.founder-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 12px;
    padding: 3px 0;
}
.founder-label { color: var(--sidebar-muted); }
.founder-name { font-weight: 600; color: var(--sidebar-text); }
.founder-award {
    font-size: 10px;
    color: #fcd34d;
    background: rgba(252,211,77,0.12);
    padding: 2px 6px;
    border-radius: 4px;
    font-weight: 600;
}

.visit-link {
    display: block;
    text-align: center;
    color: var(--accent);
    font-size: 13px;
    font-weight: 600;
    padding: 8px;
    text-decoration: none;
    border-radius: 6px;
    transition: background 0.15s;
}
.visit-link:hover { background: rgba(14,165,233,0.1); }

/* ═══════════════ MAIN ═══════════════ */
.main {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
    background: var(--bg);
}

.topbar {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 18px;
    background: var(--bg-elev);
    border-bottom: 1px solid var(--border);
    box-shadow: var(--shadow-sm);
}

.menu-btn, .theme-btn {
    color: var(--text);
    background: var(--bg-soft);
}
.menu-btn { display: none; }

.topbar-title {
    flex: 1;
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 600;
    font-size: 15px;
}

.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #22c55e;
    box-shadow: 0 0 8px rgba(34,197,94,0.5);
    animation: pulse 2s infinite;
}
@keyframes pulse {
    0%, 100% { opacity: 1; }
    50%      { opacity: 0.5; }
}

.chat-area {
    flex: 1;
    overflow-y: auto;
    padding: 24px 16px;
    scroll-behavior: smooth;
}

/* ═══════════════ WELCOME ═══════════════ */
.welcome {
    max-width: 720px;
    margin: 0 auto;
    padding: 32px 16px;
    text-align: center;
    animation: fadeIn 0.4s ease;
}
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(8px); }
    to   { opacity: 1; transform: translateY(0); }
}

.welcome-logo {
    width: 72px;
    height: 72px;
    border-radius: 20px;
    background: linear-gradient(135deg, #0ea5e9, #0284c7);
    color: white;
    font-weight: 800;
    font-size: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 20px;
    box-shadow: 0 8px 24px rgba(14,165,233,0.35);
}

.welcome h1 {
    font-size: 26px;
    font-weight: 700;
    margin-bottom: 10px;
    color: var(--text);
    line-height: 1.25;
}

.welcome-tagline {
    font-size: 15px;
    color: var(--text-muted);
    line-height: 1.55;
    margin-bottom: 32px;
    max-width: 540px;
    margin-left: auto;
    margin-right: auto;
}

.suggestions {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
    max-width: 620px;
    margin: 0 auto;
}

.suggestion {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 16px;
    background: var(--bg-elev);
    border: 1px solid var(--border);
    border-radius: 12px;
    text-align: left;
    transition: all 0.15s;
    box-shadow: var(--shadow-sm);
}
.suggestion:hover {
    border-color: var(--accent);
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.sug-icon {
    font-size: 22px;
    flex-shrink: 0;
}

.sug-text {
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
}
.sug-text strong {
    font-size: 14px;
    font-weight: 600;
    color: var(--text);
}
.sug-text small {
    font-size: 12px;
    color: var(--text-muted);
}

/* ═══════════════ MESSAGES ═══════════════ */
.messages {
    max-width: 760px;
    margin: 0 auto;
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.msg-row {
    display: flex;
    gap: 10px;
    align-items: flex-end;
    animation: msgIn 0.25s ease;
}
@keyframes msgIn {
    from { opacity: 0; transform: translateY(6px); }
    to   { opacity: 1; transform: translateY(0); }
}

.msg-row.user { flex-direction: row-reverse; }

.msg-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 14px;
    color: white;
}
.msg-row.user .msg-avatar {
    background: #16a34a;
}
.msg-row.assistant .msg-avatar {
    background: linear-gradient(135deg, #0ea5e9, #0284c7);
}

.msg-bubble {
    max-width: 78%;
    padding: 11px 15px;
    border-radius: 16px;
    line-height: 1.5;
    font-size: 14.5px;
    word-wrap: break-word;
    overflow-wrap: break-word;
    box-shadow: var(--shadow-sm);
    position: relative;
}

.msg-row.user .msg-bubble {
    background: var(--user-bubble);
    color: var(--user-bubble-text);
    border-bottom-right-radius: 4px;
}
.msg-row.assistant .msg-bubble {
    background: var(--assistant-bubble);
    color: var(--assistant-bubble-text);
    border-bottom-left-radius: 4px;
    border: 1px solid var(--border);
}

/* Adjacent assistant bubbles (multi-message replies) group together */
.msg-row.assistant + .msg-row.assistant .msg-bubble {
    border-top-left-radius: 4px;
    margin-top: -8px;
}

.msg-bubble p { margin-bottom: 6px; }
.msg-bubble p:last-child { margin-bottom: 0; }
.msg-bubble strong { font-weight: 700; }
.msg-bubble em { font-style: italic; }
.msg-bubble ul, .msg-bubble ol {
    margin: 6px 0 6px 18px;
    padding: 0;
}
.msg-bubble li { margin-bottom: 2px; }
.msg-bubble a {
    color: var(--accent);
    text-decoration: underline;
    font-weight: 600;
}
.msg-bubble code {
    background: rgba(15,23,42,0.08);
    padding: 1px 5px;
    border-radius: 4px;
    font-family: "SF Mono", Monaco, "Courier New", monospace;
    font-size: 13px;
}
[data-theme="dark"] .msg-bubble code {
    background: rgba(255,255,255,0.08);
}

/* ═══════════════ TYPING INDICATOR ═══════════════ */
.typing-row {
    display: flex;
    gap: 10px;
    align-items: flex-end;
}

.typing-bubble {
    background: var(--assistant-bubble);
    border: 1px solid var(--border);
    border-radius: 16px;
    border-bottom-left-radius: 4px;
    padding: 14px 16px;
    display: flex;
    gap: 5px;
    box-shadow: var(--shadow-sm);
}

.typing-dot {
    width: 7px;
    height: 7px;
    background: var(--text-muted);
    border-radius: 50%;
    animation: typingBounce 1.3s infinite ease-in-out;
}
.typing-dot:nth-child(2) { animation-delay: 0.15s; }
.typing-dot:nth-child(3) { animation-delay: 0.3s; }

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

/* ═══════════════ COMPOSER ═══════════════ */
.composer {
    background: var(--bg-elev);
    border-top: 1px solid var(--border);
    padding: 12px 16px 14px;
}

.composer-inner {
    max-width: 760px;
    margin: 0 auto;
    display: flex;
    align-items: flex-end;
    gap: 10px;
    background: var(--bg-soft);
    border: 1px solid var(--border);
    border-radius: 20px;
    padding: 8px 8px 8px 16px;
    transition: border-color 0.15s, box-shadow 0.15s;
}
.composer-inner:focus-within {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-soft);
}

.message-input {
    flex: 1;
    border: none;
    outline: none;
    background: transparent;
    font-size: 14.5px;
    line-height: 1.5;
    resize: none;
    padding: 6px 0;
    max-height: 140px;
    min-height: 24px;
}

.send-btn {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    background: var(--accent);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: background 0.15s, transform 0.1s, opacity 0.15s;
    box-shadow: 0 2px 8px rgba(14,165,233,0.3);
}
.send-btn:hover:not(:disabled) { background: var(--accent-dark); }
.send-btn:active:not(:disabled) { transform: scale(0.92); }
.send-btn:disabled {
    background: var(--border);
    color: var(--text-muted);
    cursor: not-allowed;
    box-shadow: none;
}

.composer-hint {
    text-align: center;
    font-size: 11.5px;
    color: var(--text-muted);
    margin-top: 8px;
    max-width: 760px;
    margin-left: auto;
    margin-right: auto;
}

/* ═══════════════ OVERLAY (mobile) ═══════════════ */
.overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    z-index: 25;
    backdrop-filter: blur(2px);
}
.overlay.visible { display: block; }

/* ═══════════════ SCROLLBAR ═══════════════ */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }

/* ═══════════════ RESPONSIVE ═══════════════ */
@media (max-width: 768px) {
    .sidebar {
        position: fixed;
        top: 0;
        left: 0;
        bottom: 0;
        transform: translateX(-100%);
    }
    .sidebar.open { transform: translateX(0); }
    .menu-btn { display: flex; }
    .suggestions { grid-template-columns: 1fr; }
    .welcome h1 { font-size: 22px; }
    .welcome-tagline { font-size: 14px; }
    .msg-bubble { max-width: 85%; font-size: 14px; }
    .chat-area { padding: 16px 12px; }
    .topbar { padding: 10px 14px; }
    .composer { padding: 10px 12px 12px; }
}

@media (min-width: 769px) {
    .overlay { display: none !important; }
}
