/* Mobile chat history — a left drawer of previous conversations on the front page. */

.chat-history-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(29, 29, 29, 0.4);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.25s ease-out;
    z-index: 1060; /* above the dashboard sheet (1050) */
}

.chat-history-backdrop.open {
    opacity: 1;
    pointer-events: auto;
}

.chat-history-panel {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: 86vw;
    max-width: 360px;
    display: flex;
    flex-direction: column;
    background: #ffffff;
    box-shadow: 4px 0 16px rgba(0, 0, 0, 0.15);
    z-index: 1070;
    transform: translateX(-100%);
    transition: transform 0.25s ease-out;
    will-change: transform;
    padding-bottom: env(safe-area-inset-bottom, 0px);
}

.chat-history-panel.open {
    transform: translateX(0);
}

/* Header */

.chat-history-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.9rem 1rem 0.6rem;
    flex-shrink: 0;
}

.chat-history-title {
    font-size: 1.05rem;
    font-weight: 400;
    color: #1d1d1d;
}

.chat-history-icon-btn {
    background: none;
    border: none;
    padding: 0.25rem 0.4rem;
    cursor: pointer;
    color: #6c757d;
    font-size: 1.1rem;
    display: flex;
    align-items: center;
}

.chat-history-icon-btn:hover {
    color: #1d1d1d;
}

/* New chat */

.chat-history-new-btn {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin: 0 1rem 0.75rem;
    padding: 0.6rem 0.75rem;
    min-height: 44px;
    font-size: 0.9rem;
    font-weight: 400;
    color: #1d1d1d;
    background: #ffffff;
    border: 1px solid #dee2e6;
    border-radius: 4px;
    cursor: pointer;
}

.chat-history-new-btn:hover {
    border-color: #1d1d1d;
}

/* Search */

.chat-history-search {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    margin: 0 1rem 0.5rem;
    padding: 0 0.5rem;
    border: 1px solid #dee2e6;
    border-radius: 4px;
    flex-shrink: 0;
}

.chat-history-search:focus-within {
    border-color: #1d1d1d;
}

.chat-history-search-icon {
    color: #adb5bd;
    font-size: 1rem;
}

.chat-history-search-input {
    flex: 1;
    min-width: 0;
    border: none;
    outline: none;
    padding: 0.5rem 0;
    /* 16px: anything smaller and iOS zooms the page in when the field takes focus. */
    font-size: 16px;
    font-weight: 300;
    background: transparent;
}

/* List */

.chat-history-list {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    padding: 0.25rem 0.5rem 1rem;
    -webkit-overflow-scrolling: touch;
}

.chat-history-empty {
    padding: 2rem 1rem;
    text-align: center;
    font-size: 0.9rem;
    font-weight: 300;
    color: #6c757d;
}

.chat-history-group-label {
    padding: 0.75rem 0.5rem 0.35rem;
    font-size: 0.7rem;
    font-weight: 400;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: #adb5bd;
}

.chat-history-row {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.6rem 0.5rem;
    min-height: 44px;
    border-radius: 4px;
    cursor: pointer;
}

.chat-history-row:active {
    background-color: #f8f9fa;
}

/* The conversation currently open in the chat behind the drawer. */
.chat-history-row.current {
    background-color: #f1f3f5;
}

.chat-history-row-content {
    flex: 1;
    min-width: 0;
}

.chat-history-preview {
    font-size: 0.9rem;
    font-weight: 300;
    color: #1d1d1d;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.chat-history-time {
    margin-top: 0.1rem;
    font-size: 0.75rem;
    font-weight: 300;
    color: #adb5bd;
}

.chat-history-delete-btn {
    background: none;
    border: none;
    padding: 0.4rem;
    color: #ced4da;
    font-size: 1rem;
    cursor: pointer;
    flex-shrink: 0;
    display: flex;
    align-items: center;
}

.chat-history-delete-btn:hover {
    color: #1d1d1d;
}
