/* Theme tweaks on top of Bootstrap 5 */
:root {
    --bs-primary: #4f46e5;           /* Indigo-600 */
    --bs-primary-rgb: 79, 70, 229;
    --bs-border-radius: .75rem;
    --bs-body-font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto,
      'Helvetica Neue', Arial, 'Noto Sans', 'Liberation Sans', sans-serif,
      'Apple Color Emoji', 'Segoe UI Emoji';
}

body {
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

h1, h2, h3, h4, h5 {
    letter-spacing: -0.02em;
}

.navbar {
    backdrop-filter: saturate(180%) blur(6px);
}

/* Cards */
.card {
    border: 1px solid rgba(0,0,0,.06);
    border-radius: 12px;
}
.card-header {
    background: transparent;
    border-bottom: 1px solid rgba(0,0,0,.06);
}

/* Tables */
.table th {
    font-weight: 600;
}
.table-responsive {
    border-radius: 10px;
}

/* Forms */
.form-control {
    border-radius: 10px;
}

/* Buttons */
.btn {
    border-radius: 10px;
}

/* Conversation styles */
.chat-box {
    background: #fff;
    border: 1px solid rgba(0,0,0,.06);
    border-radius: 12px;
    padding: 12px;
    overflow-y: auto;            /* enable vertical scroll when content overflows */
    max-height: 100%;            /* respect parent height in flex layouts */
    min-height: 0;               /* allow shrinking inside flex containers */
}

/* Ensure flex containers allow children to scroll instead of forcing growth */
.card.flex-grow-1 { min-height: 0; }
.card-body.d-flex { min-height: 0; }

.message {
    display: flex;
    margin-bottom: 8px;
}

.message .bubble {
    padding: 10px 14px;
    border-radius: 16px;
    max-width: 70%;
}

.message .bubble .bubble-meta {
    font-size: 0.75rem;
    color: #6c757d; /* muted */
    margin-top: 4px;
    text-align: right;
}

.message.guest .bubble {
    background: #f1f3f5;
}

.message.manager {
    justify-content: flex-end;
}

.message.manager .bubble {
    background: #e7f5ff;
}

.message.bot .bubble {
    background: #eef2ff;
}

.message .reply-guest {
    font-size: 0.8rem;
    margin-left: 8px;
    align-self: center;
    text-decoration: none;      /* avoid underline on icon-only button */
}

/* Icon inside the reply button */
.message .reply-guest .reply-icon {
    display: inline-block;
    font-size: 1rem;            /* size of the icon font */
    line-height: 1;
    vertical-align: middle;
}

/* Reply preview (WhatsApp-style) */
.reply-preview {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: .5rem;
    background: #f8f9fa;
    border-left: 4px solid var(--bs-primary);
    border-radius: 10px;
    padding: .5rem .75rem;
    margin-bottom: .5rem;
}
.reply-preview .rp-text {
    overflow: hidden;
}
.reply-preview .rp-title {
    font-size: .75rem;
    font-weight: 600;
    color: #495057;
    margin-bottom: 2px;
}
.reply-preview .rp-body {
    font-size: .875rem;
    color: #212529;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 100%;
}
.reply-preview .btn-close {
    flex: 0 0 auto;
}

/* Date divider */
.date-divider {
    display: table;             /* shrink-to-fit, centers with margin auto */
    padding: 4px 10px;
    margin: 10px auto;
    background: #f1f3f5;
    color: #495057;
    font-size: .75rem;
    font-weight: 600;
    border-radius: 999px;
    align-self: center;
}

.escalation {
    border: 1px solid rgba(0,0,0,.06);
    border-radius: 10px;
    padding: 10px;
}

.escalation + .escalation {
    margin-top: 8px;
}

.escalation .badge {
    margin-right: 6px;
}

.escalation-pending {
    border-left: 4px solid #ffc107;
}

.escalation-escalated {
    border-left: 4px solid #dc3545;
}

.escalation-cancelled {
    border-left: 4px solid #6c757d;
}

.escalation-resolved {
    border-left: 4px solid #198754;
}

/* Utility */
.page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
}

pre#result {
    background: #f8f9fa;
    border-radius: 8px;
    padding: 12px;
}

/* Auth page */
.auth-page { padding: 1.5rem 0 2.5rem; }
.auth-card { border-radius: 16px; }
.brand-chip {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: rgba(var(--bs-primary-rgb), .12);
    color: var(--bs-primary);
    font-weight: 700;
    font-size: 1.125rem;
}
.brand-initial { line-height: 48px; }
.auth-tabs .nav-link { border-radius: 999px; }
.auth-tabs .nav-link:not(.active) {
    background: #f1f3f5;
    color: #495057;
}
.password-toggle {
    position: absolute;
    top: 50%;
    right: .5rem;
    transform: translateY(-50%);
    text-decoration: none;
    font-weight: 500;
}
#result { margin-top: .25rem; }
.auth-card .position-relative .form-control { padding-right: 3rem; }
