/* Main layout styles */
html, body {
    margin: 0;
    padding: 0;
    width: 100%;
    height: 100%;
    overflow: hidden;
}

.main-container {
    width: 100%;
    height: 100vh;
    display: flex;
    flex-direction: column;
    position: relative;
}

/* Video container styles */
.video-container {
    width: 100%;
    position: relative;
    overflow: hidden;
}

.video-top {
    height: calc(100vh / 3);
}

.video-bottom {
    height: calc(100vh / 3);
    display: none; /* Hidden by default (Mode 1) */
}

/* Make videos take up full container width */
.video-container video {
    width: 100%;
    height: 100%;
    object-fit: contain;
    display: block;
}

/* Grid container styles */
.grid-container {
    width: 100%;
    height: calc(100vh * 2/3); /* Takes 2/3 of screen in Mode 1 */
    display: flex;
    flex-wrap: wrap;
    overflow: hidden;
}

/* Grid item styles */
.grid-item {
    position: relative;
    overflow: hidden;
    margin: 0;
    padding: 0;
    border: 2px solid grey;
}

/* Green glow effect for active/clicked grid items */
.grid-item-active {
    box-shadow: inset 0 0 24px 8px rgba(0, 255, 0, 0.6);
    z-index: 5; /* Ensure the glow is visible above adjacent items */
    position: relative;
    border-color: #00cc00;
}

/* Style for out-of-stock items (qty = 0) */
.grid-item-disabled {
    opacity: 0.6;
    filter: grayscale(70%);
    position: relative;
}
   
/* Optional overlay to enhance the disabled appearance */
.grid-item-disabled::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(200, 200, 200, 0.2);
    pointer-events: none; /* Allow clicks to pass through */
}

.grid-item img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    display: block;
}

/* Item number badge */
.item-badge {
    position: absolute;
    top: 1vh;
    left: 1.5vw;
    background-color: red;
    color: white;
    border-radius: 50%;
    width: 4vw;
    height: 4vw;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    z-index: 10;
    font-size: 1.5vw;
    opacity: 1;
    box-shadow: 0 1px 3px rgba(0,0,0,0.3);
}

/* Price badge */
.price-badge {
    position: absolute;
    bottom: 1vh;
    right: 1.5vw;
    background-color: black;
    color: white;
    border-radius: 50%;
    width: 4vw;
    height: 4vw;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    z-index: 10;
    font-size: 1.5vw;
    opacity: 1;
    box-shadow: 0 1px 3px rgba(0,0,0,0.3);
}

/* Quantity badge */
.quantity-badge {
    position: absolute;
    top: 1vh;
    right: 1.5vw;
    background-color: blue;
    color: white;
    border-radius: 50%;
    width: 4vw;
    height: 4vw;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    z-index: 10;
    font-size: 1.5vw;
    opacity: 1;
    box-shadow: 0 1px 3px rgba(0,0,0,0.3);
}

/* Floating UI Controls */
.floating-controls {
    position: absolute;
    top: 1vw;
    right: 1vw;
    z-index: 100;
}

/* Toggle button for controls */
.controls-toggle {
    position: absolute;
    top: 0;
    right: 0;
    width: 5vw;
    height: 5vw;
    border-radius: 50%;
    background-color: rgba(0, 0, 0, 0.7);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: 0 0 15px rgba(0, 0, 0, 0.3);
    z-index: 101;
    font-size: 2vw;
    transition: background-color 0.2s ease;
}

.controls-toggle:hover {
    background-color: rgba(0, 0, 0, 0.9);
}

.control-panel {
    background-color: rgba(0, 0, 0, 0.7);
    color: white;
    padding: 1.5vw;
    border-radius: 1vw;
    box-shadow: 0 0 25px rgba(0, 0, 0, 0.5);
    width: 33vw; /* Increased from 25vw to 33vw for better scaling */
    transition: transform 0.3s ease, opacity 0.3s ease;
    transform: translateX(110%); /* Start off-screen */
    opacity: 0;
}

/* Expanded state */
.controls-expanded .control-panel {
    transform: translateX(0);
    opacity: 1;
}

.control-panel .field {
    margin-bottom: 1.8vw; /* Space between control groups */
}

.control-panel .label {
    color: white;
    font-size: 2.4vw;
    display: block;
    margin-bottom: 0.8vw;
    font-weight: bold;
}

/* Fix for Bulma select element styling */
.control-panel .select {
    width: 100%;
    display: block;
}

.control-panel .select select {
    background-color: #444;
    color: white;
    border-color: #555;
    font-size: 2vw;
    padding: 0.5vw 1vw;
    width: 100%;
    height: 4vw;
    border-radius: 0.6vw;
    text-overflow: ellipsis; /* Add ellipsis for text overflow */
    padding-right: 2.5vw; /* Make room for the dropdown arrow */
}

/* Override Bulma's default select arrow styling */
.control-panel .select:not(.is-multiple):not(.is-loading)::after {
    border-color: #fff;
    border-width: 0.3vw;
    height: 0.6vw;
    width: 0.6vw;
    right: 0.8vw;
    margin-top: -0.4vw;
}

/* Control dropdown menu size */
.select select option {
    font-size: 1.6vw;
    padding: 0.4vw;
    background-color: #444;
    color: white;
}

/* Apply styles to the dropdown container */
select:focus,
.select select:focus,
select:focus option {
    background-color: #444 !important;
    color: white !important;
}

/* Fix for excessively large dropdown */
.select select option:checked,
.select select option:hover {
    background-color: #555 !important;
    color: white !important;
}

/* Mode-specific styles */
/* Mode 1: One video + large grid */
.mode-1 .grid-container {
    height: calc(100vh * 2/3);
}

.mode-1 .video-bottom {
    display: none;
}

/* Mode 4: Two videos (1/6 height each) + configurable grid */
.mode-4 .video-top,
.mode-4 .video-bottom {
    height: calc(100vh / 6); /* 1/6 of viewport height (9:32 aspect ratio) */
    display: block;
}

.mode-4 .grid-container {
    height: calc(100vh * 4/6); /* 4/6 of viewport height */
}

/* Mode 1 video position variants */
.video-position-top {
    /* Default ordering (already handled in HTML structure) */
}

.video-position-bottom {
    /* CSS order doesn't matter because we're using DOM manipulation in JS */
}

/* Mode 2: Two videos + small grid */
.mode-2 .grid-container {
    height: calc(100vh / 3);
}

.mode-2 .video-bottom {
    display: block;
}

/* Mode 3 (both Left and Right): 9×4 grid with merged cell for instructions */
.mode-3 .grid-container,
.mode-5 .grid-container {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    grid-template-rows: repeat(9, 1fr);
    height: 100vh; /* Full viewport height */
}

.mode-3 .video-top, .mode-3 .video-bottom,
.mode-5 .video-top, .mode-5 .video-bottom {
    display: none; /* Hide videos in Mode 3 variants */
}

/* Mode 3 grid items */
.mode-3 .grid-item,
.mode-5 .grid-item {
    border: 2px solid grey;
    background-color: white;
    width: 100%;
    height: 100%;
}

/* Special cell for item100 (instructions) - common styles */
.instruction-cell {
    background-color: white;
    display: flex;
    justify-content: center;
    align-items: center;
    overflow: hidden;
    border: 2px solid grey;
    /* border-radius: 10px; */
}

/* Mode 3 Right - instruction cell positioning */
.mode-3 .instruction-cell {
    grid-column: 2 / span 3; /* Columns 2, 3, 4 */
    grid-row: 1 / span 3;    /* Rows 1, 2, 3 */
}

/* Mode 3 Left - instruction cell positioning */
.mode-5 .instruction-cell {
    grid-column: 1 / span 3; /* Columns 1, 2, 3 */
    grid-row: 1 / span 3;    /* Rows 1, 2, 3 */
}

.instruction-cell h2 {
    font-size: 3rem;
    margin-bottom: 20px;
    color: white;
}

.instruction-text {
    font-size: 2.5rem;
    line-height: 1.4;
    margin: 10px 0;
}

/* Grid specific sizes */
/* These will be applied via JavaScript */
.grid-4x4 .grid-item {
    width: 25%;
    height: 25%;
}

.grid-5x5 .grid-item {
    width: 20%;
    height: 20%;
}

.grid-6x6 .grid-item {
    width: 16.666%;
    height: 16.666%;
}

.grid-7x7 .grid-item {
    width: 14.285%;
    height: 14.285%;
}

.grid-8x8 .grid-item {
    width: 12.5%;
    height: 12.5%;
}

/* Mode 2 fixed 3x5 grid */
.mode-2 .grid-item {
    width: 20%; /* 5 columns */
    height: 33.333%; /* 3 rows */
}

/* Item alert styling */
.item-alert {
    position: fixed;
    top: 15%;
    left: 50%;
    transform: translate(-50%, -35%);
    background-color: rgba(0, 0, 0, 0.8);
    color: white;
    padding: 2vh;
    border-radius: 25px;
    z-index: 1000;
    max-width: 80%;
    text-align: left;
    opacity: 0;
    transition: opacity 0.3s ease;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5); /* Larger shadow */
    font-size: 4rem; /* Adjusted font size */
}

.item-alert h3 {
    font-size: 4vh;
}

.item-alert p {
    margin: 1vh 0;
    font-size: 2.5vh;
}

/* Button container for item alert */
.item-alert-buttons {
    display: flex;
    justify-content: space-between;
    margin-top: 40px;
}

/* Button styling for item alert */
.item-alert-button {
    font-size: 2vh;
    padding: 1vw 2vh;
    border-radius: 1vh;
    border: none;
    color: white;
    cursor: pointer;
    transition: background-color 0.2s ease, transform 0.1s ease;
    /* min-width: 200px; */
    text-align: center;
    margin-left: 1vh;
    margin-right: 1vh;
}

.item-alert-button:hover {
    transform: translateY(-3px);
}

.item-alert-button:active {
    transform: translateY(1px);
}

/* Sell button */
.sell-button {
    background-color: #e74c3c; /* Red */
}

.sell-button:hover {
    background-color: #c0392b; /* Darker red */
}

.sell-button:disabled {
    background-color: #7f8c8d; /* Gray when disabled */
    cursor: not-allowed;
    transform: none;
}

/* Restock button */
.restock-button {
    background-color: #27ae60; /* Green */
}

.restock-button:hover {
    background-color: #2ecc71; /* Brighter green */
}

/* Close button */
.close-button {
    background-color: #3498db; /* Blue */
}

.close-button:hover {
    background-color: #2980b9; /* Darker blue */
}

.item-alert.show {
    opacity: 1;
}

/* Media queries for specific target resolution */
@media screen and (width: 2160px) and (height: 3840px) {
    .video-top, .video-bottom {
        height: 1215px; /* Exactly as specified */
    }
    
    .mode-1 .grid-container {
        height: calc(3840px - 1215px); /* Remaining space after top video */
    }
    
    .mode-2 .grid-container {
        height: calc(3840px - 1215px - 1215px); /* Space between videos */
    }
}

/* Responsive adjustments for extreme aspect ratios */
@media screen and (max-aspect-ratio: 9/20) {
    /* Adjustments for extremely tall displays */
    .video-container video {
        object-fit: contain;
    }
}

strong {
    color: white;
}
