/* Furniture Full Model Styles */
.furniture-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(255, 255, 255, 0.98);
    z-index: 10000;
    display: flex;
    justify-content: center;
    align-items: center;
    backdrop-filter: blur(5px);
    animation: fadeIn 0.2s ease-out;
    cursor: default;
    /* Ensure arrow cursor */
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

.modal-content {
    width: 95%;
    height: 95%;
    max-width: 1600px;
    display: flex;
    flex-direction: column;
    position: relative;
    background: transparent;
}

/* Top Right Controls Container */
.modal-controls-top-right {
    position: absolute;
    top: 10px;
    right: 10px;
    display: flex;
    align-items: center;
    justify-content: flex-end;
    /* Align right */
    gap: 8px;
    /* Space between Back and Close */
    z-index: 50;
    pointer-events: auto;
    /* Ensure clicks work */
}

/* Close Button (Now relative to container) */
.btn-close-modal {
    position: relative;
    /* Reset from absolute */
    top: auto;
    right: auto;
    background: white;
    border: 1px solid #ddd;
    border-radius: 50%;
    cursor: pointer;
    color: #555;
    padding: 0;
    /* Centering with flex */
    width: 32px;
    /* Smaller size */
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
    transition: all 0.2s;
}

.btn-close-modal .material-icons {
    font-size: 20px;
    /* Smaller icon */
}

.btn-close-modal:hover {
    background: #f5f5f5;
    color: #d32f2f;
    transform: none;
    /* Remove rotation */
}

/* Back Button (Icon Only, next to close) */
.btn-modal-back {
    position: relative;
    /* Reset from absolute */
    top: auto;
    left: auto;
    background: white;
    border: 1px solid #ddd;
    border-radius: 50%;
    /* Circle */
    padding: 0;
    width: 32px;
    /* Smaller size */
    height: 32px;
    display: flex;
    align-items: center;
    gap: 0;
    /* Icon only */
    justify-content: center;
    font-size: 14px;
    font-weight: 600;
    color: #555;
    cursor: pointer;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
    transition: all 0.2s;
}

.btn-modal-back .material-icons {
    font-size: 20px;
}

.btn-modal-back:hover {
    background: #f5f5f5;
    color: #333;
    transform: translateX(-2px);
}

/* Add Button on Grid Card - Absolute Bottom Right */
.modal-grid-add-btn {
    position: absolute;
    /* Move to corner */
    bottom: 10px;
    right: 10px;
    background: #4CAF50;
    color: white;
    border: none;
    border-radius: 50%;
    /* Circle */
    width: 28px;
    /* Smaller */
    height: 28px;
    padding: 0;
    font-size: 0;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0;
    /* Reset margin */
    transition: background 0.2s, transform 0.2s;
    z-index: 5;
}

.modal-grid-add-btn:hover {
    background: #43A047;
    transform: scale(1.1);
}

.modal-grid-add-btn .material-icons {
    font-size: 18px;
}

/* Hierarchy Title (Top Left) */
.modal-hierarchy-title {
    position: absolute;
    top: 10px;
    left: 10px;
    font-size: 14px;
    color: #888;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    z-index: 15;
    background: rgba(255, 255, 255, 0.7);
    padding: 4px 8px;
    border-radius: 4px;
    pointer-events: none;
    transition: left 0.3s ease;
}

/* Main Preview Area */
.modal-preview-area {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    min-height: 0;
    margin-bottom: 0;
    border-radius: 8px;
    overflow: hidden;
}

.modal-image-wrapper {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 40px;
}

.modal-image-wrapper img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    filter: drop-shadow(0 15px 30px rgba(0, 0, 0, 0.1));
}

.modal-preview-icon {
    font-size: 150px;
    color: #eee;
}

/* Navigation Buttons */
.modal-nav-btn {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    background: rgba(255, 255, 255, 0.5);
    border: none;
    width: 60px;
    height: 100px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s;
    color: #888;
    z-index: 10;
}

.modal-nav-btn:hover {
    background: rgba(255, 255, 255, 0.9);
    color: #000;
}

.modal-nav-btn.prev {
    left: 0;
    border-top-right-radius: 8px;
    border-bottom-right-radius: 8px;
}

.modal-nav-btn.next {
    right: 0;
    border-top-left-radius: 8px;
    border-bottom-left-radius: 8px;
}

.modal-nav-btn .material-icons {
    font-size: 48px;
}


/* Floating Caption (Bottom Left) */
.modal-floating-caption {
    position: absolute;
    bottom: 20px;
    left: 20px;
    background: rgba(255, 255, 255, 0.9);
    padding: 10px 15px;
    border-radius: 8px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
    z-index: 15;
    max-width: 40%;
    pointer-events: none;
}

#modalItemTitle {
    font-size: 16px;
    color: #333;
    font-weight: 600;
    margin-bottom: 2px;
}

#modalItemCode {
    font-size: 11px;
    color: #777;
    font-family: monospace;
}

/* Floating Add Button (Bottom Right - Above Slider) */
.btn-modal-add {
    position: absolute;
    bottom: 20px;
    /* Just above the slider (relative to preview area) */
    right: 30px;
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: #4CAF50;
    color: #fff;
    border: none;
    box-shadow: 0 4px 20px rgba(76, 175, 80, 0.4);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background-color 0.2s;
    /* No transform scale */
    z-index: 20;
}

.btn-modal-add .material-icons {
    font-size: 32px;
}

/* No hover scale/rotate, just background darken */
.btn-modal-add:hover {
    background: #43A047;
    /* No transform */
}

/* Slider Area */
.modal-slider-container {
    height: 120px;
    background: transparent;
    border-top: 1px solid #ddd;
    /* Separator Line */
    padding: 10px 0;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10;
}

.modal-slider {
    display: flex;
    gap: 15px;
    overflow-x: auto;
    width: 100%;
    height: 100%;
    padding: 0 40px;
    align-items: center;
    justify-content: center;
    scrollbar-width: none;
}

.modal-slider::-webkit-scrollbar {
    display: none;
}

.modal-slider-item {
    width: 80px;
    min-width: 80px;
    height: 80px;
    border-radius: 12px;
    border: 2px solid transparent;
    cursor: pointer;
    background: #fff;
    transition: all 0.2s;
    opacity: 0.7;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-slider-item:hover {
    opacity: 1;
    transform: translateY(-5px);
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.1);
}

.modal-slider-item.active {
    opacity: 1;
    border-color: #4CAF50;
    transform: scale(1.1);
    box-shadow: 0 5px 20px rgba(76, 175, 80, 0.2);
}

.modal-slider-item img {
    width: 80%;
    height: 80%;
    object-fit: contain;
}

/* --- NEW GRID View Styles --- */

/* Grid Container */
.modal-grid-container {
    flex: 1;
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    /* 4 Columns */
    grid-auto-rows: 250px;
    /* Fixed row height */
    gap: 20px;
    padding: 30px;
    overflow-y: auto;
    /* Scrollable */
    width: 100%;
}

/* Scrollbar styling */
.modal-grid-container::-webkit-scrollbar {
    width: 8px;
}

.modal-grid-container::-webkit-scrollbar-track {
    background: transparent;
}

.modal-grid-container::-webkit-scrollbar-thumb {
    background-color: #ccc;
    border-radius: 4px;
}

/* Grid Item Card */
.modal-grid-item {
    background: #fff;
    border-radius: 12px;
    box-shadow: 0 0 15px rgba(0, 0, 0, 0.4);
    display: flex;
    flex-direction: column;
    padding: 0;
    /* Remove padding to maximize image area */
    transition: transform 0.2s, box-shadow 0.2s;
    cursor: pointer;
    position: relative;
    border: 1px solid #eee;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    /* rounded corners for image */
}

.modal-grid-item:hover {
    transform: translateY(-5px);
    box-shadow: 0 0 25px rgba(0, 0, 0, 0.5);
    border-color: #4CAF50;
}

.modal-grid-item-img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    /* Stretch image to fill */
    padding: 0;
}

.modal-grid-item-icon {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 80px;
    color: #eee;
}

/* Floating Label (Bottom Left) */
.modal-grid-item-label {
    position: absolute;
    bottom: 10px;
    left: 10px;
    font-size: 11px;
    /* Small font */
    font-weight: normal;
    /* Not bold */
    color: #333;
    text-align: left;
    background: transparent;
    padding: 2px 4px;
    border-radius: 4px;
    box-shadow: none;
    text-shadow: 0 0 3px rgba(255, 255, 255, 1);
    /* Halo for readability */
    max-width: calc(100% - 50px);
    /* Avoid overlapping with Add button */
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    z-index: 5;
    pointer-events: none;
}



/* Add Button on Grid Card - Floating Bottom Right */
.modal-grid-add-btn {
    position: absolute;
    bottom: 10px;
    right: 10px;
    background: #4CAF50;
    color: white;
    border: none;
    border-radius: 50%;
    /* Circle */
    width: 28px;
    height: 28px;
    padding: 0;
    font-size: 0;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0;
    transition: background 0.2s, transform 0.2s;
    z-index: 10;
    box-shadow: 0 4px 10px rgba(76, 175, 80, 0.3);
}

.modal-grid-add-btn:hover {
    background: #43A047;
    transform: scale(1.1);
}

.modal-grid-add-btn .material-icons {
    font-size: 18px;
}