/* ========================================================
   Rules Copilot — floating chat launcher + panel
   ======================================================== */

/* NOTE: ScheduleCard.css defines a global ".d-flex { overflow: hidden !important-like }
   rule that clips ALL Bootstrap flex containers app-wide, including this panel.
   The rules below use higher specificity (.rules-copilot-panel .d-flex) to restore
   correct overflow behavior scoped only to this component, without touching the
   global rule (which other components may depend on). */
.rules-copilot-panel .d-flex {
    max-width: none;
    overflow: visible;
}

.rules-copilot-launcher {
    position: fixed;
    bottom: 24px;
    right: 32px;
    z-index: 1055;
    background-color: #ffffff !important;
    color: #1a4f8c !important;
    border: 1px solid #1a4f8c !important;
    font-weight: 600;
}

.rules-copilot-launcher:hover {
    background-color: #f0f6fc !important;
}

.rules-copilot-panel {
    position: fixed;
    bottom: 24px;
    right: 32px;
    width: 480px;
    max-width: calc(100vw - 32px);
    height: min(650px, calc(100vh - 48px));
    z-index: 1055;
    border: 1px solid #dee2e6;
    overflow: hidden;
}

.rules-copilot-header {
    background-color: #1a4f8c;
    flex-shrink: 0;
}

.rules-copilot-header .btn-link,
.rules-copilot-header .btn-link:hover,
.rules-copilot-header .btn-link:focus,
.rules-copilot-header .btn-link:active {
    line-height: 1;
    font-size: 1rem;
    width: 24px;
    height: 24px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    text-decoration: none;
    color: #ffffff !important;
    background: transparent !important;
    background-color: transparent !important;
    border: none !important;
    padding: 0 !important;
    opacity: 1;
    box-shadow: none !important;
}

.rules-copilot-header .btn-link i {
    font-family: "bootstrap-icons" !important;
    font-style: normal;
    font-size: 1rem;
    line-height: 1;
    color: #ffffff !important;
}

.rules-copilot-avatar {
    width: 34px;
    height: 34px;
    background-color: rgba(255, 255, 255, 0.18);
    color: #ffffff;
    font-size: 1rem;
}

.rules-copilot-panel .rules-copilot-messages.d-flex,
.rules-copilot-messages {
    background-color: #f8f9fb;
    flex: 1 1 auto;
    min-height: 0;
    max-width: 100%;
    overflow-y: auto !important;
    overflow-x: hidden;
    scrollbar-width: thin;
    scrollbar-color: #c1c9d2 transparent;
}

.rules-copilot-messages::-webkit-scrollbar {
    width: 6px;
}

.rules-copilot-messages::-webkit-scrollbar-track {
    background: transparent;
}

.rules-copilot-messages::-webkit-scrollbar-thumb {
    background-color: #c1c9d2;
    border-radius: 3px;
}

.rules-copilot-bubble-avatar {
    width: 28px;
    height: 28px;
    font-size: 0.8rem;
}

.bot-avatar {
    background-color: #e8f0fe;
    color: #1a4f8c;
}

.user-avatar {
    background-color: #1a4f8c;
    color: #ffffff;
}

.rules-copilot-bubble {
    padding: 0.6rem 0.9rem;
    border-radius: 0.9rem;
    font-size: 0.85rem;
    line-height: 1.4;
    word-break: break-word;
}

.bot-bubble {
    background-color: #ffffff;
    border: 1px solid #e9ecef;
    color: #212529;
    border-top-left-radius: 0.25rem;
}

.user-bubble {
    background-color: #1a4f8c;
    color: #ffffff;
    border-top-right-radius: 0.25rem;
}

/* ========================================================
   Rule summary cards — rendered under a "view rules" bot
   message; clicking one opens the real RuleDrawer for it.
   ======================================================== */
.rules-copilot-rule-card {
    background-color: #ede7f6;
    color: #212529;
    width: 100%;
    max-width: 100%;
    min-width: 0;
    box-sizing: border-box;
    overflow: hidden;
    transition: background-color 0.1s ease-in-out;
}

.rules-copilot-rule-card:hover,
.rules-copilot-rule-card:focus {
    background-color: #ddd3f0;
    color: #212529;
}

.rules-copilot-rule-card .fw-bold {
    color: #4527a0;
    flex-shrink: 0;
}

.rules-copilot-rule-card > span:last-child {
    min-width: 0;
    max-width: 100%;
    overflow: hidden;
}

.rules-copilot-rule-card .fw-semibold,
.rules-copilot-rule-card .small {
    display: block;
    white-space: normal;
    word-break: break-word;
    overflow-wrap: break-word;
    max-width: 100%;
}

/* Keep store/key confirmation buttons green despite global .btn styling. */
.rules-copilot-panel .btn.btn-success {
    background: #198754;
    border-color: #198754;
    color: #fff;
}

.rules-copilot-panel .btn.btn-success:hover:not(:disabled),
.rules-copilot-panel .btn.btn-success:active:not(:disabled) {
    background: #146c43;
    border-color: #13653f;
    color: #fff;
}

.rules-copilot-panel .btn.btn-success:focus-visible {
    outline: 3px solid #198754;
    outline-offset: 2px;
}

.rules-copilot-panel .btn.btn-success:disabled {
    background: #198754;
    border-color: #198754;
    color: #fff;
    opacity: 0.65;
}

.rules-copilot-panel .btn.rules-copilot-option {
    width: 48px;
    height: 48px;
    min-width: 48px;
    flex: 0 0 48px;
    padding: 0;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
    white-space: nowrap;
}