/* 
 * MPL Staff App - Premium UI 
 * Following 'create_beautiful_ui' skill principles
 */

:root {
    /* Color Palette - HSL for harmony */
    --primary: hsl(220, 90%, 56%);
    /* Vibrant Blue */
    --primary-hover: hsl(220, 90%, 50%);
    --secondary: hsl(265, 85%, 65%);
    /* Soft Purple */
    --accent: hsl(35, 95%, 60%);
    /* Warm Orange */

    --bg-color: hsl(210, 20%, 98%);
    /* Off-White Background */
    --surface-color: hsl(0, 0%, 100%);
    /* White Surface */
    --surface-glass: hsla(0, 0%, 100%, 0.85);
    /* Glassy Surface */

    --text-main: hsl(210, 30%, 15%);
    /* Dark Blue-Grey */
    --text-secondary: hsl(210, 20%, 50%);
    /* Medium Grey */
    --text-on-primary: #ffffff;

    --border-color: hsl(210, 20%, 90%);

    /* Spacing & Radius */
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --radius-full: 9999px;

    /* Shadows */
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
    --glass-shadow: 0 8px 32px 0 rgba(31, 38, 135, 0.07);

    /* Typography */
    --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;

    /* Animations */
    --transition-base: 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Reset & Base */
*,
*::before,
*::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: var(--font-sans);
    background-color: var(--bg-color);
    color: var(--text-main);
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    min-height: 100vh;
    /* Subtle mesh gradient background */
    background-image:
        radial-gradient(at 80% 0%, hsla(220, 90%, 56%, 0.1) 0px, transparent 50%),
        radial-gradient(at 0% 50%, hsla(265, 85%, 65%, 0.1) 0px, transparent 50%);
    background-attachment: fixed;
}

/* Container */
.container {
    max-width: 1280px;
    margin: 0 auto;
    padding: 2rem;
}

/* Header */
header {
    margin-bottom: 2rem;
    padding: 1.5rem;
    background: var(--surface-glass);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-radius: var(--radius-lg);
    border: 1px solid rgba(255, 255, 255, 0.5);
    box-shadow: var(--shadow-sm);
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.header-top {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

h1 {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--primary);
    letter-spacing: -0.025em;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

/* Filter Controls */
.filter-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
}

.control-group {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    min-width: 0;
    /* Prevents flex overflow */
}

label {
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text-secondary);
    white-space: nowrap;
}

input,
select {
    padding: 0.75rem 1rem;
    border-radius: var(--radius-md);
    border: 1px solid var(--border-color);
    background: var(--surface-color);
    font-size: 0.95rem;
    color: var(--text-main);
    transition: all var(--transition-base);
    outline: none;
    font-family: inherit;
    width: 100%;
}

input:disabled {
    background: #f1f5f9;
    cursor: not-allowed;
    color: #94a3b8;
}

input:focus,
select:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px hsla(220, 90%, 56%, 0.15);
}

/* Price Range Inputs */
.price-range-inputs {
    display: flex;
    gap: 0.5rem;
}

.price-range-inputs input {
    width: 100%;
    min-width: 0;
}

/* Dynamic Size Filter Section */
.size-filter-area {
    background: hsla(220, 50%, 95%, 0.5);
    padding: 1rem;
    border-radius: var(--radius-md);
    border: 1px dashed var(--border-color);
}

.size-rows {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.size-row {
    display: grid;
    grid-template-columns: 1fr 80px auto;
    gap: 0.75rem;
    align-items: center;
    animation: slideIn 0.3s ease-out;
}

.btn-icon {
    width: 36px;
    height: 36px;
    border-radius: var(--radius-full);
    border: 1px solid var(--border-color);
    background: var(--surface-color);
    color: var(--text-secondary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--transition-base);
}

.btn-icon:hover {
    background: #fee2e2;
    color: #ef4444;
    border-color: #fecaca;
}

.btn-add {
    margin-top: 0.75rem;
    align-self: flex-start;
    padding: 0.5rem 1rem;
    font-size: 0.875rem;
    color: var(--primary);
    background: hsla(220, 90%, 56%, 0.1);
    border: none;
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-weight: 600;
    transition: all 0.2s;
}

.btn-add:hover {
    background: hsla(220, 90%, 56%, 0.2);
}

/* Results Grid */
#results-count {
    margin-bottom: 1rem;
    font-size: 0.95rem;
    color: var(--text-secondary);
    font-weight: 500;
}

.product-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 1.5rem;
}

/* Product Card */
.card {
    background: var(--surface-color);
    border-radius: var(--radius-lg);
    overflow: hidden;
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border-color);
    transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
    position: relative;
    display: flex;
    flex-direction: column;
}

.card:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-lg);
}

.card-img {
    width: 100%;
    height: 200px;
    object-fit: cover;
    background: #f1f5f9;
    border-bottom: 1px solid var(--border-color);
}

/* Image Carousel */
.card-carousel {
    position: relative;
    overflow: hidden;
    background: #f1f5f9;
}

.carousel-nav {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.25rem 0.5rem;
    background: linear-gradient(transparent, rgba(0, 0, 0, 0.45));
    opacity: 0;
    transition: opacity 0.2s ease;
}

.card-carousel:hover .carousel-nav {
    opacity: 1;
}

.carousel-btn {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    border: none;
    background: linear-gradient(135deg, rgba(255,255,255,0.95), rgba(240,240,255,0.95));
    color: var(--text-main);
    font-size: 1.2rem;
    font-weight: 700;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s cubic-bezier(0.25, 0.8, 0.25, 1);
    line-height: 1;
    box-shadow: 0 2px 8px rgba(0,0,0,0.15);
}

.carousel-btn:hover {
    background: linear-gradient(135deg, #fff, #f0f4ff);
    transform: scale(1.15);
    box-shadow: 0 4px 12px rgba(0,0,0,0.2);
}

.carousel-btn:active {
    transform: scale(0.95);
}

.carousel-counter {
    font-size: 0.7rem;
    font-weight: 600;
    color: #fff;
    background: rgba(0, 0, 0, 0.5);
    padding: 3px 10px;
    border-radius: var(--radius-full);
    backdrop-filter: blur(4px);
    letter-spacing: 0.05em;
}

.card-body {
    padding: 1.25rem;
    flex: 1;
    display: flex;
    flex-direction: column;
}

.brand-badge {
    display: inline-block;
    padding: 2px 8px;
    background: hsla(220, 90%, 56%, 0.1);
    color: var(--primary);
    font-size: 0.7rem;
    font-weight: 700;
    border-radius: var(--radius-sm);
    margin-bottom: 0.5rem;
    text-transform: uppercase;
}

.product-name {
    font-size: 1rem;
    font-weight: 600;
    margin-bottom: 0.5rem;
    color: var(--text-main);
    line-height: 1.3;
}

.product-sku {
    font-size: 0.8rem;
    color: var(--text-secondary);
    margin-bottom: 1rem;
    font-family: monospace;
}

.card-footer {
    padding: 0.75rem 1.25rem;
    border-top: 1px solid var(--border-color);
    background: #f8fafc;
    margin-top: auto;
}

.btn-share-card {
    width: 100%;
    padding: 0.5rem;
    border: 1px solid var(--border-color);
    background: white;
    color: var(--text-main);
    border-radius: var(--radius-sm);
    font-size: 0.875rem;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    transition: all 0.2s;
}

.btn-share-card:hover {
    background: #f1f5f9;
    color: var(--primary);
    border-color: var(--primary);
}

/* Price & Warehouse */
.price-section {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.5rem;
    font-size: 0.95rem;
}

.price-label {
    color: var(--text-secondary);
}

.price-value {
    font-weight: 700;
    color: var(--primary);
}

.warehouse-row {
    font-size: 0.8rem;
    color: var(--text-secondary);
    margin-bottom: 0.75rem;
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.wh-tag {
    padding: 2px 6px;
    border-radius: -infinity;
    /* invalid, fix to var */
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: 600;
}

/* Stock Grid inside Card */
.stock-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(50px, 1fr));
    gap: 0.5rem;
    margin-top: auto;
}

.stock-item {
    background: #f8fafc;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    padding: 0.25rem;
    text-align: center;
}

.stock-size {
    font-size: 0.75rem;
    font-weight: 700;
    color: var(--text-secondary);
    display: block;
}

.stock-qty {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--primary);
    display: block;
}

.stock-qty.low {
    color: #ef4444;
}

.stock-qty.good {
    color: #10b981;
}

/* Floating Action Button */
.fab {
    position: fixed;
    bottom: 2rem;
    right: 2rem;
    background: #25D366;
    /* WhatsApp Green */
    color: white;
    width: 64px;
    height: 64px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 12px rgba(37, 211, 102, 0.4);
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
    z-index: 100;
    border: none;
}

.fab:hover {
    transform: scale(1.1);
    box-shadow: 0 8px 16px rgba(37, 211, 102, 0.5);
}

.fab svg {
    width: 32px;
    height: 32px;
    fill: currentColor;
}

/* Loading State */
.loading {
    grid-column: 1 / -1;
    text-align: center;
    padding: 4rem;
    color: var(--text-secondary);
    font-size: 1.1rem;
}

/* Animations */
@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

.fade-in {
    animation: fadeIn 0.5s ease-out forwards;
}

/* Reset Button */
.btn-reset {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.45rem 1rem;
    font-size: 0.8rem;
    font-weight: 600;
    font-family: inherit;
    color: var(--text-secondary);
    background: var(--surface-color);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-full);
    cursor: pointer;
    transition: all 0.25s cubic-bezier(0.25, 0.8, 0.25, 1);
}

.btn-reset:hover {
    color: #ef4444;
    border-color: #fca5a5;
    background: #fef2f2;
    box-shadow: 0 2px 8px rgba(239, 68, 68, 0.15);
}

.btn-reset:hover i {
    animation: spin-once 0.5s ease;
}

@keyframes spin-once {
    from { transform: rotate(0deg); }
    to { transform: rotate(-360deg); }
}

/* Pagination */
.pagination {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 0.75rem;
    margin-top: 2rem;
    padding: 1.25rem;
}

.pagination button {
    padding: 0.65rem 1.5rem;
    border: none;
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    color: var(--text-on-primary);
    border-radius: var(--radius-full);
    font-size: 0.85rem;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    transition: all 0.25s cubic-bezier(0.25, 0.8, 0.25, 1);
    box-shadow: 0 2px 8px rgba(59, 130, 246, 0.3);
    letter-spacing: 0.02em;
}

.pagination button:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(59, 130, 246, 0.4);
}

.pagination button:active:not(:disabled) {
    transform: translateY(0);
}

.pagination button:disabled {
    opacity: 0.35;
    cursor: not-allowed;
    background: var(--border-color);
    color: var(--text-secondary);
    box-shadow: none;
}

.page-info {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-secondary);
    background: var(--surface-glass);
    padding: 0.5rem 1rem;
    border-radius: var(--radius-full);
    border: 1px solid var(--border-color);
}

/* Responsive adjustments */
@media (max-width: 768px) {
    .header-top {
        flex-direction: column;
        align-items: flex-start;
        gap: 1rem;
    }

    .filter-grid {
        grid-template-columns: 1fr;
    }

    .size-row {
        grid-template-columns: 1fr 70px auto;
    }
}