/* ==================================================
   PRODUCT INVENTORY MODAL – Clean, aligned layout
   ================================================== */

/* --- Modal size and content --- */
#productModal.modal .modal-dialog {
    max-width: 92%;
    width: 640px;
}

#productModal .modal-content {
    height: 660px;
    border-radius: 12px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.18);
    padding: 0;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

/* Header - classic gray, matches Customer Information */
#productModal .modal-header {
    flex-shrink: 0;
    background: #e5e7eb !important;
    color: #374151 !important;
    padding: 10px 16px !important;
    border-bottom: 1px solid #d1d5db !important;
    box-shadow: none !important;
    border-radius: 12px 12px 0 0 !important;
}

#productModal .modal-header .header-content {
    display: flex;
    align-items: center;
    gap: 12px;
}

#productModal .modal-header .header-icon {
    font-size: 20px !important;
    opacity: 0.9;
    color: #4b5563;
}

#productModal .modal-header .header-text {
    flex: 1;
}

#productModal .modal-header .title-main {
    display: block;
    font-size: 16px !important;
    font-weight: 600 !important;
    margin-bottom: 2px !important;
    color: #1f2937;
}

#productModal .modal-header .title-subtitle {
    display: block;
    font-size: 12px !important;
    font-weight: 500 !important;
    color: #6b7280 !important;
}

#productModal .modal-header .close {
    color: #6b7280 !important;
    opacity: 0.9;
    font-size: 20px;
    padding: 4px;
    margin: -4px -4px 0 0;
    background: #d1d5db;
    border: 1px solid #9ca3af;
    border-radius: 8px;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
}

#productModal .modal-header .close:hover {
    opacity: 1;
    background: #e5e7eb;
    color: #374151 !important;
}

#productModal .modal-body {
    flex: 1;
    min-height: 0;
    overflow: hidden;
    padding: 4px 10px 6px 10px;
    display: grid;
    grid-template-columns: 170px 1fr;
    grid-template-rows: auto auto 1fr;
    gap: 3px 10px;
}

/* Top row: image (col 1) + product details (col 2) – compact, room for nav at bottom */
#productModal .product-inventory-preview {
    grid-column: 1 / -1;
    display: grid;
    grid-template-columns: 170px 1fr;
    gap: 10px;
    align-items: start;
    padding: 0 0 4px 0;
    border-bottom: 1px solid #e8e8e8;
    flex-shrink: 0;
}

/* Product image – equal width and height (square), maximize within space */
#productModal .custom-box {
    display: flex;
    align-items: center;
    justify-content: center;
    background: #fff;
    border: 2px solid #ccc;
    padding: 6px;
    width: 170px;
    min-width: 170px;
    height: 170px;
    min-height: 170px;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.12);
    transition: box-shadow 0.2s, transform 0.2s;
}

#productModal .custom-box:hover {
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.15);
    transform: scale(1.02);
}

#productModal .custom-box img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    border-radius: 6px;
}

/* Product details - same width as files panel (flex: 1), aligned with right pane */
#productModal .product-info {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-width: 0;
    margin: 0;
    gap: 8px;
}

/* Product detail rows - compact gray boxes, more space between */
#productModal .product-detail {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 0;
    padding: 4px 8px;
    min-height: 24px;
    background-color: #EFEFEF;
    color: #111;
    border-radius: 4px;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
    font-family: 'Arial', sans-serif;
    font-size: 11px;
    font-weight: bold;
}

/* Quantity row + Add Product button: button aligned right within container */
#productModal .product-detail.quantity-add-row {
    justify-content: flex-start;
    gap: 8px;
}
#productModal .product-detail.quantity-add-row .btn-add-product {
    margin-left: auto;
    flex-shrink: 0;
}

#productModal .product-detail .label {
    margin-right: 6px;
    font-weight: bold;
    white-space: nowrap;
    font-size: 10px;
    color: #333;
}

#productModal .product-detail input {
    flex-grow: 1;
    border: none;
    outline: none;
    background-color: #EFEFEF;
    text-align: left;
    padding: 2px 4px;
    font-size: 11px;
    color: #333;
    min-width: 0;
}

#productModal .product-detail input[type="number"]:not([readonly]) {
    border-radius: 6px;
    background-color: #fff;
    padding: 2px 4px;
    max-width: 60px;
}

/* Price and Quantity rows – input boxes aligned left (same start position) */
#productModal .product-info .product-detail:nth-child(3),
#productModal .product-info .product-detail:nth-child(4) {
    justify-content: flex-start;
}

/* Fixed label width so both price and quantity input boxes align to same left edge */
#productModal .product-info .product-detail:nth-child(3) .label,
#productModal .product-info .product-detail:nth-child(4) .label {
    min-width: 100px;
    flex-shrink: 0;
}

#productModal .product-info .product-detail:nth-child(3) input,
#productModal .product-info .product-detail:nth-child(4) input {
    flex-grow: 0;
    width: 70px;
    min-width: 70px;
    margin-left: 0;
}

/* Add Product button - compact, right-aligned within quantity row */
#productModal .btn-add-product {
    padding: 5px 12px;
    background: linear-gradient(135deg, #4caf50 0%, #43a047 100%);
    color: #fff;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    font-size: 11px;
    font-weight: 600;
    box-shadow: 0 2px 4px rgba(76, 175, 80, 0.25);
    transition: all 0.2s;
}

#productModal .btn-add-product:hover {
    background: linear-gradient(135deg, #43a047 0%, #388e3c 100%);
    box-shadow: 0 3px 8px rgba(76, 175, 80, 0.35);
}

/* ========================================
   BREADCRUMB – compact so file explorer starts higher
   ======================================== */
#productModal #breadcrumb-container {
    grid-column: 1 / -1;
    min-height: 12px;
    line-height: 12px;
    font-size: 9px;
    color: #888;
    margin: 0;
    padding: 0;
}

/* File explorer – spans full width, room for navigation at bottom */
#productModal #fileExplorerContainer {
    grid-column: 1 / -1;
    display: flex;
    gap: 10px;
    flex: 1;
    min-height: 0;
}

/* Pane base styles */
#productModal .file-explorer-container {
    border: 1px solid #ddd;
    border-radius: 6px;
    background: #fff;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

/* Left pane (Brands) */
#productModal #productInventoryFileExplorer {
    width: 170px;
    flex-shrink: 0;
}

/* Right pane (Products) */
#productModal #itemExplorer {
    flex: 1;
    min-width: 240px;
}

/* Pane header */
#productModal .pane-header {
    padding: 6px 8px;
    border-bottom: 1px solid #eee;
    background: #fafafa;
    display: flex;
    align-items: center;
    gap: 6px;
    flex-shrink: 0;
}

#productModal .pane-header .search-input {
    flex: 1;
    padding: 5px 8px;
    font-size: 11px;
    border: 1px solid #ddd;
    border-radius: 4px;
    background: #fff;
}

#productModal .pane-header .search-input:focus {
    border-color: #aaa;
    outline: none;
}

#productModal .pane-header .sort-dropdown {
    padding: 4px 6px;
    font-size: 9px;
    border: 1px solid #ddd;
    border-radius: 4px;
    background: #fff;
    flex-shrink: 0;
    max-width: 95px;
    min-height: 26px;
}

/* Refresh button in products pane header – small, next to sort */
#productModal .pane-header .btn-refresh-pane {
    flex-shrink: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 26px;
    padding: 0;
    border: 1px solid #ddd;
    border-radius: 4px;
    background: #fff;
    color: #1976d2;
    cursor: pointer;
    transition: background 0.2s, color 0.2s;
}

#productModal .pane-header .btn-refresh-pane:hover {
    background: #e3f2fd;
    border-color: #90caf9;
    color: #1565c0;
}

#productModal .pane-header .btn-refresh-pane svg {
    display: block;
    width: 14px;
    height: 14px;
}

/* Pane content */
#productModal .pane-content {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    padding: 6px;
}

#productModal .loadingIndicator {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    color: #999;
    font-size: 11px;
}

/* ========================================
   FOLDERS - Full width, easy access
   ======================================== */
#productModal .folders {
    display: flex;
    flex-direction: column;
    gap: 3px;
}

#productModal .product-inventory-folder,
#productModal .folder-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 9px 12px;
    background: #f8f9fa;
    border: 1px solid #e9ecef;
    border-radius: 5px;
    cursor: pointer;
    font-size: 12px;
    font-weight: 500;
    color: #444;
    transition: all 0.15s;
    width: 100%;
    box-sizing: border-box;
}

#productModal .product-inventory-folder:hover,
#productModal .folder-item:hover {
    background: #e9ecef;
    border-color: #dee2e6;
    color: #222;
}

#productModal .folder-back {
    font-weight: 700;
    background: #e3f2fd;
    border-color: #bbdefb;
    color: #1976d2;
}

#productModal .folder-back:hover {
    background: #bbdefb;
    border-color: #90caf9;
}

/* ========================================
   ITEM CARDS (Products list)
   ======================================== */
#productModal .files {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

#productModal .product-inventory-item-card,
#productModal .item-explorer-card {
    display: flex;
    align-items: center;
    position: relative;
    background: linear-gradient(135deg, #fffbf0 0%, #f5f0e6 100%);
    border: 1px solid #e8e0d0;
    border-radius: 6px;
    padding: 8px;
    cursor: pointer;
    transition: all 0.15s;
}

#productModal .product-inventory-item-card:hover,
#productModal .item-explorer-card:hover {
    border-color: #d4c8b8;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
    transform: translateY(-1px);
}

#productModal .item-card-image {
    width: 50px;
    height: 42px;
    object-fit: cover;
    border-radius: 4px;
    margin-right: 10px;
    flex-shrink: 0;
    border: 1px solid #e0d8c8;
}

#productModal .item-card-price {
    position: absolute;
    top: 6px;
    right: 6px;
    padding: 2px 8px;
    background: linear-gradient(135deg, #ffc107 0%, #ffb300 100%);
    color: #333;
    border-radius: 10px;
    font-size: 10px;
    font-weight: 700;
}

#productModal .item-card-details {
    flex: 1;
    min-width: 0;
}

#productModal .item-card-name {
    font-weight: 600;
    font-size: 11px;
    color: #333;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-bottom: 2px;
}

#productModal .item-card-model {
    font-size: 10px;
    color: #666;
}

#productModal .item-card-qty {
    font-size: 10px;
    color: #888;
}

#productModal .item-card-description {
    font-size: 10px;
    color: #6b7280;
    margin-top: 4px;
    line-height: 1.3;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* ========================================
   MODAL FOOTER - matches Customer Information
   ======================================== */
#productModal .modal-footer {
    flex-shrink: 0;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 20px;
    border-top: 1px solid #e0e4e8;
    background: #f1f5f9;
    border-radius: 0 0 12px 12px;
}

#productModal .modal-footer .keep-open-option {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    color: #64748b;
}

#productModal .modal-footer .keep-open-option input[type="checkbox"] {
    width: 14px;
    height: 14px;
    cursor: pointer;
    accent-color: #6b7280;
}

#productModal .modal-footer .keep-open-option label {
    margin: 0;
    cursor: pointer;
    user-select: none;
}

#productModal .modal-footer .footer-buttons {
    display: flex;
    align-items: center;
    gap: 10px;
}

#productModal .modal-footer .btn {
    margin: 0;
    padding: 8px 18px !important;
    font-size: 0.875rem !important;
    font-weight: 600;
    border-radius: 6px;
}

#productModal .modal-footer .btn-secondary {
    background: #64748b !important;
    border: none;
    color: #fff !important;
}

#productModal .modal-footer .btn-secondary:hover {
    background: #475569 !important;
    color: #fff !important;
}

/* Manual Entry button - classic dark gray */
#productModal .modal-footer #manualEntryFromInventoryBtn {
    background: #4b5563 !important;
    border: none;
    color: #fff !important;
    font-weight: 600;
}

#productModal .modal-footer #manualEntryFromInventoryBtn:hover {
    background: #374151 !important;
    color: #fff !important;
}

