/* =====================================================
   CREDBRAIN-AI — PROVIDERS DIRECTORY
===================================================== */

.providers-view {
    flex: 1;
    min-width: 0;
    min-height: 0;
    overflow-y: auto;
    padding: 26px 28px 34px;
    background:
        radial-gradient(circle at 30% 0%, rgba(51, 113, 232, 0.07), transparent 28%),
        #f5f8fc;
}

.providers-view.hidden {
    display: none !important;
}

.providers-heading {
    width: min(1380px, 100%);
    margin: 0 auto 22px;
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 24px;
}

.providers-heading-left {
    display: flex;
    align-items: flex-start;
    gap: 18px;
}

.providers-eyebrow {
    margin-bottom: 5px;
    color: #2671df;
    font-size: 9px;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.13em;
}

.providers-heading h3 {
    color: #17243a;
    font-size: 27px;
    font-weight: 800;
    letter-spacing: -0.045em;
    line-height: 1.15;
}

.providers-heading-left > div > p:last-child {
    margin-top: 7px;
    color: #6b788c;
    font-size: 12px;
    line-height: 1.55;
}

.providers-heading-actions {
    display: flex;
    align-items: center;
    gap: 12px;
}

.providers-updated-at {
    color: #8a97a9;
    font-size: 9px;
    font-weight: 600;
    white-space: nowrap;
}

.refresh-providers-button {
    min-height: 40px;
    padding: 0 15px;
    border: 1px solid #cbd8e9;
    border-radius: 11px;
    background: #ffffff;
    color: #245cac;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    cursor: pointer;
    font-size: 10px;
    font-weight: 750;
    box-shadow: 0 6px 18px rgba(15, 32, 56, 0.04);
}

.providers-summary-grid {
    width: min(1380px, 100%);
    margin: 0 auto 18px;
    display: grid;
    grid-template-columns: repeat(3, minmax(180px, 1fr));
    gap: 12px;
}

.provider-summary-card {
    min-height: 110px;
    padding: 17px;
    border: 1px solid #dfe7f0;
    border-radius: 16px;
    background: #ffffff;
    display: flex;
    align-items: center;
    gap: 14px;
    box-shadow: 0 9px 28px rgba(15, 32, 56, 0.045);
}

.provider-summary-icon {
    width: 42px;
    height: 42px;
    flex: 0 0 42px;
    border-radius: 13px;
    display: grid;
    place-items: center;
    color: #2567cb;
    background: #e9f1ff;
    font-size: 15px;
    font-weight: 850;
}

.provider-summary-icon.complete-icon {
    color: #217d59;
    background: #e3f6ed;
}

.provider-summary-icon.attention-icon {
    color: #b66b04;
    background: #fff2da;
}

.provider-summary-copy {
    display: grid;
    gap: 2px;
}

.provider-summary-copy span {
    color: #738096;
    font-size: 9px;
    font-weight: 750;
    text-transform: uppercase;
    letter-spacing: 0.08em;
}

.provider-summary-copy strong {
    color: #17243a;
    font-size: 25px;
    font-weight: 800;
    letter-spacing: -0.04em;
}

.provider-summary-copy small {
    color: #8a97a8;
    font-size: 8px;
}

.providers-toolbar {
    width: min(1380px, 100%);
    margin: 0 auto 14px;
    padding: 13px;
    border: 1px solid #dfe7f0;
    border-radius: 15px;
    background: #ffffff;
    display: grid;
    grid-template-columns: minmax(260px, 1.35fr) minmax(160px, 0.55fr) minmax(150px, 0.5fr) auto;
    align-items: end;
    gap: 12px;
    box-shadow: 0 7px 22px rgba(15, 32, 56, 0.035);
}

.provider-filter-field {
    display: grid;
    gap: 6px;
}

.provider-filter-field > span {
    color: #738096;
    font-size: 8px;
    font-weight: 750;
    text-transform: uppercase;
    letter-spacing: 0.08em;
}

.provider-filter-field input,
.provider-filter-field select {
    width: 100%;
    height: 39px;
    padding: 0 12px;
    border: 1px solid #d8e1ec;
    border-radius: 10px;
    outline: none;
    background: #f9fbfd;
    color: #25344a;
    font-size: 10px;
}

.providers-toolbar-right {
    display: flex;
    align-items: center;
    gap: 10px;
}

.providers-item-count {
    color: #78869a;
    font-size: 9px;
    font-weight: 650;
    white-space: nowrap;
}

.providers-content-card {
    width: min(1380px, 100%);
    min-height: 260px;
    margin: 0 auto;
}

.providers-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(250px, 1fr));
    gap: 14px;
}

.provider-directory-card {
    padding: 16px;
    border: 1px solid #dfe7f0;
    border-radius: 17px;
    background: #ffffff;
    box-shadow: 0 10px 28px rgba(15, 32, 56, 0.045);
}

.provider-directory-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 14px 34px rgba(15, 32, 56, 0.075);
}

.provider-directory-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.provider-directory-identity {
    display: flex;
    align-items: center;
    gap: 11px;
    min-width: 0;
}

.provider-directory-avatar {
    width: 42px;
    height: 42px;
    flex: 0 0 42px;
    border-radius: 13px;
    display: grid;
    place-items: center;
    color: #265ba7;
    background: #e6efff;
    font-size: 11px;
    font-weight: 800;
}

.provider-directory-name {
    min-width: 0;
}

.provider-directory-name strong {
    display: block;
    color: #1d2b40;
    font-size: 12px;
    font-weight: 750;
}

.provider-directory-name small {
    display: block;
    margin-top: 3px;
    color: #8794a6;
    font-size: 8px;
}

.provider-directory-status {
    min-height: 24px;
    padding: 0 8px;
    border-radius: 999px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 8px;
    font-weight: 750;
    white-space: nowrap;
}

.provider-directory-status.complete {
    color: #28734e;
    background: #e3f7ec;
}

.provider-directory-status.needs-attention {
    color: #9b5a05;
    background: #fff3d9;
}

.provider-directory-meta {
    margin-top: 15px;
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 9px;
}

.provider-directory-meta div {
    padding: 10px;
    border: 1px solid #edf1f6;
    border-radius: 11px;
    background: #f9fbfd;
}

.provider-directory-meta span {
    display: block;
    color: #8995a7;
    font-size: 7px;
    font-weight: 750;
    text-transform: uppercase;
    letter-spacing: 0.08em;
}

.provider-directory-meta strong {
    display: block;
    margin-top: 4px;
    color: #29374b;
    font-size: 9px;
    font-weight: 700;
}

.provider-progress-block {
    margin-top: 14px;
}

.provider-progress-row {
    margin-bottom: 7px;
    display: flex;
    justify-content: space-between;
    color: #6f7d90;
    font-size: 8px;
    font-weight: 650;
}

.provider-progress-track {
    width: 100%;
    height: 7px;
    border-radius: 999px;
    background: #e7edf5;
    overflow: hidden;
}

.provider-progress-bar {
    height: 100%;
    border-radius: inherit;
    background: linear-gradient(90deg, #2b70e8, #5e96f5);
}

.provider-directory-actions {
    margin-top: 15px;
    display: flex;
    gap: 8px;
}

.provider-directory-button {
    flex: 1;
    min-height: 36px;
    border: 1px solid #cbd8e9;
    border-radius: 10px;
    background: #eef4ff;
    color: #245cac;
    cursor: pointer;
    font-size: 8px;
    font-weight: 750;
}

.provider-directory-button.secondary {
    background: #ffffff;
    color: #53637a;
}

.providers-state-message {
    min-height: 260px;
    padding: 34px;
    border: 1px solid #dfe7f0;
    border-radius: 17px;
    background: #ffffff;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 11px;
    color: #758399;
    text-align: center;
    font-size: 11px;
}

.providers-error-state {
    color: #a13d3d;
    background: #fff9f9;
}

.providers-loading-spinner {
    width: 18px;
    height: 18px;
    border: 2px solid #d9e4f2;
    border-top-color: #2d70df;
    border-radius: 50%;
    animation: providers-spin 0.8s linear infinite;
}

@keyframes providers-spin {
    to { transform: rotate(360deg); }
}

body.dark-mode .providers-view {
    background: #101827;
}

body.dark-mode .providers-heading h3,
body.dark-mode .provider-summary-copy strong,
body.dark-mode .provider-directory-name strong,
body.dark-mode .provider-directory-meta strong {
    color: #edf3fc;
}

body.dark-mode .provider-summary-card,
body.dark-mode .providers-toolbar,
body.dark-mode .provider-directory-card,
body.dark-mode .providers-state-message {
    border-color: #27344a;
    background: #172235;
}

body.dark-mode .provider-filter-field input,
body.dark-mode .provider-filter-field select,
body.dark-mode .provider-directory-meta div {
    border-color: #2e3b51;
    background: #111a2a;
    color: #e4ebf5;
}

@media (max-width: 1100px) {
    .providers-grid {
        grid-template-columns: repeat(2, minmax(250px, 1fr));
    }

    .providers-toolbar {
        grid-template-columns: 1fr 1fr;
    }

    .providers-toolbar-right {
        grid-column: 1 / -1;
        justify-content: space-between;
    }
}

@media (max-width: 760px) {
    .providers-view {
        padding: 18px 14px 28px;
    }

    .providers-heading {
        flex-direction: column;
    }

    .providers-heading-left {
        flex-direction: column;
    }

    .providers-summary-grid,
    .providers-grid,
    .providers-toolbar {
        grid-template-columns: 1fr;
    }

    .providers-toolbar-right {
        grid-column: auto;
    }
}
/* =====================================================
   PROVIDERS DIRECTORY – LAYOUT REPAIR
===================================================== */

#providersView {
    display: block;
    position: relative;
    width: 100%;
    min-width: 0;
    min-height: calc(100vh - 86px);
    height: auto;
    padding: 28px;
    box-sizing: border-box;
    overflow: visible;
}

#providersView.hidden {
    display: none;
}

#providersGrid {
    display: grid;
    grid-template-columns: repeat(
        auto-fit,
        minmax(300px, 1fr)
    );
    gap: 20px;
    width: 100%;
    min-width: 0;
    height: auto;
    min-height: 1px;
    position: relative;
    overflow: visible;
}

#providersGrid.hidden {
    display: none;
}

.provider-directory-card {
    display: block;
    position: relative;
    width: 100%;
    min-width: 0;
    min-height: 280px;
    height: auto;
    padding: 22px;
    box-sizing: border-box;
    background: #ffffff;
    border: 1px solid #dce5f0;
    border-radius: 16px;
    overflow: visible;
}

.provider-directory-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
    width: 100%;
}

.provider-directory-identity {
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 0;
}

.provider-directory-avatar {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 46px;
    height: 46px;
    min-width: 46px;
    border-radius: 12px;
    background: #e8f8fc;
    color: #087f9c;
    font-weight: 700;
}

.provider-directory-name {
    display: flex;
    flex-direction: column;
    gap: 4px;
    min-width: 0;
}

.provider-directory-name strong {
    color: #12233f;
    font-size: 16px;
}

.provider-directory-name small {
    color: #64748b;
    font-size: 13px;
}

.provider-directory-status {
    display: inline-flex;
    align-items: center;
    white-space: nowrap;
    padding: 6px 10px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 700;
}

.provider-directory-status.complete {
    background: #dcfce7;
    color: #15803d;
}

.provider-directory-status.needs-attention {
    background: #fff7ed;
    color: #c2410c;
}

.provider-directory-meta {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 14px;
    width: 100%;
    margin-top: 22px;
}

.provider-directory-meta div {
    display: flex;
    flex-direction: column;
    gap: 4px;
    min-width: 0;
}

.provider-directory-meta span {
    color: #64748b;
    font-size: 12px;
}

.provider-directory-meta strong {
    color: #17233b;
    font-size: 14px;
    overflow-wrap: anywhere;
}

.provider-progress-block {
    display: block;
    width: 100%;
    margin-top: 22px;
}

.provider-progress-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 8px;
    color: #475569;
    font-size: 13px;
}

.provider-progress-track {
    display: block;
    width: 100%;
    height: 8px;
    background: #e8edf5;
    border-radius: 999px;
    overflow: hidden;
}

.provider-progress-bar {
    display: block;
    height: 100%;
    min-width: 0;
    background: #13a6c6;
    border-radius: 999px;
}

.provider-directory-actions {
    display: flex;
    gap: 10px;
    width: 100%;
    margin-top: 22px;
}

.provider-directory-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 40px;
    padding: 9px 14px;
    border: 0;
    border-radius: 10px;
    background: #0c91ad;
    color: #ffffff;
    font-weight: 700;
    cursor: pointer;
}

.provider-directory-button.secondary {
    background: #edf4f8;
    color: #155e75;
}

@media (max-width: 700px) {
    #providersView {
        padding: 18px;
    }

    #providersGrid {
        grid-template-columns: 1fr;
    }

    .provider-directory-meta {
        grid-template-columns: 1fr;
    }

    .provider-directory-actions {
        flex-direction: column;
    }
}


/* Entity type display */
.provider-name-meta {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 7px;
    margin-top: 5px;
}

.provider-name-meta small {
    margin-top: 0;
}

.provider-entity-badge {
    min-height: 22px;
    padding: 3px 8px;
    border-radius: 999px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 8px;
    font-weight: 800;
    letter-spacing: 0.04em;
    text-transform: uppercase;
}

.provider-entity-badge.individual {
    background: #e8f1ff;
    color: #245cac;
}

.provider-entity-badge.group {
    background: #eee9ff;
    color: #6545b5;
}

body.dark-mode .provider-entity-badge.individual {
    background: rgba(47, 111, 221, 0.18);
    color: #9bc0ff;
}

body.dark-mode .provider-entity-badge.group {
    background: rgba(118, 82, 194, 0.2);
    color: #c9b7ff;
}


/* =====================================================
   V1 FINAL FIX — PROVIDERS DIRECTORY SCROLL OVERRIDE
   ===================================================== */

/*
The later "PROVIDERS DIRECTORY – LAYOUT REPAIR" block sets
#providersView { height:auto; overflow:visible; }, which overrides the
original scrollable .providers-view rule.

Force the Providers Directory itself to be the vertical scroll container.
*/
#providersView {
    flex: 1;
    min-width: 0;
    min-height: 0;
    height: 100%;
    max-height: 100%;
    overflow-y: auto !important;
    overflow-x: hidden !important;
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
}

/* Give the final row breathing room so the last cards are fully reachable. */
#providersGrid {
    padding-bottom: 32px;
}


/* =====================================================
   V1 MOBILE POLISH — PROVIDERS DIRECTORY
   ===================================================== */

@media (max-width: 760px) {
    #providersView {
        padding: 18px 14px 28px;
    }

    /* The global mobile topbar already shows Providers Directory.
       Hide the repeated inner title block on phones. */
    .providers-heading-left > div {
        display: none;
    }

    .providers-heading {
        margin-bottom: 18px;
        align-items: center;
    }

    .providers-heading-left {
        width: auto;
        flex-direction: row;
    }

    .providers-heading-actions {
        width: 100%;
        justify-content: space-between;
        gap: 10px;
    }

    .providers-updated-at {
        font-size: 9px;
    }

    .refresh-providers-button {
        min-height: 38px;
        padding: 0 12px;
        font-size: 10px;
        border-radius: 10px;
    }

    .providers-summary-grid {
        gap: 10px;
    }

    .provider-summary-card {
        min-height: 96px;
        padding: 15px;
    }

    .providers-toolbar {
        padding: 12px;
        gap: 10px;
    }

    .providers-content-card {
        min-height: 220px;
    }

    .providers-grid {
        gap: 12px;
    }

    .provider-directory-card {
        min-height: 0;
        padding: 17px;
    }
}

@media (max-width: 520px) {
    .providers-heading {
        gap: 10px;
    }

    .providers-heading-actions {
        align-items: center;
    }

    .providers-updated-at {
        white-space: normal;
        line-height: 1.3;
    }
}


/* =====================================================
   CREDBRAIN-AI V1 — PREMIUM PROVIDERS LIGHT THEME
   ===================================================== */

body:not(.dark-mode) #providersView {
    background:
        radial-gradient(circle at 76% 0%, rgba(38, 105, 222, .055), transparent 27%),
        #e9edf3;
}

body:not(.dark-mode) .providers-heading h3 {
    color: #111d35;
}

body:not(.dark-mode) .providers-heading-left > div > p:last-child,
body:not(.dark-mode) .providers-updated-at {
    color: #6c7a90;
}

body:not(.dark-mode) .refresh-providers-button,
body:not(.dark-mode) .back-to-chat-button,
body:not(.dark-mode) .clear-filter-button {
    border-color: #d8e0e8;
    color: #2f5d9b;
    background: #ffffff;
    box-shadow: 0 5px 14px rgba(16, 33, 58, .04);
}

body:not(.dark-mode) .providers-summary-grid {
    grid-template-columns: repeat(3, minmax(180px, 1fr));
}

body:not(.dark-mode) .provider-summary-card {
    min-height: 100px;
    border-color: #dce3ea;
    background: #ffffff;
    box-shadow: 0 8px 22px rgba(16, 33, 58, .045);
}

body:not(.dark-mode) .providers-toolbar {
    border-color: #dce3ea;
    background: #ffffff;
    box-shadow: 0 7px 20px rgba(16, 33, 58, .035);
}

body:not(.dark-mode) .provider-filter-field input,
body:not(.dark-mode) .provider-filter-field select {
    border-color: #dbe2e9;
    background: #f5f7fa;
}

/* Premium directory list rather than oversized dashboard cards */
body:not(.dark-mode) #providersGrid {
    grid-template-columns: 1fr;
    gap: 9px;
}

body:not(.dark-mode) .provider-directory-card {
    min-height: 0;
    padding: 14px 16px;
    border-color: #dce3ea;
    border-radius: 14px;
    background: #ffffff;
    box-shadow: 0 6px 18px rgba(16, 33, 58, .04);
    display: grid;
    grid-template-columns: minmax(230px, 1.2fr) minmax(260px, 1fr) minmax(190px, .75fr);
    align-items: center;
    gap: 18px;
}

body:not(.dark-mode) .provider-directory-card:hover {
    border-color: #bfcddd;
    transform: translateY(-1px);
    box-shadow: 0 11px 24px rgba(16, 33, 58, .075);
}

body:not(.dark-mode) .provider-directory-header {
    min-width: 0;
}

body:not(.dark-mode) .provider-directory-meta {
    margin-top: 0;
    grid-template-columns: repeat(2, minmax(0,1fr));
}

body:not(.dark-mode) .provider-directory-meta div {
    border: 0;
    padding: 5px 8px;
    background: #f5f7fa;
}

body:not(.dark-mode) .provider-progress-block {
    margin-top: 0;
}

body:not(.dark-mode) .provider-directory-actions {
    margin-top: 9px;
}

body:not(.dark-mode) .provider-directory-button {
    border: 0;
    color: #ffffff;
    background: linear-gradient(135deg, #14a9c4, #176be1);
}

body:not(.dark-mode) .provider-directory-button.secondary {
    border: 1px solid #d8e0e8;
    color: #345778;
    background: #f7f9fb;
}

@media (max-width: 980px) {
    body:not(.dark-mode) .provider-directory-card {
        grid-template-columns: 1fr;
        gap: 12px;
    }

    body:not(.dark-mode) .provider-progress-block {
        margin-top: 4px;
    }
}
