/* Styles for Sathi AI Chatbot Page */

/* ── Layout & Container ───────────────────────────────────────── */
.chat-shell {
    display: flex;
    height: 100vh;
    width: 100vw;
    overflow: hidden;
    background: var(--bg-page);
    color: var(--text-pri);
    font-family: 'Inter', sans-serif;
    /* Text on the workspace's own accent colour, which doesn't change with the theme. */
    --text-on-primary: #ffffff;
}

/* ── Sidebar ────────────────────────────────────────────────── */
.chat-shell .sidebar {
    width: var(--sidebar-width, 280px);
    min-width: var(--sidebar-width, 280px);
    background: var(--bg-surface);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    height: 100%;
    overflow: hidden;
    box-shadow: var(--shadow-sm);
    z-index: 10;
    transition: all 0.3s ease;
}

.chat-shell .sidebar-brand {
    padding: 20px;
    display: flex;
    align-items: center;
    gap: 12px;
    border-bottom: 1px solid var(--border-soft);
}

.chat-shell .brand-icon {
    width: 40px;
    height: 40px;
    flex-shrink: 0;
}

.chat-shell .brand-initial {
    display: grid;
    place-items: center;
    width: 100%;
    height: 100%;
    border-radius: 50%;
    background: var(--accent, var(--color-primary));
    color: var(--text-on-primary);
    font-weight: 700;
}

.chat-shell .brand-icon svg {
    width: 100%;
    height: 100%;
    display: block;
}

.chat-shell .brand-text {
    display: flex;
    flex-direction: column;
}

.chat-shell .brand-name {
    font-weight: 800;
    font-size: 1.15rem;
    color: var(--text-pri);
    letter-spacing: -0.02em;
    line-height: 1.2;
}

.chat-shell .brand-tagline {
    font-size: 11px;
    color: var(--text-muted);
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.chat-shell .sidebar-nav {
    flex: 1;
    padding: 20px 12px;
    display: flex;
    flex-direction: column;
    gap: 6px;
    overflow-y: auto;
}

.chat-shell .nav-label {
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-muted);
    padding: 10px 12px 4px 12px;
}

.chat-shell .nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 14px;
    border-radius: var(--radius-md, 10px);
    color: var(--text-sec);
    font-weight: 600;
    font-size: 13px;
    text-decoration: none;
    transition: all 0.15s ease;
}

.chat-shell .nav-item:hover {
    background: var(--bg-hover);
    color: var(--color-primary-text);
}

.chat-shell .nav-item.active {
    background: var(--accent, var(--color-primary));
    color: var(--text-on-primary);
    box-shadow: var(--shadow-sm);
}

.chat-shell .nav-icon {
    font-size: 16px;
}

.chat-shell .sidebar-info-cards {
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    border-top: 1px solid var(--border-soft);
    background: var(--bg-elevated);
}

.chat-shell .info-card {
    padding: 12px 14px;
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-md, 10px);
    box-shadow: var(--shadow-sm);
}

.chat-shell .info-card-title {
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
    margin-bottom: 4px;
}

.chat-shell .info-card-body {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-sec);
}

.chat-shell .sidebar-footer {
    padding: 16px;
    border-top: 1px solid var(--border-soft);
    background: var(--bg-surface);
}

.chat-shell .btn-clear {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px;
    font-family: inherit;
    font-size: 13px;
    font-weight: 600;
    color: var(--color-danger, #ef4444);
    background: var(--color-danger-bg, rgba(239, 68, 68, 0.08));
    border: 1px solid transparent;
    border-radius: var(--radius-md, 10px);
    cursor: pointer;
    transition: all 0.15s ease;
}

.chat-shell .btn-clear:hover {
    background: var(--color-danger);
    color: #ffffff;
    box-shadow: 0 4px 12px rgba(239, 68, 68, 0.2);
}

/* ── Main Chat Area ────────────────────────────────────────── */
.chat-shell .chat-main {
    flex: 1;
    display: flex;
    flex-direction: column;
    height: 100%;
    overflow: hidden;
    position: relative;
    background: var(--bg-page);
}

/* Header */
.chat-shell .chat-header {
    height: 70px;
    min-height: 70px;
    background: var(--bg-surface);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 24px;
    box-shadow: var(--shadow-sm);
    z-index: 5;
}

.chat-shell .header-avatar {
    position: relative;
    width: 42px;
    height: 42px;
    margin-right: 12px;
}

.chat-shell .avatar-ring {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    background: var(--bg-hover);
    border: 2px solid var(--accent, var(--color-primary));
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    box-shadow: 0 0 10px var(--color-primary-glow);
}

.chat-shell .status-dot {
    position: absolute;
    bottom: -1px;
    right: -1px;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: var(--color-success);
    border: 2px solid var(--bg-surface);
}

.chat-shell .status-dot.online {
    background: var(--color-success);
}

.chat-shell .status-dot.thinking {
    background: var(--color-warning);
    animation: pulseThinking-chat 1.4s infinite ease-in-out;
}

@keyframes pulseThinking-chat {
    0%, 100% { transform: scale(1); opacity: 1; }
    50% { transform: scale(1.2); opacity: 0.5; }
}

.chat-shell .header-info {
    flex: 1;
    display: flex;
    flex-direction: column;
}

.chat-shell .header-title {
    font-size: 16px;
    font-weight: 800;
    color: var(--text-pri);
    margin: 0;
    line-height: 1.2;
}

.chat-shell .header-subtitle {
    font-size: 12px;
    color: var(--text-muted);
    margin: 2px 0 0 0;
}

.chat-shell .header-badge {
    background: var(--color-secondary-light);
    color: var(--color-secondary-text);
    font-size: 11px;
    font-weight: 700;
    padding: 4px 10px;
    border-radius: var(--radius-pill);
    display: flex;
    align-items: center;
    gap: 4px;
    border: 1px solid var(--color-secondary);
}

/* Handoff Banner */
.chat-shell .handoff-banner {
    background: var(--color-warning-bg);
    border-bottom: 1px solid var(--color-warning);
    padding: 12px 24px;
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 13px;
    color: var(--color-warning-text, #92400e);
    animation: slideDown-chat 0.3s ease-out;
}

@keyframes slideDown-chat {
    from { transform: translateY(-100%); }
    to { transform: translateY(0); }
}

.chat-shell .handoff-icon {
    font-size: 18px;
}

.chat-shell .handoff-close {
    margin-left: auto;
    background: none;
    border: none;
    cursor: pointer;
    font-size: 14px;
    color: inherit;
    opacity: 0.6;
    transition: opacity 0.15s ease;
}

.chat-shell .handoff-close:hover {
    opacity: 1;
}

/* Messages Area */
.chat-shell .messages-area {
    flex: 1;
    overflow-y: auto;
    padding: 24px;
    display: flex;
    flex-direction: column;
    gap: 20px;
    background: var(--bg-page);
    scroll-behavior: smooth;
}

/* Custom Scrollbar */
.chat-shell .messages-area::-webkit-scrollbar {
    width: 6px;
}
.chat-shell .messages-area::-webkit-scrollbar-track {
    background: transparent;
}
.chat-shell .messages-area::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 3px;
}
.chat-shell .messages-area::-webkit-scrollbar-thumb:hover {
    background: var(--text-ph);
}

/* Welcome Screen */
.chat-shell .welcome-screen {
    max-width: 640px;
    margin: auto;
    padding: 40px 20px;
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    animation: fadeIn-chat 0.4s ease-out;
}

@keyframes fadeIn-chat {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

.chat-shell .welcome-icon {
    font-size: 54px;
    margin-bottom: 16px;
    animation: float-chat 3s ease-in-out infinite;
}

@keyframes float-chat {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-10px); }
}

.chat-shell .welcome-title {
    font-size: 28px;
    font-weight: 800;
    color: var(--text-pri);
    margin-bottom: 8px;
    letter-spacing: -0.02em;
}

.chat-shell .welcome-sub {
    font-size: 15px;
    color: var(--text-sec);
    line-height: 1.6;
    margin-bottom: 28px;
}

.chat-shell .suggestion-chips {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 8px;
    max-width: 550px;
}

.chat-shell .chip {
    padding: 10px 16px;
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-pill);
    color: var(--text-sec);
    font-family: inherit;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow: var(--shadow-sm);
}

.chat-shell .chip:hover {
    border-color: var(--accent, var(--color-primary));
    background: var(--color-primary-light);
    color: var(--color-primary-text);
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
}

/* Message Rows */
.chat-shell .message-row {
    display: flex;
    align-items: flex-end;
    gap: 10px;
    max-width: 800px;
    width: 100%;
    animation: bubbleIn-chat 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes bubbleIn-chat {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
}

.chat-shell .user-row {
    align-self: flex-end;
    flex-direction: row-reverse;
}

.chat-shell .bot-row {
    align-self: flex-start;
}

.chat-shell .msg-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    flex-shrink: 0;
    margin-bottom: 2px;
    box-shadow: var(--shadow-sm);
}

.chat-shell .bot-avatar {
    background: var(--color-secondary);
    color: var(--color-secondary-text);
    border: 1px solid var(--border);
}

.chat-shell .user-avatar {
    background: var(--bg-hover);
    border: 1px solid var(--border);
}

/* Message Bubbles */
.chat-shell .bubble {
    position: relative;
    max-width: calc(100% - 42px);
    padding: 12px 16px;
    box-shadow: var(--shadow-sm);
    line-height: 1.5;
    font-size: 14px;
}

.chat-shell .bot-bubble {
    background: var(--bg-surface);
    border: 1px solid var(--border);
    color: var(--text-pri);
    border-radius: 16px 16px 16px 4px;
}

.chat-shell .user-bubble {
    background: var(--accent, var(--color-primary));
    color: var(--text-on-primary);
    border-radius: 16px 16px 4px 16px;
}

.chat-shell .bubble-sender {
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
    margin-bottom: 4px;
}

.chat-shell .user-bubble .bubble-sender {
    color: rgba(255, 255, 255, 0.8);
}

.chat-shell .bubble-content {
    word-break: break-word;
}

.chat-shell .bubble-content h2, .chat-shell .bubble-content h3 {
    font-size: 16px;
    font-weight: 700;
    margin: 8px 0 4px 0;
}

.chat-shell .bubble-content p {
    margin-bottom: 8px;
}

.chat-shell .bubble-content p:last-child {
    margin-bottom: 0;
}

.chat-shell .bubble-content li {
    list-style-type: disc;
    margin-left: 20px;
    margin-bottom: 4px;
}

.chat-shell .bubble-content li:last-child {
    margin-bottom: 0;
}

.chat-shell .bubble-content strong {
    font-weight: 700;
}

.chat-shell .bubble-content br {
    display: block;
    content: "";
    margin-top: 6px;
}

.chat-shell .bubble-time {
    font-size: 10px;
    color: var(--text-muted);
    margin-top: 6px;
    text-align: right;
}

.chat-shell .user-bubble .bubble-time {
    color: rgba(255, 255, 255, 0.7);
}

/* Typing Bubble */
.chat-shell .typing-bubble {
    padding: 16px 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 16px 16px 16px 4px;
}

.chat-shell .typing-indicator {
    display: flex;
    align-items: center;
    gap: 4px;
    height: 12px;
}

.chat-shell .typing-indicator span {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--text-muted);
    display: inline-block;
    animation: bounceDots-chat 1.4s infinite ease-in-out both;
}

.chat-shell .typing-indicator span:nth-child(1) {
    animation-delay: -0.32s;
}

.chat-shell .typing-indicator span:nth-child(2) {
    animation-delay: -0.16s;
}

@keyframes bounceDots-chat {
    0%, 80%, 100% { transform: scale(0); }
    40% { transform: scale(1); }
}

/* ── Input Bar ────────────────────────────────────────────── */
.chat-shell .input-bar {
    max-width: 800px;
    width: calc(100% - 48px);
    margin: 0 auto 24px auto;
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-xl, 20px);
    box-shadow: var(--shadow-md);
    padding: 10px 16px;
    display: flex;
    align-items: center;
    gap: 12px;
    position: relative;
    z-index: 10;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.chat-shell .input-bar:focus-within {
    border-color: var(--accent, var(--color-primary));
    box-shadow: 0 4px 20px var(--color-primary-glow);
}

.chat-shell .chat-input {
    flex: 1;
    border: none;
    background: transparent;
    font-family: inherit;
    font-size: 14px;
    color: var(--text-pri);
    resize: none;
    outline: none;
    line-height: 1.5;
    padding: 6px 0;
    min-height: 24px;
    max-height: 120px;
    overflow-y: auto;
}

.chat-shell .chat-input::placeholder {
    color: var(--text-ph);
}

.chat-shell .chat-input:disabled {
    cursor: not-allowed;
    opacity: 0.6;
}

.chat-shell .send-btn {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--accent, var(--color-primary));
    color: var(--text-on-primary);
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    flex-shrink: 0;
}

.chat-shell .send-btn:hover:not(.disabled) {
    transform: scale(1.05) translateY(-1px);
    box-shadow: 0 4px 12px var(--color-primary-glow);
}

.chat-shell .send-btn:active:not(.disabled) {
    transform: scale(0.95) translateY(0);
}

.chat-shell .send-btn.disabled, .chat-shell .send-btn:disabled {
    background: var(--bg-hover);
    color: var(--text-ph);
    cursor: not-allowed;
    transform: none !important;
    box-shadow: none !important;
}

/* ── Responsiveness ────────────────────────────────────────── */
@media (max-width: 768px) {
    .chat-shell .sidebar {
        position: absolute;
        left: -100%;
        top: 0;
        bottom: 0;
        width: 260px;
        box-shadow: var(--shadow-lg);
    }
    
    .chat-shell .sidebar.open {
        left: 0;
    }
    
    .chat-shell .input-bar {
        width: calc(100% - 24px);
        margin: 0 12px 12px 12px;
    }
    
    .chat-shell .chat-header {
        padding: 0 16px;
    }
}

/* ================================================================
   EMBEDDED PREVIEW MODE
   The public shell is 100vw/100vh. Inside the Counselor Hub it has to
   behave as a contained card instead of taking over the viewport.
   ================================================================ */
.chat-shell.embedded-admin {
    /* Fills the hub content area: 100vh minus the topbar and .admin-main padding */
    height: calc(100vh - 130px);
    min-height: 460px;
    width: 100%;
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    overflow: hidden;
}

/* The chat is the whole page here — no section gap above it */
.admin-section.chat-page {
    gap: 0;
}

.chat-shell.embedded-admin .chat-header {
    background: var(--bg-elevated);
}

.chat-shell.embedded-admin .input-bar {
    margin-bottom: 12px;
}

/* ── Header Action Cluster ─────────────────────────────────────── */
.chat-shell .header-actions {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-shrink: 0;
}

/* ── Workspace Not Found ───────────────────────────────────────── */
.workspace-not-found {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 12px;
    padding: 40px 20px;
    text-align: center;
    background: var(--bg-page);
}

.workspace-not-found .wnf-icon {
    font-size: 44px;
    opacity: 0.85;
}

.workspace-not-found .wnf-title {
    font-size: 22px;
    font-weight: 800;
    color: var(--text-pri);
    margin: 0;
}

.workspace-not-found .wnf-sub {
    font-size: 14px;
    color: var(--text-sec);
    max-width: 420px;
    margin: 0;
}

.workspace-not-found .wnf-link {
    margin-top: 8px;
    display: inline-flex;
    align-items: center;
    padding: 10px 18px;
    border-radius: var(--radius-md);
    background: var(--color-primary);
    color: var(--text-on-primary);
    font-size: 13px;
    font-weight: 700;
    text-decoration: none;
    box-shadow: var(--shadow-sm);
}

.workspace-not-found .wnf-link:hover {
    background: var(--color-primary-hover);
}

/* Embedded preview keeps the not-found state inside the card */
.admin-section .workspace-not-found {
    min-height: 320px;
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
}
