/* ============================================
   B2B Clients Page Styles - Compact Version
   ============================================ */

/* Container */
.b2b-clients-container {
    padding: 15px 0;
}

/* ============================================
   Header Controls
   ============================================ */
.b2b-clients-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
    flex-wrap: wrap;
    gap: 10px;
}

.b2b-header-left {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

.b2b-header-right {
    display: flex;
    align-items: center;
    gap: 10px;
}

/* View Toggle - Compact */
.b2b-view-toggle {
    display: flex;
    gap: 1px;
    background: #dee2e6;
    border-radius: 4px;
    padding: 2px;
}

.b2b-view-toggle .btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 5px 12px;
    border: none;
    border-radius: 3px;
    background: transparent;
    cursor: pointer;
    font-size: 12px;
    color: #6c757d;
    transition: all 0.15s ease;
}

.b2b-view-toggle .btn:hover {
    color: #495057;
}

.b2b-view-toggle .btn.active {
    background: #fff;
    color: #007bff;
    box-shadow: 0 1px 2px rgba(0,0,0,0.08);
}

.b2b-view-toggle .btn i {
    margin-right: 4px;
}

/* Filter Box - Compact */
.b2b-filter-box {
    background: #fff;
    border: 1px solid #dee2e6;
    border-radius: 6px;
    padding: 10px 15px;
    margin-bottom: 15px;
}

.b2b-filter-controls {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    align-items: center;
}

/* Search Wrapper */
.b2b-search-wrap {
    position: relative;
    flex: 1;
    min-width: 200px;
    max-width: 300px;
}

.b2b-search-icon {
    position: absolute;
    left: 10px;
    top: 50%;
    transform: translateY(-50%);
    color: #6c757d;
    font-size: 12px;
    pointer-events: none;
}

.b2b-search-input {
    width: 100%;
    padding: 6px 30px 6px 30px;
    border: 1px solid #ced4da;
    border-radius: 4px;
    font-size: 12px;
}

.b2b-search-input:focus {
    outline: none;
    border-color: #007bff;
    box-shadow: 0 0 0 2px rgba(0,123,255,0.1);
}

.b2b-search-clear {
    position: absolute;
    right: 8px;
    top: 50%;
    transform: translateY(-50%);
    color: #999;
    cursor: pointer;
    padding: 2px;
    line-height: 1;
    background: none;
    border: none;
}

.b2b-search-clear:hover {
    color: #333;
}

/* Filter Group */
.b2b-filter-group {
    display: flex;
    align-items: center;
    gap: 6px;
}

.b2b-filter-label {
    font-size: 12px;
    color: #6c757d;
    white-space: nowrap;
}

.b2b-filter-select {
    padding: 5px 8px;
    border: 1px solid #ced4da;
    border-radius: 4px;
    font-size: 12px;
    min-width: 100px;
}

/* Buttons */
.b2b-btn {
    display: inline-flex;
    align-items: center;
    padding: 5px 10px;
    border: none;
    border-radius: 4px;
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.15s ease;
}

.b2b-btn i {
    margin-right: 4px;
}

.b2b-btn-primary {
    background: #007bff;
    color: #fff;
}

.b2b-btn-primary:hover {
    background: #0056b3;
}

/* Filter Info */
.b2b-filter-info {
    margin-left: auto;
    font-size: 11px;
    color: #6c757d;
}

/* ============================================
   List View Table Styles
   ============================================ */
.b2b-list-view {
    overflow-x: auto;
}

.b2b-clients-table {
    width: 100%;
}

.b2b-clients-table th {
    white-space: nowrap;
}

/* Credential cell in table */
.credential-cell {
    display: flex;
    align-items: center;
    gap: 5px;
    white-space: nowrap;
}

.credential-cell .credential-value {
    font-family: 'Consolas', 'Monaco', monospace;
    font-size: 11px;
    background: #f8f9fa;
    padding: 2px 6px;
    border-radius: 3px;
    border: 1px solid #e9ecef;
    color: #555;
}

.credential-cell .copy-btn {
    padding: 2px 6px;
    opacity: 0.6;
    transition: opacity 0.2s;
}

.credential-cell .copy-btn:hover {
    opacity: 1;
}

/* ============================================
   Cards View Styles - Compact
   ============================================ */
.b2b-cards-container {
    min-height: 200px;
}

/* Loading Indicator */
.b2b-loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 60px 20px;
    color: #666;
}

.b2b-loading i {
    margin-bottom: 15px;
    color: #007bff;
}

/* Cards Skeleton Loader */
@keyframes skeleton-pulse {
    0% { opacity: 1; }
    50% { opacity: 0.4; }
    100% { opacity: 1; }
}

.skeleton-line {
    display: block;
    background: linear-gradient(90deg, var(--bs-secondary-bg) 25%, var(--bs-tertiary-bg) 50%, var(--bs-secondary-bg) 75%);
    background-size: 200% 100%;
    animation: skeleton-pulse 1.5s ease-in-out infinite;
    border-radius: 4px;
}

/* No Results */
.b2b-no-results {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 60px 20px;
    color: #999;
    text-align: center;
}

.b2b-no-results i {
    margin-bottom: 15px;
    color: #ccc;
}

.b2b-no-results p {
    margin-bottom: 15px;
}

/* Cards Grid - Higher Density */
.b2b-cards-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 12px;
}

/* Individual Card - Compact */
.b2b-card {
    background: #fff;
    border-radius: 6px;
    border: 2px solid #dee2e6;
    box-shadow: 0 1px 3px rgba(0,0,0,0.06);
    overflow: hidden;
    transition: all 0.15s ease;
    display: flex;
    flex-direction: column;
}

.b2b-card:hover {
    box-shadow: 0 3px 8px rgba(0,0,0,0.1);
}

.b2b-card.b2b-card-enabled {
    border-color: #28a745;
}

.b2b-card.b2b-card-disabled {
    border-color: #dc3545;
}

/* Card Header - Compact */
.b2b-card-header {
    padding: 10px 12px;
    border-bottom: 1px solid #f0f0f0;
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 8px;
}

.b2b-card-info {
    flex: 1;
    min-width: 0;
}

.b2b-card-name {
    margin: 0 0 2px 0;
    font-size: 14px;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.b2b-card-name a {
    color: #0056b3;
    text-decoration: none;
}

.b2b-card-name a:hover {
    color: #007bff;
    text-decoration: underline;
}

.b2b-card-email {
    margin: 0;
    font-size: 11px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.b2b-card-email a {
    color: #6c757d;
    text-decoration: none;
}

.b2b-card-email a:hover {
    color: #007bff;
}

/* Toggle Switch - Mini */
.b2b-toggle {
    position: relative;
    width: 36px;
    height: 20px;
    flex-shrink: 0;
}

.b2b-toggle-slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: #dc3545;
    transition: 0.2s;
    border-radius: 20px;
}

.b2b-toggle-slider:before {
    position: absolute;
    content: "";
    height: 14px;
    width: 14px;
    left: 3px;
    bottom: 3px;
    background-color: white;
    transition: 0.2s;
    border-radius: 50%;
}

.b2b-toggle-on .b2b-toggle-slider {
    background-color: #28a745;
}

.b2b-toggle-on .b2b-toggle-slider:before {
    transform: translateX(16px);
}

/* Card Body - Compact */
.b2b-card-body {
    padding: 8px 12px;
    flex: 1;
}

.b2b-card-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 4px 0;
}

.b2b-card-label {
    font-size: 11px;
    color: #6c757d;
    display: flex;
    align-items: center;
    gap: 4px;
}

.b2b-card-label i {
    width: 12px;
    font-size: 10px;
}

.b2b-card-value {
    font-size: 12px;
    font-weight: 500;
    color: #495057;
    display: flex;
    align-items: center;
    gap: 4px;
}

/* Secret/Masked Fields - Compact */
.b2b-secret-field {
    display: flex;
    align-items: center;
    gap: 4px;
}

.b2b-secret-value {
    font-family: monospace;
    font-size: 11px;
    background: #f8f9fa;
    padding: 2px 6px;
    border-radius: 3px;
    border: 1px solid #e9ecef;
    min-width: 80px;
    text-align: center;
}

.b2b-copy-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 22px;
    height: 22px;
    border: none;
    border-radius: 3px;
    background: transparent;
    color: #6c757d;
    cursor: pointer;
    transition: all 0.15s ease;
    font-size: 11px;
}

.b2b-copy-btn:hover {
    background: #e7f3ff;
    color: #007bff;
}

.b2b-copy-btn.copied {
    background: #d4edda;
    color: #28a745;
}

/* Implementation Badge - Compact */
.b2b-badge {
    display: inline-flex;
    align-items: center;
    padding: 2px 6px;
    border-radius: 3px;
    font-size: 10px;
    font-weight: 500;
}

.b2b-badge-default {
    background: #e9ecef;
    color: #6c757d;
}

.b2b-badge-info {
    background: #cce5ff;
    color: #004085;
}

/* Card Footer - Compact */
.b2b-card-footer {
    padding: 6px 12px;
    background: #f8f9fa;
    border-top: 1px solid #f0f0f0;
    display: flex;
    justify-content: flex-end;
}

.b2b-card-link {
    display: inline-flex;
    align-items: center;
    padding: 4px 8px;
    font-size: 11px;
    color: #6c757d;
    text-decoration: none;
    border-radius: 3px;
    transition: all 0.15s ease;
}

.b2b-card-link:hover {
    background: #e9ecef;
    color: #007bff;
    text-decoration: none;
}

.b2b-card-link i {
    margin-right: 4px;
    font-size: 10px;
}

/* ============================================
   Detail View Quick Links Bar
   ============================================ */
.quick-links-bar {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    padding: 0px 12px 16px 0px;
    /*background: #f0f7ff;*/
    border-bottom: 1px solid #b8daff;
    margin-bottom: 0;
}

.quick-links-bar .quick-links-label {
    display: flex;
    align-items: center;
    font-size: 12px;
    color: #0056b3;
    margin-right: 5px;
}

.quick-links-bar .btn {
    display: inline-flex;
    align-items: center;
    padding: 6px 12px;
    border-radius: 4px;
    font-size: 12px;
    color: #0056b3;
    text-decoration: none;
    background: transparent;
    border: none;
    transition: all 0.15s ease;
}

.quick-links-bar .btn:hover {
    background: #cce5ff;
}

.quick-links-bar .btn i {
    margin-right: 5px;
}

/* ============================================
   Detail View Section Styling
   ============================================ */
.b2b-detail-section {
    background: #fff;
    border: 1px solid #dee2e6;
    border-radius: 6px;
    margin-bottom: 15px;
    overflow: hidden;
}

.b2b-detail-section > legend,
.b2b-detail-section .panel-heading {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    margin: 0;
    background: #f8f9fa;
    border-bottom: 1px solid #dee2e6;
    font-size: 14px;
    font-weight: 600;
    color: #495057;
    cursor: pointer;
}

.b2b-detail-section > legend i,
.b2b-detail-section .panel-heading i {
    color: #6c757d;
    margin-right: 8px;
}

.b2b-detail-section .section-content,
.b2b-detail-section .panel-body {
    padding: 16px;
}

/* Form Rows in Detail View */
.b2b-detail-section .form-group {
    display: flex;
    align-items: center;
    padding: 10px 0;
    border-bottom: 1px solid #f0f0f0;
    margin-bottom: 0;
}

.b2b-detail-section .form-group:last-child {
    border-bottom: none;
}

.b2b-detail-section .control-label {
    width: 180px;
    flex-shrink: 0;
    font-size: 13px;
    color: #6c757d;
    font-weight: 500;
    padding-top: 0;
    text-align: left;
}

.b2b-detail-section .form-control {
    max-width: 400px;
}

.b2b-detail-section .form-control[readonly] {
    background: #f8f9fa;
    border-color: #e9ecef;
}

/* Secret Field with Copy Button */
.b2b-detail-secret-group {
    display: flex;
    align-items: center;
    gap: 8px;
    max-width: 400px;
}

.b2b-detail-secret-group .form-control {
    flex: 1;
    font-family: monospace;
    font-size: 13px;
}

.b2b-detail-copy-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 34px;
    border: 1px solid #ced4da;
    border-radius: 4px;
    background: #fff;
    color: #6c757d;
    cursor: pointer;
    transition: all 0.15s ease;
}

.b2b-detail-copy-btn:hover {
    border-color: #007bff;
    color: #007bff;
    background: #e7f3ff;
}

.b2b-detail-copy-btn.copied {
    border-color: #28a745;
    color: #28a745;
    background: #d4edda;
}

/* Toggle in Detail View */
.b2b-detail-toggle-wrap {
    display: flex;
    align-items: center;
    gap: 10px;
}

.b2b-detail-toggle-text {
    font-size: 12px;
    font-weight: 500;
}

.b2b-detail-toggle-text.enabled {
    color: #28a745;
}

.b2b-detail-toggle-text.disabled {
    color: #dc3545;
}

/* Test Encryption Area */
.b2b-test-area {
    display: flex;
    align-items: stretch;
    gap: 10px;
}

.b2b-test-area textarea {
    flex: 1;
    min-height: 80px;
    resize: vertical;
}

.b2b-test-buttons {
    display: flex;
    flex-direction: column;
    gap: 6px;
    justify-content: center;
}

/* Action Footer */
.b2b-action-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 15px 0;
    margin-top: 10px;
}

.b2b-footer-left {
    display: flex;
    gap: 8px;
}

.b2b-footer-right {
    display: flex;
    gap: 8px;
}

/* ============================================
   Detail Page Layout
   ============================================ */
.b2b-detail-page {
    max-width: 900px;
    margin: 0 auto;
    padding: 20px 0;
}

/* Detail Header */
.b2b-detail-header {
    margin-bottom: 15px;
}

.b2b-detail-back {
    display: inline-block;
    font-size: 13px;
    color: #6c757d;
    text-decoration: none;
    margin-bottom: 8px;
}

.b2b-detail-back:hover {
    color: #007bff;
    text-decoration: none;
}

.b2b-detail-title {
    margin: 0;
    font-size: 22px;
    font-weight: 600;
    color: #212529;
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

.b2b-detail-title i {
    color: #6c757d;
}

/* Status Badges for Detail Page */
.b2b-badge-enabled {
    background: #d4edda;
    color: #155724;
}

.b2b-badge-disabled {
    background: #f8d7da;
    color: #721c24;
}

/* Detail Section Header (icon bar) */
.b2b-detail-section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    margin: 0;
    background: #f0f4f8;
    border-bottom: 1px solid #dee2e6;
    font-size: 14px;
    font-weight: 600;
    color: #495057;
    cursor: pointer;
    user-select: none;
}

.b2b-detail-section-header:hover {
    background: #e8eef4;
}

.b2b-detail-section-header span i {
    color: #5a7da0;
    margin-right: 8px;
}

/* Collapsible section arrow */
.b2b-section-arrow {
    color: #6c757d;
    font-size: 12px;
    transition: transform 0.25s ease;
}

.b2b-detail-section-header.collapsed .b2b-section-arrow {
    transform: rotate(-90deg);
}

/* Remove bottom border when section is collapsed */
.b2b-detail-section-header.collapsed {
    border-bottom-color: transparent;
}

/* Detail Section Body */
.b2b-detail-section-body {
    padding: 16px;
}

/* Form Groups in Detail View */
.b2b-detail-form-group {
    display: flex;
    align-items: center;
    padding: 10px 0;
    border-bottom: 1px solid #f0f0f0;
}

.b2b-detail-form-group:last-child {
    border-bottom: none;
}

.b2b-detail-form-group-top {
    align-items: flex-start;
}

.b2b-detail-form-group > label {
    width: 180px;
    flex-shrink: 0;
    font-size: 13px;
    color: #6c757d;
    font-weight: 500;
    margin: 0;
    padding-top: 6px;
}

.b2b-detail-form-group .form-control {
    max-width: 400px;
}

/* Toggle Row */
.b2b-detail-toggle-row {
    display: flex;
    align-items: center;
    gap: 10px;
}

.b2b-detail-toggle-label {
    font-size: 13px;
    font-weight: 500;
}

/* Input wrap with edit icon */
.b2b-detail-input-wrap {
    position: relative;
    max-width: 400px;
    flex: 1;
}

.b2b-detail-input-wrap .form-control {
    max-width: 100%;
    padding-right: 32px;
}

.b2b-detail-edit-icon {
    position: absolute;
    right: 10px;
    top: 50%;
    transform: translateY(-50%);
    color: #adb5bd;
    pointer-events: none;
}

/* Detail Select */
.b2b-detail-select {
    max-width: 400px;
    appearance: auto;
}

/* Secret Field in Detail View */
.b2b-detail-section-body .b2b-secret-field {
    display: flex;
    align-items: center;
    gap: 8px;
    max-width: 440px;
}

.b2b-detail-section-body .b2b-secret-field .form-control {
    flex: 1;
    max-width: none;
    font-family: monospace;
}

.b2b-detail-section-body .b2b-copy-btn {
    width: 34px;
    height: 34px;
    border: 1px solid #ced4da;
    border-radius: 4px;
    background: #fff;
    font-size: 13px;
}

.b2b-detail-section-body .b2b-copy-btn:hover {
    border-color: #007bff;
}

/* Domain List */
.b2b-domain-list {
    flex: 1;
    max-width: 440px;
}

.b2b-domain-row {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 6px;
}

.b2b-domain-row .form-control {
    flex: 1;
    max-width: none;
}

.b2b-domain-delete {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 30px;
    height: 30px;
    border: none;
    border-radius: 4px;
    background: transparent;
    color: #dc3545;
    cursor: pointer;
    font-size: 14px;
    transition: background 0.15s;
}

.b2b-domain-delete:hover {
    background: #f8d7da;
}

.b2b-domain-add {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 30px;
    height: 30px;
    border: none;
    border-radius: 4px;
    background: transparent;
    color: #28a745;
    cursor: pointer;
    font-size: 14px;
    transition: background 0.15s;
}

.b2b-domain-add:hover {
    background: #d4edda;
}

.b2b-domain-add-row .form-control {
    opacity: 0.5;
}

/* Advanced Collapsible */
.b2b-detail-advanced {
    margin-bottom: 16px;
}

.b2b-detail-advanced-toggle {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 13px;
    font-weight: 500;
    color: #495057;
    text-decoration: none;
    padding: 6px 0;
}

.b2b-detail-advanced-toggle:hover {
    color: #007bff;
    text-decoration: none;
}

.b2b-detail-advanced-toggle i {
    transition: transform 0.2s;
    width: 12px;
    text-align: center;
}

.b2b-detail-advanced-toggle:not(.collapsed) i {
    transform: rotate(90deg);
}

.b2b-detail-advanced .collapse {
    margin-top: 10px;
}

/* Encryption Test Area */
.b2b-encryption-test {
    flex: 1;
    max-width: 440px;
}

.b2b-encryption-test textarea.form-control {
    max-width: 100%;
    min-height: 60px;
    resize: vertical;
    font-family: monospace;
    font-size: 12px;
}

.b2b-encryption-buttons {
    display: flex;
    gap: 8px;
    margin: 8px 0;
}

/* Key-Value Rows (Additional Settings) */
.b2b-detail-kv-row {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 6px;
}

.b2b-detail-kv-row .form-control {
    flex: 1;
    max-width: none;
}

/* Detail Footer */
.b2b-detail-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 15px 0;
    margin-top: 10px;
    border-top: 1px solid #dee2e6;
}

.b2b-detail-footer-left {
    display: flex;
    align-items: center;
    gap: 8px;
}

.b2b-detail-footer-right {
    display: flex;
    align-items: center;
    gap: 8px;
}

/* Footer Buttons - custom classes to avoid SmartAdmin overrides */
.b2b-btn-footer {
    display: inline-flex;
    align-items: center;
    padding: 8px 16px;
    border: none;
    border-radius: 4px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    text-decoration: none;
    white-space: nowrap;
    line-height: 1.4;
}

.b2b-btn-footer i {
    margin-right: 6px;
}

.b2b-btn-footer-primary {
    background: #007bff;
    color: #fff;
}

.b2b-btn-footer-primary:hover {
    background: #0056b3;
    color: #fff;
    text-decoration: none;
}

.b2b-btn-footer-secondary {
    background: #6c757d;
    color: #fff;
}

.b2b-btn-footer-secondary:hover {
    background: #545b62;
    color: #fff;
    text-decoration: none;
}

.b2b-btn-footer-success {
    background: #28a745;
    color: #fff;
}

.b2b-btn-footer-success:hover {
    background: #1e7e34;
    color: #fff;
    text-decoration: none;
}

.b2b-btn-footer-warning {
    background: #ffc107;
    color: #212529;
}

.b2b-btn-footer-warning:hover {
    background: #e0a800;
    color: #212529;
    text-decoration: none;
}

.b2b-btn-footer-dark {
    background: #343a40;
    color: #fff;
}

.b2b-btn-footer-dark:hover {
    background: #23272b;
    color: #fff;
    text-decoration: none;
}

.b2b-btn-footer-default {
    background: #fff;
    color: #495057;
    border: 1px solid #ced4da;
}

.b2b-btn-footer-default:hover {
    background: #e9ecef;
    color: #495057;
    text-decoration: none;
}

/* Dark button (Bootstrap 3 doesn't have btn-dark) */
.btn-dark {
    background-color: #343a40;
    border-color: #343a40;
    color: #fff;
}

.btn-dark:hover,
.btn-dark:focus {
    background-color: #23272b;
    border-color: #1d2124;
    color: #fff;
}

/* ============================================
   Responsive Adjustments
   ============================================ */
@media (max-width: 768px) {
    .b2b-clients-header {
        flex-direction: column;
        align-items: stretch;
    }

    .b2b-header-left,
    .b2b-header-right {
        justify-content: flex-start;
    }

    .b2b-filter-controls {
        flex-direction: column;
        align-items: stretch;
    }

    .b2b-search-wrap {
        max-width: 100%;
    }

    .b2b-filter-info {
        margin-left: 0;
        text-align: center;
    }

    .b2b-cards-grid {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 1200px) {
    .b2b-cards-grid {
        grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    }
}
