/* ==========================================================================
   BCMX UI Enhancement Styles
   Tooltips, toasts, modals, empty states, spinners, breadcrumbs, help text
   ========================================================================== */

/* ---------- CSS Tooltips (data-tooltip attribute) ---------- */
[data-tooltip] {
    position: relative;
    cursor: help;
}
[data-tooltip]::after {
    content: attr(data-tooltip);
    position: absolute;
    bottom: 125%;
    left: 50%;
    transform: translateX(-50%);
    background: var(--text-primary, #333);
    color: var(--bg-primary, #fff);
    padding: 6px 12px;
    border-radius: var(--radius-sm, 4px);
    font-size: 12px;
    font-weight: normal;
    white-space: nowrap;
    max-width: 300px;
    white-space: normal;
    z-index: 9999;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s;
    line-height: 1.4;
    box-shadow: var(--shadow-md, 0 2px 8px rgba(0,0,0,0.2));
}
[data-tooltip]::before {
    content: "";
    position: absolute;
    bottom: 115%;
    left: 50%;
    transform: translateX(-50%);
    border: 6px solid transparent;
    border-top-color: var(--text-primary, #333);
    z-index: 9999;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s;
}
[data-tooltip]:hover::after,
[data-tooltip]:hover::before,
[data-tooltip]:focus::after,
[data-tooltip]:focus::before {
    opacity: 1;
}

/* ---------- Toast Notifications ---------- */
.bcmx-toast-container {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 10001;
    display: flex;
    flex-direction: column;
    gap: 8px;
    max-width: 400px;
}
.bcmx-toast {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    border-radius: var(--radius, 6px);
    color: #fff;
    font-size: 14px;
    line-height: 1.4;
    box-shadow: var(--shadow-md, 0 4px 12px rgba(0,0,0,0.2));
    animation: bcmx-toast-in 0.3s ease-out;
    min-width: 280px;
}
.bcmx-toast.success { background: #16a34a; }
.bcmx-toast.error   { background: #dc2626; }
.bcmx-toast.warning { background: #d97706; color: #fff; }
.bcmx-toast.info    { background: #0284c7; }

.bcmx-toast-close {
    background: none;
    border: none;
    color: inherit;
    font-size: 18px;
    cursor: pointer;
    margin-left: 12px;
    padding: 0 4px;
    opacity: 0.8;
    line-height: 1;
}
.bcmx-toast-close:hover { opacity: 1; }

@keyframes bcmx-toast-in {
    from { opacity: 0; transform: translateX(40px); }
    to   { opacity: 1; transform: translateX(0); }
}
@keyframes bcmx-toast-out {
    from { opacity: 1; transform: translateX(0); }
    to   { opacity: 0; transform: translateX(40px); }
}

/* ---------- Modal / Confirm Dialog ---------- */
.bcmx-modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    z-index: 10000;
    display: flex;
    align-items: center;
    justify-content: center;
    animation: bcmx-fade-in 0.15s ease-out;
    backdrop-filter: blur(2px);
}
.bcmx-modal {
    background: var(--card-bg, #fff);
    border-radius: var(--radius, 8px);
    padding: 24px 28px;
    max-width: 440px;
    width: 90%;
    box-shadow: 0 8px 30px rgba(0,0,0,0.25);
    animation: bcmx-scale-in 0.15s ease-out;
    border: 1px solid var(--border-color, #e2e8f0);
}
.bcmx-modal h3 {
    margin: 0 0 12px 0;
    font-size: 18px;
    color: var(--text-primary, #333);
    font-weight: 600;
}
.bcmx-modal p {
    margin: 0 0 20px 0;
    color: var(--text-secondary, #555);
    line-height: 1.5;
    font-size: 14px;
}
.bcmx-modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
}
.bcmx-modal-actions button {
    padding: 8px 20px;
    border: none;
    border-radius: var(--radius-sm, 4px);
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    transition: background 0.15s;
}
.bcmx-modal-cancel {
    background: var(--btn-neutral-bg, #e0e0e0);
    color: var(--btn-neutral-text, #333);
}
.bcmx-modal-cancel:hover { background: var(--btn-neutral-hover, #ccc); }
.bcmx-modal-confirm {
    background: var(--btn-danger-bg, #c0392b);
    color: #fff;
}
.bcmx-modal-confirm:hover { background: var(--btn-danger-hover, #a93226); }
.bcmx-modal-confirm.primary {
    background: var(--btn-primary-bg, #1f8dd6);
}
.bcmx-modal-confirm.primary:hover { background: var(--btn-primary-hover, #1a75b5); }

/* Modal input field (for prompt dialogs) */
.bcmx-modal input[type="text"],
.bcmx-modal input[type="tel"],
.bcmx-modal input[type="number"] {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--border-color, #ccc);
    border-radius: var(--radius-sm, 4px);
    font-size: 14px;
    margin-bottom: 16px;
    box-sizing: border-box;
    background: var(--bg-primary, #fff);
    color: var(--text-primary, #333);
}
.bcmx-modal input:focus {
    border-color: var(--accent, #1f8dd6);
    outline: none;
    box-shadow: 0 0 0 3px var(--accent-light, rgba(31,141,214,0.2));
}
.bcmx-modal label {
    display: block;
    margin-bottom: 6px;
    font-size: 13px;
    color: var(--text-secondary, #555);
    font-weight: 500;
}

@keyframes bcmx-fade-in {
    from { opacity: 0; }
    to   { opacity: 1; }
}
@keyframes bcmx-scale-in {
    from { opacity: 0; transform: scale(0.95); }
    to   { opacity: 1; transform: scale(1); }
}

/* ---------- Empty States ---------- */
.bcmx-empty-state {
    text-align: center;
    padding: 40px 20px;
    color: var(--text-muted, #888);
    width: 100%;
}
.bcmx-empty-state .bcmx-empty-icon {
    font-size: 48px;
    margin-bottom: 12px;
    opacity: 0.4;
}
.bcmx-empty-state p {
    font-size: 16px;
    margin: 0 0 16px 0;
    color: var(--text-secondary, #666);
}
.bcmx-empty-state .pure-button {
    margin-top: 8px;
}

/* ---------- Loading Spinner ---------- */
.bcmx-loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 40px 20px;
    color: var(--text-muted, #888);
    width: 100%;
}
.bcmx-spinner {
    width: 36px;
    height: 36px;
    border: 4px solid var(--border-color, #e0e0e0);
    border-top-color: var(--accent, #1f8dd6);
    border-radius: 50%;
    animation: bcmx-spin 0.8s linear infinite;
    margin-bottom: 12px;
}
@keyframes bcmx-spin {
    to { transform: rotate(360deg); }
}
.bcmx-loading p {
    font-size: 14px;
    margin: 0;
}

/* ---------- Breadcrumbs ---------- */
.bcmx-breadcrumbs {
    padding: 10px 2em;
    font-size: 13px;
    color: var(--text-muted, #888);
    background: var(--bg-primary);
}
.bcmx-breadcrumbs a {
    color: var(--accent, #1f8dd6);
    text-decoration: none;
}
.bcmx-breadcrumbs a:hover {
    text-decoration: underline;
}
.bcmx-breadcrumbs .bcmx-bc-sep,
.bcmx-breadcrumbs > span[aria-hidden] {
    margin: 0 6px;
    color: var(--text-muted, #bbb);
}
.bcmx-breadcrumbs .bcmx-bc-current {
    color: var(--text-secondary, #555);
    font-weight: 500;
}

/* ---------- Help Text (below form fields) ---------- */
.bcmx-help-text {
    display: block;
    font-size: 12px;
    color: var(--text-muted, #999);
    margin-top: 4px;
    line-height: 1.4;
}
.pure-control-group .bcmx-help-text {
    margin-left: 0;
}

/* ---------- Status Badges ---------- */
.bcmx-badge {
    display: inline-block;
    padding: 2px 10px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}
.bcmx-badge-active,
.bcmx-badge-online  { background: var(--status-online-bg, #d4edda); color: var(--status-online-text, #155724); }
.bcmx-badge-inactive,
.bcmx-badge-offline  { background: var(--status-offline-bg, #f8d7da); color: var(--status-offline-text, #721c24); }
.bcmx-badge-pending  { background: #fff3cd; color: #856404; }

/* ---------- Form Validation Feedback ---------- */
.bcmx-field-error {
    border-color: var(--btn-danger-bg, #c0392b) !important;
    box-shadow: 0 0 0 2px rgba(239,68,68,0.15) !important;
}
.bcmx-field-error-msg {
    display: block;
    font-size: 12px;
    color: var(--btn-danger-bg, #c0392b);
    margin-top: 4px;
}

/* ---------- Misc Utility ---------- */
.bcmx-sr-only,
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0,0,0,0);
    white-space: nowrap;
    border: 0;
}

/* ---------- Footer ---------- */
.bcmx-footer {
    text-align: center;
    padding: 16px;
    background: var(--bg-primary);
    border-top: 1px solid var(--border-color);
    font-size: 0.85em;
    color: var(--text-muted);
}

/* ---------- Responsive Adjustments ---------- */
@media (max-width: 48em) {
    .bcmx-toast-container {
        left: 10px;
        right: 10px;
        max-width: none;
    }
    .bcmx-modal {
        width: 95%;
        padding: 20px;
    }
    [data-tooltip]::after {
        max-width: 200px;
        font-size: 11px;
    }
    .bcmx-breadcrumbs {
        padding: 8px 1em;
        font-size: 12px;
    }
}

/* ---------- Login Page ---------- */
.bcmx-login-page {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    background: var(--bg-secondary, #f7f8fa);
    margin: 0;
    padding: 1em;
}

.bcmx-login-card {
    background: var(--card-bg, #fff);
    border: 1px solid var(--card-border, #e2e8f0);
    border-radius: var(--radius-lg, 12px);
    box-shadow: var(--shadow-md, 0 4px 12px rgba(0,0,0,0.08));
    padding: 2.5em 2em;
    width: 100%;
    max-width: 380px;
}

.bcmx-login-heading {
    margin: 0 0 0.2em;
    font-size: 1.6em;
    color: var(--text-primary, #1e293b);
    text-align: center;
}

.bcmx-login-subheading {
    margin: 0 0 1.5em;
    font-size: 0.95em;
    color: var(--text-muted, #94a3b8);
    text-align: center;
}

.bcmx-login-card label {
    display: block;
    margin-bottom: 0.3em;
    font-size: 0.9em;
    color: var(--text-secondary, #475569);
    font-weight: 600;
}

.bcmx-login-card input[type="text"],
.bcmx-login-card input[type="password"] {
    width: 100%;
    padding: 0.6em 0.8em;
    margin-bottom: 1em;
    border: 1px solid var(--border-color, #e2e8f0);
    border-radius: var(--radius-sm, 4px);
    font-size: 1em;
    background: var(--bg-primary, #fff);
    color: var(--text-primary, #1e293b);
    box-sizing: border-box;
}

.bcmx-login-card input:focus {
    outline: none;
    border-color: var(--accent, #1f8dd6);
    box-shadow: 0 0 0 3px var(--accent-light, rgba(31,141,214,0.08));
}

.bcmx-login-btn {
    width: 100%;
    padding: 0.7em;
    font-size: 1em;
    margin-top: 0.5em;
}

.bcmx-login-error {
    background: var(--status-offline-bg, #fee2e2);
    color: var(--status-offline-text, #991b1b);
    padding: 0.7em 1em;
    border-radius: var(--radius-sm, 4px);
    font-size: 0.9em;
    margin-bottom: 1em;
    text-align: center;
}

/* ---------- User Management Styles ---------- */
.bcmx-badge {
    display: inline-block;
    padding: 0.2em 0.6em;
    border-radius: var(--radius-sm, 4px);
    font-size: 0.8em;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.bcmx-badge-admin {
    background: var(--accent-light, rgba(31,141,214,0.08));
    color: var(--accent, #1f8dd6);
}

.bcmx-badge-user {
    background: var(--btn-neutral-bg, #f1f5f9);
    color: var(--text-secondary, #475569);
}

.bcmx-status-badge {
    display: inline-block;
    padding: 0.2em 0.6em;
    border-radius: var(--radius-sm, 4px);
    font-size: 0.8em;
    font-weight: 600;
}

.bcmx-status-online {
    background: var(--status-online-bg, #dcfce7);
    color: var(--status-online-text, #166534);
}

.bcmx-status-offline {
    background: var(--status-offline-bg, #fee2e2);
    color: var(--status-offline-text, #991b1b);
}

.bcmx-actions {
    white-space: nowrap;
}

.bcmx-actions .pure-button {
    margin-right: 0.3em;
}

.bcmx-btn-danger {
    background: var(--btn-danger-bg, #ef4444) !important;
    color: #fff !important;
}

.bcmx-btn-danger:hover {
    background: var(--btn-danger-hover, #dc2626) !important;
}

/* Sidebar user info */
.bcmx-user-info .bcmx-user-display {
    cursor: default;
    font-size: 0.85em;
    line-height: 1.3;
}

.bcmx-user-role {
    display: block;
    font-size: 0.8em;
    opacity: 0.6;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

@media (max-width: 48em) {
    .bcmx-login-card {
        padding: 2em 1.5em;
    }
}

/* ---------- Company Filter (sidebar dropdown) ---------- */
.bcmx-company-filter {
    padding: 8px 16px;
}
.bcmx-filter-form {
    display: flex;
    flex-direction: column;
    gap: 4px;
}
.bcmx-filter-label {
    font-size: 0.75em;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    opacity: 0.7;
    color: inherit;
}
.bcmx-filter-select {
    width: 100%;
    padding: 4px 6px;
    font-size: 0.85em;
    border-radius: 4px;
    border: 1px solid rgba(255,255,255,0.2);
    background: rgba(255,255,255,0.1);
    color: inherit;
    cursor: pointer;
}
.bcmx-filter-select:focus {
    outline: 2px solid var(--accent-color, #1f8dd6);
    outline-offset: -1px;
}
.bcmx-filter-select option {
    background: #333;
    color: #fff;
}
