/* ============================================================
   Global Overrides
   ============================================================ */

/* ── Global font size & row gap tuning ────────────────────── */

/* Base font bump: 13px → 14px across all portal pages */
.main-section,
.web-footer,
.partner-content {
    font-size: 14px !important;
}

/* Utility class overrides — Frappe uses fs-11, fs-12 etc. */
.fs-10 { font-size: 11px !important; }
.fs-11 { font-size: 12px !important; }
.fs-12 { font-size: 13px !important; }
.fs-13 { font-size: 14px !important; }

/* ============================================================
   Unified Table Design — Partner Portal
   Applied globally to all .table elements
   ============================================================ */

/* Base table styling */
.table {
    border-collapse: separate;
    border-spacing: 0;
    width: 100%;
    margin-bottom: 0;
}

/* Table cells */
.table th,
.table td {
    font-size: 13px !important;
    padding: 0.55rem 0.75rem !important;
    vertical-align: middle;
    border-bottom: 1px solid #edf2f7;
}

/* Header: consistent dark-ish header for ALL tables */
.table thead th {
    background-color: #f0f3f8 !important;
    color: #4a5568 !important;
    font-weight: 600 !important;
    font-size: 12px !important;
    text-transform: uppercase;
    letter-spacing: 0.4px;
    border-bottom: 2px solid #dde3ed !important;
    white-space: nowrap;
    padding: 0.6rem 0.75rem !important;
}

/* ── Kill Bootstrap 5's box-shadow trick that fakes cell backgrounds ── */
/* Bootstrap uses: box-shadow: inset 0 0 0 9999px var(--bs-table-accent-bg)
   on every td/th. We must neutralize this for our zebra stripes to show. */
.table > :not(caption) > * > * {
    --bs-table-bg: transparent !important;
    --bs-table-accent-bg: transparent !important;
    --bs-table-bg-type: transparent !important;
    box-shadow: none !important;
}

/* Alternate row colors — zebra stripe for ALL tables */
.table > tbody > tr:nth-child(even) > td,
.table > tbody > tr:nth-child(even) > th {
    background-color: #f0f4fa !important;
}

.table > tbody > tr:nth-child(odd) > td,
.table > tbody > tr:nth-child(odd) > th {
    background-color: #ffffff !important;
}

/* Header cells — override zebra so header keeps its own color */
.table > thead > tr > th {
    background-color: #f0f3f8 !important;
}

/* Hover: subtle blue tint */
.table.table-hover > tbody > tr:hover > td,
.table.table-hover > tbody > tr:hover > th {
    background-color: #e3ecff !important;
    transition: background-color 0.15s ease;
}

/* Active/selected row */
.table > tbody > tr.table-active > td,
.table > tbody > tr.selected > td {
    background-color: #dbe7ff !important;
}

/* Last row: no bottom border */
.table tbody tr:last-child td {
    border-bottom: none;
}

/* Table footer */
.table tfoot th,
.table tfoot td {
    background-color: #f0f3f8 !important;
    font-weight: 600 !important;
    border-top: 2px solid #dde3ed !important;
}

/* Clickable rows — pointer cursor */
.table tbody tr[onclick],
.table tbody tr[data-href],
.table tbody tr[style*="cursor"] {
    cursor: pointer;
}

/* Amount columns — right aligned, monospace */
.table .text-end {
    font-variant-numeric: tabular-nums;
}

/* Responsive wrapper — subtle shadow hint for scroll */
.table-responsive {
    border-radius: 6px;
    border: 1px solid #edf2f7;
}

/* Empty state row */
.table tbody tr td[colspan] {
    text-align: center;
    color: #a0aec0;
    padding: 1.5rem 0.75rem !important;
    font-style: italic;
    background-color: #ffffff !important;
}

/* Mobile: tighter padding */
@media (max-width: 768px) {
    .table th,
    .table td {
        font-size: 12px !important;
        padding: 0.4rem 0.5rem !important;
    }
    .table thead th {
        font-size: 11px !important;
        padding: 0.45rem 0.5rem !important;
    }
}

/* Override for inline-style tables (e.g. print layouts) — do not affect */
table[style*="border-collapse"] th,
table[style*="border-collapse"] td {
    background-color: unset;
}

/* Special tables: .bulk-table, .cr-table, .tbl-pkg — keep their own style */
.bulk-table,
.cr-table,
.tbl-pkg {
    border-collapse: collapse;
}
.bulk-table th, .cr-table th, .tbl-pkg th,
.bulk-table td, .cr-table td, .tbl-pkg td {
    background-color: unset;
}

/* ============================================================
   Unified Button Design — Partner Portal
   Standardize all buttons across all pages
   ============================================================ */

/* ── Base button styling ───────────────────────────────────── */
.btn {
    font-weight: 500;
    border-radius: 6px;
    transition: all 0.2s ease;
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
}

.btn i {
    font-size: inherit;
}

/* ── Primary action (Create, Save, Submit) ─────────────────── */
.btn-primary {
    background-color: #4f6ef7 !important;
    border-color: #4f6ef7 !important;
    color: #fff !important;
    box-shadow: 0 2px 4px rgba(79, 110, 247, 0.2);
}

.btn-primary:hover,
.btn-primary:focus {
    background-color: #3d5ce5 !important;
    border-color: #3d5ce5 !important;
    box-shadow: 0 4px 8px rgba(79, 110, 247, 0.3);
    transform: translateY(-1px);
}

/* ── Secondary / Cancel / Back ─────────────────────────────── */
/* Normalize btn-secondary, btn-light, btn-light-brand to same look */
.btn-secondary,
.btn-light,
.btn-light-brand {
    background-color: #f0f3f8 !important;
    border-color: #dde3ed !important;
    color: #4a5568 !important;
}

.btn-secondary:hover,
.btn-light:hover,
.btn-light-brand:hover {
    background-color: #e2e8f0 !important;
    border-color: #cbd5e0 !important;
    color: #2d3748 !important;
}

/* ── Outline primary (Export, Download) ────────────────────── */
.btn-outline-primary {
    border-color: #4f6ef7 !important;
    color: #4f6ef7 !important;
}

.btn-outline-primary:hover {
    background-color: #4f6ef7 !important;
    color: #fff !important;
}

/* ── Success (Enable, Approve) ─────────────────────────────── */
.btn-success {
    background-color: #28a745 !important;
    border-color: #28a745 !important;
    box-shadow: 0 2px 4px rgba(40, 167, 69, 0.2);
}

.btn-success:hover {
    background-color: #218838 !important;
    border-color: #218838 !important;
}

/* ── Danger (Delete, Disable, Reject) ──────────────────────── */
.btn-danger {
    background-color: #dc3545 !important;
    border-color: #dc3545 !important;
    box-shadow: 0 2px 4px rgba(220, 53, 69, 0.2);
}

.btn-danger:hover {
    background-color: #c82333 !important;
    border-color: #c82333 !important;
}

/* ── Warning (Pending actions) ─────────────────────────────── */
.btn-warning {
    background-color: #ffc107 !important;
    border-color: #ffc107 !important;
    color: #212529 !important;
}

/* ── Small buttons — consistent sizing ─────────────────────── */
.btn-sm {
    font-size: 12.5px !important;
    padding: 0.3rem 0.65rem !important;
    border-radius: 5px;
}

/* ── Custom button classes → normalize to standard ─────────── */
/* cr-btn (card request) → match btn styling */
.cr-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    font-weight: 500;
    border-radius: 6px;
    font-size: 13px;
    padding: 0.4rem 0.85rem;
    transition: all 0.2s ease;
    cursor: pointer;
    border: 1px solid transparent;
}

.cr-btn-primary,
.cr-btn:not(.cr-btn-outline) {
    background-color: #4f6ef7;
    color: #fff;
    border-color: #4f6ef7;
}

.cr-btn-primary:hover,
.cr-btn:not(.cr-btn-outline):hover {
    background-color: #3d5ce5;
    border-color: #3d5ce5;
}

.cr-btn-outline {
    background-color: #f0f3f8;
    color: #4a5568;
    border-color: #dde3ed;
}

.cr-btn-outline:hover {
    background-color: #e2e8f0;
    border-color: #cbd5e0;
}

/* ── Floating action buttons → consistent round style ──────── */
.float-action-btn,
.float-circle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    width: 36px;
    height: 36px;
    padding: 0;
    transition: all 0.2s ease;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.1);
}

.float-action-btn:hover,
.float-circle:hover {
    transform: scale(1.1);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

/* ── Button groups — consistent spacing ────────────────────── */
.btn-group .btn,
.d-flex.gap-2 .btn,
.hstack.gap-2 .btn {
    border-radius: 6px;
}

/* ============================================================
   Modal Fix — Remove theme blur on background when modal opens
   The theme applies filter:blur(3px) to .nxl-container etc.
   ============================================================ */
body.modal-open .nxl-container,
body.modal-open .nxl-header,
body.modal-open .nxl-navigation,
body.modal-open .page-header {
    filter: none !important;
}

/* Card body — tighter vertical padding */
.card-body {
    padding: 0.75rem 1rem !important;
}

/* Card header — compact */
.card-header {
    padding: 0.5rem 1rem !important;
}

/* Row gaps — tighter between stacked rows */
.row.g-3 { --bs-gutter-y: 0.75rem !important; }
.row.g-4 { --bs-gutter-y: 0.85rem !important; }

/* Form labels — slightly larger */
.form-label {
    font-size: 13px !important;
    margin-bottom: 0.25rem !important;
}

/* Form inputs — comfortable size */
.form-control,
.form-select {
    font-size: 13.5px !important;
}

/* Badge text */
.badge {
    font-size: 11.5px !important;
}

/* Buttons — comfortable touch targets */
.btn-sm {
    font-size: 13px !important;
    padding: 0.3rem 0.7rem !important;
}

/* Nav tabs — compact */
.nav-link {
    font-size: 12.5px !important;
    padding: 0.35rem 0.75rem !important;
}

.nav-item.border-top {
    border-top: none !important;
    border-bottom: 1px solid rgba(0,0,0,0.06) !important;
}

.nav-link i {
    font-size: 13px !important;
}

/* Info rows (label: value pairs) — tighter */
.d-flex.justify-content-between + .d-flex.justify-content-between,
.hstack + .hstack {
    margin-top: 0 !important;
}

/* Margin/padding between stacked cards */
.mb-3 { margin-bottom: 0.65rem !important; }
.mb-4 { margin-bottom: 0.85rem !important; }
.py-3 { padding-top: 0.65rem !important; padding-bottom: 0.65rem !important; }
.py-4 { padding-top: 0.85rem !important; padding-bottom: 0.85rem !important; }

.page-header {
    min-height: 45px !important;
    padding-top: 6px !important;
    padding-bottom: 6px !important;
    margin-bottom: 4px !important;
}

/* Tighten gap between page header and main content */
.main-content {
    padding-top: 0 !important;
}

.nxl-content > .main-content {
    margin-top: 0 !important;
}

.page-header-right .btn-icon {
    width: 28px !important;
    height: 28px !important;
    padding: 0 !important;
    font-size: 13px !important;
}

.page-header-right .btn-icon i {
    font-size: 13px !important;
}

/* KPI + Quick Actions row — equal height */
.col-xxl-8 > .row {
    height: 100%;
}

.col-xxl-8 > .row > [class*="col-"] {
    display: flex;
}

.col-xxl-8 > .row > [class*="col-"] > .card {
    flex: 1;
}

/* KPI card font sizes — fluid across all screens */
.col-xxl-8 .card .fs-3 {
    font-size: clamp(0.85rem, 1.5vw, 1.1rem) !important;
}

.col-xxl-8 .card .fs-12 {
    font-size: clamp(9px, 1vw, 11px) !important;
}

.col-xxl-8 .card .avatar-text.avatar-lg {
    width: 30px !important;
    height: 30px !important;
    font-size: 13px !important;
}

.col-xxl-8 .card .card-body {
    padding: 0.4rem 0.6rem !important;
}

/* ============================================================
   Duralux Global Search - Modern Command Palette Style
   ============================================================ */

/* Modal Backdrop with Blur */
#globalSearchModal.modal.show {
    backdrop-filter: blur(4px);
    background-color: rgba(0, 0, 0, 0.4);
}

/* Modal Dialog */
#globalSearchModal .modal-dialog {
    margin-top: 80px;
    max-width: 680px;
    transition: transform 0.3s ease-out;
}

#globalSearchModal.show .modal-dialog {
    animation: slideDown 0.3s ease-out;
}

@keyframes slideDown {
    from {
        transform: translateY(-30px);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

/* Modal Content */
#globalSearchModal .modal-content {
    border-radius: 16px;
    box-shadow: 0 24px 48px rgba(0, 0, 0, 0.15),
                0 0 0 1px rgba(0, 0, 0, 0.05);
    border: none;
    overflow: hidden;
    background: linear-gradient(135deg, #ffffff 0%, #f8f9fa 100%);
}

/* Header Section */
#globalSearchModal .modal-header {
    padding: 1.25rem 1.5rem;
    background: white;
    border-bottom: 2px solid #f1f3f5;
}

#globalSearchModal .input-group {
    background: #f8f9fa;
    border-radius: 12px;
    padding: 0.5rem 1rem;
    transition: all 0.2s ease;
}

#globalSearchModal .input-group:focus-within {
    background: white;
    box-shadow: 0 0 0 3px rgba(66, 133, 244, 0.1);
}

#globalSearchModal .input-group-text {
    font-size: 1.4rem;
    color: #4285f4;
    padding: 0;
    margin-right: 0.75rem;
}

#globalSearchInput {
    font-size: 1.125rem;
    padding: 0.5rem 0;
    border: none !important;
    background: transparent !important;
    color: #212529;
    font-weight: 500;
}

#globalSearchInput::placeholder {
    color: #adb5bd;
    font-weight: 400;
}

#globalSearchInput:focus {
    outline: none;
    box-shadow: none !important;
}

#globalSearchModal .btn-close {
    padding: 0.5rem;
    opacity: 0.4;
    transition: all 0.2s ease;
}

#globalSearchModal .btn-close:hover {
    opacity: 1;
    transform: rotate(90deg);
}

/* Body Section */
#globalSearchModal .modal-body {
    padding: 0;
    max-height: 500px;
    overflow-y: auto;
    background: white;
}

/* Custom Scrollbar */
#globalSearchModal .modal-body::-webkit-scrollbar {
    width: 8px;
}

#globalSearchModal .modal-body::-webkit-scrollbar-track {
    background: #f8f9fa;
}

#globalSearchModal .modal-body::-webkit-scrollbar-thumb {
    background: #dee2e6;
    border-radius: 4px;
}

#globalSearchModal .modal-body::-webkit-scrollbar-thumb:hover {
    background: #adb5bd;
}

/* Search Results */
#searchResults {
    min-height: 250px;
}

/* Search Group Headers */
.search-group {
    margin-bottom: 0;
}

.search-group > div:first-child {
    padding: 0.875rem 1.5rem 0.5rem;
    background: linear-gradient(to bottom, #f8f9fa, transparent);
    font-size: 0.6875rem;
    font-weight: 700;
    letter-spacing: 0.5px;
    color: #6c757d;
    text-transform: uppercase;
    border-top: 1px solid #f1f3f5;
}

.search-group:first-child > div:first-child {
    border-top: none;
}

/* Result Items */
.search-result-item {
    padding: 0.875rem 1.5rem !important;
    cursor: pointer;
    transition: all 0.15s ease;
    border-left: 3px solid transparent;
    background: white;
    position: relative;
}

.search-result-item::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 0;
    background: linear-gradient(90deg, #4285f4 0%, transparent 100%);
    transition: width 0.2s ease;
}

.search-result-item:hover,
.search-result-item.active {
    background: linear-gradient(90deg, #f8f9ff 0%, #ffffff 100%);
    border-left-color: #4285f4;
}

.search-result-item:hover::before,
.search-result-item.active::before {
    width: 4px;
}

.search-result-item.active {
    box-shadow: inset 0 0 0 1px rgba(66, 133, 244, 0.1);
}

/* Result Icon */
.search-result-item .avatar-text {
    width: 40px;
    height: 40px;
    background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

.search-result-item:hover .avatar-text,
.search-result-item.active .avatar-text {
    background: linear-gradient(135deg, #4285f4 0%, #2a75f3 100%);
    color: white !important;
    transform: scale(1.05);
    box-shadow: 0 4px 12px rgba(66, 133, 244, 0.3);
}

.search-result-item .avatar-text i {
    font-size: 1.125rem;
}

/* Result Title */
.search-result-item .fw-semibold {
    font-size: 0.9375rem;
    color: #212529;
    font-weight: 600;
    margin-bottom: 0.25rem;
}

/* Result Description */
.search-result-item .text-muted {
    font-size: 0.8125rem;
    color: #6c757d !important;
    line-height: 1.4;
}

/* Badges */
.search-result-item .badge {
    font-size: 0.6875rem;
    padding: 0.35rem 0.65rem;
    border-radius: 6px;
    font-weight: 600;
    letter-spacing: 0.3px;
}

/* Badge Colors */
.bg-soft-success {
    background: linear-gradient(135deg, #d4edda 0%, #c3e6cb 100%) !important;
    color: #155724 !important;
}

.bg-soft-warning {
    background: linear-gradient(135deg, #fff3cd 0%, #ffeaa7 100%) !important;
    color: #856404 !important;
}

.bg-soft-danger {
    background: linear-gradient(135deg, #f8d7da 0%, #f5c6cb 100%) !important;
    color: #721c24 !important;
}

.bg-soft-primary {
    background: linear-gradient(135deg, #cfe2ff 0%, #b8d4fe 100%) !important;
    color: #004085 !important;
}

.bg-soft-info {
    background: linear-gradient(135deg, #d1ecf1 0%, #bee5eb 100%) !important;
    color: #0c5460 !important;
}

.bg-soft-secondary {
    background: linear-gradient(135deg, #e2e3e5 0%, #d6d8db 100%) !important;
    color: #383d41 !important;
}

/* Empty State */
#searchResults .text-center {
    padding: 3rem 2rem !important;
}

#searchResults .text-center i {
    font-size: 3.5rem !important;
    opacity: 0.15;
    color: #4285f4;
    margin-bottom: 1.5rem !important;
}

#searchResults .text-center p {
    font-size: 1rem;
    color: #495057;
    margin-bottom: 0.5rem;
}

#searchResults .text-center small {
    font-size: 0.875rem;
    color: #868e96;
}

/* Loading State */
.spinner-border-sm {
    width: 2rem !important;
    height: 2rem !important;
    border-width: 3px !important;
    color: #4285f4;
}

/* Footer */
#globalSearchModal .modal-footer {
    padding: 0.875rem 1.5rem;
    background: linear-gradient(to top, #f8f9fa, white);
    border-top: 1px solid #e9ecef;
}

#globalSearchModal .modal-footer span {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.75rem;
    color: #6c757d;
}

/* Keyboard Shortcut Keys */
#globalSearchModal kbd {
    padding: 0.25rem 0.5rem;
    font-size: 0.6875rem;
    background: white;
    border: 1px solid #dee2e6;
    border-radius: 5px;
    box-shadow: 0 2px 0 rgba(0, 0, 0, 0.1),
                inset 0 0 0 1px rgba(255, 255, 255, 0.7);
    font-family: 'SF Mono', 'Monaco', 'Menlo', monospace;
    font-weight: 600;
    color: #495057;
    min-width: 1.5rem;
    text-align: center;
    display: inline-block;
}

/* Search Icon in Header */
.global-search-trigger {
    position: relative;
    transition: all 0.2s ease;
}

.global-search-trigger:hover {
    transform: scale(1.1);
}

.global-search-trigger:hover i {
    color: #4285f4;
}

.global-search-trigger::after {
    content: 'Ctrl+K';
    position: absolute;
    bottom: -20px;
    left: 50%;
    transform: translateX(-50%);
    font-size: 0.625rem;
    color: #868e96;
    background: white;
    padding: 0.125rem 0.375rem;
    border-radius: 4px;
    border: 1px solid #dee2e6;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s ease;
    white-space: nowrap;
}

.global-search-trigger:hover::after {
    opacity: 1;
}

/* Mobile Responsive */
@media (max-width: 768px) {
    #globalSearchModal .modal-dialog {
        margin: 0.5rem;
        margin-top: 60px;
        max-width: calc(100% - 1rem);
    }

    #globalSearchModal .modal-content {
        border-radius: 12px;
    }

    #globalSearchInput {
        font-size: 1rem;
    }

    .search-result-item {
        padding: 0.75rem 1rem !important;
    }

    .search-result-item .avatar-text {
        width: 36px;
        height: 36px;
    }

    #globalSearchModal .modal-body {
        max-height: 400px;
    }

    .global-search-trigger::after {
        display: none;
    }

    #searchResults .text-center {
        padding: 2rem 1rem !important;
    }
}

/* Spin animation for refresh/recheck icon */
@keyframes spin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

/* Float circle active rotation */
.float-circle.active i {
    transition: transform 0.25s;
}

/* Print styles */
@media print {
    #globalSearchModal {
        display: none !important;
    }
}
