/* Returns & Warranties - Red Design System */

/* Stats Cards */
#statsCards {
    display: flex;
    flex-wrap: wrap;
}

#statsCards > div {
    flex: 1 1 0;
    min-width: 0;
}

.stats-card {
    background: white;
    border-radius: 8px;
    padding: 0.6rem 0.75rem;
    display: flex;
    align-items: center;
    gap: 0.6rem;
    box-shadow: 0 1px 4px rgba(0,0,0,0.06);
    transition: all 0.3s ease;
    border: 1px solid #e9ecef;
    height: 100%;
}

.stats-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
}

.stats-card-icon {
    width: 34px;
    height: 34px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.95rem;
    flex-shrink: 0;
}

.stats-card-body {
    flex: 1;
    min-width: 0;
}

.stats-card-label {
    font-size: 0.7rem;
    font-weight: 500;
    color: #6c757d;
    margin-bottom: 0.1rem;
}

.stats-card-value {
    font-size: 1.2rem;
    font-weight: 700;
    color: #1a1a2e;
    line-height: 1;
}

.stats-card-trend {
    font-size: 0.65rem;
    color: #6c757d;
    margin-top: 0.15rem;
}

/* Card color variants */
.stats-card-pending .stats-card-icon {
    background: #fef3c7;
    color: #f59e0b;
}

.stats-card-received .stats-card-icon {
    background: #d1fae5;
    color: #10b981;
}

.stats-card-completed .stats-card-icon {
    background: #dbeafe;
    color: #3b82f6;
}

.stats-card-rejected .stats-card-icon {
    background: #fee2e2;
    color: #ef4444;
}

.stats-card-sm {
    padding: 0.5rem 0.75rem;
    gap: 0.5rem;
    border-radius: 8px;
}

.stats-card-sm .stats-card-icon {
    width: 32px;
    height: 32px;
    font-size: 0.85rem;
    border-radius: 8px;
    background: #e9ecef;
    color: #6c757d;
}

.stats-card-sm .stats-card-value {
    font-size: 1.1rem;
}

.stats-card-sm .stats-card-label {
    font-size: 0.7rem;
}

.sortable-th,
.sortable-th * {
    cursor: pointer !important;
    user-select: none;
    white-space: nowrap;
}

.sortable-th:hover {
    color: #0d6efd;
}

.stats-card.active {
    border-color: #0d6efd;
    box-shadow: 0 0 0 2px rgba(13,110,253,0.25);
}

/* Warranty Reason Chips */
.warranty-reasons-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
}

.warranty-chip {
    padding: 0.3rem 0.7rem;
    border-radius: 50rem;
    border: 1px solid #dee2e6;
    background: #f8f9fa;
    color: #495057;
    font-size: 0.8rem;
    cursor: pointer;
    transition: all 0.15s ease;
}

.warranty-chip:hover {
    border-color: #adb5bd;
    background: #e9ecef;
}

.warranty-chip.selected {
    background: #0d6efd;
    color: #fff;
    border-color: #0d6efd;
}

/* Status Badges */
.returns-badge {
    display: inline-block;
    padding: 0.3rem 0.7rem;
    border-radius: 50rem;
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.returns-badge-pending {
    background: #fef3c7;
    color: #92400e;
}

.returns-badge-received {
    background: #10b981;
    color: #fff;
}

.returns-badge-completed {
    background: #dbeafe;
    color: #1e40af;
}

.returns-badge-rejected {
    background: #fee2e2;
    color: #991b1b;
}

.returns-badge-core {
    background: #f3f4f6;
    color: #374151;
}

.returns-badge-warranty {
    background: #fef3c7;
    color: #92400e;
}

.returns-badge-repair {
    background: #dbeafe;
    color: #1e40af;
}

.returns-badge-other {
    background: #ede9fe;
    color: #5b21b6;
}

.returns-badge-clickable {
    transition: filter 0.15s ease, transform 0.15s ease;
}

.returns-badge-clickable:hover {
    filter: brightness(0.9);
    transform: scale(1.05);
}

/* Flagged row highlight */
.returns-row-flagged > td {
    background: #fefce8 !important;
}

/* Returns table wrapper — horizontal scroll when needed */
[data-page="returns"] .table-responsive {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

/* Returns table compact styling */
[data-page="returns"] .product-table {
    min-width: 900px;
}

[data-page="returns"] .product-table tbody td {
    padding: 0.5rem 0.5rem;
    font-size: 0.8rem;
    vertical-align: middle;
    white-space: nowrap;
}

[data-page="returns"] .product-table thead th {
    font-size: 0.68rem;
    padding: 0.5rem 0.5rem;
    white-space: nowrap;
}

/* Type badge — compact for long Latvian labels */
[data-page="returns"] .product-table tbody td:nth-child(8) {
    white-space: normal;
}

[data-page="returns"] .product-table tbody td:nth-child(8) .returns-badge {
    font-size: 0.6rem;
    padding: 0.2rem 0.45rem;
    line-height: 1.3;
}

/* Return ID link */
.return-id-link {
    cursor: pointer;
    color: #dc2626;
    font-weight: 600;
    transition: color 0.2s;
}

.return-id-link:hover {
    color: #991b1b;
    text-decoration: underline;
}

/* Table action buttons */
.returns-table .btn-edit-sm {
    background: #fce4ec;
    color: #dc2626;
    border: 1px solid #f8bbd0;
    padding: 0.25rem 0.6rem;
    font-size: 0.75rem;
    border-radius: 6px;
}

.returns-table .btn-edit-sm:hover {
    background: #f8bbd0;
    border-color: #ef9a9a;
}

.returns-table .btn-delete-sm {
    background: #fee2e2;
    color: #dc2626;
    border: 1px solid #fecaca;
    padding: 0.25rem 0.6rem;
    font-size: 0.75rem;
    border-radius: 6px;
}

.returns-table .btn-delete-sm:hover {
    background: #fecaca;
    border-color: #fca5a5;
}

/* Form Sections in modals */
.returns-form-section {
    margin-bottom: 1.5rem;
    padding: 1.25rem;
    background: #f8f9fa;
    border-radius: 10px;
    border-left: 4px solid #dc2626;
}

.returns-form-section-title {
    font-weight: 600;
    color: #1a1a2e;
    margin-bottom: 1rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid #e9ecef;
}

/* Detail Sections in modals */
.returns-detail-section {
    margin-bottom: 1.25rem;
    padding: 1rem;
    background: #f8f9fa;
    border-radius: 8px;
}

.returns-detail-section-title {
    font-weight: 600;
    color: #1a1a2e;
    margin-bottom: 0.75rem;
    padding-bottom: 0.5rem;
    border-bottom: 2px solid #dc2626;
}

/* Photo preview grids */
.returns-photo-preview {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 0.75rem;
    margin-top: 0.5rem;
}

.returns-photo-item {
    position: relative;
    border: 2px solid #e9ecef;
    border-radius: 8px;
    overflow: hidden;
}

.returns-photo-item img {
    width: 100%;
    height: 120px;
    object-fit: cover;
}

.returns-photo-item .returns-photo-remove {
    position: absolute;
    top: 4px;
    right: 4px;
    background: rgba(220, 38, 38, 0.85);
    color: white;
    border: none;
    border-radius: 50%;
    width: 24px;
    height: 24px;
    font-size: 1rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
}

.returns-photo-item .returns-photo-remove:hover {
    background: rgba(220, 38, 38, 1);
}

.returns-photo-item .returns-photo-name {
    display: block;
    padding: 0.35rem;
    font-size: 0.7rem;
    text-align: center;
    background: #f8f9fa;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Images grid (detail/edit modals) */
.returns-images-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 0.75rem;
}

.returns-image-card {
    position: relative;
    border: 1px solid #e9ecef;
    border-radius: 8px;
    overflow: hidden;
    cursor: pointer;
    transition: transform 0.2s;
}

.returns-image-card:hover {
    transform: scale(1.03);
}

.returns-image-card img {
    width: 100%;
    height: 160px;
    object-fit: cover;
}

.returns-image-card .returns-image-info {
    padding: 0.4rem 0.5rem;
    background: #f8f9fa;
    font-size: 0.75rem;
    color: #6c757d;
}

.returns-image-card .returns-image-delete {
    position: absolute;
    top: 4px;
    right: 4px;
    background: rgba(220, 38, 38, 0.85);
    color: white;
    border: none;
    border-radius: 50%;
    width: 26px;
    height: 26px;
    font-size: 1.1rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
}

.returns-image-card .returns-image-delete:hover {
    background: rgba(220, 38, 38, 1);
}

/* Sale search results */
.returns-sale-results {
    max-height: 250px;
    overflow-y: auto;
    border: 1px solid #e9ecef;
    border-radius: 8px;
    margin-bottom: 1rem;
}

.returns-sale-item {
    padding: 0.75rem 1rem;
    border-bottom: 1px solid #f3f4f6;
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    align-items: center;
    transition: all 0.2s;
}

.returns-sale-item:last-child {
    border-bottom: none;
}

.returns-sale-item:hover {
    background: #fef2f2;
    padding-left: 1.25rem;
    border-left: 3px solid #dc2626;
}

.returns-sale-item strong {
    color: #1a1a2e;
}

.returns-sale-item .sale-date {
    color: #6c757d;
    font-size: 0.85rem;
}

.returns-sale-item .items-count {
    background: linear-gradient(135deg, #dc2626 0%, #991b1b 100%);
    color: white;
    padding: 0.2rem 0.6rem;
    border-radius: 50rem;
    font-size: 0.75rem;
    font-weight: 600;
}

/* Line item checkboxes */
.returns-line-item {
    display: flex;
    align-items: flex-start;
    padding: 0.75rem;
    border: 1px solid #e9ecef;
    border-radius: 8px;
    margin-bottom: 0.5rem;
    transition: all 0.2s;
    background: white;
    cursor: pointer;
}

.returns-line-item:hover {
    border-color: #dc2626;
    background: #fef2f2;
}

.returns-line-item input[type="checkbox"] {
    margin-right: 0.75rem;
    margin-top: 0.25rem;
    accent-color: #dc2626;
    width: 18px;
    height: 18px;
    cursor: pointer;
}

.returns-line-item-details {
    flex: 1;
}

.returns-line-item-details strong {
    display: block;
    margin-bottom: 0.4rem;
    color: #1a1a2e;
}

.returns-line-item-meta {
    display: flex;
    gap: 1rem;
    font-size: 0.85rem;
    color: #6c757d;
    flex-wrap: wrap;
}

/* Toast styles */
#toastNotification.bg-success {
    background-color: #10b981 !important;
}

#toastNotification.bg-danger {
    background-color: #ef4444 !important;
}

#toastNotification {
    color: white;
}

/* Responsive — tablets / large phones landscape */
@media (max-width: 768px) {
    .stats-card { padding: 0.75rem; gap: 0.6rem; }
    .stats-card-value { font-size: 1.25rem; }
    .stats-card-icon { width: 36px; height: 36px; font-size: 0.95rem; }
    .stats-card-label { font-size: 0.7rem; }
    .stats-card-trend { font-size: 0.65rem; }
    .stats-card:hover { transform: none; } /* no hover lift on touch */
    .returns-form-section { padding: 1rem; }
}

/* Responsive — phones portrait */
@media (max-width: 576px) {
    /* Hero compact */
    .hero-section .display-5 { font-size: 1.5rem; }
    .hero-section p { font-size: 0.85rem; }

    /* Stats: 2×2 grid, tighter */
    #statsCards { gap: 0.5rem !important; }
    #statsCards > div { flex: 0 0 calc(50% - 0.25rem); }
    .stats-card { padding: 0.6rem; gap: 0.5rem; border-radius: 8px; }
    .stats-card-icon { width: 32px; height: 32px; font-size: 0.85rem; border-radius: 8px; }
    .stats-card-value { font-size: 1.1rem; }
    .stats-card-label { font-size: 0.65rem; }
    .stats-card-trend { font-size: 0.6rem; }

    /* Filter bar: stack vertically */
    [data-page="returns"] .card-body.d-flex.flex-wrap {
        flex-direction: column;
        align-items: stretch;
    }
    [data-page="returns"] .card-body .flex-grow-1 { min-width: 100% !important; }
    .date-range-group { flex-wrap: wrap; width: 100%; }
    .date-range-group span { display: none; }
    [data-page="returns"] .date-range-group #dateFrom,
    [data-page="returns"] .date-range-group #dateTo { max-width: 100% !important; width: 100%; }
    [data-page="returns"] #typeFilter { max-width: 100% !important; width: 100%; }
    [data-page="returns"] #searchBtn,
    [data-page="returns"] #clearFiltersBtn { width: 100%; }

    /* Return ID link — larger on mobile */
    [data-page="returns"] .return-id-link { font-size: 1rem; }

    /* Status badge — larger tap target on mobile */
    [data-page="returns"] .returns-badge { font-size: 0.8rem; padding: 0.4rem 0.85rem; }

    /* Table → card layout: reset desktop overrides */
    [data-page="returns"] .product-table { min-width: 0 !important; }
    [data-page="returns"] .product-table tbody td { white-space: normal !important; }
    [data-page="returns"] .product-table thead { display: none; }
    [data-page="returns"] .product-table tbody tr {
        display: block;
        padding: 0.75rem;
        margin-bottom: 0.75rem;
        border: 1px solid #e9ecef;
        border-radius: 10px;
        background: white;
        box-shadow: 0 2px 8px rgba(0,0,0,0.12);
    }

    /* Table header — stack title and button on mobile */
    [data-page="returns"] .card-header.d-flex {
        flex-direction: column;
        align-items: flex-start !important;
        gap: 0.5rem;
    }
    [data-page="returns"] .card-header h5 {
        font-size: 1rem;
    }
    [data-page="returns"] .product-table tbody td {
        display: flex;
        justify-content: space-between;
        align-items: center;
        padding: 0.3rem 0;
        border: none;
        font-size: 0.8rem;
    }
    [data-page="returns"] .product-table tbody td::before {
        content: attr(data-label);
        font-weight: 600;
        color: #6c757d;
        font-size: 0.72rem;
        flex-shrink: 0;
        margin-right: 0.5rem;
    }
    [data-page="returns"] .product-table tbody td:last-child {
        justify-content: flex-end;
        padding-top: 0.5rem;
        margin-top: 0.25rem;
        border-top: 1px solid #f0f0f0;
    }

    /* Modals full-width */
    .modal-dialog { max-width: 100%; margin: 0.5rem; }

    /* Pagination compact */
    .card-footer { padding: 0.5rem !important; }
    .card-footer .btn { font-size: 0.75rem; }
}

/* ============================================================
   Rugby Warehouse
   ============================================================ */
.rugby-badge-instock {
    display: inline-block;
    padding: 0.25rem 0.6rem;
    border-radius: 50rem;
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    background: #e8f5e9;
    color: #2e7d32;
}

.rugby-badge-sold {
    display: inline-block;
    padding: 0.25rem 0.6rem;
    border-radius: 50rem;
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    background: #fce4ec;
    color: #c62828;
}

.rugby-badge-partial {
    display: inline-block;
    padding: 0.25rem 0.6rem;
    border-radius: 50rem;
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    background: #fff3e0;
    color: #e65100;
}

.rugby-row-sold td {
    opacity: 0.55;
}

#rugby-warehouse-section .rugby-status-filter {
    display: flex;
    gap: 6px;
    align-items: center;
    flex-wrap: wrap;
}

.rugby-view-toggle {
    display: flex;
    gap: 6px;
    margin-bottom: 1rem;
}

.rugby-view-toggle .btn {
    font-size: 13px;
    padding: 6px 16px;
    border-radius: 6px;
}

/* Rugby warehouse table — wrap long columns instead of stretching */
#rugbyTableBody td {
    white-space: normal !important;
    vertical-align: middle;
}
#rugbyTableBody td div[style] {
    white-space: normal;
    word-break: break-word;
}
