/* ============================================================
   AGENDAX PRODUCTION UI REPAIR — ANCHOR LEATHER & CRAFTS
   Target Bench: /root/frappe-bench
   ============================================================ */

/* 1. RESTORE MISSING FORM ICONS (Print, Forward, Prev, Checkbox, Menu) */
.page-head .btn svg,
.page-head .icon,
.standard-actions .btn svg,
.custom-actions .btn svg,
.btn-icon svg,
.grid-row .icon,
.grid-row svg,
.form-header svg,
.like-action svg,
.actions-btn-group svg {
    display: inline-block !important;
    visibility: visible !important;
    opacity: 1 !important;
    width: 14px !important;
    height: 14px !important;
    stroke: #334155 !important;
    stroke-width: 1.75px !important;
    fill: none !important;
}

.page-head .btn svg use,
.page-actions svg use {
    stroke: #334155 !important;
}

/* 2. REPAIR OVER-DARKENED BUTTONS (Submit, Save, Actions) */
body:not(.page-login) .page-head .btn-primary,
body:not(.page-login) .standard-actions .btn-primary {
    background-color: #1e293b !important;
    border: 1px solid #0f172a !important;
    color: #ffffff !important;
    font-weight: 600 !important;
    font-size: 13px !important;
    padding: 6px 16px !important;
    border-radius: 6px !important;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1) !important;
}

body:not(.page-login) .page-head .btn-primary:hover {
    background-color: #334155 !important;
    color: #ffffff !important;
}

/* Secondary Toolbar Action Buttons (Preview, Get Items From, Print, Prev/Next) */
body:not(.page-login) .page-head .btn-default,
body:not(.page-login) .page-head .btn:not(.btn-primary) {
    background-color: #ffffff !important;
    border: 1px solid #cbd5e1 !important;
    color: #1e293b !important;
    font-size: 12.5px !important;
    font-weight: 500 !important;
    border-radius: 6px !important;
    padding: 6px 12px !important;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.03) !important;
}

body:not(.page-login) .page-head .btn-default:hover,
body:not(.page-login) .page-head .btn:not(.btn-primary):hover {
    background-color: #f8fafc !important;
    border-color: #94a3b8 !important;
    color: #0f172a !important;
}

/* 3. FIX CHILD TABLE RATE & CURRENCY OVERLAP (Sh 500.00 collision) */
.grid-row .input-with-feedback,
.frappe-control[data-fieldtype="Currency"] .input-with-feedback,
.frappe-control[data-fieldtype="Float"] .input-with-feedback {
    position: relative !important;
}

/* Force padding on currency input cells so numbers never collide with the currency badge */
.grid-body .grid-row td[data-fieldtype="Currency"] input,
.grid-body .grid-row td[data-fieldtype="Float"] input,
.grid-row input[data-fieldtype="Currency"],
.grid-row input[data-fieldtype="Float"] {
    text-align: right !important;
    padding-left: 36px !important;
    font-size: 12.5px !important;
}

/* Position the currency prefix (Sh / KES) cleanly to the left */
.grid-body .input-group-prepend,
.grid-body .input-group-addon,
.grid-body .currency-symbol,
.grid-body .unit-symbol {
    position: absolute !important;
    left: 8px !important;
    top: 50% !important;
    transform: translateY(-50%) !important;
    background: transparent !important;
    border: none !important;
    font-size: 11px !important;
    font-weight: 600 !important;
    color: #64748b !important;
    pointer-events: none !important;
    z-index: 5 !important;
}

/* 4. TITLE & HEADER OVERLAP FIX */
.title-area {
    display: flex !important;
    flex-direction: column !important;
    gap: 2px !important;
}

.title-area .title-text {
    font-size: 16px !important;
    font-weight: 700 !important;
    color: #0f172a !important;
}

.title-area .sub-title {
    font-size: 12px !important;
    color: #64748b !important;
}

/* ============================================================
   AI CHAT CONTAINER & DRAWER STYLING
   ============================================================ */
#agendax-ai-bubble {
    position: fixed !important;
    bottom: 24px !important;
    right: 24px !important;
    width: 52px !important;
    height: 52px !important;
    background: #09090b !important;
    border: 2px solid #C5A059 !important;
    border-radius: 50% !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    cursor: pointer !important;
    box-shadow: 0 8px 24px rgba(0,0,0,0.3) !important;
    z-index: 9999 !important;
    transition: transform 0.2s ease, box-shadow 0.2s ease !important;
}

#agendax-ai-bubble:hover {
    transform: scale(1.08) !important;
    box-shadow: 0 12px 30px rgba(197, 160, 89, 0.25) !important;
}

#agendax-ai-drawer {
    display: none;
    position: fixed !important;
    bottom: 86px !important;
    right: 24px !important;
    width: 380px !important;
    height: 520px !important;
    background: #ffffff !important;
    border: 1px solid #e4e4e7 !important;
    border-radius: 12px !important;
    box-shadow: 0 20px 40px rgba(0,0,0,0.2) !important;
    z-index: 9999 !important;
    flex-direction: column !important;
    overflow: hidden !important;
}

[data-theme="dark"] #agendax-ai-drawer {
    background: #121215 !important;
    border-color: #27272a !important;
}

.ai-chat-header {
    background: #09090b !important;
    padding: 14px 16px !important;
    display: flex !important;
    justify-content: space-between !important;
    align-items: center !important;
    border-bottom: 2px solid #C5A059 !important;
    color: #ffffff !important;
}

.ai-chat-messages {
    flex: 1 !important;
    height: 380px !important;
    overflow-y: auto !important;
    padding: 16px !important;
    background: #faf9f6 !important;
    display: flex !important;
    flex-direction: column !important;
    gap: 12px !important;
}

[data-theme="dark"] .ai-chat-messages {
    background: #0c0c0e !important;
}

.ai-msg {
    padding: 10px 14px !important;
    border-radius: 10px !important;
    font-size: 13px !important;
    line-height: 1.5 !important;
    max-width: 85% !important;
    word-wrap: break-word !important;
}

.ai-msg.user {
    background: #18181b !important;
    color: #ffffff !important;
    align-self: flex-end !important;
    border-bottom-right-radius: 2px !important;
}

.ai-msg.bot {
    background: #ffffff !important;
    color: #09090b !important;
    border: 1px solid #e4e4e7 !important;
    align-self: flex-start !important;
    border-bottom-left-radius: 2px !important;
}

[data-theme="dark"] .ai-msg.bot {
    background: #18181b !important;
    color: #f4f4f5 !important;
    border-color: #27272a !important;
}

.ai-chat-input-bar {
    padding: 10px 14px !important;
    display: flex !important;
    gap: 8px !important;
    background: #ffffff !important;
    border-top: 1px solid #e4e4e7 !important;
}

[data-theme="dark"] .ai-chat-input-bar {
    background: #121215 !important;
    border-color: #27272a !important;
}

.ai-chat-input-bar input {
    flex: 1 !important;
    background: #faf9f6 !important;
    border: 1px solid #e4e4e7 !important;
    border-radius: 6px !important;
    padding: 8px 12px !important;
    font-size: 12.5px !important;
    color: #09090b !important;
    outline: none !important;
}

[data-theme="dark"] .ai-chat-input-bar input {
    background: #09090b !important;
    border-color: #27272a !important;
    color: #ffffff !important;
}

.ai-chat-input-bar button {
    background: #09090b !important;
    color: #C5A059 !important;
    border: 1px solid #C5A059 !important;
    border-radius: 6px !important;
    padding: 8px 16px !important;
    font-size: 12.5px !important;
    font-weight: 600 !important;
    cursor: pointer !important;
}

/* Strictly hide on login pages */
body.page-login #agendax-ai-bubble,
body.page-login #agendax-ai-drawer,
.for-login #agendax-ai-bubble,
.for-login #agendax-ai-drawer,
body[data-route="login"] #agendax-ai-bubble,
body[data-route="login"] #agendax-ai-drawer {
    display: none !important;
    visibility: hidden !important;
    opacity: 0 !important;
    pointer-events: none !important;
}
