/* =========================================
   CSA Portal - eBay Style Design System
   ========================================= */

:root {
    /* Main Font */
    --main-font-family: 'Arial', sans-serif;

    /* ===== Colors ===== */
    --csa-white: #FFFFFF;
    --csa-primary: #C21E37;
    --csa-primary-hover: #A01A2E;
    --csa-link: #0071C1;
    --csa-link-hover: #005a9c;
    --csa-text: #212529;
    --csa-text-muted: #6C757D;
    --csa-border: #DEE2E6;
    --csa-bg-light: #F8F9FA;
    --csa-success: #28a745;
    --csa-warning: #ffc107;
    --csa-danger: #dc3545;
    --csa-info: #17a2b8;

    /* ===== Shadows ===== */
    --csa-shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.08);
    --csa-shadow-md: 0 4px 12px rgba(0, 0, 0, 0.1);
    --csa-shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.12);

    /* ===== Border Radius ===== */
    --csa-radius-sm: 4px;
    --csa-radius: 8px;
    --csa-radius-lg: 12px;
    --csa-radius-full: 9999px;

    /* ===== Transitions ===== */
    --transition-fast: 0.15s ease;
    --transition-normal: 0.25s ease;
    --transition-slow: 0.4s ease;

    /* ===== Spacing ===== */
    --spacing-xs: 4px;
    --spacing-sm: 8px;
    --spacing-md: 16px;
    --spacing-lg: 24px;
    --spacing-xl: 32px;

    /* ===== Layout ===== */
    --max-content-width: 1400px;
    --header-height: 120px;
}

/* ===== Base Styles ===== */
html, body {
    font-family: var(--main-font-family) !important;
    color: var(--csa-text);
    background: var(--csa-white);
    line-height: 1.5;
}

h1:focus {
    outline: none;
}

a, .btn-link {
    color: var(--csa-link);
    text-decoration: none;
    transition: color var(--transition-fast);
}

a:hover, .btn-link:hover {
    color: var(--csa-link-hover);
}

/* ===== Bootstrap-Style Button Base ===== */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--spacing-sm);
    padding: 10px 20px;
    border-radius: var(--csa-radius);
    font-weight: 500;
    font-size: 14px;
    cursor: pointer;
    transition: all var(--transition-fast);
    border: none;
    text-decoration: none;
}

.btn:active {
    transform: scale(0.97);
}

.btn:disabled {
    opacity: 0.65;
    cursor: not-allowed;
    transform: none;
}

.btn-primary {
    background: var(--csa-primary);
    color: var(--csa-white);
    border: none;
}

.btn-primary:hover:not(:disabled) {
    background: var(--csa-primary-hover);
}

.btn-secondary {
    background: var(--csa-white);
    color: var(--csa-text);
    border: 1px solid var(--csa-border);
}

.btn-secondary:hover:not(:disabled) {
    background: var(--csa-bg-light);
    border-color: #c0c4c8;
}

.btn-outline {
    background: transparent;
    color: var(--csa-primary);
    border: 1px solid var(--csa-primary);
}

.btn-outline:hover:not(:disabled) {
    background: var(--csa-primary);
    color: var(--csa-white);
}

.btn-link {
    background: none;
    color: var(--csa-link);
    border: none;
    padding: 0;
    text-decoration: none;
}

.btn-link:hover {
    text-decoration: underline;
}

.btn-success {
    background: var(--csa-success);
    color: var(--csa-white);
    border: none;
}

.btn-danger {
    background: var(--csa-danger);
    color: var(--csa-white);
    border: none;
}

.btn-sm {
    padding: 6px 12px;
    font-size: 13px;
}

.btn-lg {
    padding: 14px 28px;
    font-size: 16px;
}

.btn:focus, .btn:active:focus, .btn-link.nav-link:focus, .form-control:focus, .form-check-input:focus {
    box-shadow: 0 0 0 0.1rem white, 0 0 0 0.25rem var(--csa-link);
}

/* ===== Card Styles ===== */
.csa-card {
    background: var(--csa-white);
    border: 1px solid var(--csa-border);
    border-radius: var(--csa-radius);
    overflow: hidden;
    transition: transform var(--transition-normal), box-shadow var(--transition-normal);
}

.csa-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--csa-shadow-md);
}

.csa-card-body {
    padding: var(--spacing-md);
}

/* ===== Form Styles ===== */
.content {
    padding-top: 1.1rem;
}

.valid.modified:not([type=checkbox]) {
    outline: 1px solid var(--csa-success);
}

.invalid {
    outline: 1px solid var(--csa-danger);
}

.validation-message {
    color: var(--csa-danger);
    font-size: 13px;
    margin-top: var(--spacing-xs);
}

/* ===== Badge Styles ===== */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 4px 10px;
    font-size: 12px;
    font-weight: 600;
    border-radius: var(--csa-radius-sm);
}

.badge-primary {
    background: var(--csa-primary);
    color: var(--csa-white);
}

.badge-success {
    background: #d4edda;
    color: #155724;
}

.badge-warning {
    background: #fff3cd;
    color: #856404;
}

.badge-danger {
    background: #f8d7da;
    color: #721c24;
}

.badge-info {
    background: #d1ecf1;
    color: #0c5460;
}

.badge-promo {
    position: absolute;
    top: 8px;
    right: 8px;
    background: var(--csa-primary);
    color: var(--csa-white);
    padding: 4px 8px;
    font-size: 11px;
    font-weight: 600;
    border-radius: var(--csa-radius-sm);
}

/* ===== Product Card Styles ===== */
.product-card {
    background: var(--csa-white);
    border: 1px solid var(--csa-border);
    border-radius: var(--csa-radius);
    overflow: hidden;
    transition: transform var(--transition-normal), box-shadow var(--transition-normal);
}

.product-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--csa-shadow-md);
}

.product-image {
    position: relative;
    aspect-ratio: 1;
    background: var(--csa-bg-light);
}

.product-image img {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.product-info {
    padding: var(--spacing-md);
}

.product-title {
    font-size: 14px;
    font-weight: 500;
    color: var(--csa-text);
    margin: 0 0 4px;
    line-height: 1.4;
}

.product-supplier {
    font-size: 12px;
    color: var(--csa-text-muted);
    margin: 0 0 8px;
}

.price {
    font-size: 18px;
    font-weight: 700;
    color: var(--csa-text);
}

.price-promo {
    font-size: 18px;
    font-weight: 700;
    color: var(--csa-primary);
}

.price-original {
    font-size: 14px;
    color: var(--csa-text-muted);
    text-decoration: line-through;
    margin-left: 8px;
}

.btn-add-cart {
    width: 100%;
    padding: 10px;
    background: var(--csa-primary);
    color: var(--csa-white);
    border: none;
    border-radius: var(--csa-radius);
    font-weight: 500;
    cursor: pointer;
    margin-top: 12px;
    transition: background var(--transition-fast);
}

.btn-add-cart:hover {
    background: var(--csa-primary-hover);
}

/* ===== Products Grid Layout ===== */
.products-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 20px;
}

/* ===== Filter Sidebar Styles ===== */
.filter-sidebar {
    background: var(--csa-white);
    border: 1px solid var(--csa-border);
    border-radius: var(--csa-radius);
    padding: 20px;
    height: fit-content;
    position: sticky;
    top: 130px;
}

.filter-section {
    margin-bottom: 24px;
    padding-bottom: 24px;
    border-bottom: 1px solid var(--csa-border);
}

.filter-section:last-child {
    border-bottom: none;
    margin-bottom: 0;
    padding-bottom: 0;
}

.filter-title {
    font-weight: 600;
    font-size: 14px;
    color: var(--csa-text);
    margin-bottom: 12px;
}

.filter-option {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 0;
    cursor: pointer;
}

.filter-option input[type="checkbox"] {
    accent-color: var(--csa-primary);
    width: 16px;
    height: 16px;
}

.filter-clear {
    color: var(--csa-link);
    font-size: 13px;
    cursor: pointer;
    text-decoration: none;
}

.filter-clear:hover {
    text-decoration: underline;
}

/* ===== Layout Styles ===== */
.page-container {
    max-width: var(--max-content-width);
    margin: 0 auto;
    padding: var(--spacing-lg);
}

.page-title {
    font-size: 24px;
    font-weight: 600;
    color: var(--csa-text);
    margin: 0 0 var(--spacing-lg);
}

/* ===== Radzen Overrides ===== */
/* DataGrid Header - Red gradient to match page headers */
.rz-grid-table th {
    background: linear-gradient(135deg, var(--csa-primary) 0%, #a01a2e 100%) !important;
}

.rz-datatable-thead th .rz-column-title-content,
.rz-grid-table thead th .rz-column-title-content {
    color: white !important;
    text-wrap: auto !important;
    font-weight: 600;
}

/* DataGrid header icons and sort indicators */
.rz-grid-table th .rz-sortable-column-icon,
.rz-grid-table th .rz-cell-filter-icon,
.rz-grid-table th i {
    color: rgba(255, 255, 255, 0.9) !important;
}

.rz-grid-table th:hover {
    background: linear-gradient(135deg, #a01a2e 0%, #8a1526 100%) !important;
}

/* Radzen Card Overrides */
.rz-card {
    border: 1px solid var(--csa-border);
    border-radius: var(--csa-radius);
    box-shadow: none;
}

/* ===== Error & Loading States ===== */
#blazor-error-ui {
    background: lightyellow;
    bottom: 0;
    box-shadow: 0 -1px 2px rgba(0, 0, 0, 0.2);
    display: none;
    left: 0;
    padding: 0.6rem 1.25rem 0.7rem 1.25rem;
    position: fixed;
    width: 100%;
    z-index: 1000;
}

#blazor-error-ui .dismiss {
    cursor: pointer;
    position: absolute;
    right: 0.75rem;
    top: 0.5rem;
}

.blazor-error-boundary {
    background: url(data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iNTYiIGhlaWdodD0iNDkiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgeG1sbnM6eGxpbms9Imh0dHA6Ly93d3cudzMub3JnLzE5OTkveGxpbmsiIG92ZXJmbG93PSJoaWRkZW4iPjxkZWZzPjxjbGlwUGF0aCBpZD0iY2xpcDAiPjxyZWN0IHg9IjIzNSIgeT0iNTEiIHdpZHRoPSI1NiIgaGVpZ2h0PSI0OSIvPjwvY2xpcFBhdGg+PC9kZWZzPjxnIGNsaXAtcGF0aD0idXJsKCNjbGlwMCkiIHRyYW5zZm9ybT0idHJhbnNsYXRlKC0yMzUgLTUxKSI+PHBhdGggZD0iTTI2My41MDYgNTFDMjY0LjcxNyA1MSAyNjUuODEzIDUxLjQ4MzcgMjY2LjYwNiA1Mi4yNjU4TDI2Ny4wNTIgNTIuNzk4NyAyNjcuNTM5IDUzLjYyODMgMjkwLjE4NSA5Mi4xODMxIDI5MC41NDUgOTIuNzk1IDI5MC42NTYgOTIuOTk2QzI5MC44NzcgOTMuNTEzIDI5MSA5NC4wODE1IDI5MSA5NC42NzgyIDI5MSA5Ny4wNjUxIDI4OS4wMzggOTkgMjg2LjYxNyA5OUwyNDAuMzgzIDk5QzIzNy45NjMgOTkgMjM2IDk3LjA2NTEgMjM2IDk0LjY3ODIgMjM2IDk0LjM3OTkgMjM2LjAzMSA5NC4wODg2IDIzNi4wODkgOTMuODA3MkwyMzYuMzM4IDkzLjAxNjIgMjM2Ljg1OCA5Mi4xMzE0IDI1OS40NzMgNTMuNjI5NCAyNTkuOTYxIDUyLjc5ODUgMjYwLjQwNyA1Mi4yNjU4QzI2MS4yIDUxLjQ4MzcgMjYyLjI5NiA1MSAyNjMuNTA2IDUxWk0yNjMuNTg2IDY2LjAxODNDMjYwLjczNyA2Ni4wMTgzIDI1OS4zMTMgNjcuMTI0NSAyNTkuMzEzIDY5LjMzNyAyNTkuMzEzIDY5LjYxMDIgMjU5LjMzMiA2OS44NjA4IDI1OS4zNzEgNzAuMDg4N0wyNjEuNzk1IDg0LjAxNjEgMjY1LjM4IDg0LjAxNjEgMjY3LjgyMSA2OS43NDc1QzI2Ny44NiA2OS43MzA5IDI2Ny44NzkgNjkuNTg3NyAyNjcuODc5IDY5LjMxNzkgMjY3Ljg3OSA2Ny4xMTgyIDI2Ni40NDggNjYuMDE4MyAyNjMuNTg2IDY2LjAxODNaTTI2My41NzYgODYuMDU0N0MyNjEuMDQ5IDg2LjA1NDcgMjU5Ljc4NiA4Ny4zMDA1IDI1OS43ODYgODkuNzkyMSAyNTkuNzg2IDkyLjI4MzcgMjYxLjA0OSA5My41Mjk1IDI2My41NzYgOTMuNTI5NSAyNjYuMTE2IDkzLjUyOTUgMjY3LjM4NyA5Mi4yODM3IDI2Ny4zODcgODkuNzkyMSAyNjcuMzg3IDg3LjMwMDUgMjY2LjExNiA4Ni4wNTQ3IDI2My41NzYgODYuMDU0N1oiIGZpbGw9IiNGRkU1MDAiIGZpbGwtcnVsZT0iZXZlbm9kZCIvPjwvZz48L3N2Zz4=) no-repeat 1rem/1.8rem, #b32121;
    padding: 1rem 1rem 1rem 3.7rem;
    color: white;
}

.blazor-error-boundary::after {
    content: "An error has occurred."
}

/* ===== Loading Progress ===== */
.loading-progress {
    position: relative;
    display: block;
    width: 8rem;
    height: 8rem;
    margin: 20vh auto 1rem auto;
}

.loading-progress circle {
    fill: none;
    stroke: #e0e0e0;
    stroke-width: 0.6rem;
    transform-origin: 50% 50%;
    transform: rotate(-90deg);
}

.loading-progress circle:last-child {
    stroke: var(--csa-primary);
    stroke-dasharray: calc(3.141 * var(--blazor-load-percentage, 0%) * 0.8), 500%;
    transition: stroke-dasharray 0.05s ease-in-out;
}

.loading-progress-text {
    position: absolute;
    text-align: center;
    font-weight: bold;
    inset: calc(20vh + 3.25rem) 0 auto 0.2rem;
}

.loading-progress-text:after {
    content: var(--blazor-load-percentage-text, "Loading");
}

/* ===== Spinner ===== */
.spinner-border {
    display: inline-block;
    width: 2rem;
    height: 2rem;
    vertical-align: text-bottom;
    border: 0.25em solid currentColor;
    border-right-color: transparent;
    border-radius: 50%;
    animation: spinner-border .75s linear infinite;
}

@keyframes spinner-border {
    to { transform: rotate(360deg); }
}

/* ===== Code Styling ===== */
code {
    color: #c02d76;
}

/* ===== Animations ===== */
/* Fade In Animation */
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

.fade-in {
    animation: fadeIn var(--transition-slow) ease-out;
}

/* Stagger animation for grid items */
.products-grid .product-card:nth-child(1) { animation: fadeIn var(--transition-slow) ease-out 0.05s both; }
.products-grid .product-card:nth-child(2) { animation: fadeIn var(--transition-slow) ease-out 0.1s both; }
.products-grid .product-card:nth-child(3) { animation: fadeIn var(--transition-slow) ease-out 0.15s both; }
.products-grid .product-card:nth-child(4) { animation: fadeIn var(--transition-slow) ease-out 0.2s both; }

/* Badge Pulse (for cart count) */
@keyframes pulse {
    0% { transform: scale(1); }
    50% { transform: scale(1.1); }
    100% { transform: scale(1); }
}

.cart-badge.updated {
    animation: pulse 0.3s ease;
}

/* Loading Skeleton */
@keyframes shimmer {
    0% { background-position: -200% 0; }
    100% { background-position: 200% 0; }
}

.skeleton {
    background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite;
    border-radius: var(--csa-radius);
}

/* ===== Mobile Bottom Tab Bar ===== */
.mobile-tab-bar {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: var(--csa-white);
    border-top: 1px solid var(--csa-border);
    display: none;
    justify-content: space-around;
    padding: 8px 0;
    z-index: 1000;
}

.tab-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    color: var(--csa-text-muted);
    text-decoration: none;
    font-size: 10px;
    padding: 4px 8px;
    transition: color var(--transition-fast);
}

.tab-item i {
    font-size: 20px;
    margin-bottom: 4px;
    transition: transform var(--transition-fast);
}

.tab-item:active i {
    transform: scale(1.1);
}

.tab-item.active {
    color: var(--csa-primary);
}

@media (max-width: 768px) {
    .mobile-tab-bar {
        display: flex;
    }

    .csa-main {
        padding-bottom: 70px !important;
    }
}

/* ===== Mobile Filter Panel ===== */
@media (max-width: 768px) {
    .products-page {
        grid-template-columns: 1fr;
    }

    .filter-sidebar {
        position: fixed;
        top: 0;
        left: -100%;
        width: 280px;
        height: 100vh;
        z-index: 1001;
        border-radius: 0;
        transition: left var(--transition-normal);
        overflow-y: auto;
    }

    .filter-sidebar.open {
        left: 0;
    }

    .filter-overlay {
        position: fixed;
        inset: 0;
        background: rgba(0, 0, 0, 0.5);
        z-index: 1000;
        display: none;
    }

    .filter-overlay.show {
        display: block;
    }

    .mobile-filter-btn {
        display: flex;
        margin-bottom: 16px;
    }
}

/* ===== Utility Classes ===== */
.text-primary { color: var(--csa-primary) !important; }
.text-muted { color: var(--csa-text-muted) !important; }
.text-success { color: var(--csa-success) !important; }
.text-danger { color: var(--csa-danger) !important; }
.text-center { text-align: center !important; }

.bg-light { background: var(--csa-bg-light) !important; }
.bg-white { background: var(--csa-white) !important; }

.mb-0 { margin-bottom: 0 !important; }
.mb-1 { margin-bottom: var(--spacing-xs) !important; }
.mb-2 { margin-bottom: var(--spacing-sm) !important; }
.mb-3 { margin-bottom: var(--spacing-md) !important; }
.mb-4 { margin-bottom: var(--spacing-lg) !important; }
.mb-5 { margin-bottom: var(--spacing-xl) !important; }

.mt-0 { margin-top: 0 !important; }
.mt-1 { margin-top: var(--spacing-xs) !important; }
.mt-2 { margin-top: var(--spacing-sm) !important; }
.mt-3 { margin-top: var(--spacing-md) !important; }
.mt-4 { margin-top: var(--spacing-lg) !important; }
.mt-5 { margin-top: var(--spacing-xl) !important; }

.p-0 { padding: 0 !important; }
.p-1 { padding: var(--spacing-xs) !important; }
.p-2 { padding: var(--spacing-sm) !important; }
.p-3 { padding: var(--spacing-md) !important; }
.p-4 { padding: var(--spacing-lg) !important; }

.d-flex { display: flex !important; }
.d-block { display: block !important; }
.d-none { display: none !important; }
.d-grid { display: grid !important; }

.align-items-center { align-items: center !important; }
.justify-content-between { justify-content: space-between !important; }
.justify-content-center { justify-content: center !important; }
.justify-content-end { justify-content: flex-end !important; }

.gap-1 { gap: var(--spacing-xs) !important; }
.gap-2 { gap: var(--spacing-sm) !important; }
.gap-3 { gap: var(--spacing-md) !important; }
.gap-4 { gap: var(--spacing-lg) !important; }

.w-100 { width: 100% !important; }
.h-100 { height: 100% !important; }

.border { border: 1px solid var(--csa-border) !important; }
.border-0 { border: none !important; }
.rounded { border-radius: var(--csa-radius) !important; }
.rounded-lg { border-radius: var(--csa-radius-lg) !important; }

.shadow-sm { box-shadow: var(--csa-shadow-sm) !important; }
.shadow { box-shadow: var(--csa-shadow-md) !important; }
.shadow-lg { box-shadow: var(--csa-shadow-lg) !important; }

.overflow-hidden { overflow: hidden !important; }
.overflow-auto { overflow: auto !important; }

.cursor-pointer { cursor: pointer !important; }
