/**
 * Planogram Builder Styles
 * File: assets/planogram.css
 */

/* Main Container */
.smputra-planogram-wrapper {
    max-width: 1400px;
    margin: 20px auto;
    padding: 20px;
    background: #fff;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

/* Header */
.planogram-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    padding-bottom: 20px;
    border-bottom: 2px solid #e5e5e5;
}

.header-left, .header-right {
    display: flex;
    align-items: center;
    gap: 10px;
}

.header-left h2 {
    margin: 0 20px 0 0;
    font-size: 24px;
    color: #333;
}

.project-select {
    min-width: 250px;
    padding: 8px 12px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 14px;
}

.save-status {
    padding: 6px 12px;
    border-radius: 4px;
    font-size: 13px;
    font-weight: 500;
}

.save-status.saving {
    background: #fff3cd;
    color: #856404;
}

.save-status.saved {
    background: #d4edda;
    color: #155724;
}

.save-status.error {
    background: #f8d7da;
    color: #721c24;
}

/* Buttons */
.btn {
    padding: 8px 16px;
    border: none;
    border-radius: 4px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s ease;
    display: inline-flex;
    align-items: center;
    gap: 5px;
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.btn-primary {
    background: #0073aa;
    color: #fff;
}

.btn-primary:hover:not(:disabled) {
    background: #005177;
}

.btn-secondary {
    background: #6c757d;
    color: #fff;
}

.btn-secondary:hover:not(:disabled) {
    background: #545b62;
}

.btn-success {
    background: #28a745;
    color: #fff;
}

.btn-success:hover:not(:disabled) {
    background: #218838;
}

.btn-info {
    background: #17a2b8;
    color: #fff;
}

.btn-info:hover:not(:disabled) {
    background: #138496;
}

.btn-sm {
    padding: 6px 12px;
    font-size: 13px;
}

.btn-icon {
    padding: 6px;
    background: transparent;
    border: none;
    cursor: pointer;
    color: #666;
    transition: color 0.3s ease;
}

.btn-icon:hover {
    color: #0073aa;
}

.btn-icon .dashicons {
    font-size: 18px;
    width: 18px;
    height: 18px;
}

/* View Mode Toggle */
.view-mode-toggle {
    display: flex;
    gap: 5px;
    margin-bottom: 20px;
    border-bottom: 1px solid #e5e5e5;
    padding-bottom: 10px;
}

.btn-mode {
    padding: 10px 20px;
    border: none;
    background: #f5f5f5;
    color: #666;
    cursor: pointer;
    border-radius: 4px 4px 0 0;
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
    transition: all 0.3s ease;
}

.btn-mode:hover {
    background: #e5e5e5;
}

.btn-mode.active {
    background: #0073aa;
    color: #fff;
}

/* Empty State */
.empty-state {
    text-align: center;
    padding: 80px 20px;
    color: #666;
}

.empty-icon {
    font-size: 80px;
    margin-bottom: 20px;
}

.empty-state h3 {
    font-size: 24px;
    margin-bottom: 10px;
    color: #333;
}

.empty-state p {
    font-size: 16px;
    color: #999;
}

/* Areas Container */
.areas-container {
    margin-top: 20px;
}

.areas-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.areas-header h3 {
    margin: 0;
    font-size: 20px;
    color: #333;
}

.areas-list {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

/* Area Card */
.area-card {
    border: 2px solid #e5e5e5;
    border-radius: 8px;
    overflow: hidden;
    transition: all 0.3s ease;
}

.area-card:hover {
    border-color: #0073aa;
    box-shadow: 0 4px 12px rgba(0,115,170,0.1);
}

.area-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px 20px;
    background: #f8f9fa;
    border-bottom: 1px solid #e5e5e5;
}

.area-title {
    display: flex;
    align-items: center;
    gap: 12px;
}

.area-code {
    background: #0073aa;
    color: #fff;
    padding: 4px 12px;
    border-radius: 4px;
    font-weight: 600;
    font-size: 13px;
}

.area-name {
    margin: 0;
    font-size: 18px;
    color: #333;
}

.area-actions {
    display: flex;
    gap: 5px;
}

.area-body {
    padding: 20px;
}

.area-body.collapsed {
    display: none;
}

/* Racks Grid */
.racks-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 15px;
}

/* Rack Card */
.rack-card {
    border: 1px solid #ddd;
    border-radius: 6px;
    padding: 15px;
    background: #fff;
    transition: all 0.3s ease;
}

.rack-card:hover {
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
    transform: translateY(-2px);
}

.rack-header {
    margin-bottom: 10px;
}

.rack-number {
    display: inline-block;
    background: #17a2b8;
    color: #fff;
    padding: 4px 10px;
    border-radius: 4px;
    font-weight: 600;
    font-size: 12px;
    margin-bottom: 8px;
}

.rack-name {
    font-size: 16px;
    font-weight: 600;
    color: #333;
    margin-bottom: 8px;
}

.rack-info {
    display: flex;
    gap: 15px;
    margin-bottom: 12px;
    font-size: 13px;
    color: #666;
}

.rack-info span::before {
    content: '📊 ';
}

.rack-actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

/* Modal */
.smputra-modal {
    display: none;
    position: fixed;
    z-index: 9999;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.6);
    animation: fadeIn 0.3s ease;
}

.smputra-modal.active {
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-content {
    background: #fff;
    border-radius: 8px;
    width: 90%;
    max-width: 500px;
    max-height: 90vh;
    overflow: visible; /* Changed from auto to visible */
    animation: slideIn 0.3s ease;
    position: relative;
    z-index: 10000;
}

.modal-large .modal-content {
    max-width: 900px;
}

.modal-xl .modal-content {
    max-width: 1200px;
}

.modal-body {
    padding: 20px;
    max-height: calc(90vh - 150px);
    overflow-y: auto;
    overflow-x: hidden;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px;
    border-bottom: 1px solid #e5e5e5;
}

.modal-header h3 {
    margin: 0;
    font-size: 20px;
    color: #333;
}

.modal-close {
    font-size: 28px;
    font-weight: 300;
    color: #999;
    cursor: pointer;
    line-height: 1;
}

.modal-close:hover {
    color: #333;
}

.modal-body {
    padding: 20px;
}

.modal-body label {
    display: block;
    margin-bottom: 5px;
    font-weight: 600;
    color: #333;
    font-size: 14px;
}

.modal-body input[type="text"],
.modal-body input[type="number"],
.modal-body select,
.modal-body textarea {
    margin-bottom: 15px;
}

.input-full {
    width: 100%;
    padding: 10px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 14px;
}

.input-group {
    display: flex;
    gap: 15px;
}

.input-half {
    flex: 1;
}

.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    padding: 15px 20px;
    border-top: 1px solid #e5e5e5;
    background: #f8f9fa;
}

/* Products Table */
.products-table-container {
    margin-top: 15px;
    overflow-x: auto;
}

.products-table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 10px;
}

.products-table th {
    background: #f8f9fa;
    padding: 12px;
    text-align: left;
    font-weight: 600;
    border-bottom: 2px solid #dee2e6;
    font-size: 13px;
}

.products-table td {
    padding: 10px 12px;
    border-bottom: 1px solid #dee2e6;
}

.products-table input[type="number"] {
    width: 70px;
    padding: 6px;
    border: 1px solid #ddd;
    border-radius: 4px;
}

.products-table .product-select {
    width: 100%;
}

/* Visual Layout Grid */
.visual-toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    padding: 15px;
    background: #f8f9fa;
    border-radius: 6px;
}

.product-selector-inline {
    display: flex;
    align-items: center;
    gap: 10px;
}

.product-selector-inline label {
    font-weight: 600;
    margin: 0;
}

.visual-info {
    font-size: 13px;
    color: #666;
    font-style: italic;
}

.visual-grid-container {
    background: #fff;
    border: 2px solid #ddd;
    border-radius: 6px;
    padding: 20px;
    overflow: auto;
}

.visual-grid {
    display: table;
    border-collapse: collapse;
    margin: 0 auto;
}

.visual-row {
    display: table-row;
}

.visual-row-label {
    display: table-cell;
    padding: 8px 12px;
    font-weight: 600;
    text-align: center;
    background: #f8f9fa;
    border: 1px solid #dee2e6;
    min-width: 60px;
}

.visual-cell {
    display: table-cell;
    width: 80px;
    height: 80px;
    border: 1px solid #dee2e6;
    cursor: pointer;
    position: relative;
    transition: all 0.2s ease;
    background: #fff;
}

.visual-cell:hover {
    background: #e7f3ff;
    border-color: #0073aa;
}

.visual-cell.filled {
    background: #d4edda;
    border-color: #28a745;
}

.visual-cell.selected {
    background: #fff3cd;
    border-color: #ffc107;
}

.visual-cell-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 5px;
    height: 100%;
}

.visual-cell-image {
    width: 40px;
    height: 40px;
    object-fit: cover;
    border-radius: 4px;
    margin-bottom: 3px;
}

.visual-cell-name {
    font-size: 10px;
    text-align: center;
    line-height: 1.2;
    overflow: hidden;
    text-overflow: ellipsis;
    max-height: 24px;
    color: #333;
}

.visual-cell-qty {
    position: absolute;
    top: 2px;
    right: 2px;
    background: #0073aa;
    color: #fff;
    padding: 2px 6px;
    border-radius: 10px;
    font-size: 10px;
    font-weight: 600;
}

.visual-legend {
    display: flex;
    gap: 20px;
    margin-top: 20px;
    padding: 15px;
    background: #f8f9fa;
    border-radius: 6px;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
}

.legend-color {
    width: 24px;
    height: 24px;
    border: 1px solid #dee2e6;
    border-radius: 4px;
}

.legend-color.empty {
    background: #fff;
}

.legend-color.filled {
    background: #d4edda;
}

.legend-color.selected {
    background: #fff3cd;
}

/* Animations */
@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes slideIn {
    from {
        transform: translateY(-50px);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

/* Responsive */
@media (max-width: 768px) {
    .planogram-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 15px;
    }
    
    .header-left, .header-right {
        width: 100%;
        flex-wrap: wrap;
    }
    
    .racks-grid {
        grid-template-columns: 1fr;
    }
    
    .modal-content {
        width: 95%;
        margin: 10px;
    }
    
    .visual-cell {
        width: 60px;
        height: 60px;
    }
}

/* ========================================
   SELECT2 DROPDOWN Z-INDEX FIX
   ======================================== */

/* Force Select2 dropdown to appear above modal */
.select2-container {
    z-index: 99999 !important;
}

.select2-container--default .select2-results__option--highlighted[aria-selected] {
    background-color: #0073aa !important;
}

.select2-dropdown {
    z-index: 999999 !important;
    border: 1px solid #ddd;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
}

.select2-container--open .select2-dropdown--below {
    z-index: 999999 !important;
}

.select2-container--open .select2-dropdown--above {
    z-index: 999999 !important;
}

/* Make sure Select2 search field is styled properly */
.select2-search--dropdown .select2-search__field {
    padding: 8px;
    border: 1px solid #ddd;
    border-radius: 4px;
}

/* Select2 in modal specific styling */
.smputra-modal .select2-container {
    z-index: 999998 !important;
}

.smputra-modal .select2-dropdown {
    z-index: 999999 !important;
}

/* Override any conflicting z-index */
span.select2-container.select2-container--default {
    z-index: 999998 !important;
}

span.select2-container.select2-container--default.select2-container--open {
    z-index: 999999 !important;
}

.select2-results {
    z-index: 999999 !important;
}

.select2-container--open {
    z-index: 999999 !important;
}