/* ============================================================================
   FILE: copilot-widget.css
   PATH: public/css/copilot-widget.css
   PURPOSE: Clean-light "Safety Copilot" chat widget (bottom-right), locked to
            the ICAO light design system (white surface, slate text, #E2E8F0
            borders).
   AUTHOR: AviaSAFE Systems
   =========================================================================== */

.copilot-widget-root {
    --cpi-accent: #b45309;
    --cpi-bg: #ffffff;
    --cpi-bg-2: #f1f5f9;
    --cpi-bg-input: #f8fafc;
    --cpi-text: #0f172a;
    --cpi-muted: #64748b;
    --cpi-border: #e2e8f0;
    --cpi-user-bubble: var(--color-brand-600);
    --cpi-bot-bubble: #f8fafc;
    position: fixed;
    right: 22px;
    bottom: 22px;
    z-index: 2147483000;
    font-family: 'Inter', 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}

/* ── Floating toggle button ── */
.cpi-toggle {
    display: flex;
    align-items: center;
    gap: 10px;
    background: linear-gradient(135deg, var(--cpi-bg), var(--cpi-bg-2));
    color: var(--cpi-text);
    border: 1px solid var(--cpi-border);
    border-radius: 999px;
    padding: 12px 20px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
    cursor: pointer;
    transition: transform 0.15s ease, box-shadow 0.15s ease;
    font-size: 14px;
    font-weight: 600;
}
.cpi-toggle:hover { transform: translateY(-2px); box-shadow: 0 12px 30px rgba(0, 0, 0, 0.45); }
.cpi-toggle .cpi-icon { font-size: 20px; }
.cpi-toggle .cpi-badge {
    background: var(--cpi-accent);
    color: var(--color-deep-teal-900);
    border-radius: 999px;
    font-size: 11px;
    font-weight: 800;
    padding: 2px 8px;
    letter-spacing: 0.4px;
}

/* ── Chat modal ── */
.cpi-modal {
    position: fixed;
    right: 22px;
    bottom: 22px;
    width: 380px;
    max-width: calc(100vw - 44px);
    height: min(560px, calc(100vh - 120px));
    background: var(--cpi-bg);
    color: var(--cpi-text);
    border: 1px solid var(--cpi-border);
    border-radius: 16px;
    box-shadow: 0 18px 50px rgba(0, 0, 0, 0.5);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    animation: cpi-pop 0.18s ease-out;
}
@keyframes cpi-pop {
    from { opacity: 0; transform: translateY(12px) scale(0.98); }
    to   { opacity: 1; transform: translateY(0) scale(1); }
}

.cpi-header {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 16px;
    background: linear-gradient(135deg, var(--cpi-bg-2), var(--cpi-bg));
    border-bottom: 1px solid var(--cpi-border);
}
.cpi-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--cpi-accent);
    color: var(--color-deep-teal-900);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    font-weight: 800;
    flex-shrink: 0;
}
.cpi-header .cpi-title { font-size: 14px; font-weight: 700; line-height: 1.2; }
.cpi-header .cpi-subtitle { font-size: 11px; color: var(--cpi-muted); margin-top: 2px; }
.cpi-close {
    margin-left: auto;
    background: transparent;
    border: none;
    color: var(--cpi-muted);
    font-size: 18px;
    cursor: pointer;
    padding: 4px 8px;
    border-radius: 6px;
}
.cpi-close:hover { color: var(--cpi-text); background: rgba(255, 255, 255, 0.06); }

.cpi-body {
    flex: 1;
    overflow-y: auto;
    padding: 14px 16px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    scroll-behavior: smooth;
}
.cpi-body::-webkit-scrollbar { width: 6px; }
.cpi-body::-webkit-scrollbar-thumb { background: var(--cpi-border); border-radius: 3px; }

.cpi-welcome {
    background: var(--cpi-bot-bubble);
    border: 1px solid var(--cpi-border);
    border-radius: 12px 12px 12px 4px;
    padding: 12px 14px;
    font-size: 13px;
    line-height: 1.55;
    color: var(--cpi-text);
}
.cpi-welcome .cpi-wl-title { font-weight: 700; color: var(--cpi-accent); margin-bottom: 4px; }

.cpi-chips { display: flex; flex-direction: column; gap: 6px; }
.cpi-chip {
    text-align: left;
    background: transparent;
    color: var(--cpi-text);
    border: 1px solid var(--cpi-border);
    border-radius: 999px;
    padding: 8px 14px;
    font-size: 12.5px;
    cursor: pointer;
    transition: background 0.12s ease, border-color 0.12s ease;
}
.cpi-chip:hover { background: var(--cpi-bg-2); border-color: var(--cpi-accent); }

.cpi-msg { max-width: 88%; padding: 10px 13px; border-radius: 12px; font-size: 13px; line-height: 1.55; white-space: pre-wrap; word-wrap: break-word; }
.cpi-msg.user { align-self: flex-end; background: var(--cpi-user-bubble); border-bottom-right-radius: 4px; }
.cpi-msg.bot { align-self: flex-start; background: var(--cpi-bot-bubble); border: 1px solid var(--cpi-border); border-bottom-left-radius: 4px; }
.cpi-msg.bot p { margin: 0 0 8px 0; }
.cpi-msg.bot p:last-child { margin-bottom: 0; }
.cpi-msg.bot ul, .cpi-msg.bot ol { margin: 4px 0 8px; padding-left: 18px; }
.cpi-msg.bot strong { color: var(--cpi-accent); }
.cpi-msg.bot h1, .cpi-msg.bot h2, .cpi-msg.bot h3 { font-size: 13.5px; margin: 8px 0 4px; color: var(--cpi-accent); }
.cpi-msg.bot a { color: var(--color-brand-300); }

.cpi-typing {
    align-self: flex-start;
    background: var(--cpi-bot-bubble);
    border: 1px solid var(--cpi-border);
    border-radius: 12px 12px 12px 4px;
    padding: 11px 15px;
    display: flex;
    gap: 4px;
}
.cpi-typing span {
    width: 7px; height: 7px;
    border-radius: 50%;
    background: var(--cpi-muted);
    animation: cpi-blink 1.2s infinite ease-in-out;
}
.cpi-typing span:nth-child(2) { animation-delay: 0.15s; }
.cpi-typing span:nth-child(3) { animation-delay: 0.3s; }
@keyframes cpi-blink { 0%, 80%, 100% { opacity: 0.25; } 40% { opacity: 1; } }

.cpi-error {
    align-self: center;
    color: #ffb4a8;
    font-size: 12.5px;
    background: rgba(214, 69, 65, 0.15);
    border: 1px solid rgba(214, 69, 65, 0.35);
    border-radius: 10px;
    padding: 8px 12px;
}

.cpi-notice {
    align-self: center;
    color: var(--cpi-text, #e6edf3);
    font-size: 12.5px;
    background: rgba(255, 166, 43, 0.12);
    border: 1px solid rgba(255, 166, 43, 0.4);
    border-radius: 10px;
    padding: 8px 12px;
    text-align: center;
}

.cpi-notice a {
    color: var(--color-brand-500, #ffb454);
    font-weight: 700;
    text-decoration: underline;
}

.cpi-footer {
    border-top: 1px solid var(--cpi-border);
    padding: 10px 12px;
    display: flex;
    gap: 8px;
    align-items: flex-end;
    background: var(--cpi-bg);
}
.cpi-footer textarea {
    flex: 1;
    resize: none;
    background: var(--cpi-bg-input);
    color: var(--cpi-text);
    border: 1px solid var(--cpi-border);
    border-radius: 10px;
    padding: 10px 12px;
    font-size: 13px;
    font-family: inherit;
    min-height: 38px;
    max-height: 110px;
}
.cpi-footer textarea:focus { outline: none; border-color: var(--cpi-accent); }
.cpi-footer textarea::placeholder { color: var(--cpi-muted); }
.cpi-send {
    background: var(--cpi-accent);
    color: var(--color-deep-teal-900);
    border: none;
    border-radius: 10px;
    padding: 10px 14px;
    font-size: 14px;
    font-weight: 700;
    cursor: pointer;
    flex-shrink: 0;
}
.cpi-send:hover { filter: brightness(1.08); }
.cpi-send:disabled { opacity: 0.5; cursor: not-allowed; }

.cpi-footer .cpi-disclaimer {
    position: absolute;
    bottom: 2px;
    right: 0;
    left: 0;
    text-align: center;
    font-size: 10px;
    color: var(--cpi-muted);
}

@media (max-width: 480px) {
    .cpi-modal { right: 10px; left: 10px; width: auto; bottom: 78px; height: calc(100vh - 140px); }
    .cpi-toggle .cpi-label { display: none; }
    .cpi-toggle { padding: 12px 14px; }
}

/* ============================================================================
   LIGHT VARIANT — NATIVE
   The widget is light by default (tokens on .copilot-widget-root). These rules
   refine shadows / error / link colors for the locked light theme.
   ============================================================================ */
.copilot-widget-root .cpi-toggle {
    box-shadow: 0 8px 24px rgba(15, 23, 42, 0.14);
}
.copilot-widget-root .cpi-toggle:hover {
    box-shadow: 0 12px 30px rgba(15, 23, 42, 0.2);
}
.copilot-widget-root .cpi-modal {
    box-shadow: 0 18px 50px rgba(15, 23, 42, 0.2);
}
.copilot-widget-root .cpi-close:hover {
    background: rgba(15, 23, 42, 0.06);
}
.copilot-widget-root .cpi-error {
    color: #b3261e;
    background: rgba(214, 69, 65, 0.1);
    border-color: rgba(214, 69, 65, 0.3);
}
.copilot-widget-root .cpi-msg.bot a {
    color: var(--color-brand-600);
}