/* =========================================================
   TrackServe - Service Providers & Partner Directory Stylesheet
   ========================================================= */

/* Desktop Horizontal Layout for Summary Stats & Filters */
.providers-stats-grid {
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: 10px;
    margin-bottom: 12px;
}

@media (max-width: 1200px) {
    .providers-stats-grid {
        grid-template-columns: repeat(3, 1fr);
    }
}

@media (max-width: 900px) {
    .providers-stats-grid {
        grid-template-columns: 1fr;
    }
}

.providers-stats-grid .stat-card {
    background: #ffffff;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    padding: 8px 12px;
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 10px;
    box-shadow: 0 1px 3px rgba(15, 23, 42, 0.04);
    min-height: auto !important;
    height: 64px;
    box-sizing: border-box;
    transition: transform 0.15s ease, box-shadow 0.15s ease, border-color 0.15s ease;
}

.providers-stats-grid .stat-card:hover {
    transform: translateY(-1px);
    box-shadow: 0 3px 8px rgba(15, 23, 42, 0.06);
    border-color: #cbd5e1;
}

.providers-stats-grid .stat-card .stat-icon {
    width: 34px;
    height: 34px;
    border-radius: 7px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    flex-shrink: 0;
    margin-bottom: 0;
}

.providers-stats-grid .stat-card .stat-info {
    display: flex;
    flex-direction: column;
    min-width: 0;
    flex: 1;
    overflow: hidden;
}

.providers-stats-grid .stat-card .stat-label {
    font-size: 9.5px;
    font-weight: 700;
    color: #64748b;
    text-transform: uppercase;
    letter-spacing: 0.4px;
    line-height: 1.2;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.providers-stats-grid .stat-card .stat-value {
    font-size: 18px;
    font-weight: 800;
    color: #0f172a;
    line-height: 1.15;
    letter-spacing: -0.3px;
    margin-top: 1px;
}

.providers-stats-grid .stat-card .stat-sub {
    font-size: 9.5px;
    color: #94a3b8;
    line-height: 1.2;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-top: 1px;
}

.stat-card.stat-nga {
    border-top: 3px solid var(--primary);
}
.stat-card.stat-nga .stat-icon {
    background: #eef4ff;
    color: var(--primary);
}

.stat-card.stat-ngo {
    border-top: 3px solid #10b981;
}
.stat-card.stat-ngo .stat-icon {
    background: #ecfdf5;
    color: #059669;
}

.stat-card.stat-cso {
    border-top: 3px solid #f59e0b;
}
.stat-card.stat-cso .stat-icon {
    background: #fffbeb;
    color: #d97706;
}

.stat-card.stat-lgu {
    border-top: 3px solid #8b5cf6;
}
.stat-card.stat-lgu .stat-icon {
    background: #f5f3ff;
    color: #7c3aed;
}

/* View Mode Selector Tabs */
.view-mode-toggle {
    display: inline-flex;
    align-items: center;
    background: #f1f5f9;
    border: 1px solid #cbd5e1;
    border-radius: 6px;
    padding: 2px;
    gap: 2px;
}

.view-mode-btn {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 4px 10px;
    border-radius: 4px;
    font-size: 11.5px;
    font-weight: 700;
    color: #64748b;
    background: transparent;
    border: none;
    cursor: pointer;
    transition: all 0.15s ease;
    white-space: nowrap;
}

.view-mode-btn:hover {
    color: #1e293b;
}

.view-mode-btn.active {
    background: #ffffff;
    color: var(--primary, #0b4db8);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
}

/* =========================================================
   TABLE VIEW DIRECTORY SECTION
   ========================================================= */
.providers-table-card {
    background: #ffffff;
    border: 1px solid var(--border);
    border-radius: 10px;
    box-shadow: 0 1px 4px rgba(20, 45, 90, 0.04);
    margin-bottom: 20px;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.providers-table-card .card-heading {
    padding: 12px 18px;
    background: #ffffff;
    border-bottom: 1px solid #f1f5f9;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 10px;
}

.providers-table-wrap {
    overflow-x: auto;
    width: 100%;
}

.providers-data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 12.5px;
    color: #1e293b;
    text-align: left;
}

.providers-data-table thead tr {
    background: #f8fafc;
    border-bottom: 1px solid #e2e8f0;
}

.providers-data-table th {
    padding: 10px 14px;
    font-size: 11px;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.4px;
    color: #475569;
    vertical-align: middle;
    white-space: nowrap;
    border-bottom: 2px solid #e2e8f0;
}

.providers-data-table th.sortable {
    cursor: pointer;
    user-select: none;
    transition: color 0.15s ease, background 0.15s ease;
}

.providers-data-table th.sortable:hover {
    color: var(--primary, #0b4db8);
    background: #f1f5f9;
}

.providers-data-table tbody tr {
    border-bottom: 1px solid #f1f5f9;
    transition: background 0.12s ease;
}

.providers-data-table tbody tr:hover {
    background: #f8fafc;
}

.providers-data-table td {
    padding: 11px 14px;
    vertical-align: middle;
}

/* Organization Cell in Table */
.table-provider-cell {
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 220px;
}

.table-provider-avatar {
    width: 36px;
    height: 36px;
    border-radius: 8px;
    background: linear-gradient(135deg, #17233c, #2c3e5d);
    color: #ffffff;
    display: grid;
    place-items: center;
    font-size: 11px;
    font-weight: 800;
    flex-shrink: 0;
    box-shadow: 0 1px 4px rgba(23, 35, 60, 0.14);
    text-transform: uppercase;
    overflow: hidden;
    position: relative;
    border: 1px solid rgba(0, 0, 0, 0.06);
}

.table-provider-avatar.nga { background: linear-gradient(135deg, #0b4db8, #1d72d5); }
.table-provider-avatar.ngo { background: linear-gradient(135deg, #059669, #10b981); }
.table-provider-avatar.cso { background: linear-gradient(135deg, #d97706, #f59e0b); }
.table-provider-avatar.lgu { background: linear-gradient(135deg, #7c3aed, #8b5cf6); }

.table-provider-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.table-provider-info {
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.table-provider-acronym {
    font-size: 13.5px;
    font-weight: 800;
    color: #0f172a;
    cursor: pointer;
    transition: color 0.15s ease;
}

.table-provider-acronym:hover {
    color: var(--primary, #0b4db8);
    text-decoration: underline;
}

.table-provider-name {
    font-size: 11px;
    color: #64748b;
    line-height: 1.25;
    max-width: 260px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.table-address-sub {
    font-size: 10px;
    color: #94a3b8;
    margin-top: 2px;
}

/* Service Tags in Table */
.table-services-wrap {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    max-width: 320px;
}

.table-service-pill {
    display: inline-flex;
    align-items: center;
    gap: 3px;
    background: #f1f5f9;
    border: 1px solid #e2e8f0;
    color: #334155;
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 10.5px;
    font-weight: 600;
    line-height: 1.2;
}

.table-service-pill i {
    font-style: normal;
    color: #059669;
    font-weight: bold;
}

.table-service-more-pill {
    display: inline-flex;
    align-items: center;
    background: #e2e8f0;
    color: #475569;
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 10px;
    font-weight: 700;
    cursor: pointer;
}

.table-service-more-pill:hover {
    background: #cbd5e1;
    color: #0f172a;
}

/* Contact Info Column */
.table-contact-info {
    display: flex;
    flex-direction: column;
    gap: 2px;
    font-size: 11px;
    line-height: 1.3;
    min-width: 150px;
}

.table-focal-name {
    font-weight: 700;
    color: #1e293b;
}

.table-contact-row {
    color: #64748b;
    display: flex;
    align-items: center;
    gap: 4px;
}

.table-contact-row a {
    color: #2563eb;
    text-decoration: none;
}

.table-contact-row a:hover {
    text-decoration: underline;
}

/* Caseload Count Badge */
.table-caseload-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 8px;
    border-radius: 20px;
    font-size: 11px;
    font-weight: 700;
    background: #eff6ff;
    color: #1d4ed8;
    border: 1px solid #bfdbfe;
    white-space: nowrap;
}

.table-caseload-badge.zero {
    background: #f8fafc;
    color: #94a3b8;
    border-color: #e2e8f0;
}

/* Table Pagination Footer */
.table-pagination-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 18px;
    background: #ffffff;
    border-top: 1px solid #f1f5f9;
    flex-wrap: wrap;
    gap: 10px;
    font-size: 12px;
    color: #64748b;
}

.pagination-controls {
    display: flex;
    align-items: center;
    gap: 4px;
}

.pagination-btn {
    min-width: 28px;
    height: 28px;
    padding: 0 6px;
    border: 1px solid #cbd5e1;
    background: #ffffff;
    border-radius: 4px;
    font-size: 11.5px;
    font-weight: 600;
    color: #334155;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.15s ease;
}

.pagination-btn:hover:not(:disabled) {
    background: #f1f5f9;
    border-color: #94a3b8;
    color: #0f172a;
}

.pagination-btn.active {
    background: var(--primary, #0b4db8);
    border-color: var(--primary, #0b4db8);
    color: #ffffff;
}

.pagination-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

/* =========================================================
   CARDS GRID VIEW STYLES
   ========================================================= */
.provider-cards-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 10px;
    margin-bottom: 16px;
}

.provider-card {
    background: #ffffff;
    border: 1px solid var(--border);
    border-radius: 8px;
    box-shadow: 0 1px 4px rgba(20, 45, 90, 0.04);
    padding: 11px 13px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    gap: 8px;
    transition: transform 0.15s ease, box-shadow 0.15s ease, border-color 0.15s ease;
}

.provider-card:hover {
    transform: translateY(-1px);
    border-color: #b5cde8;
    box-shadow: 0 4px 12px rgba(20, 45, 90, 0.07);
}

.provider-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 8px;
}

.provider-avatar-group {
    display: flex;
    align-items: center;
    gap: 9px;
    min-width: 0;
}

.provider-avatar {
    width: 34px;
    height: 34px;
    border-radius: 7px;
    background: linear-gradient(135deg, #17233c, #2c3e5d);
    color: #ffffff;
    display: grid;
    place-items: center;
    font-size: 11px;
    font-weight: 800;
    flex-shrink: 0;
    box-shadow: 0 1px 4px rgba(23, 35, 60, 0.14);
    text-transform: uppercase;
    overflow: hidden;
    position: relative;
    border: 1px solid rgba(0, 0, 0, 0.06);
}

.provider-avatar.nga { background: linear-gradient(135deg, #0b4db8, #1d72d5); }
.provider-avatar.ngo { background: linear-gradient(135deg, #059669, #10b981); }
.provider-avatar.cso { background: linear-gradient(135deg, #d97706, #f59e0b); }
.provider-avatar.lgu { background: linear-gradient(135deg, #7c3aed, #8b5cf6); }

.provider-avatar-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.provider-title-group {
    display: flex;
    flex-direction: column;
    gap: 1px;
    min-width: 0;
}

.provider-acronym {
    font-size: 13.5px;
    font-weight: 800;
    color: #17233c;
    line-height: 1.2;
}

.provider-name {
    font-size: 11px;
    color: #64748b;
    line-height: 1.2;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: 160px;
}

/* Classification Badge */
.classification-badge {
    display: inline-flex;
    align-items: center;
    gap: 3px;
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 9.5px;
    font-weight: 800;
    text-transform: uppercase;
    white-space: nowrap;
    flex-shrink: 0;
}

.classification-badge.nga { background: #eef4ff; color: #0b4db8; border: 1px solid #c8dbf9; }
.classification-badge.ngo { background: #ecfdf5; color: #047857; border: 1px solid #a7f3d0; }
.classification-badge.cso { background: #fffbeb; color: #b45309; border: 1px solid #fde68a; }
.classification-badge.lgu { background: #f5f3ff; color: #7c3aed; border: 1px solid #ddd6fe; }
.classification-badge.private { background: #f1f5f9; color: #334155; border: 1px solid #cbd5e1; }

/* Service Tags Container */
.services-offered-section {
    background: #f8fafc;
    border-radius: 6px;
    padding: 5px 8px;
    border: 1px solid #edf2f7;
    margin-top: 6px;
}

.services-tags-wrap {
    display: flex;
    flex-wrap: wrap;
    gap: 3px;
}

.service-tag {
    display: inline-flex;
    align-items: center;
    gap: 2px;
    background: #ffffff;
    border: 1px solid #d5e4fc;
    color: #1e293b;
    padding: 1px 5px;
    border-radius: 3px;
    font-size: 9.5px;
    font-weight: 600;
    line-height: 1.2;
}

.service-tag i {
    font-style: normal;
    color: #059669;
    font-weight: bold;
}

/* Provider Meta Info */
.provider-meta-list {
    display: flex;
    flex-direction: column;
    gap: 2px;
    font-size: 10.5px;
    color: #475569;
    margin-top: 5px;
}

.provider-meta-row {
    display: flex;
    align-items: center;
    gap: 5px;
    line-height: 1.25;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Card Actions */
.provider-card-actions {
    display: flex;
    justify-content: flex-end;
    align-items: center;
    gap: 5px;
    padding-top: 6px;
    border-top: 1px dashed #edf2f7;
}

.action-btn {
    width: 25px;
    height: 25px;
    border-radius: 5px;
    border: 1px solid var(--border);
    background: #ffffff;
    font-size: 11px;
    display: inline-flex;
    justify-content: center;
    align-items: center;
    transition: all 0.15s ease;
    cursor: pointer;
    padding: 0;
}

.action-btn:hover {
    background: #f4f7fb;
    border-color: #c4d2e8;
    transform: translateY(-1px);
}

.action-btn.edit-btn:hover {
    background: #eef4ff;
    border-color: #bad3ff;
}

.action-btn.delete-btn:hover {
    background: #ffebeb;
    border-color: #ffb8b8;
}

/* =========================================================
   CENTERED & COMPACT PROVIDER MODAL STYLING
   ========================================================= */
.provider-modal-card {
    width: min(520px, 94vw);
    max-height: min(88vh, 760px);
    background: #ffffff;
    border-radius: 10px;
    border: 1px solid var(--border, #cbd5e1);
    box-shadow: 0 20px 45px rgba(15, 23, 42, 0.22);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    animation: fadeIn 0.15s ease-out;
}

.provider-modal-header {
    padding: 10px 16px;
    background: #ffffff;
    border-bottom: 1px solid var(--border, #e2e8f0);
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-shrink: 0;
}

.provider-modal-header h2 {
    margin: 1px 0 0;
    font-size: 14.5px;
    font-weight: 800;
    color: #0f172a;
}

.provider-modal-body {
    padding: 10px 16px;
    background: #f8fafc;
    overflow-y: auto;
    flex: 1 1 auto;
    display: flex;
    flex-direction: column;
    gap: 8px;
    box-sizing: border-box;
}

.provider-modal-body .form-section-card {
    background: #ffffff;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    padding: 9px 12px;
    box-shadow: 0 1px 3px rgba(15, 23, 42, 0.02);
}

.provider-modal-body .form-section-card .section-title {
    font-size: 11px;
    font-weight: 800;
    color: #1e293b;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.provider-modal-body .form-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px 12px;
    margin-top: 6px;
}

.provider-modal-body .form-grid .full {
    grid-column: 1 / -1;
}

.provider-modal-body .form-field {
    display: flex;
    flex-direction: column;
    margin-bottom: 0;
}

.provider-modal-body .form-field label {
    font-size: 11px;
    font-weight: 700;
    color: #475569;
    margin-bottom: 3px;
    line-height: 1.25;
}

.provider-modal-body .input,
.provider-modal-body select.input {
    width: 100%;
    height: 30px;
    padding: 3px 8px;
    font-size: 11.5px;
    color: #0f172a;
    background-color: #ffffff;
    border: 1px solid #cbd5e1;
    border-radius: 5px;
    outline: none;
    box-sizing: border-box;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.provider-modal-body .input:focus,
.provider-modal-body select.input:focus {
    border-color: var(--primary, #0b4db8);
    box-shadow: 0 0 0 2px rgba(11, 77, 184, 0.12);
}

.provider-modal-footer {
    padding: 8px 16px;
    background: #ffffff;
    border-top: 1px solid var(--border, #e2e8f0);
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    align-items: center;
    flex-shrink: 0;
}

.avatar-upload-row {
    display: flex;
    align-items: center;
    gap: 10px;
}

.provider-avatar-preview {
    width: 42px;
    height: 42px;
    border-radius: 8px;
    background: linear-gradient(135deg, #17233c, #2c3e5d);
    color: #ffffff;
    display: grid;
    place-items: center;
    font-size: 13px;
    font-weight: 900;
    flex-shrink: 0;
    box-shadow: 0 2px 6px rgba(23, 35, 60, 0.14);
    text-transform: uppercase;
    overflow: hidden;
    border: 1.5px solid #e2e8f0;
    position: relative;
}

.provider-avatar-preview.nga { background: linear-gradient(135deg, #0b4db8, #1d72d5); }
.provider-avatar-preview.ngo { background: linear-gradient(135deg, #059669, #10b981); }
.provider-avatar-preview.cso { background: linear-gradient(135deg, #d97706, #f59e0b); }
.provider-avatar-preview.lgu { background: linear-gradient(135deg, #7c3aed, #8b5cf6); }

.avatar-upload-controls {
    display: flex;
    flex-direction: column;
    justify-content: center;
}

/* Printable Provider Catalog Sheet */
.provider-catalog-sheet {
    background: #ffffff;
    border: 1px solid #cbd5e1;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.06);
    padding: 32px 38px;
    max-width: 880px;
    margin: 0 auto;
    font-family: 'Segoe UI', Arial, sans-serif;
    color: #0f172a;
    line-height: 1.4;
}

@media print {
    body * {
        visibility: hidden;
    }
    .provider-catalog-sheet, .provider-catalog-sheet * {
        visibility: visible;
    }
    .provider-catalog-sheet {
        position: absolute;
        left: 0;
        top: 0;
        width: 100%;
        margin: 0;
        padding: 20px;
        border: none;
        box-shadow: none;
    }
    .slip-modal-header, .slip-modal-footer, .side-panel-backdrop, .app-shell {
        display: none !important;
    }
}
