/* ============================================================================
   Sandbox Game Page - Free Play Mode
   Requires: game-common.css loaded first
   ============================================================================ */

/* ============================================================================
   Main Dashboard Layout
   ============================================================================ */

.sandbox-dashboard {
    display: flex;
    flex-direction: column;
    height: 100vh;
    padding: 1rem;
    gap: 0;
    max-width: 1800px;
    margin: 0 auto;
}

.sandbox-dashboard .header {
    flex-shrink: 0;
    margin-bottom: 1rem;
}

/* ============================================================================
   Main Content Area
   ============================================================================ */

.sandbox-content {
    display: flex;
    gap: 1rem;
    flex: 1;
    min-height: 0;
    overflow: hidden;
}

/* ============================================================================
   Sidebar
   ============================================================================ */

.sandbox-dashboard .sidebar {
    width: 340px;
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    gap: 1rem;
    overflow-y: auto;
    overflow-x: hidden;
}

.sandbox-dashboard .ble-panel {
    flex-shrink: 0;
}

.sandbox-dashboard .controls-panel {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
}

/* Ensure device list can show all 6 robots */
.sandbox-dashboard .device-list {
    max-height: 180px;
    min-height: 60px;
}

/* Better spacing for device cards */
.sandbox-dashboard .device-card {
    padding: 0.5rem 0.75rem;
}

.sandbox-dashboard .device-name {
    font-size: 0.8rem;
}

/* Ensure slider values are visible in narrow sidebar */
.sandbox-dashboard .slider-row {
    flex-wrap: nowrap;
}

.sandbox-dashboard .slider-value {
    min-width: 2rem;
    flex-shrink: 0;
}

.sandbox-dashboard .control-row {
    flex-wrap: wrap;
    gap: 0.75rem;
}

.sandbox-dashboard .control-row .half {
    flex: 1 1 100%;
    min-width: 0;
}

/* ============================================================================
   Robot Grid Area
   ============================================================================ */

.robot-area {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
    background: var(--card-bg);
    -webkit-backdrop-filter: blur(10px);
    backdrop-filter: blur(10px);
    border-radius: 16px;
    border: 1px solid var(--card-border);
    padding: 1.25rem;
    overflow: hidden;
}

.robot-area-header {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-bottom: 1rem;
    flex-shrink: 0;
}

.robot-area-header h2 {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin: 0;
}

.robot-count {
    display: inline-block;
    background: var(--accent-purple);
    color: white;
    font-size: 0.7rem;
    font-weight: 600;
    padding: 0.2rem 0.5rem;
    border-radius: 10px;
    margin-left: 0.25rem;
}

.robot-hint {
    font-size: 0.8rem;
    color: var(--text-muted);
    margin: 0;
}

.robot-grid {
    flex: 1;
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(440px, 1fr));
    gap: 1rem;
    align-content: start;
    overflow-y: auto;
    padding: 0.5rem 0.5rem 0.5rem 0;
}

.robot-grid-empty {
    grid-column: 1 / -1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 300px;
    color: var(--text-muted);
    text-align: center;
}

.robot-grid-empty .empty-icon {
    font-size: 4rem;
    margin-bottom: 1rem;
    opacity: 0.5;
}

.robot-grid-empty p {
    margin: 0.25rem 0;
    font-size: 1rem;
}

.robot-grid-empty .empty-hint {
    font-size: 0.85rem;
    opacity: 0.7;
}

/* ============================================================================
   Robot Card (sandbox-specific: uses .robot-card instead of .player-card)
   ============================================================================ */

.robot-card {
    background: var(--card-hover);
    border-radius: 8px;
    border: 2px solid transparent;
    padding: 0.4rem 0.6rem;
    cursor: pointer;
    transition: all 0.15s ease;
}

.robot-card:hover {
    background: rgba(255, 255, 255, 0.1);
    border-color: var(--accent-blue);
}

.robot-card.selected {
    border-color: var(--accent-green);
    box-shadow: 0 0 10px rgba(38, 222, 129, 0.25);
}

.robot-card.stale { opacity: 0.5; }

.pc-selected {
    color: var(--accent-green);
    font-weight: 700;
    flex-shrink: 0;
}

/* ============================================================================
   LED Layout - Robot Visual Representation
   ============================================================================ */

.led-layout {
    display: flex;
    gap: 1.25rem;
    justify-content: center;
    padding: 0.5rem 0;
}

.led-side {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.4rem;
}

.led-row {
    display: flex;
    justify-content: center;
    gap: 0.35rem;
}

.led-row.single { width: 100%; justify-content: center; }
.led-row.double { width: 100%; }
.led-row.triple { width: 100%; }

.led-layout .led-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.1rem;
    min-width: 42px;
}

.led-layout .led-item span {
    font-size: 0.55rem;
    color: var(--text-muted);
    white-space: nowrap;
    text-align: center;
}

/* Square color pickers */
.led-layout input[type="color"] {
    width: 34px;
    height: 34px;
    border: 2px solid var(--card-border);
    border-radius: 6px;
    background: var(--input-bg);
    cursor: pointer;
    padding: 2px;
    transition: border-color 0.2s, box-shadow 0.2s, opacity 0.2s;
}

.led-layout input[type="color"]:hover {
    border-color: var(--accent-blue);
    box-shadow: 0 0 8px rgba(77, 171, 247, 0.3);
}

.led-layout input[type="color"]::-webkit-color-swatch-wrapper { padding: 2px; }
.led-layout input[type="color"]::-webkit-color-swatch { border-radius: 3px; border: none; }

.led-layout input[type="color"].is-black { opacity: 0.3; border-style: dashed; }
.led-layout input[type="color"].is-black:hover { opacity: 0.7; }

/* Side labels */
.left-side { position: relative; }
.right-side { position: relative; }

.left-side::before,
.right-side::before {
    position: absolute;
    top: -0.35rem;
    font-size: 0.5rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-muted);
}

.left-side::before { content: 'LEFT'; left: 0; }
.right-side::before { content: 'RIGHT'; right: 0; }

.led-hint {
    font-size: 0.65rem;
    color: var(--text-muted);
    font-weight: normal;
    margin-left: 0.5rem;
}

/* ============================================================================
   Send Row with Find Button
   ============================================================================ */

.send-row {
    display: flex;
    gap: 0.5rem;
    align-items: stretch;
    margin-top: 0.5rem;
}

.btn-send { flex: 1; }

.find-wrapper {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.2rem;
}

.find-hint {
    font-size: 0.6rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* Panel find button override (bigger than card find buttons) */
.find-wrapper .find-btn {
    width: 44px;
    height: 38px;
    border-radius: 8px;
    font-size: 1.1rem;
    box-shadow: 0 2px 8px rgba(102, 126, 234, 0.4);
}

.find-wrapper .find-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.find-wrapper .find-btn:not(:disabled):hover {
    transform: scale(1.05);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.6);
}

.find-wrapper .find-btn:not(:disabled):active,
.find-wrapper .find-btn.active {
    transform: scale(0.95);
}

[data-theme="light"] .find-wrapper .find-btn {
    background: linear-gradient(135deg, #7d6bab, #5a4f8a);
}

/* ============================================================================
   Responsive Adjustments
   ============================================================================ */

@media (max-width: 1200px) {
    .sandbox-dashboard .sidebar { width: 300px; }
    .robot-grid { grid-template-columns: 1fr; }
}

@media (max-width: 900px) {
    .sandbox-content { flex-direction: column; }

    .sandbox-dashboard .sidebar {
        width: 100%;
        flex-direction: row;
        flex-wrap: wrap;
    }

    .sandbox-dashboard .ble-panel,
    .sandbox-dashboard .controls-panel {
        flex: 1;
        min-width: 280px;
    }

    .robot-area { min-height: 400px; }
}

/* ============================================================================
   Light Theme Adjustments
   ============================================================================ */

[data-theme="light"] .robot-card {
    background: rgba(255, 255, 255, 0.9);
    border-color: rgba(140, 125, 105, 0.2);
}

[data-theme="light"] .robot-card:hover {
    background: rgba(255, 255, 255, 1);
    border-color: var(--accent-blue);
}

[data-theme="light"] .robot-card.selected {
    border-color: var(--accent-green);
    box-shadow: 0 0 15px rgba(74, 153, 100, 0.25);
}

[data-theme="light"] .robot-area {
    box-shadow: 0 2px 10px rgba(140, 125, 105, 0.12);
}
