/* /assets/styles.css */
/* A single, combined stylesheet for all ByteGuard Frontend components. */

/* --- Global Styles --- */
html,
body {
    background: #fff;
}

:root {
    --bgf-primary: #FACC15;          /* amber/yellow */
    --bgf-primary-hover: #EAB308;    /* darker on hover */
    --bgf-primary-text: #111827;     /* readable on yellow */
    --focus-ring: #2563eb;           /* accessible focus color */

    /* Cap used by chat window auto-grow JS (read via getComputedStyle). */
    --composer-actions-h: 140;
}

*:focus-visible {
    outline: 2px solid var(--focus-ring);
    outline-offset: 2px;
}

/* --- Layout & Utilities --- */
.bgf-wrap {
    max-width: 720px;
    margin: 2rem auto;
    padding: 0 1rem;
}

.layout {
    display: grid;
    grid-template-columns: 320px 1fr;
    gap: 1rem;
    height: calc(100vh - 100px);
    padding: 1rem;
    width: 100%;
    min-height: 0;
}

@supports (height: 100dvh) {
    .layout {
        height: calc(100dvh - 100px);
    }
}

.main {
    display: flex;
    flex-direction: column;
    min-height: 0;
}

.card {
    border: 1px solid #e3e6ea;
    border-radius: 12px;
    padding: 1rem;
    background: #fff;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
}

.lbl {
    font-size: .85rem;
    color: #57606a;
    font-weight: 500;
}

.muted {
    color: #6b7280;
    font-size: .9rem;
}

.muted.success {
    color: #0c7a43;
}

.muted.danger {
    color: #b42318;
}

.link {
    color: #2563eb;
    text-decoration: none;
}

.link:hover {
    text-decoration: underline;
}

.inp {
    width: 100%;
    border: 1px solid #d1d5db;
    border-radius: 10px;
    padding: .6rem .7rem;
    font: inherit;
    background: #f9fafb;
    transition: box-shadow .15s, border-color .15s, background-color .15s;
}

.inp.small {
    padding: .3rem .5rem;
    font-size: .9rem;
}

.inp:focus,
.inp:focus-visible {
    background: #fff;
    border-color: #94a3b8;
    box-shadow: 0 0 0 3px rgba(148, 163, 184, .25);
}

.btn {
    border: 1px solid #cbd5e1;
    background: #f8fafc;
    padding: .5rem .8rem;
    border-radius: 10px;
    font: inherit;
    cursor: pointer;
    transition: background-color 0.2s, box-shadow .15s, border-color .15s;
}

.btn:hover {
    background: #eef2ff;
}

.btn:disabled {
    cursor: not-allowed;
    opacity: 0.6;
}

.btn.btn-primary {
    background: var(--bgf-primary);
    border-color: var(--bgf-primary);
    color: var(--bgf-primary-text);
    font-weight: 500;
}

.btn.btn-primary:hover {
    background: var(--bgf-primary-hover);
    border-color: var(--bgf-primary-hover);
}

.btn.btn-primary:focus-visible {
    box-shadow: 0 0 0 3px rgba(250, 204, 21, .45);
}

.btn.btn-ghost {
    background: transparent;
    border: none;
    color: #475569;
}

.btn.btn-ghost:hover {
    background: #f1f5f9;
}

/* Inline action buttons inserted by chat_window.js (copy/narrate, attachment remove, etc.) */
.btn-inline {
    all: unset;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: .35rem;
    cursor: pointer;
    font-size: .85rem;
    color: #2563eb;
    padding: 2px 8px;
    border-radius: 999px;
}
.btn-inline:hover {
    background: #e2e8f0;
}
.btn-inline:focus-visible {
    outline: 2px solid var(--focus-ring);
    outline-offset: 2px;
}

/* --- Sidebar Component Styles --- */
.sidebar {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    overflow-y: auto;
    min-height: 0;
}

.brand {
    font-weight: 700;
    font-size: 1.25rem;
    letter-spacing: .3px;
    padding: 0 0.5rem;
}

.card.card-status {
    background: #f8fafc;
    padding: 0.75rem 1rem;
    gap: .4rem; /* slightly tighter to look balanced without Tier row */
}

.card.card-status .row {
    font-size: 0.8rem;
}

.pill {
    display: inline-flex;
    align-items: center;
    gap: .35rem;
    padding: .18rem .5rem;
    border: 1px solid #e2e8f0;
    border-radius: 999px;
    font-size: .8rem;
    color: #475569;
    background: #f8fafc;
}

.pill.ok {
    border-color: #a7f3d0;
    color: #065f46;
    background: #d1fae5;
}

.pill.warn {
    border-color: #fecaca;
    color: #991b1b;
    background: #fee2e2;
}

/* Voice clone controls (AI settings card) */
.voice-clone-controls {
    display: flex;
    align-items: center;
    gap: .5rem;
}
.voice-clone-controls select {
    flex: 1;
}

/* Conversation list */
.conv-list {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.conv-item {
    all: unset;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    padding: 8px 10px;
    cursor: pointer;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.conv-item.active,
.conv-item:hover {
    border-color: var(--bgf-primary);
}

.conv-item.active {
    box-shadow: 0 0 0 1px var(--bgf-primary);
}

.conv-title {
    flex-grow: 1;
    text-align: left;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.conv-actions {
    display: flex;
    align-items: center;
    gap: 4px;
    opacity: 0;
    transition: opacity 0.2s;
}

.conv-item:hover .conv-actions,
.conv-item.active .conv-actions {
    opacity: 1;
}

.conv-action-btn {
    all: unset;
    padding: 4px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
}

.conv-action-btn:hover {
    background-color: #e2e8f0;
}

.conv-action-btn svg {
    width: 14px;
    height: 14px;
    color: #64748b;
}

/* --- Chat Window Component Styles --- */
.toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: .75rem;
    border-bottom: 1px solid #e5e7eb;
    padding: .5rem 1rem;
    min-height: 48px;
}

.crumbs {
    font-weight: 500;
    color: #334155;
}

/* Narration toggle in toolbar */
.narration-toggle {
    display: inline-flex;
    align-items: center;
    gap: .5rem;
    user-select: none;
}

/* Checkbox styled as a switch */
.toggle-switch {
    -webkit-appearance: none;
    appearance: none;
    width: 42px;
    height: 24px;
    border-radius: 999px;
    background: #e5e7eb;
    border: 1px solid #cbd5e1;
    position: relative;
    cursor: pointer;
    transition: background-color .2s, border-color .2s, box-shadow .15s;
}
.toggle-switch::after {
    content: "";
    position: absolute;
    top: 2px;
    left: 2px;
    width: 20px;
    height: 20px;
    border-radius: 999px;
    background: #fff;
    box-shadow: 0 1px 2px rgba(0,0,0,.15);
    transition: transform .2s;
}
.toggle-switch:checked {
    background: var(--bgf-primary);
    border-color: var(--bgf-primary);
}
.toggle-switch:checked::after {
    transform: translateX(18px);
}
.toggle-switch:focus-visible {
    box-shadow: 0 0 0 3px rgba(37, 99, 235, .25);
}

.chat {
    flex: 1;
    overflow: auto;
    padding: 1rem;
    display: flex;
    flex-direction: column;
    gap: .75rem;
    background: #f9fafb;
    min-height: 0;
    overscroll-behavior: contain;
}

/* Message wrapper is a vertical stack so msg-actions sits under the bubble */
.msg {
    display: flex;
    flex-direction: column;
    gap: .25rem;
}

.msg.user {
    align-items: flex-end;
}

.msg.ai {
    align-items: flex-start;
}

.msg.error {
    align-items: flex-start;
}

/* Message bubbles */
.bubble {
    max-width: 80ch;
    padding: .75rem 1rem;
    border-radius: 16px;
    line-height: 1.4;
    word-wrap: break-word;
}

.msg.user .bubble {
    background: #2563eb;
    color: #fff;
    border-bottom-right-radius: 4px;
}

.msg.ai .bubble {
    background: #fff;
    border: 1px solid #e5e7eb;
    color: #111827;
    border-bottom-left-radius: 4px;
}

.msg.error .bubble {
    background: #fef2f2;
    border: 1px solid #fecaca;
    color: #b91c1c;
}

.bubble-content {
    white-space: pre-wrap;
}
.bubble-content > *:first-child { margin-top: 0; }
.bubble-content > *:last-child { margin-bottom: 0; }

/* Actions inserted after bubbles (Narrate / Copy) */
.msg-actions {
    display: flex;
    gap: .35rem;
    padding: 0 .25rem;
}

/* Image attachment shown inside user bubble */
.bubble-image {
    margin-top: .5rem;
}
.bubble-image img {
    display: block;
    max-width: min(360px, 80vw);
    max-height: 360px;
    border-radius: 10px;
    object-fit: contain;
    border: 1px solid rgba(0,0,0,.08);
    background: rgba(255,255,255,.5);
}

/* Code block styling */
.codebox {
    border: 1px solid #e5e7eb;
    background: #0f172a08;
    border-radius: 10px;
    overflow: hidden;
    margin: 0.5em 0;
}

.codebox-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: .35rem .6rem;
    border-bottom: 1px solid #e5e7eb;
    font-size: .8rem;
    color: #475569;
    background: #f8fafc;
}

.codebox-copy {
    all: unset;
    padding: .15rem .4rem;
    border-radius: 6px;
    cursor: pointer;
    border: 1px solid transparent;
}
.codebox-copy:hover { background: #e5e7eb55; }

.bubble pre {
    margin: 0;
    overflow: auto;
    padding: .6rem .75rem;
    background: transparent !important; /* Override theme styles */
}

.bubble code {
    background: rgba(15, 23, 42, .06);
    padding: 0.1em .3em;
    border-radius: 4px;
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
    font-size: .9em;
}

.bubble pre > code {
    background: transparent;
    padding: 0;
    border-radius: 0;
}

/* Composer */
.composer {
    display: flex;
    flex-direction: column;
    gap: .75rem;
    padding: .75rem 1rem;
    border-top: 1px solid #e5e7eb;
    background: #fff;
}

.composer textarea {
    resize: none;
    border: 1px solid #d1d5db;
    border-radius: 10px;
    padding: .75rem 1rem;
    font: inherit;
    min-height: 48px;
    max-height: 30vh;
    overflow-y: auto;
    background: #fff;
    transition: box-shadow .15s, border-color .15s;
}

.composer textarea:focus,
.composer textarea:focus-visible {
    border-color: #94a3b8;
    box-shadow: 0 0 0 3px rgba(148, 163, 184, .25);
}

.composer-actions {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-wrap: wrap;
}

/* Attachment Preview */
.attachment-preview {
    display: none;
    align-items: center;
    gap: 8px;
    border: 1px solid #e5e7eb;
    background: #fff;
    padding: 6px 8px;
    border-radius: 10px;
}
.attachment-preview img {
    max-width: 60px;
    max-height: 60px;
    object-fit: contain;
    border-radius: 4px;
}
.attachment-remove {
    font-size: 18px;
    line-height: 1;
    padding: 4px;
}

/* Narration Bar */
.narration-bar {
    padding: .5rem 1rem;
    border-top: 1px solid #e5e7eb;
    background: #fff;
}
.narration-bar details {
    border: 1px solid #e2e8f0;
    border-radius: 10px;
    background: #f8fafc;
}
.narration-bar summary {
    padding: 0.5rem 0.75rem;
    cursor: pointer;
    list-style: none;
    font-size: 0.9rem;
    color: #475569;
}
.narration-bar summary::-webkit-details-marker { display: none; }
.narration-content {
    padding: 0.75rem;
    border-top: 1px solid #e2e8f0;
    font-size: 0.85rem;
    color: #64748b;
    white-space: pre-wrap;
    max-height: 200px;
    overflow-y: auto;
}

/* Media bar (buttons under chat) */
.media-actions {
    display: flex;
    gap: .5rem;
    flex-wrap: wrap;
    padding: .75rem 1rem;
    border-top: 1px solid #e5e7eb;
    background: #fff;
}

/* --- Toast Notification Styles --- */
.toast {
    background: #111827;
    color: #fff;
    padding: .5rem .75rem;
    border-radius: 8px;
    box-shadow: 0 6px 24px rgba(0, 0, 0, .15);
    font-size: .9rem;
    z-index: 9999;
    display: flex;
    align-items: center;
    gap: 6px;
    max-width: 360px;
}

.toast.error {
    background: #b42318;
}

.toast-message {
    flex-grow: 1;
}

.toast-close-btn {
    margin-left: 8px;
    background: transparent;
    border: none;
    color: inherit;
    cursor: pointer;
    font-size: 1.2rem;
    line-height: 1;
    padding: 0.25rem;
}

/* --- Responsive & Accessibility --- */
@media (max-width: 900px) {
    .layout {
        grid-template-columns: 1fr;
        height: auto;
    }
}

@media (prefers-reduced-motion: reduce) {
    .btn,
    .inp,
    .conv-item,
    .toggle-switch,
    .composer textarea {
        transition: none;
    }
}

