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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen',
        'Ubuntu', 'Cantarell', 'Fira Sans', 'Droid Sans', 'Helvetica Neue', sans-serif;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    background-color: #F9FAFB;
    color: #111827;
    line-height: 1.6;
}

.container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 2rem 1rem;
}

/* Header */
.header {
    background: white;
    border-radius: 12px;
    padding: 2rem;
    margin-bottom: 2rem;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.header-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 1rem;
    margin-bottom: 1rem;
}

.title {
    font-size: 2rem;
    font-weight: 700;
    color: #111827;
}

.header-controls {
    display: flex;
    gap: 0.75rem;
    align-items: center;
}

.refresh-btn {
    background: #3B82F6;
    color: white;
    border: none;
    border-radius: 8px;
    padding: 0.6rem;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.refresh-btn:hover {
    background: #2563EB;
    transform: scale(1.05);
}

.refresh-btn:active {
    transform: scale(0.95);
}

.refresh-btn.spinning svg {
    animation: spin 1s linear infinite;
}

@keyframes spin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

.toggle-btn {
    background: #6B7280;
    color: white;
    border: none;
    border-radius: 8px;
    padding: 0.6rem 1rem;
    cursor: pointer;
    transition: all 0.2s;
    font-size: 0.9rem;
    font-weight: 500;
}

.toggle-btn:hover {
    background: #4B5563;
}

.header-info {
    display: flex;
    gap: 1.5rem;
    align-items: center;
    flex-wrap: wrap;
    font-size: 0.9rem;
}

.last-updated {
    color: #6B7280;
}

.status {
    color: #10B981;
    font-weight: 500;
}

/* Search */
.search-container {
    margin-bottom: 1.5rem;
}

.search-input {
    width: 100%;
    padding: 0.875rem 1rem;
    font-size: 1rem;
    border: 2px solid #E5E7EB;
    border-radius: 8px;
    background: white;
    transition: border-color 0.2s;
}

.search-input:focus {
    outline: none;
    border-color: #3B82F6;
}

/* Loading State */
.loading-state {
    text-align: center;
    padding: 4rem 2rem;
    background: white;
    border-radius: 12px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.loading-spinner {
    width: 50px;
    height: 50px;
    border: 4px solid #E5E7EB;
    border-top-color: #3B82F6;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto 1rem;
}

/* Error State */
.error-state {
    text-align: center;
    padding: 4rem 2rem;
    background: white;
    border-radius: 12px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.error-icon {
    font-size: 3rem;
    margin-bottom: 1rem;
}

.error-state h3 {
    color: #DC2626;
    margin-bottom: 0.5rem;
}

.error-state p {
    color: #6B7280;
    margin-bottom: 1.5rem;
}

.retry-btn {
    background: #3B82F6;
    color: white;
    border: none;
    border-radius: 8px;
    padding: 0.75rem 1.5rem;
    cursor: pointer;
    font-size: 1rem;
    font-weight: 500;
    transition: background 0.2s;
}

.retry-btn:hover {
    background: #2563EB;
}

/* Table Container */
.inventory-container {
    animation: fadeIn 0.3s ease-in;
}

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

.table-container {
    background: white;
    border-radius: 12px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    overflow: hidden;
}

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

.inventory-table thead {
    background: #F9FAFB;
    border-bottom: 2px solid #E5E7EB;
}

.inventory-table th {
    padding: 1rem;
    text-align: left;
    font-weight: 600;
    color: #374151;
    font-size: 0.875rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.inventory-table th.sortable {
    cursor: pointer;
    user-select: none;
    position: relative;
    padding-right: 2rem;
}

.inventory-table th.sortable:hover {
    background: #F3F4F6;
}

.sort-indicator {
    position: absolute;
    right: 0.75rem;
    top: 50%;
    transform: translateY(-50%);
    opacity: 0.3;
}

.sort-indicator::after {
    content: '↕';
}

.inventory-table th.sorted-asc .sort-indicator::after {
    content: '↑';
    opacity: 1;
}

.inventory-table th.sorted-desc .sort-indicator::after {
    content: '↓';
    opacity: 1;
}

.inventory-table tbody tr {
    border-bottom: 1px solid #E5E7EB;
    transition: background-color 0.15s;
}

.inventory-table tbody tr:hover {
    background: #F9FAFB;
}

.inventory-table td {
    padding: 1rem;
}

.item-name {
    font-weight: 500;
    color: #111827;
}

.category-badge {
    display: inline-block;
    padding: 0.25rem 0.75rem;
    background: #E5E7EB;
    color: #374151;
    border-radius: 9999px;
    font-size: 0.875rem;
    font-weight: 500;
}

.quantity-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.5rem 1rem;
    border-radius: 8px;
    font-weight: 600;
    font-size: 1.125rem;
    min-width: 60px;
}

.badge-total {
    background: #DBEAFE;
    color: #1E40AF;
}

.badge-in-use {
    background: #FEF3C7;
    color: #92400E;
}

.badge-available {
    background: #D1FAE5;
    color: #065F46;
}

.badge-low-stock {
    background: #FEE2E2;
    color: #991B1B;
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.7; }
}

/* Mobile Cards */
.inventory-cards {
    display: none;
    gap: 1rem;
}

.inventory-card {
    background: white;
    border-radius: 12px;
    padding: 1.5rem;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    transition: transform 0.2s, box-shadow 0.2s;
}

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

.card-header {
    margin-bottom: 1rem;
}

.card-name {
    font-size: 1.125rem;
    font-weight: 600;
    color: #111827;
    margin-bottom: 0.5rem;
}

.card-quantities {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 0.75rem;
}

.card-quantity {
    text-align: center;
}

.card-quantity-label {
    font-size: 0.75rem;
    color: #6B7280;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 0.25rem;
}

.card-quantity-value {
    font-size: 1.5rem;
    font-weight: 700;
}

/* Hide/Show Category */
.category-column.hidden,
.category-cell.hidden {
    display: none;
}

/* Responsive Design */
@media (max-width: 768px) {
    .container {
        padding: 1rem 0.75rem;
    }

    .header {
        padding: 1.5rem;
    }

    .title {
        font-size: 1.5rem;
    }

    .header-content {
        flex-direction: column;
        align-items: flex-start;
    }

    .header-controls {
        width: 100%;
        justify-content: space-between;
    }

    .table-container {
        display: none;
    }

    .inventory-cards {
        display: flex;
        flex-direction: column;
    }
}

@media (max-width: 480px) {
    .card-quantities {
        grid-template-columns: 1fr;
    }

    .header-info {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.5rem;
    }
}
