/* ─────────────────────────────────────────────────────────────────────────
   CRM CONSISTENCY OVERLAY
   Loaded last in layout.blade.php so it wins specificity over the various
   per-page button/card/input class systems (.ld-*, .lb-*, .ml-*, .cf-*,
   .db-*, .master-*).  Goal: every page snaps onto the same brand palette,
   radii, shadows, and focus rings without rewriting individual blades.
───────────────────────────────────────────────────────────────────────── */

:root {
    /* Single source of truth for brand & semantic colors.
       Mirrors modern-ui.css tokens but adds the semantic surface set
       used by ad-hoc page styles. */
    --crm-primary:        #163f7a;
    --crm-primary-hover:  #0f2d57;
    --crm-primary-soft:   rgba(22, 63, 122, 0.08);
    --crm-primary-ring:   rgba(22, 63, 122, 0.18);

    --crm-success:        #34a853;
    --crm-warning:        #f29900;
    --crm-danger:         #ea4335;
    --crm-info:           #1a73e8;

    --crm-text:           #1e293b;
    --crm-muted:          #64748b;
    --crm-surface:        #ffffff;
    --crm-bg:             #f4f7f6;
    --crm-border:         #e2e8f0;

    --crm-radius-sm:      8px;
    --crm-radius-md:      12px;
    --crm-radius-lg:      16px;

    --crm-shadow-soft:    0 4px 10px -2px rgba(15, 45, 87, 0.06), 0 2px 4px -2px rgba(0,0,0,0.04);
    --crm-shadow-hover:   0 8px 18px -4px rgba(15, 45, 87, 0.12), 0 4px 8px -4px rgba(0,0,0,0.05);

    --crm-font:           'Inter', -apple-system, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
}

/* ───────── 1. BUTTONS ─────────
   Every "primary" class family lands on the same brand pill.
   Every "ghost / outline" lands on the same neutral look.
   Every "danger" lands on the same red. */
.ld-btn,
.lb-btn,
.ml-btn,
.cf-btn,
.db-btn,
.hb-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    font-family: var(--crm-font);
    font-weight: 600;
    font-size: 0.85rem;
    line-height: 1.2;
    padding: 8px 16px;
    border-radius: var(--crm-radius-sm);
    border: 1.5px solid transparent;
    cursor: pointer;
    transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease, transform 0.05s ease;
    text-decoration: none;
    white-space: nowrap;
}

.ld-btn:active,
.lb-btn:active,
.ml-btn:active,
.cf-btn:active,
.db-btn:active,
.hb-btn:active { transform: translateY(1px); }

/* Primary */
.ld-btn-primary,
.lb-btn-primary,
.ml-btn-primary,
.cf-btn-primary,
.db-btn-primary,
.hb-btn-primary,
.ld-btn.ld-btn-primary {
    background: var(--crm-primary) !important;
    color: #fff !important;
    border-color: var(--crm-primary) !important;
    box-shadow: 0 1px 2px rgba(15, 45, 87, 0.18);
}

.ld-btn-primary:hover,
.lb-btn-primary:hover,
.ml-btn-primary:hover,
.cf-btn-primary:hover,
.db-btn-primary:hover,
.hb-btn-primary:hover {
    background: var(--crm-primary-hover) !important;
    border-color: var(--crm-primary-hover) !important;
    color: #fff !important;
}

/* Ghost / Secondary */
.ld-btn-ghost,
.lb-btn-ghost,
.lb-btn-secondary,
.ml-btn-ghost,
.cf-btn-ghost,
.db-btn-ghost,
.hb-btn-ghost {
    background: #fff !important;
    color: var(--crm-text) !important;
    border-color: var(--crm-border) !important;
}

.ld-btn-ghost:hover,
.lb-btn-ghost:hover,
.lb-btn-secondary:hover,
.ml-btn-ghost:hover,
.cf-btn-ghost:hover,
.db-btn-ghost:hover,
.hb-btn-ghost:hover {
    background: var(--crm-primary-soft) !important;
    color: var(--crm-primary) !important;
    border-color: var(--crm-primary-soft) !important;
}

/* Danger */
.ld-btn-danger,
.lb-btn-danger,
.ml-btn-danger,
.cf-btn-danger,
.db-btn-danger {
    background: #fff !important;
    color: var(--crm-danger) !important;
    border-color: rgba(234, 67, 53, 0.25) !important;
}

.ld-btn-danger:hover,
.lb-btn-danger:hover,
.ml-btn-danger:hover,
.cf-btn-danger:hover,
.db-btn-danger:hover {
    background: var(--crm-danger) !important;
    color: #fff !important;
    border-color: var(--crm-danger) !important;
}

/* Focus ring — applies to every button family */
.ld-btn:focus-visible,
.lb-btn:focus-visible,
.ml-btn:focus-visible,
.cf-btn:focus-visible,
.db-btn:focus-visible,
.hb-btn:focus-visible,
.btn:focus-visible {
    outline: none;
    box-shadow: 0 0 0 3px var(--crm-primary-ring) !important;
}

/* ───────── 2. CARDS ─────────
   Unify radius + shadow + hairline border on every "card" the CRM ships. */
.ld-card,
.ml-card,
.db-card,
.dash-card,
.master-card,
.cf-card {
    background: var(--crm-surface);
    border: 1px solid var(--crm-border);
    border-radius: var(--crm-radius-md);
    box-shadow: var(--crm-shadow-soft);
}

/* Card headers */
.ml-card-header,
.db-card-head,
.ld-card-header,
.cf-card-header {
    padding: 14px 18px;
    border-bottom: 1px solid var(--crm-border);
    background: #fafbfc;
    border-top-left-radius: var(--crm-radius-md);
    border-top-right-radius: var(--crm-radius-md);
}

.ml-card-body,
.ld-card-body,
.cf-card-body {
    padding: 18px;
}

.ml-card-title,
.db-card-title,
.ld-card-title,
.cf-card-title {
    font-weight: 700;
    color: var(--crm-text);
    font-size: 0.92rem;
    margin: 0;
}

.ml-card-sub,
.ld-card-sub,
.cf-card-sub {
    font-size: 0.75rem;
    color: var(--crm-muted);
}

/* ───────── 3. FORM INPUTS & LABELS ─────────
   Make every input feel the same regardless of which page-local class
   the blade happens to use. */
.ml-label,
.ld-label,
.cf-label,
.kb-filter-label,
.form-label {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--crm-muted);
    margin-bottom: 6px;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

.form-control,
.form-select,
.form-control-premium,
.lb-select,
.kb-filter-input,
.kb-filter-select {
    border: 1.5px solid var(--crm-border) !important;
    border-radius: var(--crm-radius-sm) !important;
    padding: 9px 12px !important;
    font-size: 0.88rem !important;
    color: var(--crm-text) !important;
    background-color: #fff !important;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
    line-height: 1.3 !important;
}

.form-control:focus,
.form-select:focus,
.form-control-premium:focus,
.lb-select:focus,
.kb-filter-input:focus,
.kb-filter-select:focus {
    border-color: var(--crm-primary) !important;
    box-shadow: 0 0 0 3px var(--crm-primary-ring) !important;
    outline: none !important;
}

.input-group-text {
    background: #f8fafc !important;
    border: 1.5px solid var(--crm-border) !important;
    color: var(--crm-muted) !important;
    border-radius: var(--crm-radius-sm) !important;
}

/* ───────── 4. MODALS ─────────
   Unify modal radius and kill the per-page gradient headers. */
.modal-content {
    border-radius: var(--crm-radius-lg) !important;
    border: none !important;
    box-shadow: 0 24px 48px -12px rgba(15, 45, 87, 0.25) !important;
    overflow: hidden;
}

.master-modal .modal-header,
.ld-modal .modal-header,
.modal-header.brand,
.cf-modal-header {
    background: var(--crm-primary) !important;
    color: #fff !important;
    padding: 18px 24px !important;
    border-bottom: none !important;
}

.master-modal .modal-header .modal-title,
.modal-header.brand .modal-title {
    color: #fff !important;
    font-weight: 700;
}

/* ───────── 5. BADGES / CHIPS ─────────
   Make status pills use a consistent shape and weight. */
.badge,
.lb-badge,
.ld-badge,
.cf-badge,
.badge-category,
.badge-default {
    font-weight: 600 !important;
    font-size: 0.7rem !important;
    padding: 4px 10px !important;
    border-radius: 999px !important;
    letter-spacing: 0.2px;
}

/* ───────── 6. TABLES ─────────
   Cleanup spacing and header treatment across DataTable / custom tables. */
.leads-table thead th,
.master-table thead th,
.dash-card table thead th,
table.dataTable thead th {
    background: #f8fafc !important;
    color: var(--crm-muted) !important;
    font-weight: 700 !important;
    text-transform: uppercase !important;
    font-size: 0.7rem !important;
    letter-spacing: 0.06em !important;
    border-bottom: 2px solid var(--crm-border) !important;
    padding: 12px 14px !important;
}

.leads-table tbody td,
.master-table tbody td,
table.dataTable tbody td {
    padding: 12px 14px !important;
    font-size: 0.86rem !important;
    color: var(--crm-text) !important;
    border-bottom: 1px solid #f1f5f9 !important;
    vertical-align: middle !important;
}

.leads-table tbody tr:hover,
.master-table tbody tr:hover,
table.dataTable tbody tr:hover {
    background: #fafbfc !important;
}

/* ───────── 7. SECTION HEADERS / DIVIDERS ───────── */
.section-divider,
.ld-section-label {
    font-size: 0.72rem !important;
    font-weight: 700 !important;
    color: var(--crm-muted) !important;
    text-transform: uppercase !important;
    letter-spacing: 0.5px !important;
    padding-bottom: 6px !important;
    margin: 12px 0 10px !important;
    border-bottom: 1px solid var(--crm-border) !important;
}

/* ───────── 8. UTILITY: icon buttons ───────── */
/*.lb-icon-btn,
.ld-quick-btn,
.action-btn,
.cf-icon-btn {
    width: 36px;
    height: 36px;
    border-radius: var(--crm-radius-sm);
    background: var(--crm-surface);
    color: var(--crm-muted);
    border: 1px solid var(--crm-border);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 1.05rem;
    cursor: pointer;
    transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}*/
.lb-icon-btn, .ld-quick-btn, .action-btn, .cf-icon-btn {
    width: 36px;
    height: 36px;
    border-radius: var(--crm-radius-sm);
    background: rgba(255, 255, 255, 0.1);
    color: #ffffff !important;
    border: 1px solid rgba(255, 255, 255, 0.15);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 1.05rem;
    cursor: pointer;
    transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}

.lb-icon-btn:hover,
.ld-quick-btn:hover,
.action-btn:hover,
.cf-icon-btn:hover {
    background: var(--crm-primary-soft);
    color: var(--crm-primary);
    border-color: var(--crm-primary-soft);
}

/* ───────── 9. SCROLLBAR (subtle, brand-tinted) ───────── */
*::-webkit-scrollbar { width: 8px; height: 8px; }
*::-webkit-scrollbar-thumb { background: var(--crm-border); border-radius: 8px; }
*::-webkit-scrollbar-thumb:hover { background: var(--crm-muted); }
*::-webkit-scrollbar-track { background: transparent; }

/* ───────── 10. RESPONSIVE TYPE SCALE ─────────
   Smaller header titles on phones so the header doesn't overflow. */
@media (max-width: 576px) {
    .header-page-title { font-size: 1rem !important; }
    .hb-greeting { font-size: 1.4rem !important; }
    .db-kpi-val { font-size: 1.3rem !important; }
}

/* ═══════════════════════════════════════════════════════════════════
   11. PREMIUM CARD HOVER & MICRO-ANIMATIONS
   Adds depth and interactivity to info-cards used in lead modals.
═══════════════════════════════════════════════════════════════════ */
.ld-info-card {
    transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease !important;
    align-self: start !important;
}

.ld-info-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--crm-shadow-hover) !important;
    border-color: rgba(22, 63, 122, 0.15) !important;
}

.ld-info-card-header {
    border-bottom-color: rgba(22, 63, 122, 0.08) !important;
}

/* Full-width info rows — label above, value below */
.ld-info-row.full-width {
    flex-direction: column;
    align-items: flex-start;
}

.ld-info-row.full-width .ld-info-val {
    width: 100%;
    word-break: break-word;
}

/* Info-row subtle hover highlight */
.ld-info-row {
    transition: background 0.12s ease;
    border-radius: 4px;
    padding-left: 4px !important;
    padding-right: 4px !important;
}

.ld-info-row:hover {
    background: var(--crm-primary-soft);
}

/* ═══════════════════════════════════════════════════════════════════
   12. ML-CARD (ManageLead Form) ENHANCEMENTS
   Adds hover depth, premium separator lines, and polished look.
═══════════════════════════════════════════════════════════════════ */
.ml-card {
    transition: transform 0.2s ease, box-shadow 0.2s ease !important;
    overflow: hidden;
}

.ml-card:hover {
    box-shadow: var(--crm-shadow-hover) !important;
}

.ml-card-header {
    display: flex;
    align-items: center;
    gap: 14px;
}

.ml-card-icon {
    width: 42px;
    height: 42px;
    border-radius: var(--crm-radius-sm);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
    flex-shrink: 0;
    transition: transform 0.15s ease;
}

.ml-card:hover .ml-card-icon {
    transform: scale(1.08);
}

/* ═══════════════════════════════════════════════════════════════════
   13. CONTACT CLONER BUTTONS (manageLead dynamic rows)
   Modern +/− buttons with premium hover transitions.
═══════════════════════════════════════════════════════════════════ */
.contact-row .btn {
    transition: all 0.18s ease !important;
    border-radius: var(--crm-radius-sm) !important;
    font-size: 1rem !important;
    min-width: 38px;
}

.contact-row .btn:hover {
    transform: scale(1.08);
    box-shadow: 0 2px 8px rgba(22, 63, 122, 0.15) !important;
}

.contact-row .btn-outline-primary {
    color: var(--crm-primary) !important;
    border-color: var(--crm-primary) !important;
}

.contact-row .btn-outline-primary:hover {
    background: var(--crm-primary) !important;
    color: #fff !important;
}

.contact-row .btn-outline-danger:hover {
    background: var(--crm-danger) !important;
    color: #fff !important;
    border-color: var(--crm-danger) !important;
}

/* "Add More" address button premium style */
#addMoreAddressBtn {
    background: var(--crm-primary) !important;
    border-color: var(--crm-primary) !important;
    color: #fff !important;
    border-radius: var(--crm-radius-sm) !important;
    font-weight: 600 !important;
    transition: all 0.18s ease !important;
}

#addMoreAddressBtn:hover {
    background: var(--crm-primary-hover) !important;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(22, 63, 122, 0.2) !important;
}

/* ═══════════════════════════════════════════════════════════════════
   14. BULK ACTION BAR — GLASSMORPHIC FLOATING
   Premium frosted-glass bottom bar with safe mobile wrap.
═══════════════════════════════════════════════════════════════════ */
#bulkActionBar {
    background: rgba(255, 255, 255, 0.85) !important;
    backdrop-filter: blur(12px) !important;
    -webkit-backdrop-filter: blur(12px) !important;
    border-top: 1px solid var(--crm-border) !important;
    box-shadow: 0 -4px 16px -4px rgba(15, 45, 87, 0.1) !important;
    border-radius: var(--crm-radius-md) var(--crm-radius-md) 0 0 !important;
    padding: 12px 20px !important;
    z-index: 1050 !important;
}

@media (max-width: 768px) {
    #bulkActionBar {
        flex-wrap: wrap !important;
        gap: 8px !important;
        justify-content: center !important;
        padding: 10px 12px !important;
    }

    #bulkActionBar .btn,
    #bulkActionBar .ld-btn {
        font-size: 0.75rem !important;
        padding: 6px 10px !important;
    }
}

/* ═══════════════════════════════════════════════════════════════════
   15. UNIFIED STATUS PIPELINE BADGE COLORS
   Single source of truth for pipeline stage badge colors.
═══════════════════════════════════════════════════════════════════ */
.badge-status-new,
.badge-status-0 {
    background: #5f6368 !important;
    color: #fff !important;
}

.badge-status-contacted,
.badge-status-1 {
    background: #f29900 !important;
    color: #fff !important;
}

.badge-status-qualified,
.badge-status-2 {
    background: #7c3aed !important;
    color: #fff !important;
}

.badge-status-proposal,
.badge-status-3 {
    background: #1a73e8 !important;
    color: #fff !important;
}

.badge-status-converted,
.badge-status-5 {
    background: #1e8e3e !important;
    color: #fff !important;
}

.badge-status-lost,
.badge-status-9 {
    background: #ea4335 !important;
    color: #fff !important;
}

/* ═══════════════════════════════════════════════════════════════════
   16. FORM CHECKBOX PREMIUM STYLE
   Better alignment and color for check inputs.
═══════════════════════════════════════════════════════════════════ */
.form-check-input:checked {
    background-color: var(--crm-primary) !important;
    border-color: var(--crm-primary) !important;
}

.form-check-input:focus {
    box-shadow: 0 0 0 3px var(--crm-primary-ring) !important;
    border-color: var(--crm-primary) !important;
}

/* ═══════════════════════════════════════════════════════════════════
   17. ML-FORM FOOTER (ManageLead submit area)
   Clean sticky footer with modern spacing.
═══════════════════════════════════════════════════════════════════ */
.ml-form-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 18px 24px;
    background: var(--crm-surface);
    border: 1px solid var(--crm-border);
    border-radius: var(--crm-radius-md);
    box-shadow: var(--crm-shadow-soft);
}

@media (max-width: 576px) {
    .ml-form-footer {
        flex-direction: column;
        gap: 10px;
    }

    .ml-form-footer .d-flex {
        width: 100%;
        justify-content: stretch;
    }

    .ml-form-footer .d-flex .lb-btn {
        flex: 1;
    }
}

/* ═══════════════════════════════════════════════════════════════════
   18. LEAD DETAIL MODAL RESPONSIVE
   Cards stack on small screens.
═══════════════════════════════════════════════════════════════════ */
@media (max-width: 576px) {
    .ld-info-grid {
        grid-template-columns: 1fr !important;
        gap: 10px !important;
    }

    .ld-info-card {
        grid-column: 1 / -1 !important;
    }
}

/* ═══════════════════════════════════════════════════════════════════
   19. PAGE TOPBAR (ManageLead header)
   Premium topbar with spacing and badge.
═══════════════════════════════════════════════════════════════════ */
.ml-page-topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 12px;
}

.ml-page-topbar-left {
    display: flex;
    align-items: center;
    gap: 14px;
}

.ml-back-btn {
    width: 40px;
    height: 40px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--crm-radius-sm);
    border: 1px solid var(--crm-border);
    color: var(--crm-text);
    background: var(--crm-surface);
    font-size: 1.1rem;
    text-decoration: none;
    transition: all 0.15s ease;
}

.ml-back-btn:hover {
    background: var(--crm-primary-soft);
    color: var(--crm-primary);
    border-color: var(--crm-primary-soft);
}

.ml-page-title {
    font-size: 1.15rem;
    font-weight: 700;
    color: var(--crm-text);
    margin: 0;
    line-height: 1.3;
}

.ml-page-subtitle {
    font-size: 0.78rem;
    color: var(--crm-muted);
    margin: 0;
}

.ml-lead-badge {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 5px 14px;
    border-radius: 999px;
    font-size: 0.72rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.4px;
    background: rgba(22, 63, 122, 0.08);
    color: var(--crm-primary);
}

.ml-lead-badge-new {
    background: rgba(30, 142, 62, 0.08);
    color: #1e8e3e;
}

/* ═══════════════════════════════════════════════════════════════════
   20. SMOOTH PAGE ENTRY ANIMATION
   Subtle fade-in for main content area.
═══════════════════════════════════════════════════════════════════ */
@keyframes crm-fadeInUp {
    from {
        opacity: 0;
        transform: translateY(12px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.dash-container {
    animation: crm-fadeInUp 0.35s ease-out;
}

.ld-info-grid {
    animation: crm-fadeInUp 0.3s ease-out;
}
