/* ===================================================================
   BaobabProcure — Cross-Page Harmonization Layer
   Normalizes page-scoped custom classes (Dashboard, Users, Roles,
   Organization, Tenants, Workflows, Catalog, Settings, etc.) so they
   share the same visual language across light + dark themes.
   Loaded AFTER app.css and AFTER each page's inline <style>, so these
   rules win the cascade (page styles use specificity 0,1,0 — we match
   that but rely on file order).
   =================================================================== */

/* ── Generic surfaces used by multiple pages ── */
.metric-card,
.panel-glass,
.users-dashboard .metric-card {
    background: var(--bg-surface) !important;
    border: 1px solid var(--border);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-sm);
    transition: box-shadow var(--duration) var(--ease), transform var(--duration) var(--ease);
}
.metric-card:hover,
.panel-glass:hover { box-shadow: var(--shadow-md); }

.metric-value {
    color: var(--text-primary);
    font-family: var(--font-mono);
    font-variant-numeric: tabular-nums;
    font-weight: 650;
    letter-spacing: -0.015em;
}
.metric-label {
    color: var(--text-muted);
    font-size: 13px;
    font-weight: 500;
}
.metric-details { color: var(--text-secondary); font-size: 13px; }

/* ── Tabs (used in Organization, AppSettings, Accounting, Reporting) ── */
.tabs-container {
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 4px;
    display: inline-flex;
    gap: 2px;
}
.tab-btn {
    background: transparent;
    color: var(--text-secondary);
    border: none;
    padding: 8px 16px;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--duration) var(--ease);
    display: inline-flex; align-items: center; gap: 8px;
    line-height: 1.4;
}
.tab-btn:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}
.tab-btn.active {
    background: var(--bg-surface);
    color: var(--primary);
    box-shadow: var(--shadow-xs);
}
[data-theme="dark"] .tab-btn.active {
    background: var(--primary);
    color: white;
    box-shadow: 0 2px 8px rgba(96, 165, 250, 0.25);
}

/* ── Action Card (Users top metric) ── */
.action-card {
    background: var(--primary-gradient) !important;
    border-radius: var(--radius-xl);
    color: white;
    box-shadow: 0 8px 28px rgba(37, 99, 235, 0.25), inset 0 1px 0 rgba(255, 255, 255, 0.18);
    border: none !important;
}
.action-card .icon-box {
    background: rgba(255, 255, 255, 0.18) !important;
    border-radius: 12px;
    backdrop-filter: blur(8px);
}
.action-card .metric-value,
.action-card .text-purple { color: white !important; }
.action-card .metric-label { color: rgba(255, 255, 255, 0.85) !important; }

/* ── Color helpers used in Users ── */
.bg-purple-dim { background-color: var(--primary-muted) !important; }
.text-purple   { color: var(--primary) !important; }
.bg-green-dim  { background-color: var(--success-muted) !important; }
.text-green    { color: var(--success) !important; }
[data-theme="dark"] .bg-purple-dim { background-color: rgba(96, 165, 250, 0.12) !important; }
[data-theme="dark"] .text-purple   { color: var(--primary-light) !important; }
[data-theme="dark"] .bg-green-dim  { background-color: rgba(52, 211, 153, 0.10) !important; }
[data-theme="dark"] .text-green    { color: var(--success-light) !important; }

/* ── Btn-action (filter pills) ── */
.btn-action {
    background: var(--bg-surface);
    color: var(--text-secondary);
    border: 1px solid var(--border-strong);
    border-radius: 10px;
    padding: 8px 14px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--duration) var(--ease);
}
.btn-action:hover { background: var(--bg-hover); color: var(--text-primary); }
.btn-action.active {
    background: var(--primary) !important;
    color: white !important;
    border-color: var(--primary) !important;
    box-shadow: 0 2px 8px rgba(37, 99, 235, 0.25);
}

/* ── User list cards (Users page) ── */
.user-item-card {
    border-bottom: 1px solid var(--border) !important;
    transition: background var(--duration) var(--ease);
}
.user-item-card:hover { background: var(--bg-hover); }
[data-theme="dark"] .user-avatar {
    background: var(--bg-elevated) !important;
    color: var(--text-primary) !important;
}
.role-badge {
    background: var(--bg-hover);
    color: var(--text-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius-full);
    padding: 3px 10px;
    font-size: 11px;
    font-weight: 600;
}
[data-theme="dark"] .role-badge {
    background: var(--bg-elevated) !important;
    color: var(--text-secondary) !important;
}
.dot-active {
    box-shadow: 0 0 8px rgba(5, 150, 105, 0.5);
    background: var(--success);
}
[data-theme="dark"] .dot-active {
    box-shadow: 0 0 8px rgba(52, 211, 153, 0.5) !important;
}

/* ── Generic icon button (Users, etc.) ── */
.btn-icon {
    background: var(--bg-elevated);
    color: var(--text-secondary);
    border: 1px solid var(--border);
    border-radius: 8px;
    width: 32px; height: 32px;
    display: inline-flex; align-items: center; justify-content: center;
    cursor: pointer;
    transition: all var(--duration) var(--ease);
}
.btn-icon:hover {
    background: var(--bg-hover);
    color: var(--danger);
    border-color: rgba(220, 38, 38, 0.20);
}
[data-theme="dark"] .btn-icon {
    background: var(--bg-elevated) !important;
    color: var(--text-secondary) !important;
}
[data-theme="dark"] .btn-icon:hover {
    background: var(--bg-hover) !important;
    color: var(--danger) !important;
}

/* ── Floating Action Button ── */
.fab-btn {
    background: var(--primary-gradient);
    color: white !important;
    box-shadow: 0 6px 22px rgba(37, 99, 235, 0.35);
    border-radius: 50%;
    border: none;
    transition: all var(--duration) var(--ease);
}
.fab-btn:hover {
    box-shadow: 0 10px 32px rgba(37, 99, 235, 0.50);
    transform: translateY(-2px) scale(1.02);
}
[data-theme="dark"] .fab-btn {
    color: white !important;
    box-shadow: 0 6px 22px rgba(96, 165, 250, 0.40) !important;
}
[data-theme="dark"] .fab-btn:hover {
    box-shadow: 0 10px 32px rgba(96, 165, 250, 0.55) !important;
}

/* ── Roles page ── */
.roles-grid .role-card,
.role-card {
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-sm);
    transition: all var(--duration) var(--ease);
}
.role-card:hover { box-shadow: var(--shadow-md); border-color: var(--border-strong); }
[data-theme="dark"] .roles-grid .role-card,
[data-theme="dark"] .role-card { background: var(--bg-surface) !important; }

.permission-group-title {
    font-size: 11px;
    font-weight: 700;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.06em;
    margin-bottom: 10px;
    display: flex; align-items: center; gap: 10px;
}
.permission-group-title::after {
    content: '';
    flex: 1;
    height: 1px;
    background: var(--border);
}
[data-theme="dark"] .permission-group-title::after { background: var(--border) !important; }

.permission-item {
    background: var(--bg-elevated);
    color: var(--text-secondary);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 8px 12px;
    font-size: 12px;
    font-weight: 500;
    transition: all var(--duration) var(--ease);
}
.permission-item:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}
.permission-item.granted {
    background: var(--primary-muted);
    color: var(--primary);
    border-color: rgba(37, 99, 235, 0.18);
}
[data-theme="dark"] .permission-item {
    background: var(--bg-elevated) !important;
    color: var(--text-secondary) !important;
}
[data-theme="dark"] .permission-item:hover { background: var(--bg-hover) !important; }
[data-theme="dark"] .permission-item.granted {
    background: var(--primary-muted) !important;
    color: var(--primary-light) !important;
    border-color: var(--border-focus) !important;
}

/* ── Organization tree (org chart) ── */
.org-card {
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    transition: all var(--duration) var(--ease);
}
.org-card:hover { box-shadow: var(--shadow-md); border-color: var(--border-strong); }
.org-card.highlight-me {
    background: var(--primary-muted);
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-muted), var(--shadow-md);
}
[data-theme="dark"] .org-card { box-shadow: 0 2px 8px rgba(0, 0, 0, 0.25) !important; }
[data-theme="dark"] .org-card:hover { box-shadow: 0 4px 16px rgba(0, 0, 0, 0.35) !important; }
[data-theme="dark"] .org-card.highlight-me { background: var(--primary-muted) !important; }

/* ── KPI tiles (Dashboard / Reporting) ── */
.kpi-tile, .rpt-kpi-card {
    background: var(--bg-surface) !important;
    border: 1px solid var(--border) !important;
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-sm);
    transition: all var(--duration) var(--ease);
}
.kpi-tile:hover, .rpt-kpi-card:hover {
    box-shadow: var(--shadow-md);
    transform: translateY(-2px);
    border-color: var(--border-strong) !important;
}

.kpi-icon {
    border-radius: 10px;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.06);
}
.rpt-kpi-icon { border-radius: 11px; }

.kpi-value, .rpt-kpi-value {
    font-family: var(--font-mono);
    color: var(--text-primary) !important;
    font-variant-numeric: tabular-nums;
    letter-spacing: -0.02em;
}
.kpi-label, .rpt-kpi-label {
    color: var(--text-secondary) !important;
}

/* ── Catalog category cards ── */
.cat-card {
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-sm);
    transition: all var(--duration) var(--ease);
}
.cat-card:hover {
    box-shadow: var(--shadow-md);
    transform: translateY(-2px);
    border-color: var(--border-strong);
}

/* ── Cost center / budget cards ── */
.budget-card {
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-sm);
}
.stat-box {
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 10px 14px;
}
.stat-box .stat-amount {
    font-family: var(--font-mono);
    font-weight: 600;
    color: var(--text-primary);
    font-variant-numeric: tabular-nums;
}
.stat-box .stat-label {
    color: var(--text-muted);
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    font-weight: 600;
}

.progress-bar-bg {
    background: var(--bg-active);
    border-radius: var(--radius-full);
    overflow: hidden;
}
.progress-bar-fill,
.fill-success { background: linear-gradient(90deg, var(--success), var(--success-light)); }
.fill-warning { background: linear-gradient(90deg, var(--warning), var(--warning-light)); }
.fill-danger  { background: linear-gradient(90deg, var(--danger), var(--danger-light)); }

/* ── Detail cards (PR / PO / Invoice / GR detail pages) ── */
.detail-card {
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-sm);
    padding: 22px;
}
.detail-card-title {
    font-size: 16px;
    font-weight: 650;
    color: var(--text-primary);
    margin-bottom: 16px;
    letter-spacing: -0.012em;
}
.detail-row {
    display: flex;
    padding: 10px 0;
    border-bottom: 1px solid var(--border-light);
    gap: 16px;
}
.detail-row:last-child { border-bottom: none; }
.detail-label {
    color: var(--text-muted);
    font-size: 13px;
    font-weight: 500;
    flex-shrink: 0;
    min-width: 160px;
}
.detail-value {
    color: var(--text-primary);
    font-size: 14px;
    font-weight: 500;
    flex: 1;
}

/* ── PR form sections ── */
.pr-form-section {
    margin-bottom: 24px;
}
.pr-form-section-title {
    font-size: 12px;
    font-weight: 700;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.06em;
    margin-bottom: 14px;
    padding-bottom: 8px;
    border-bottom: 1px solid var(--border);
    display: flex; align-items: center; gap: 8px;
}
.pr-form-section-title i { color: var(--primary); font-size: 14px; }
.pr-item-count {
    margin-left: auto;
    background: var(--primary-muted);
    color: var(--primary);
    border-radius: var(--radius-full);
    padding: 2px 10px;
    font-size: 11px;
    font-weight: 700;
}

.pr-form-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 16px;
}
.pr-form-field { display: flex; flex-direction: column; }
.pr-form-field--wide { grid-column: 1 / -1; }
.pr-form-field label {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 6px;
}
@media (max-width: 768px) {
    .pr-form-grid { grid-template-columns: 1fr; }
}

.pr-items-table-wrap {
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    overflow: hidden;
}
.pr-items-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.pr-items-table th {
    background: var(--bg-elevated);
    color: var(--text-muted);
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    padding: 10px 12px;
    text-align: left;
    border-bottom: 1px solid var(--border);
}
.pr-items-table td {
    padding: 8px 12px;
    border-bottom: 1px solid var(--border-light);
    vertical-align: middle;
}
.pr-items-table tr:last-child td { border-bottom: none; }
.pr-item-total {
    font-family: var(--font-mono);
    font-weight: 600;
    color: var(--text-primary);
    font-variant-numeric: tabular-nums;
}
.pr-item-remove {
    background: transparent;
    border: 1px solid var(--border);
    color: var(--text-muted);
    width: 28px; height: 28px;
    border-radius: 6px;
    cursor: pointer;
    transition: all var(--duration) var(--ease);
}
.pr-item-remove:hover {
    background: var(--danger-muted);
    border-color: var(--danger);
    color: var(--danger);
}
.pr-item-catalog-tag {
    display: inline-flex; align-items: center; gap: 5px;
    margin-top: 4px;
    font-size: 11px;
    color: var(--primary);
    background: var(--primary-muted);
    padding: 2px 7px;
    border-radius: var(--radius-full);
    font-weight: 600;
}

/* ── Quick action buttons (Dashboard) ── */
.quick-btn {
    background: var(--bg-elevated) !important;
    border: 1px solid var(--border) !important;
    transition: all var(--duration) var(--ease);
}
.quick-btn:hover {
    background: var(--primary-muted) !important;
    border-color: var(--primary) !important;
    transform: translateY(-2px);
    box-shadow: var(--shadow-sm);
}
.quick-btn i { color: var(--primary) !important; }
.quick-btn span { color: var(--text-primary) !important; }

/* ── Activity / approval feed rows ── */
.activity-item, .approval-row {
    transition: background var(--duration) var(--ease);
    border-bottom: 1px solid var(--border) !important;
}
.activity-item:hover, .approval-row:hover {
    background: var(--bg-hover) !important;
}
.approval-ref {
    color: var(--primary) !important;
    font-family: var(--font-mono);
    font-weight: 650;
}

/* ── Login refinements (page-specific overrides) ── */
[data-theme="dark"] .login-brand {
    background: linear-gradient(160deg, #050810 0%, #0a0e1a 40%, #0c1224 100%) !important;
}

/* ── Profile page ── */
.profile-header {
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-xl);
    padding: 24px;
    box-shadow: var(--shadow-sm);
}
.info-row {
    display: flex;
    padding: 10px 0;
    border-bottom: 1px solid var(--border-light);
}
.info-row:last-child { border-bottom: none; }
.info-label {
    color: var(--text-muted);
    font-size: 13px;
    font-weight: 500;
    min-width: 180px;
}

/* ── Avatar placeholder ── */
.avatar-placeholder {
    background: var(--primary-gradient);
    color: white;
    border-radius: var(--radius-lg);
    display: inline-flex; align-items: center; justify-content: center;
    font-family: var(--font-display);
    font-weight: 700;
    box-shadow: 0 4px 14px rgba(37, 99, 235, 0.30);
}

/* ── Catch-all polish: any sub-page heading or label leaks ── */
.detail-header h1,
.detail-header h2,
.detail-header h3 {
    color: var(--text-primary);
    letter-spacing: -0.022em;
}

/* ── Inline-styled badges with color:white on primary backgrounds (legacy) ── */
[data-theme="dark"] .badge[style*="color:white"] { color: white !important; }

/* ── Sortable table column headers ── */
.sortable {
    cursor: pointer;
    user-select: none;
    transition: color var(--duration) var(--ease);
}
.sortable:hover { color: var(--text-primary); }
.sortable i { margin-left: 4px; opacity: 0.5; font-size: 10px; }

/* ── Sticky form footer ── */
.form-footer {
    display: flex; justify-content: flex-end; gap: 10px;
    padding-top: 18px;
    margin-top: 18px;
    border-top: 1px solid var(--border);
}

/* ── Stg-field (storage / settings field) ── */
.stg-field { margin-bottom: 18px; }
.stg-field label {
    display: block;
    font-size: 13px; font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 7px;
}
