/* ═══════════════════════════════════════════════════════════
   EmpanelChat — Standalone Jury Service Chat Application
   Telerik Chat Component + Custom Login
   ═══════════════════════════════════════════════════════════ */

:root {
    --brand: #7f1517;
    --brand-light: #a02020;
    --bg: #ffffff;
    --bg-surface: #f4f5f7;
    --bg-surface-strong: #e9ecef;
    --text: #1a1a1a;
    --text-muted: #5f6368;
    --border: #dcdcdc;
    --primary: #005fcc;
    --success: #059669;
    --warning: #d97706;
    --error: #dc2626;
    --font: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; padding: 0; height: 100%; }
body { font-family: var(--font); color: var(--text); background: var(--bg-surface); }

/* ── App Shell ── */
.app-shell { min-height: 100vh; display: flex; flex-direction: column; }
.site-main { flex: 1; overflow: visible; }

/* ── Header ── */
.site-header {
    background: var(--brand);
    color: white;
    padding: 0 20px;
    height: 56px;
    display: flex;
    align-items: center;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
    z-index: 10;
}
.header-brand { display: flex; align-items: center; gap: 10px; }
.header-icon { font-size: 1.4rem; }
.header-title { font-weight: 600; font-size: 1rem; }

/* ── Footer ── */
.site-footer {
    text-align: center;
    padding: 12px;
    font-size: 0.75rem;
    color: var(--text-muted);
    background: var(--bg);
    border-top: 1px solid var(--border);
}

/* ═══════════════════════════════════════════════════════════
   LOGIN PAGE
   ═══════════════════════════════════════════════════════════ */

.login-page {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: calc(100vh - 100px);
    padding: 20px;
}

.login-card {
    background: var(--bg);
    border-radius: 16px;
    box-shadow: 0 4px 24px rgba(0,0,0,0.08);
    border: 1px solid var(--border);
    padding: 48px 40px;
    max-width: 420px;
    width: 100%;
    text-align: center;
}

.login-icon { font-size: 3.5rem; margin-bottom: 8px; }
.login-title { margin: 0 0 4px; font-size: 1.5rem; color: var(--text); }
.login-subtitle { margin: 0 0 16px; font-size: 0.95rem; color: var(--brand); font-weight: 600; }
.login-instructions {
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-bottom: 24px;
    line-height: 1.5;
}

.login-form { text-align: left; }

.field { margin-bottom: 16px; }
.field label {
    display: block;
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--text);
    margin-bottom: 6px;
}
.field input, .field select {
    width: 100%;
    padding: 10px 14px;
    font-size: 1rem;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--bg);
    color: var(--text);
    transition: border-color 0.15s;
}
.field input:focus, .field select:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(0, 95, 204, 0.1);
}

.dob-row { display: flex; gap: 8px; }
.dob-row select { flex: 1; }

.btn-primary {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: 100%;
    padding: 12px 24px;
    font-size: 1rem;
    font-weight: 600;
    color: white;
    background: var(--brand);
    border: none;
    border-radius: 8px;
    cursor: pointer;
    transition: background 0.15s;
    margin-top: 8px;
}
.btn-primary:hover:not(:disabled) { background: var(--brand-light); }
.btn-primary:disabled { opacity: 0.5; cursor: default; }

.login-help {
    margin-top: 24px;
    padding-top: 16px;
    border-top: 1px solid var(--border);
    font-size: 0.8rem;
    color: var(--text-muted);
}
.login-help p { margin: 4px 0; }

.alert { padding: 10px 14px; border-radius: 8px; font-size: 0.85rem; margin-bottom: 16px; }
.alert-error { background: #fef2f2; border: 1px solid #fca5a5; color: var(--error); }

/* ═══════════════════════════════════════════════════════════
   CHAT PAGE
   ═══════════════════════════════════════════════════════════ */

.chat-page {
    max-width: 700px;
    margin: 16px auto;
    padding: 0 16px;
    overflow: visible;
}

/* ── Status Banners ── */
.status-banner {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 16px;
    border-radius: 8px;
    margin-bottom: 8px;
    font-size: 0.85rem;
    font-weight: 500;
}
.banner-waiting { background: #fffbeb; border: 1px solid #fcd34d; color: #92400e; }
.banner-active  { background: #ecfdf5; border: 1px solid #6ee7b7; color: #065f46; }
.banner-closed  { background: #f1f5f9; border: 1px solid #cbd5e1; color: #475569; }

.restart-link {
    background: none; border: none; color: var(--primary);
    cursor: pointer; text-decoration: underline; font-size: 0.85rem;
    margin-left: 8px;
}

/* ── Chat Header (inside TelerikChat HeaderTemplate) ── */
.ec-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 16px;
    width: 100%;
}
.ec-header-info {
    display: flex;
    align-items: center;
    gap: 10px;
    font-weight: 600;
    color: #1e293b;
}
.ec-avatar {
    width: 32px; height: 32px; border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    font-size: 1rem; color: white;
}
.ec-avatar-bot { background: linear-gradient(135deg, #3b82f6, #6366f1); }
.ec-avatar-clerk { background: linear-gradient(135deg, #10b981, #059669); }

.ec-end-btn {
    background: none; border: none; cursor: pointer;
    color: #94a3b8; font-size: 1.2rem; padding: 4px 8px;
}
.ec-end-btn:hover { color: #ef4444; }

/* ── Upload Button (in HeaderTemplate) ── */
.ec-upload-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 1.2rem;
    padding: 4px 10px;
    border-radius: 4px;
    transition: background 0.15s;
}
.ec-upload-btn:hover { background: rgba(0,0,0,0.05); }

.ec-header-actions {
    display: flex;
    align-items: center;
    gap: 4px;
}

/* ═══════════════════════════════════════════════════════════
   TELERIK CHAT — Appearance Customization
   ═══════════════════════════════════════════════════════════
   All overridable via CSS variables or class overrides.
   Telerik uses .k-* classes from the Kendo theme.
   ═══════════════════════════════════════════════════════════ */

/* ── Outer container ── */
.k-chat {
    border-radius: 12px;
    overflow: visible;
    border: 1px solid var(--border);
    box-shadow: 0 2px 12px rgba(0,0,0,0.06);
}

/* Ensure Telerik popups/menus aren't clipped */
.k-chat .k-chat-header,
.k-chat .k-chat-toolbar {
    overflow: visible;
    position: relative;
    z-index: 10;
}

/* Telerik animation container (popup menus) must float above everything */
.k-animation-container {
    z-index: 10002 !important;
}

/* Telerik popup/action menu styling */
.k-chat .k-actions,
.k-chat .k-menu-popup,
.k-chat .k-popup {
    overflow: visible;
    z-index: 10001;
}

/* ── Message list (scrollable area) ── */
.k-chat .k-message-list {
    background: var(--bg-surface);
}

/* ── All bubbles — base styling ── */
.k-chat .k-bubble {
    max-width: 80%;
    border-radius: 16px;
    padding: 10px 16px;
    font-size: 0.92rem;
    line-height: 1.5;
    box-shadow: 0 1px 3px rgba(0,0,0,0.06);
}

/* ── Juror (current user) bubbles — right side ── */
.k-chat .k-message.k-alt .k-bubble {
    background: var(--brand);
    color: white;
    border-bottom-right-radius: 4px;
}

/* ── Bot / Clerk / System bubbles — left side ── */
.k-chat .k-message:not(.k-alt) .k-bubble {
    background: white;
    color: var(--text);
    border: 1px solid #e2e8f0;
    border-bottom-left-radius: 4px;
}

/* ── Author name above message groups ── */
.k-chat .k-author {
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--text-muted);
    margin-bottom: 2px;
}

/* ── Timestamps ── */
.k-chat .k-timestamp {
    font-size: 0.72rem;
    color: #94a3b8;
}

/* ── Message input area (bottom bar) ── */
.k-chat .k-message-box {
    background: white;
    border-top: 1px solid var(--border);
    padding: 8px 12px;
}

/* ── Text input field ── */
.k-chat .k-message-box .k-input,
.k-chat .k-message-box input,
.k-chat .k-message-box textarea {
    font-size: 0.95rem;
    border-radius: 20px;
    padding: 8px 16px;
    border: 1px solid var(--border);
    background: var(--bg-surface);
}

.k-chat .k-message-box .k-input:focus,
.k-chat .k-message-box input:focus,
.k-chat .k-message-box textarea:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 2px rgba(0, 95, 204, 0.1);
    outline: none;
}

/* ── Send button (arrow icon) — nuclear override ── */
.k-chat .k-message-box .k-button,
.k-chat .k-message-box .k-button.k-button-md,
.k-chat .k-message-box .k-button.k-button-flat,
.k-chat .k-message-box .k-button.k-button-solid,
.k-chat .k-message-box .k-button.k-rounded-full,
.k-chat .k-message-box button.k-button {
    background: var(--brand) !important;
    background-color: var(--brand) !important;
    color: white !important;
    border: none !important;
    border-radius: 50% !important;
    width: 40px !important;
    height: 40px !important;
    min-width: 40px !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    cursor: pointer;
    transition: background 0.15s;
    box-shadow: 0 2px 8px rgba(127,21,23,0.3) !important;
}

.k-chat .k-message-box .k-button:hover,
.k-chat .k-message-box button.k-button:hover {
    background: var(--brand-light) !important;
    background-color: var(--brand-light) !important;
    box-shadow: 0 3px 12px rgba(127,21,23,0.4) !important;
}

.k-chat .k-message-box .k-button:active,
.k-chat .k-message-box button.k-button:active {
    transform: scale(0.95);
}

/* Force the SVG arrow icon inside send button to be white and bold */
.k-chat .k-message-box .k-button svg,
.k-chat .k-message-box .k-button .k-icon,
.k-chat .k-message-box .k-button .k-svg-icon,
.k-chat .k-message-box .k-button .k-svg-icon svg {
    color: white !important;
    fill: white !important;
}
.k-chat .k-message-box .k-button svg path,
.k-chat .k-message-box .k-button .k-svg-icon svg path {
    fill: white !important;
    stroke: white !important;
    stroke-width: 1 !important;
}

/* ── Suggested actions (quick reply buttons) ── */
.k-chat .k-quick-reply {
    border: 1px solid var(--brand);
    color: var(--brand);
    background: white;
    border-radius: 20px;
    padding: 6px 16px;
    font-size: 0.85rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.15s;
}

.k-chat .k-quick-reply:hover {
    background: var(--brand);
    color: white;
}

/* ── Typing indicator ── */
.k-chat .k-typing-indicator {
    color: var(--brand);
}
.k-chat .k-typing-indicator .k-typing-indicator-dot,
.k-chat .k-typing-indicator span {
    background-color: var(--brand) !important;
}

/* ── Chat header area (wraps our HeaderTemplate) ── */
.k-chat .k-chat-header {
    background: white;
    border-bottom: 1px solid var(--border);
    padding: 0;
}

/* ── Spinners ── */
.spinner {
    display: inline-block; width: 14px; height: 14px;
    border: 2px solid rgba(255,255,255,0.3); border-top-color: white;
    border-radius: 50%; animation: spin 0.6s linear infinite;
}
.spinner-sm {
    display: inline-block; width: 14px; height: 14px;
    border: 2px solid rgba(146,64,14,0.3); border-top-color: #92400e;
    border-radius: 50%; animation: spin 0.6s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ═══════════════════════════════════════════════════════════
   MOBILE
   ═══════════════════════════════════════════════════════════ */

@media (max-width: 640px) {
    .chat-page { padding: 0; margin: 0; }
    .k-chat { border-radius: 0; }
    .login-card { border-radius: 0; padding: 32px 24px; box-shadow: none; border: none; }
    .login-page { align-items: flex-start; padding: 0; }
}
