/* Coach / Lene Chat Interface */

/* --- Coach-specific variables --- */
.coach-layout {
    --bg-hover: color-mix(in srgb, var(--text) 6%, var(--bg));
    --lene-gradient: linear-gradient(135deg, var(--accent) 0%, #C49564 100%);
}

/* Override main-content constraints for full-bleed chat */
.main-content:has(.coach-layout) {
    max-width: none;
    padding: 0;
}

.coach-layout {
    display: flex;
    flex-direction: row;
    height: 100vh;
    gap: 0;
    background: var(--bg-card);
    overflow: hidden;
}

/* ============================================
   Conversation Sidebar
   ============================================ */
.conv-sidebar {
    width: 300px;
    min-width: 300px;
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    background: var(--bg);
}

.conv-sidebar-header {
    padding: 1.25rem 1rem;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
}

.conv-sidebar-header h3 {
    margin: 0;
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.06em;
}

.btn-new-conv {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.4rem 0.85rem;
    font-size: 0.8rem;
    font-weight: 500;
    font-family: var(--font);
    background: var(--accent);
    color: #fff;
    border: none;
    border-radius: var(--radius);
    cursor: pointer;
    transition: all 0.15s ease;
}

.btn-new-conv:hover {
    background: var(--accent-hover);
}

.conv-list {
    flex: 1;
    overflow-y: auto;
    padding: 0.5rem;
}

/* Individual conversation items */
.conv-item {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    padding: 0.75rem 0.85rem;
    border-radius: var(--radius);
    color: var(--text);
    text-decoration: none;
    margin-bottom: 2px;
    transition: all 0.15s ease;
    cursor: pointer;
    border: 1px solid transparent;
}

.conv-item:hover {
    background: var(--bg-hover);
    color: var(--text);
    border-color: var(--border);
}

.conv-item.active {
    background: color-mix(in srgb, var(--accent) 12%, var(--bg-card));
    border-color: color-mix(in srgb, var(--accent) 30%, transparent);
    color: var(--text);
}

.conv-item.active .conv-item-title {
    color: var(--text);
    font-weight: 600;
}

.conv-item-title {
    font-size: 0.875rem;
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    line-height: 1.3;
}

.conv-item-meta {
    font-size: 0.75rem;
    color: var(--text-muted);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.conv-type-badge {
    display: inline-block;
    font-size: 0.6rem;
    padding: 0.1rem 0.4rem;
    border-radius: 3px;
    background: color-mix(in srgb, var(--accent) 15%, var(--bg));
    color: var(--accent-hover);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    font-weight: 600;
}

.conv-item.active .conv-type-badge {
    background: color-mix(in srgb, var(--accent) 25%, transparent);
    color: var(--accent-hover);
}

/* ============================================
   Chat Area
   ============================================ */
.chat-area {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
    background: var(--bg-card);
}

.chat-header {
    padding: 1rem 1.5rem;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: var(--bg-card);
}

.chat-header h2 {
    margin: 0;
    font-size: 1rem;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.chat-header .btn-sm {
    opacity: 0.5;
    transition: opacity 0.15s;
}

.chat-header .btn-sm:hover {
    opacity: 1;
}

.chat-messages {
    flex: 1 1 0;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 1.5rem 1.5rem 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    background: var(--bg);
    min-height: 0;
}

/* ============================================
   Empty State — No active conversation
   ============================================ */
.chat-empty {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2rem;
    background: var(--bg);
}

.chat-empty-inner {
    text-align: center;
    max-width: 360px;
}

.chat-empty-avatar {
    width: 72px;
    height: 72px;
    border-radius: 50%;
    background: var(--lene-gradient);
    color: #fff;
    font-size: 1.75rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 1.25rem;
    box-shadow: 0 4px 16px rgba(212, 165, 116, 0.3);
}

.chat-empty-title {
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--text);
    margin-bottom: 0.5rem;
}

.chat-empty-subtitle {
    font-size: 0.9rem;
    color: var(--text-muted);
    line-height: 1.5;
    margin-bottom: 1.5rem;
}

.chat-empty-form {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    align-items: center;
}

.chat-empty-form select {
    width: 100%;
    max-width: 240px;
    padding: 0.6rem 0.85rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--bg-card);
    color: var(--text);
    font-family: var(--font);
    font-size: 0.875rem;
    cursor: pointer;
    transition: border-color 0.15s ease;
    appearance: none;
    -webkit-appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%23636E72' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 0.75rem center;
    padding-right: 2rem;
}

.chat-empty-form select:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(212, 165, 116, 0.15);
}

.btn-start-conv {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.7rem 1.5rem;
    background: var(--lene-gradient);
    color: #fff;
    border: none;
    border-radius: var(--radius);
    font-family: var(--font);
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow: 0 2px 8px rgba(212, 165, 116, 0.25);
}

.btn-start-conv:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(212, 165, 116, 0.35);
}

/* Quick-start conversation type pills */
.chat-empty-types {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    justify-content: center;
    margin-top: 0.5rem;
}

.type-pill {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.4rem 0.85rem;
    border: 1px solid var(--border);
    border-radius: 20px;
    background: var(--bg-card);
    color: var(--text-muted);
    font-family: var(--font);
    font-size: 0.8rem;
    cursor: pointer;
    transition: all 0.15s ease;
    text-decoration: none;
}

.type-pill:hover {
    border-color: var(--accent);
    color: var(--accent);
    background: color-mix(in srgb, var(--accent) 8%, var(--bg-card));
}

.type-pill i, .type-pill svg {
    width: 14px;
    height: 14px;
}

/* ============================================
   Message Bubbles
   ============================================ */
.message {
    display: flex;
    flex-direction: column;
    max-width: 70%;
    min-width: 0;
    animation: message-in 0.15s ease-out;
}

@keyframes message-in {
    from { opacity: 0; transform: translateY(4px); }
    to { opacity: 1; transform: translateY(0); }
}

.message.user {
    align-self: flex-end;
}

.message.assistant {
    align-self: flex-start;
}

.message-avatar {
    display: none;
}

.message-bubble {
    padding: 0.6rem 0.85rem;
    border-radius: var(--radius-lg);
    line-height: 1.55;
    font-size: 0.9375rem;
    word-wrap: break-word;
    overflow-wrap: break-word;
}

.message.user .message-bubble {
    background: var(--accent);
    color: #fff;
    border-bottom-right-radius: 4px;
}

.message.assistant .message-bubble {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-bottom-left-radius: 4px;
}

/* Markdown inside bubbles */
.message-bubble .markdown-content {
    font-size: 0.9375rem;
    line-height: 1.6;
}

.message-bubble p {
    margin: 0 0 0.6rem 0;
}

.message-bubble p:last-child {
    margin-bottom: 0;
}

.message-bubble strong {
    font-weight: 600;
}

.message-bubble em {
    font-style: italic;
}

.message-bubble ul, .message-bubble ol {
    margin: 0.4rem 0;
    padding-left: 1.25rem;
}

.message-bubble li {
    margin-bottom: 0.2rem;
}

.message-bubble li p {
    margin: 0;
}

.message-bubble h1, .message-bubble h2, .message-bubble h3 {
    font-size: 0.95em;
    font-weight: 700;
    margin: 0.75rem 0 0.3rem;
}

.message-bubble h1:first-child,
.message-bubble h2:first-child,
.message-bubble h3:first-child {
    margin-top: 0;
}

.message-bubble blockquote {
    border-left: 3px solid var(--accent);
    margin: 0.4rem 0;
    padding: 0.25rem 0.75rem;
    color: var(--text-muted);
}

.message-bubble code {
    background: rgba(0, 0, 0, 0.07);
    padding: 0.1rem 0.35rem;
    border-radius: 3px;
    font-size: 0.85em;
    font-family: 'SF Mono', 'Fira Code', monospace;
}

.message-bubble pre {
    background: rgba(0, 0, 0, 0.05);
    padding: 0.65rem 0.85rem;
    border-radius: var(--radius);
    overflow-x: auto;
    margin: 0.4rem 0;
    font-size: 0.85em;
}

.message-bubble pre code {
    background: none;
    padding: 0;
}

[data-theme="dark"] .message-bubble code {
    background: rgba(255, 255, 255, 0.1);
}

[data-theme="dark"] .message-bubble pre {
    background: rgba(255, 255, 255, 0.06);
}

.message-bubble hr {
    border: none;
    border-top: 1px solid var(--border);
    margin: 0.6rem 0;
}

/* ============================================
   Typing Indicator
   ============================================ */
.typing-indicator {
    display: none;
    align-self: flex-start;
    margin-left: 44px;
    padding: 0.75rem 1rem;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    border-bottom-left-radius: 4px;
}

.typing-indicator.visible {
    display: flex;
    gap: 0.3rem;
    align-items: center;
}

.typing-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--accent);
    animation: typing-bounce 1.4s infinite ease-in-out;
}

.typing-dot:nth-child(2) {
    animation-delay: 0.2s;
}

.typing-dot:nth-child(3) {
    animation-delay: 0.4s;
}

@keyframes typing-bounce {
    0%, 80%, 100% { transform: translateY(0); opacity: 0.4; }
    40% { transform: translateY(-6px); opacity: 1; }
}

/* ============================================
   Slash Command Menu
   ============================================ */
.slash-menu {
    position: absolute;
    bottom: 100%;
    left: 1rem;
    right: 1rem;
    max-height: 360px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    overflow: hidden;
    z-index: 50;
    display: flex;
    flex-direction: column;
}

.slash-menu-header {
    padding: 0.65rem 1rem;
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-muted);
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
}

.slash-menu-list {
    overflow-y: auto;
    padding: 0.35rem;
}

.slash-menu-item {
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
    padding: 0.6rem 0.75rem;
    border: none;
    background: none;
    width: 100%;
    text-align: left;
    cursor: pointer;
    border-radius: var(--radius);
    transition: background 0.1s;
    font-family: var(--font);
    color: var(--text);
}

.slash-menu-item:hover,
.slash-menu-item.highlighted {
    background: var(--bg-hover);
}

.slash-menu-icon {
    font-size: 1.1rem;
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    border-radius: var(--radius);
    background: color-mix(in srgb, var(--accent) 12%, var(--bg));
}

.slash-menu-body {
    display: flex;
    flex-direction: column;
    gap: 0.1rem;
    min-width: 0;
}

.slash-menu-name {
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--text);
}

.slash-menu-desc {
    font-size: 0.8rem;
    color: var(--text-muted);
    line-height: 1.4;
}

.slash-menu-empty {
    padding: 1rem;
    text-align: center;
    color: var(--text-muted);
    font-size: 0.85rem;
}

[x-cloak] { display: none !important; }

/* ============================================
   Chat Input
   ============================================ */
.chat-input-area {
    position: relative;
    padding: 1rem 1.5rem;
    border-top: 1px solid var(--border);
    background: var(--bg-card);
}

.chat-input-form {
    display: flex;
    gap: 0.75rem;
    align-items: flex-end;
}

.chat-input-form textarea {
    flex: 1;
    resize: none;
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 0.75rem 1rem;
    font-family: var(--font);
    font-size: 0.9375rem;
    line-height: 1.5;
    background: var(--bg);
    color: var(--text);
    min-height: 44px;
    max-height: 150px;
    transition: border-color 0.15s ease;
}

.chat-input-form textarea:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(212, 165, 116, 0.1);
}

.btn-send {
    padding: 0 1rem;
    background: var(--accent);
    color: #fff;
    border: none;
    border-radius: var(--radius-lg);
    cursor: pointer;
    font-size: 0;
    font-weight: 500;
    white-space: nowrap;
    height: 44px;
    width: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.15s ease;
    flex-shrink: 0;
}

.btn-send::after {
    content: '';
    display: block;
    width: 18px;
    height: 18px;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='18' height='18' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M5 12h14'/%3E%3Cpath d='m12 5 7 7-7 7'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-size: contain;
}

.btn-send:hover {
    background: var(--accent-hover);
}

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

/* ============================================
   Library
   ============================================ */
.library-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
}

.library-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 1rem;
}

.library-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 1.25rem;
    transition: border-color 0.15s ease;
}

.library-card:hover {
    border-color: var(--accent);
}

.library-card-title {
    font-weight: 600;
    margin-bottom: 0.5rem;
}

.library-card-meta {
    font-size: 0.8rem;
    color: var(--text-muted);
}

.upload-form {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 1.5rem;
    margin-bottom: 1.5rem;
}

.upload-form .form-group {
    margin-bottom: 1rem;
}

.upload-form label {
    display: block;
    font-size: 0.875rem;
    font-weight: 500;
    margin-bottom: 0.375rem;
}

/* ============================================
   Responsive
   ============================================ */
@media (max-width: 768px) {
    .conv-sidebar {
        display: none;
    }

    .coach-layout {
        height: calc(100vh - 4rem);
        border-radius: 0;
        border: none;
    }

    .message {
        max-width: 90%;
    }

    .chat-messages {
        padding: 1rem;
    }

    .chat-input-area {
        padding: 0.75rem;
    }
}
