/* =================================
   CSS Variables for Brand Customization
   ================================= */
:root {
    /* Brand Colors */
    --primary-color: #2c5f4f;
    --primary-dark: #1f4439;
    --primary-light: #3d7a66;
    --accent-color: #d4a574;
    --accent-light: #e8c9a3;
    
    /* Neutral Colors */
    --bg-color: #fafaf8;
    --surface-color: #ffffff;
    --border-color: #e5e3dc;
    --text-primary: #1a1a1a;
    --text-secondary: #5a5a5a;
    --text-muted: #898989;
    
    /* Shadows */
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.06);
    --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.08);
    --shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.12);
    
    /* Spacing */
    --spacing-xs: 0.5rem;
    --spacing-sm: 0.75rem;
    --spacing-md: 1rem;
    --spacing-lg: 1.5rem;
    --spacing-xl: 2rem;
    --spacing-2xl: 3rem;
    --spacing-3xl: 4rem;
    
    /* Typography */
    --font-display: 'DM Serif Display', Georgia, serif;
    --font-body: 'Work Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    
    /* Transitions */
    --transition-fast: 150ms ease-in-out;
    --transition-base: 250ms ease-in-out;
    --transition-slow: 400ms ease-in-out;
}

/* =================================
   Reset & Base Styles
   ================================= */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: var(--font-body);
    font-size: 16px;
    line-height: 1.6;
    color: var(--text-primary);
    background-color: var(--bg-color);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* =================================
   Header
   ================================= */
.header {
    background: linear-gradient(135deg, var(--primary-dark) 0%, var(--primary-color) 100%);
    padding: var(--spacing-lg) 0;
    box-shadow: var(--shadow-md);
    position: relative;
    overflow: hidden;
}

.header::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: url('data:image/svg+xml,<svg width="60" height="60" viewBox="0 0 60 60" xmlns="http://www.w3.org/2000/svg"><path d="M0 0h30v30H0z" fill="none"/><path d="M15 0L30 15L15 30L0 15z" fill="rgba(255,255,255,0.02)"/></svg>');
    opacity: 0.4;
}

.header-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 var(--spacing-lg);
    display: flex;
    align-items: center;
    gap: var(--spacing-lg);
    position: relative;
    z-index: 1;
}

.logo {
    width: 60px;
    height: 60px;
    object-fit: contain;
    background: var(--surface-color);
    border-radius: 8px;
    padding: 8px;
    box-shadow: var(--shadow-md);
    animation: fadeInScale 0.6s ease-out;
}

.header-text {
    flex: 1;
}

.header-title {
    font-family: var(--font-display);
    font-size: 1.75rem;
    font-weight: 400;
    color: var(--surface-color);
    letter-spacing: -0.02em;
    animation: fadeInUp 0.6s ease-out 0.1s both;
}

/* =================================
   Main Content
   ================================= */
.main-content {
    flex: 1;
    padding: var(--spacing-2xl) 0;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 var(--spacing-lg);
}

/* =================================
   State Containers (Loading, Error, Empty)
   ================================= */
.state-container {
    text-align: center;
    padding: var(--spacing-3xl) var(--spacing-lg);
    animation: fadeIn 0.4s ease-out;
}

.spinner {
    width: 50px;
    height: 50px;
    margin: 0 auto var(--spacing-lg);
    border: 4px solid var(--border-color);
    border-top-color: var(--primary-color);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

.state-icon {
    width: 64px;
    height: 64px;
    margin: 0 auto var(--spacing-lg);
    color: var(--text-muted);
}

.state-message {
    font-size: 1.125rem;
    color: var(--text-secondary);
    font-weight: 400;
}

.error-state .state-icon {
    color: #c53030;
}

.error-state .state-message {
    color: #c53030;
}

/* =================================
   Products Table (Desktop View)
   ================================= */
.table-wrapper {
    display: none; /* Hidden on mobile, shown on desktop */
    background: var(--surface-color);
    border-radius: 12px;
    box-shadow: var(--shadow-md);
    overflow: hidden;
    animation: fadeInUp 0.5s ease-out;
}

.products-table {
    width: 100%;
    border-collapse: collapse;
}

.products-table thead {
    background: linear-gradient(to right, var(--primary-dark), var(--primary-color));
    color: var(--surface-color);
}

.products-table th {
    padding: var(--spacing-lg);
    text-align: left;
    font-weight: 600;
    font-size: 0.875rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    border: none;
}

.products-table th.price-column {
    text-align: right;
    width: 180px;
}

.products-table tbody tr {
    border-bottom: 1px solid var(--border-color);
    transition: background-color var(--transition-fast);
}

.products-table tbody tr:last-child {
    border-bottom: none;
}

.products-table tbody tr:hover {
    background-color: #f9f8f4;
}

.products-table td {
    padding: var(--spacing-lg);
    vertical-align: top;
}

.product-name {
    font-weight: 600;
    color: var(--text-primary);
    font-size: 1rem;
    margin-bottom: 0.25rem;
}

.product-description {
    color: var(--text-secondary);
    font-size: 0.9375rem;
    line-height: 1.5;
}

.product-price {
    font-family: var(--font-display);
    font-size: 1.5rem;
    color: var(--primary-color);
    font-weight: 400;
    text-align: right;
    white-space: nowrap;
    letter-spacing: -0.01em;
}

/* =================================
   Products Cards (Mobile View)
   ================================= */
.products-cards {
    display: flex;
    flex-direction: column;
    gap: var(--spacing-lg);
}

.product-card {
    background: var(--surface-color);
    border-radius: 12px;
    padding: var(--spacing-lg);
    box-shadow: var(--shadow-md);
    border-left: 4px solid var(--primary-color);
    animation: fadeInUp 0.4s ease-out both;
    transition: transform var(--transition-base), box-shadow var(--transition-base);
}

.product-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}

.product-card:nth-child(1) { animation-delay: 0.05s; }
.product-card:nth-child(2) { animation-delay: 0.1s; }
.product-card:nth-child(3) { animation-delay: 0.15s; }
.product-card:nth-child(4) { animation-delay: 0.2s; }
.product-card:nth-child(5) { animation-delay: 0.25s; }
.product-card:nth-child(n+6) { animation-delay: 0.3s; }

.card-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: var(--spacing-md);
    margin-bottom: var(--spacing-md);
    padding-bottom: var(--spacing-md);
    border-bottom: 1px solid var(--border-color);
}

.card-title {
    flex: 1;
}

.card-product-name {
    font-weight: 600;
    color: var(--text-primary);
    font-size: 1.125rem;
    margin-bottom: 0.25rem;
    line-height: 1.3;
}

.card-price {
    font-family: var(--font-display);
    font-size: 1.75rem;
    color: var(--primary-color);
    font-weight: 400;
    white-space: nowrap;
    letter-spacing: -0.02em;
}

.card-description {
    color: var(--text-secondary);
    font-size: 0.9375rem;
    line-height: 1.6;
}

/* =================================
   Footer
   ================================= */
.footer {
    background-color: var(--primary-dark);
    color: rgba(255, 255, 255, 0.7);
    padding: var(--spacing-lg) 0;
    margin-top: auto;
}

.footer-text {
    text-align: center;
    font-size: 0.875rem;
}

/* =================================
   Animations
   ================================= */
@keyframes spin {
    to { transform: rotate(360deg); }
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes fadeInScale {
    from {
        opacity: 0;
        transform: scale(0.9);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

/* =================================
   Responsive Design
   ================================= */

/* Mobile First - Cards are default */
@media (max-width: 767px) {
    .header-title {
        font-size: 1.375rem;
    }
    
    .logo {
        width: 50px;
        height: 50px;
    }
    
    .main-content {
        padding: var(--spacing-xl) 0;
    }
    
    .container {
        padding: 0 var(--spacing-md);
    }
}

/* Tablet and Desktop - Show Table */
@media (min-width: 768px) {
    .table-wrapper {
        display: block;
    }
    
    .products-cards {
        display: none;
    }
    
    .header-title {
        font-size: 2rem;
    }
    
    .logo {
        width: 70px;
        height: 70px;
    }
}

/* Large Desktop - Enhanced spacing */
@media (min-width: 1024px) {
    .header-title {
        font-size: 2.25rem;
    }
    
    .products-table th {
        padding: var(--spacing-xl);
    }
    
    .products-table td {
        padding: var(--spacing-xl);
    }
    
    .product-price {
        font-size: 1.75rem;
    }
}

/* =================================
   Print Styles
   ================================= */
@media print {
    .header::before {
        display: none;
    }
    
    .footer {
        display: none;
    }
    
    .products-table tbody tr:hover {
        background-color: transparent;
    }
    
    .product-card {
        break-inside: avoid;
        box-shadow: none;
        border: 1px solid var(--border-color);
    }
}

/* =================================
   Accessibility Enhancements
   ================================= */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    :root {
        --border-color: #000000;
    }
    
    .products-table tbody tr {
        border-bottom: 2px solid #000000;
    }
}

/* Focus styles for keyboard navigation */
a:focus-visible,
button:focus-visible {
    outline: 2px solid var(--primary-color);
    outline-offset: 2px;
}
