/* Hailey — global styles. Bootstrap 5.3 dark theme is the baseline. */

:root {
    --hailey-bg:        #0f0c29;
    --hailey-bg-2:      #1a1a2e;
    --hailey-panel:     #16162a;
    --hailey-accent:    #a29bfe;
    --hailey-accent-2: #6c5ce7;
    --hailey-pink:      #fd79a8;
    --hailey-text:      #e9ecef;
    --hailey-muted:     #8a8aa8;
    --hailey-border:    #2a2a44;
}

html, body { height: 100%; }
body {
    background: linear-gradient(135deg, #0f0c29, #1a1530 60%, #14132a);
    color: var(--hailey-text);
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

.hailey-navbar {
    background: rgba(15, 12, 41, 0.85);
    backdrop-filter: blur(8px);
    border-color: var(--hailey-border) !important;
}

.hailey-logo-dot {
    display: inline-block; width: 14px; height: 14px; border-radius: 50%;
    background: radial-gradient(circle at 30% 30%, var(--hailey-accent), var(--hailey-accent-2));
    box-shadow: 0 0 10px rgba(162,155,254,.6);
}

.hailey-avatar {
    display: inline-flex; align-items: center; justify-content: center;
    width: 30px; height: 30px; border-radius: 50%;
    background: linear-gradient(135deg, var(--hailey-accent), var(--hailey-accent-2));
    color: #fff; font-weight: 600; font-size: .9rem;
}
.hailey-avatar-btn { background: transparent; border: 1px solid var(--hailey-border); }
.hailey-avatar-btn:hover { background: rgba(255,255,255,.04); }

/* Auth pages */
.hailey-auth-shell {
    min-height: calc(100vh - 60px);
    display: flex; flex-direction: column;
    align-items: center; justify-content: flex-start;
    padding: clamp(2rem, 8vh, 8rem) 1rem 2rem;
}
.hailey-auth-card {
    width: 100%; max-width: 420px;
    background: rgba(22, 22, 42, .85);
    border: 1px solid var(--hailey-border);
    border-radius: 14px; padding: 2rem;
    box-shadow: 0 10px 40px rgba(0,0,0,.4);
}

/* Chat layout */
.hailey-app {
    display: grid;
    grid-template-columns: 280px 1fr;
    height: calc(100vh - 60px);
    overflow: hidden;
}
.hailey-sidebar {
    background: rgba(15, 12, 41, .6);
    border-right: 1px solid var(--hailey-border);
    display: flex; flex-direction: column;
    overflow: hidden;
}
.hailey-sidebar-head { padding: .75rem; border-bottom: 1px solid var(--hailey-border); }
.hailey-chats { flex: 1 1 auto; overflow-y: auto; padding: .5rem; }

.hailey-chat-row {
    position: relative;
    display: flex; align-items: stretch;
    border-radius: 8px;
}
.hailey-chat-row:hover, .hailey-chat-row.active { background: rgba(255,255,255,.04); }
.hailey-chat-row.active { background: rgba(162,155,254,.15); }
.hailey-chat-row.active .hailey-chat-item { color: #fff; }

.hailey-chat-item {
    flex: 1 1 auto; min-width: 0;
    display: block; padding: .5rem .5rem .5rem .75rem; border-radius: 8px;
    color: var(--hailey-text); text-decoration: none; font-size: .9rem;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.hailey-chat-item:hover { color: var(--hailey-text); }

.hailey-chat-menu { flex: 0 0 auto; display: flex; align-items: center; }
.hailey-chat-menu-btn {
    background: transparent; color: var(--hailey-muted); border: none;
    padding: 0 .5rem; line-height: 1; font-size: 1.1rem;
    opacity: 0; transition: opacity .15s, color .15s;
}
.hailey-chat-row:hover .hailey-chat-menu-btn,
.hailey-chat-menu-btn:focus,
.hailey-chat-menu.show .hailey-chat-menu-btn {
    opacity: 1;
}
.hailey-chat-menu-btn:hover { color: #fff; background: rgba(255,255,255,.06); border-radius: 6px; }
@media (hover: none) {
    /* On touch devices keep the menu visible since there's no hover */
    .hailey-chat-menu-btn { opacity: .6; }
}

.hailey-main {
    display: flex; flex-direction: column;
    overflow: hidden; height: 100%;
}

.hailey-chat-header {
    border-bottom: 1px solid var(--hailey-border);
    background: rgba(15, 12, 41, .4);
    padding: .5rem 1rem;
}
.hailey-chat-header-inner {
    max-width: 820px; margin: 0 auto;
}
.hailey-tags {
    display: flex; flex-wrap: wrap; gap: .35rem; align-items: center;
}
.hailey-tag {
    display: inline-flex; align-items: center;
    background: rgba(162,155,254,.12);
    border: 1px solid rgba(162,155,254,.25);
    border-radius: 999px;
    font-size: .8rem;
    padding: 2px 2px 2px 10px;
    gap: .25rem;
}
.hailey-tag-name {
    color: var(--hailey-accent); text-decoration: none;
}
.hailey-tag-name:hover { color: #fff; }
.hailey-tag-remove {
    background: transparent; border: none; color: var(--hailey-muted);
    line-height: 1; padding: 0 6px; border-radius: 999px;
    font-size: 1rem;
}
.hailey-tag-remove:hover { background: rgba(255, 90, 120, .2); color: #fff; }
.hailey-tag-add { gap: .25rem; }
.hailey-tag-add input { width: 110px; font-size: .8rem; height: 26px; padding: 0 8px;
    background: rgba(22,22,42,.6); color: var(--hailey-text); border-color: var(--hailey-border); }
.hailey-tag-add input:focus { border-color: var(--hailey-accent); box-shadow: none; }

.hailey-system-chip {
    display: inline-flex; align-items: center; gap: .5rem;
    background: rgba(255, 159, 67, .08);
    border: 1px solid rgba(255, 159, 67, .35);
    border-radius: 10px;
    padding: 4px 4px 4px 10px;
    margin-bottom: .35rem;
    max-width: 100%;
    font-size: .82rem;
}
.hailey-system-label {
    font-size: .65rem; font-weight: 700; letter-spacing: .04em;
    text-transform: uppercase; color: #ffb86b;
    padding: 1px 6px; background: rgba(255,159,67,.18); border-radius: 999px;
}
.hailey-system-text {
    color: var(--hailey-text);
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
    min-width: 0;
}
.hailey-system-clear {
    background: transparent; border: none; color: var(--hailey-muted);
    line-height: 1; padding: 0 6px; border-radius: 999px; font-size: 1rem;
}
.hailey-system-clear:hover { background: rgba(255, 90, 120, .2); color: #fff; }

/* Header tool toggle (web search) */
.hailey-toolset { margin-right: .35rem; }
.hailey-tool-toggle {
    display: inline-flex; align-items: center; gap: .35rem;
    background: rgba(255,255,255,.04);
    border: 1px solid var(--hailey-border);
    color: var(--hailey-muted);
    padding: 4px 10px; border-radius: 999px;
    font-size: .78rem; font-weight: 500;
    transition: background .15s, color .15s, border-color .15s;
}
.hailey-tool-toggle:hover { background: rgba(255,255,255,.08); color: var(--hailey-text); }
.hailey-tool-toggle.is-on {
    background: rgba(108,231,162,.15);
    border-color: rgba(108,231,162,.4);
    color: #6ce7a2;
}
.hailey-tool-state { opacity: .7; font-size: .7em; text-transform: uppercase; letter-spacing: .04em; }

/* In-message tool status pill (during streaming) */
.hailey-tool-status {
    display: inline-flex; align-items: center; gap: .4rem;
    margin-bottom: .5rem;
    padding: 4px 10px; border-radius: 999px;
    background: rgba(108,231,162,.10);
    border: 1px solid rgba(108,231,162,.25);
    color: #6ce7a2; font-size: .78rem;
}
.hailey-tool-status.is-done {
    background: rgba(108,231,162,.18);
}
.hailey-tool-status .hailey-typing-dot { background: #6ce7a2; }
.hailey-tool-sources {
    margin-left: .5rem; color: var(--hailey-muted); font-size: .72rem;
}
.hailey-tool-sources summary { cursor: pointer; outline: none; }
.hailey-tool-sources ol { margin: .25rem 0 0 1.25rem; padding: 0; }
.hailey-tool-sources a { color: var(--hailey-accent); }
.hailey-tool-sources a:hover { color: #fff; }

/* File chips in chat header */
.hailey-file-add-btn { gap: .25rem; }
.hailey-file-chip {
    display: inline-flex; align-items: center; gap: .35rem;
    background: rgba(108, 162, 231, .10);
    border: 1px solid rgba(108, 162, 231, .30);
    border-radius: 999px;
    padding: 2px 2px 2px 8px;
    font-size: .78rem;
    max-width: 280px;
}
.hailey-file-chip.is-pending { opacity: .7; }
.hailey-file-chip.is-error {
    background: rgba(255, 90, 120, .12);
    border-color: rgba(255, 90, 120, .35);
}
.hailey-file-chip-link {
    display: inline-flex; align-items: center; gap: .35rem;
    color: var(--hailey-text); text-decoration: none;
    min-width: 0;
}
.hailey-file-chip-link:hover .hailey-file-name { color: var(--hailey-accent); }
.hailey-file-name {
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
    max-width: 180px;
}
.hailey-file-mode {
    font-size: .58rem; font-weight: 700; letter-spacing: .04em;
    padding: 1px 5px; border-radius: 999px;
    background: rgba(108, 162, 231, .25); color: #9bc6ff;
}
.hailey-file-mode.is-pending { background: rgba(255, 255, 255, .12); color: var(--hailey-muted); }
.hailey-file-mode.is-error   { background: rgba(255, 90, 120, .25); color: #ffb0b8; }

.hailey-mode-group .btn { font-size: .8rem; padding: .35rem .8rem; }

/* Image generation */
.hailey-gen-card { overflow: hidden; }
.hailey-gen-thumb {
    width: 100%; aspect-ratio: 1 / 1; object-fit: cover;
    background: #0b0b1a;
    transition: opacity .2s;
}
.hailey-gen-thumb:hover { opacity: .9; }
.hailey-img-bubble {
    display: block; max-width: 100%; border-radius: 10px;
    margin: .5rem 0; border: 1px solid var(--hailey-border);
    background: #0b0b1a;
}
.hailey-imagine-meta {
    font-size: .72rem; color: var(--hailey-muted); margin-top: .35rem;
}
.hailey-imagine-meta code { color: var(--hailey-accent); }

.hailey-slash-badge-system {
    background: rgba(255,159,67,.18) !important;
    color: #ffb86b !important;
}
.hailey-messages {
    flex: 1 1 auto; overflow-y: auto; padding: 1.5rem;
    scroll-behavior: smooth;
}
/* When the chat has no messages, anchor the welcome state toward the upper-third — true center
   reads as "too low" once the composer + chat header eat into the visible area. */
.hailey-messages.is-empty {
    display: flex; flex-direction: column;
    align-items: center; justify-content: flex-start;
    padding: clamp(2rem, 10vh, 8rem) 1rem 1rem;
}
.hailey-msg { max-width: 820px; margin: 0 auto 1.25rem; }
.hailey-msg-role {
    font-size: .75rem; text-transform: uppercase; letter-spacing: 1px;
    color: var(--hailey-muted); margin-bottom: .35rem;
}
.hailey-msg-body {
    background: var(--hailey-panel); border: 1px solid var(--hailey-border);
    border-radius: 12px; padding: 1rem 1.25rem; line-height: 1.6;
    overflow-wrap: anywhere;
}
.hailey-msg-user .hailey-msg-body { background: rgba(108,92,231,.15); border-color: rgba(162,155,254,.25); }
.hailey-msg-body pre {
    background: #0b0b1a; border: 1px solid var(--hailey-border);
    border-radius: 8px; padding: .85rem; overflow-x: auto;
}
.hailey-msg-body code:not(pre code) {
    background: rgba(255,255,255,.06); padding: .1em .35em;
    border-radius: 4px; font-size: .9em;
}
.hailey-msg-body p { margin: 0 0 .65rem; }
.hailey-msg-body p:last-child { margin-bottom: 0; }
.hailey-msg-body table {
    border-collapse: collapse; margin: .5rem 0;
}
.hailey-msg-body table th, .hailey-msg-body table td {
    border: 1px solid var(--hailey-border); padding: .35rem .6rem;
}

.hailey-composer {
    border-top: 1px solid var(--hailey-border);
    background: rgba(15, 12, 41, .6);
    padding: 1rem;
}
.hailey-composer-inner { max-width: 820px; margin: 0 auto; position: relative; }

.hailey-slash-popup {
    position: absolute;
    left: 0; right: 0; bottom: calc(100% + 0.5rem);
    z-index: 20;
    background: var(--hailey-panel);
    border: 1px solid var(--hailey-border);
    border-radius: 10px;
    box-shadow: 0 10px 30px rgba(0,0,0,.5);
    overflow: hidden;
    max-height: 360px; display: flex; flex-direction: column;
}
.hailey-slash-popup ul {
    list-style: none; margin: 0; padding: .25rem;
    overflow-y: auto; flex: 1 1 auto;
}
.hailey-slash-popup li {
    padding: .5rem .75rem; border-radius: 6px; cursor: pointer;
}
.hailey-slash-popup li:hover,
.hailey-slash-popup li.active {
    background: rgba(162,155,254,.18);
}
.hailey-slash-title {
    color: var(--hailey-text); font-weight: 500; font-size: .92rem;
    display: flex; align-items: center; gap: .4rem;
}
.hailey-slash-preview {
    color: var(--hailey-muted); font-size: .78rem; margin-top: .15rem;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
}
.hailey-slash-badge {
    font-size: .65rem; padding: 1px 6px; border-radius: 999px;
    background: rgba(253,121,168,.18); color: var(--hailey-pink);
    text-transform: uppercase; letter-spacing: .04em;
}
.hailey-slash-hint {
    padding: .35rem .75rem; font-size: .7rem; color: var(--hailey-muted);
    border-top: 1px solid var(--hailey-border);
    background: rgba(0,0,0,.2);
}
.hailey-composer textarea {
    background: var(--hailey-panel); color: var(--hailey-text);
    border: 1px solid var(--hailey-border); border-radius: 12px;
    resize: none; min-height: 56px; max-height: 240px;
}
.hailey-composer textarea:focus { border-color: var(--hailey-accent); box-shadow: 0 0 0 .2rem rgba(162,155,254,.15); }

.hailey-preset-menu {
    min-width: 320px; max-width: 480px; max-height: 60vh; overflow-y: auto;
}
.hailey-preset-menu .dropdown-item { white-space: normal; }
.hailey-preset-menu .dropdown-item .text-truncate { max-width: 380px; }
.hailey-preset-picker .dropdown-toggle { white-space: nowrap; }

.hailey-typing-dot {
    display: inline-block; width: 6px; height: 6px; border-radius: 50%;
    background: var(--hailey-accent); margin-right: 4px;
    animation: hailey-blink 1.2s infinite ease-in-out;
}
.hailey-typing-dot:nth-child(2) { animation-delay: .15s; }
.hailey-typing-dot:nth-child(3) { animation-delay: .3s; }
@keyframes hailey-blink {
    0%, 80%, 100% { opacity: .25; transform: scale(.8); }
    40%           { opacity: 1;   transform: scale(1); }
}

.hailey-empty {
    text-align: center; color: var(--hailey-muted);
    padding: 1rem;
    max-width: 520px;
}
.hailey-empty h2 { color: var(--hailey-text); font-weight: 700; }
.hailey-empty .accent {
    background: linear-gradient(90deg, var(--hailey-accent), var(--hailey-pink));
    -webkit-background-clip: text; -webkit-text-fill-color: transparent;
}

@media (max-width: 768px) {
    .hailey-app { grid-template-columns: 1fr; }
    .hailey-sidebar { display: none; }
    .hailey-sidebar.is-open {
        display: flex; position: fixed; inset: 60px 0 0 0; z-index: 1040;
        width: 100%; background: var(--hailey-bg);
    }
}
