/* Reset and Base Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    color: #333;
    overflow: hidden; /* keep background static */
}

html { height: 100%; }

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
    height: 100vh; /* fill viewport */
    display: flex;
    flex-direction: column;
}

/* Header Styles */
.header {
    text-align: center;
    margin-bottom: 30px;
    color: white;
}

.header h1 {
    font-size: 2.5rem;
    margin-bottom: 10px;
    text-shadow: 2px 2px 4px rgba(0,0,0,0.3);
}

.header p {
    font-size: 1.1rem;
    opacity: 0.9;
}

/* Search Section */
.search-section {
    background: white;
    border-radius: 15px;
    padding: 25px;
    margin-bottom: 30px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.1);
    position: sticky; /* keep toolbar static */
    top: 0;
    z-index: 1000;
}

.search-container {
    max-width: 800px;
    margin: 0 auto;
}

.filters-row {
    display: flex;
    gap: 12px;
    align-items: center;
    justify-content: space-between;
}

.filters-row .search-filters { flex: 1 1 auto; }

.search-input-group {
    position: relative;
    margin-bottom: 20px;
}

.search-icon {
    position: absolute;
    left: 15px;
    top: 50%;
    transform: translateY(-50%);
    color: #666;
    font-size: 1.1rem;
}

#searchInput {
    width: 100%;
    padding: 15px 50px 15px 45px;
    border: 2px solid #e1e5e9;
    border-radius: 25px;
    font-size: 1rem;
    transition: all 0.3s ease;
    background: #f8f9fa;
}

#searchInput:focus {
    outline: none;
    border-color: #667eea;
    background: white;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.clear-btn {
    position: absolute;
    right: 15px;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    color: #999;
    cursor: pointer;
    padding: 5px;
    border-radius: 50%;
    transition: all 0.3s ease;
}

.clear-btn:hover {
    background: #f0f0f0;
    color: #666;
}

.search-filters {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 15px;
}

.search-filters select {
    padding: 12px 15px;
    border: 2px solid #e1e5e9;
    border-radius: 8px;
    background: white;
    font-size: 0.9rem;
    cursor: pointer;
    transition: all 0.3s ease;
}

.search-filters select:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

/* Results Section */
.results-section {
    background: white;
    border-radius: 15px;
    padding: 25px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.1);
    display: flex;
    flex-direction: column;
    height: calc(100vh - 250px); /* cards area fills remaining space */
}

.results-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 25px;
    padding-bottom: 15px;
    border-bottom: 2px solid #f0f0f0;
}

.results-count {
    font-size: 1.1rem;
    font-weight: 600;
    color: #667eea;
}

.sort-options select {
    padding: 8px 12px;
    border: 2px solid #e1e5e9;
    border-radius: 6px;
    background: white;
    font-size: 0.9rem;
    cursor: pointer;
}

/* Loading and Error States */
.loading, .error-message, .no-results {
    text-align: center;
    padding: 60px 20px;
    color: #666;
}

.loading i, .error-message i, .no-results i {
    font-size: 3rem;
    margin-bottom: 20px;
    color: #667eea;
}

.error-message i {
    color: #e74c3c;
}

.loading span, .error-message span {
    display: block;
    font-size: 1.1rem;
}

.no-results h3 {
    margin-bottom: 10px;
    color: #333;
}

/* Inventory Grid */
.inventory-scroll {
    overflow-y: auto;
    flex: 1 1 auto;
}

.inventory-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 16px;
    padding-right: 6px; /* avoid scrollbar overlay */
}

.inventory-item {
    background: #f8f9fa;
    border: 2px solid #e1e5e9;
    border-radius: 12px;
    padding: 14px; /* smaller cards */
    transition: all 0.3s ease;
    cursor: pointer;
}

.inventory-item:hover {
    transform: translateY(-5px);
    box-shadow: 0 15px 35px rgba(0,0,0,0.1);
    border-color: #667eea;
}

.item-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 15px;
}

.saf-code {
    background: #667eea;
    color: white;
    padding: 6px 12px;
    border-radius: 20px;
    font-size: 0.8rem;
    font-weight: 600;
}

.category-badge {
    background: #e8f4fd;
    color: #2980b9;
    padding: 4px 8px;
    border-radius: 12px;
    font-size: 0.75rem;
    font-weight: 500;
}

.item-title {
    font-size: 1.2rem;
    font-weight: 600;
    color: #333;
    margin-bottom: 8px;
    line-height: 1.3;
}

.item-subtitle {
    color: #666;
    font-size: 0.85rem;
    margin-bottom: 15px;
}

.item-details {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    margin-bottom: 10px;
}

.detail-item {
    display: flex;
    flex-direction: column;
}

.detail-label {
    font-size: 0.75rem;
    color: #999;
    text-transform: uppercase;
    font-weight: 600;
    margin-bottom: 2px;
}

.detail-value {
    font-size: 0.9rem;
    color: #333;
    font-weight: 500;
}

.qty-badge {
    background: #27ae60;
    color: white;
    padding: 4px 8px;
    border-radius: 12px;
    font-size: 0.8rem;
    font-weight: 600;
    text-align: center;
}

.condition-badge {
    padding: 4px 8px;
    border-radius: 12px;
    font-size: 0.8rem;
    font-weight: 600;
    text-align: center;
}

.condition-new {
    background: #d4edda;
    color: #155724;
}

.condition-good {
    background: #d1ecf1;
    color: #0c5460;
}

.condition-fair {
    background: #fff3cd;
    color: #856404;
}

.condition-poor {
    background: #f8d7da;
    color: #721c24;
}

.remarks {
    margin-top: 15px;
    padding-top: 15px;
    border-top: 1px solid #e1e5e9;
    font-size: 0.8rem;
    color: #666;
    font-style: italic;
}

/* Mobile Responsiveness */
@media (max-width: 768px) {
    .container {
        padding: 15px;
    }
    
    .header h1 {
        font-size: 2rem;
    }
    
    .search-section, .results-section {
        padding: 20px;
    }
    
    .search-filters {
        grid-template-columns: 1fr;
    }
    
    .results-header {
        flex-direction: column;
        gap: 15px;
        align-items: stretch;
    }
    
    .inventory-grid {
        grid-template-columns: 1fr; /* 1 card per row on mobile */
        gap: 12px;
    }
    
    .inventory-item {
        padding: 15px;
    }
    
    .item-details {
        grid-template-columns: 1fr;
        gap: 8px;
    }
}

@media (max-width: 480px) {
    .header h1 {
        font-size: 1.8rem;
    }
    
    .header p {
        font-size: 1rem;
    }
    
    #searchInput {
        padding: 12px 45px 12px 40px;
        font-size: 0.9rem;
    }
    
    .search-icon {
        left: 12px;
        font-size: 1rem;
    }
    
    .clear-btn {
        right: 12px;
    }
}

/* Animation for smooth transitions */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.inventory-item {
    animation: fadeIn 0.3s ease-out;
}

/* Scrollbar Styling */
::-webkit-scrollbar {
    width: 8px;
}

::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 4px;
}

::-webkit-scrollbar-thumb {
    background: #667eea;
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: #5a6fd8;
}

/* Floating action button */
.fab {
    position: fixed;
    right: 24px;
    bottom: 24px;
    background: #667eea;
    color: #fff;
    width: 56px;
    height: 56px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 8px 24px rgba(0,0,0,0.2);
    cursor: pointer;
    z-index: 1100;
}

/* Modal */
.modal {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.45);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 1200;
}

.modal.open { display: flex; }

.modal-content {
    background: #fff;
    width: min(720px, 92%);
    border-radius: 12px;
    padding: 20px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.2);
    max-height: 85vh;
    overflow: auto;
}

.modal-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

.modal-grid label { font-size: 0.85rem; color: #555; }
.modal-grid input, .modal-grid select, .modal-grid textarea {
    width: 100%;
    padding: 10px 12px;
    border: 2px solid #e1e5e9;
    border-radius: 8px;
}

.modal-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 12px; }
.btn { padding: 10px 14px; border-radius: 8px; border: none; cursor: pointer; }
.btn-primary { background: #667eea; color: #fff; }
.btn-secondary { background: #f0f2f5; color: #333; }
