/**
 * iHandi Portal - Inventory Module Styles
 * Based on ACTUAL PHP output from class-inventory-module.php
 * Version: 1.0.0
 */

/* ========================================
   INVENTORY MODULE MAIN CONTAINER
   ======================================== */

.inventory-module {
    padding: 0;
    background: #f5f5f5;
}

/* ========================================
   INVENTORY HEADER & STATS
   ======================================== */

.inventory-header {
    margin-bottom: 2rem;
}

.inventory-stats-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1.5rem;
}

.inventory-stat-card {
    background: #ffffff;
    padding: 1.5rem;
    border-radius: 10px;
    display: flex;
    align-items: center;
    gap: 1.5rem;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
    transition: all 0.3s ease;
    border-left: 4px solid;
}

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

.inventory-stat-card.stat-primary {
    border-left-color: #2196F3;
}

.inventory-stat-card.stat-warning {
    border-left-color: #FF9800;
}

.inventory-stat-card.stat-danger {
    border-left-color: #F44336;
}

.inventory-stat-card.stat-success {
    border-left-color: #4CAF50;
}

/* ========================================
   INVENTORY TOOLBAR
   ======================================== */

.inventory-toolbar {
    background: #ffffff;
    padding: 1.5rem;
    border-radius: 10px;
    margin-bottom: 2rem;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

.inventory-filters {
    margin-bottom: 1rem;
}

#inventory-filter-form {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
}

#inventory-filter-form input,
#inventory-filter-form select {
    padding: 0.7rem;
    border: 2px solid #e0e0e0;
    border-radius: 6px;
    font-size: 0.9rem;
    transition: all 0.3s ease;
}

#inventory-filter-form input:focus,
#inventory-filter-form select:focus {
    outline: none;
    border-color: #FFD700;
    box-shadow: 0 0 0 3px rgba(255, 215, 0, 0.1);
}

.inventory-actions {
    display: flex;
    gap: 0.8rem;
    flex-wrap: wrap;
    margin-top: 1rem;
}

/* ========================================
   INVENTORY TABLE
   ======================================== */

.inventory-table-wrapper {
    background: #ffffff;
    border-radius: 10px;
    overflow: hidden;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

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

.inventory-table thead {
    background: linear-gradient(135deg, #FFD700 0%, #FFA500 100%);
}

.inventory-table thead th {
    padding: 1rem;
    text-align: left;
    font-weight: 600;
    color: #1a1a1a;
    font-size: 0.9rem;
    white-space: nowrap;
}

.inventory-table thead th.location-column {
    text-align: center;
}

.inventory-table thead th.total-column {
    text-align: center;
    font-weight: 700;
}

.inventory-table tbody tr {
    border-bottom: 1px solid #f0f0f0;
    transition: background 0.2s ease;
}

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

/* Stock status row colors */
.inventory-row.out-of-stock {
    background: rgba(244, 67, 54, 0.05);
}

.inventory-row.low-stock {
    background: rgba(255, 152, 0, 0.05);
}

.inventory-table tbody td {
    padding: 1rem;
    vertical-align: middle;
}

/* ========================================
   PRODUCT CELL
   ======================================== */

.product-cell {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.product-thumbnail {
    width: 50px;
    height: 50px;
    border-radius: 6px;
    object-fit: cover;
    flex-shrink: 0;
}

.product-info {
    display: flex;
    flex-direction: column;
}

.product-name {
    font-weight: 600;
    color: #1a1a1a;
    font-size: 0.95rem;
    margin-bottom: 0.3rem;
}

.product-meta {
    display: flex;
    gap: 0.8rem;
    font-size: 0.8rem;
    color: #666;
}

.product-brand,
.product-condition {
    display: inline-block;
}

.product-sku {
    background: #f5f5f5;
    padding: 0.3rem 0.6rem;
    border-radius: 4px;
    font-family: 'Courier New', monospace;
    font-size: 0.85rem;
}

.product-price {
    color: #4CAF50;
    font-size: 1.1rem;
}

/* Initial Stock Inputs */
.stock-inputs-row {
    display: flex;
    gap: 15px;
    flex-wrap: wrap;
}
.stock-input-item {
    flex: 1;
    min-width: 100px;
}
.stock-input-item span {
    display: block;
    font-size: 12px;
    color: #666;
    margin-bottom: 5px;
}
.stock-input-item input {
    width: 100%;
    padding: 8px;
    border: 1px solid #ddd;
    border-radius: 6px;
    text-align: center;
}

/* ========================================
   STOCK INPUT CELLS
   ======================================== */

.location-stock-cell {
    text-align: center;
}

.stock-input-group {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
}

.stock-input {
    width: 70px;
    padding: 0.5rem;
    border: 2px solid #e0e0e0;
    border-radius: 6px;
    text-align: center;
    font-weight: 600;
    font-size: 0.95rem;
    transition: all 0.3s ease;
}

.stock-input:focus {
    outline: none;
    border-color: #FFD700;
    box-shadow: 0 0 0 3px rgba(255, 215, 0, 0.1);
}

.stock-input[data-original]:not([value]) {
    border-color: #FF9800;
}

.stock-save-btn {
    width: 32px;
    height: 32px;
    border-radius: 6px;
    border: none;
    background: #4CAF50;
    color: #ffffff;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
}

.stock-save-btn:hover {
    background: #45a049;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(76, 175, 80, 0.4);
}

.stock-display {
    font-weight: 600;
    font-size: 0.95rem;
    color: #1a1a1a;
}

/* ========================================
   TOTAL STOCK CELL
   ======================================== */

.total-stock-cell {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.6rem;
}

.total-stock-value {
    font-size: 1.1rem;
    color: #1a1a1a;
}

.stock-badge {
    padding: 0.25rem 0.6rem;
    border-radius: 12px;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

.stock-badge.badge-success {
    background: rgba(76, 175, 80, 0.1);
    color: #4CAF50;
    border: 1px solid #4CAF50;
}

.stock-badge.badge-warning {
    background: rgba(255, 152, 0, 0.1);
    color: #FF9800;
    border: 1px solid #FF9800;
}

.stock-badge.badge-danger {
    background: rgba(244, 67, 54, 0.1);
    color: #F44336;
    border: 1px solid #F44336;
}

/* ========================================
   LAST UPDATED
   ======================================== */

.last-updated {
    display: flex;
    flex-direction: column;
    font-size: 0.85rem;
    color: #666;
}

.last-updated small {
    font-size: 0.75rem;
    color: #999;
}

.text-muted {
    color: #999;
    font-size: 0.85rem;
}

/* ========================================
   INVENTORY ACTIONS CELL
   ======================================== */

.inventory-actions-cell {
    display: flex;
    gap: 0.5rem;
    justify-content: center;
}

.action-btn {
    width: 36px;
    height: 36px;
    border-radius: 6px;
    border: none;
    background: #f5f5f5;
    color: #666;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.3s ease;
    font-size: 0.9rem;
    text-decoration: none;
}

.action-btn:hover {
    background: #FFD700;
    color: #1a1a1a;
    transform: translateY(-2px);
}

/* ========================================
   EMPTY STATE
   ======================================== */

.inventory-empty {
    text-align: center;
    padding: 4rem 2rem;
    color: #999;
}

.inventory-empty i {
    font-size: 4rem;
    color: #ddd;
    margin-bottom: 1rem;
}

.inventory-empty h3 {
    font-size: 1.5rem;
    color: #666;
    margin: 1rem 0 0.5rem 0;
}

.inventory-empty p {
    font-size: 1rem;
    margin: 0 0 1.5rem 0;
}

/* ========================================
   PORTAL MODAL (Transfer Stock)
   ======================================== */

.portal-modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.6);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 10000;
    padding: 20px;
}

.portal-modal.active {
    display: flex;
}

.portal-modal-content {
    background: #ffffff;
    border-radius: 12px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
    max-width: 600px;
    width: 100%;
    max-height: 90vh;
    overflow-y: auto;
}

.portal-modal-header {
    padding: 1.5rem;
    border-bottom: 1px solid #f0f0f0;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.portal-modal-header h3 {
    margin: 0;
    color: #1a1a1a;
    display: flex;
    align-items: center;
    gap: 0.6rem;
}

.portal-modal-header h3 i {
    color: #FFD700;
}

.portal-modal-close {
    width: 32px;
    height: 32px;
    border-radius: 6px;
    border: none;
    background: #f5f5f5;
    color: #666;
    font-size: 1.5rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    line-height: 1;
}

.portal-modal-close:hover {
    background: #F44336;
    color: #ffffff;
}

.portal-modal-body {
    padding: 1.5rem;
}

.portal-modal-footer {
    padding: 1.5rem;
    border-top: 1px solid #f0f0f0;
    display: flex;
    justify-content: flex-end;
    gap: 0.8rem;
}

/* Form inside modal */
.portal-modal-body form {
    display: flex;
    flex-direction: column;
    gap: 1.2rem;
}

.portal-modal-body label {
    display: block;
    font-weight: 600;
    color: #1a1a1a;
    margin-bottom: 0.5rem;
    font-size: 0.9rem;
}

.portal-modal-body input,
.portal-modal-body select {
    width: 100%;
    padding: 0.7rem;
    border: 2px solid #e0e0e0;
    border-radius: 6px;
    font-size: 0.9rem;
    transition: all 0.3s ease;
}

.portal-modal-body input:focus,
.portal-modal-body select:focus {
    outline: none;
    border-color: #FFD700;
    box-shadow: 0 0 0 3px rgba(255, 215, 0, 0.1);
}

/* ========================================
   PORTAL BUTTONS (used throughout)
   ======================================== */

.portal-btn {
    padding: 0.7rem 1.5rem;
    border: none;
    border-radius: 6px;
    font-weight: 600;
    font-size: 0.9rem;
    cursor: pointer;
    transition: all 0.3s ease;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    text-decoration: none;
}

.portal-btn-primary {
    background: linear-gradient(135deg, #FFD700 0%, #FFA500 100%);
    color: #1a1a1a;
}

.portal-btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(255, 215, 0, 0.4);
}

.portal-btn-success {
    background: #4CAF50;
    color: #ffffff;
}

.portal-btn-success:hover {
    background: #45a049;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(76, 175, 80, 0.4);
}

.portal-btn-info {
    background: #2196F3;
    color: #ffffff;
}

.portal-btn-info:hover {
    background: #1976D2;
}

.portal-btn-secondary {
    background: #f5f5f5;
    color: #666;
}

.portal-btn-secondary:hover {
    background: #e0e0e0;
    color: #333;
}

/* ========================================
   RESPONSIVE DESIGN
   ======================================== */

@media (max-width: 1200px) {
    .inventory-stats-row {
        grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    }
    
    #inventory-filter-form {
        grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    }
}

@media (max-width: 968px) {
    /* Make table scrollable on tablets */
    .inventory-table-wrapper {
        overflow-x: auto;
    }
    
    .inventory-table {
        min-width: 1100px;
    }
}

@media (max-width: 768px) {
    .inventory-stats-row {
        grid-template-columns: 1fr 1fr;
    }
    
    #inventory-filter-form {
        grid-template-columns: 1fr;
    }
    
    .inventory-actions {
        flex-direction: column;
    }
    
    .inventory-actions .portal-btn {
        width: 100%;
        justify-content: center;
    }
    
    .product-cell {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.5rem;
    }
}

@media (max-width: 480px) {
    .inventory-stats-row {
        grid-template-columns: 1fr;
    }
    
    .stat-value {
        font-size: 1.5rem;
    }
    
    .portal-modal-content {
        max-width: 100%;
        border-radius: 0;
    }
}