/**
 * Surface Styles - Floor and Wall Specific
 * Reusable styling for all surfaces (floor and walls)
 */

/* Tile Grid Container */
.tile-grid {
    position: absolute;
    cursor: move;
    transform-origin: top left;
}

.tile-grid.locked {
    cursor: default;
}

/* Individual Tiles */
.tile {
    position: absolute;
    border: 1px solid rgba(204, 204, 204, 0.4);
    box-sizing: border-box;
    transition: all var(--transition-fast);
}

.tile:hover {
    z-index: 10;
    box-shadow: 0 0 8px rgba(52, 152, 219, 0.5);
    border-color: rgba(52, 152, 219, 0.8);
}

.tile-full {
    background-color: rgba(212, 230, 241, 0.4);
    border-color: rgba(52, 152, 219, 0.3);
}

.tile-cut {
    background-color: rgba(249, 231, 159, 0.4);
    border-color: rgba(243, 156, 18, 0.4);
    background-image: repeating-linear-gradient(
        45deg,
        transparent,
        transparent 10px,
        rgba(0, 0, 0, 0.08) 10px,
        rgba(0, 0, 0, 0.08) 20px
    );
}

.tile-outside {
    background-color: rgba(232, 232, 232, 0.2);
    border-color: rgba(187, 187, 187, 0.3);
    opacity: 0.3;
}

/* Tile locked for color picking */
.tile-grid.locked .tile {
    cursor: pointer;
}

.tile-grid.locked .tile:hover {
    transform: scale(1.05);
    box-shadow: 0 0 12px rgba(52, 152, 219, 0.8);
}

/* Room Structure */
#structure {
    width: 100%;
    height: 500px;
    position: relative;
    background: transparent;
    border: none;
    border-radius: 0;
}

/* Wall Canvas */
.wall-canvas {
    position: relative;
    min-height: 350px;
    background: transparent;
    border: none;
    border-radius: 0;
    overflow: hidden;
}

.wall-tile-grid {
    position: relative;
    cursor: move;
    transform-origin: top left;
}

.wall-tile-grid.locked {
    cursor: default;
}

/* Furniture Items ON CANVAS (not in palette) */
#structure .furniture-item,
.wall-canvas .furniture-item {
    position: absolute;
    background: rgba(100, 150, 200, 0.6);
    border: 3px solid #2c3e50;
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 28px;
    cursor: move;
    user-select: none;
    transition: all var(--transition-fast);
    box-shadow: var(--shadow-md);
}

#structure .furniture-item:hover,
.wall-canvas .furniture-item:hover {
    background: rgba(100, 150, 200, 0.8);
    transform: scale(1.05);
    z-index: 100;
    box-shadow: var(--shadow-lg);
}

#structure .furniture-item:active,
.wall-canvas .furniture-item:active {
    cursor: grabbing;
}

/* Wall Sections */
.wall-section {
    margin-bottom: var(--spacing-xl);
}

.wall-section .surface-header {
    background: linear-gradient(135deg, #34495e 0%, #5d6d7e 100%);
    padding: var(--spacing-md);
    border-radius: var(--radius-md) var(--radius-md) 0 0;
    color: var(--white);
}

.wall-section .surface-title {
    color: var(--white);
}

.wall-stats {
    margin-top: var(--spacing-md);
}

/* Floor Section Specific */
.floor-panel #structure {
    background-image:
        repeating-linear-gradient(
            0deg,
            rgba(52, 152, 219, 0.05),
            rgba(52, 152, 219, 0.05) 1px,
            transparent 1px,
            transparent 20px
        ),
        repeating-linear-gradient(
            90deg,
            rgba(52, 152, 219, 0.05),
            rgba(52, 152, 219, 0.05) 1px,
            transparent 1px,
            transparent 20px
        );
}

/* Surface Border Indicators */
.surface-panel.active {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 4px rgba(52, 152, 219, 0.2);
}

/* Drag Indicators */
.tile-grid.dragging,
.wall-tile-grid.dragging {
    opacity: 0.8;
    cursor: grabbing !important;
}

#structure .furniture-item.dragging,
.wall-canvas .furniture-item.dragging {
    opacity: 0.7;
    cursor: grabbing !important;
}

/* Grid Position Indicators */
.grid-position-indicator {
    position: absolute;
    top: 5px;
    right: 5px;
    background: rgba(44, 62, 80, 0.8);
    color: var(--white);
    padding: 4px 8px;
    border-radius: var(--radius-sm);
    font-size: var(--font-size-sm);
    font-weight: 600;
    pointer-events: none;
}

/* Tile Selection (Multi-select) */
.tile.selected {
    outline: 3px solid var(--danger-color);
    outline-offset: -3px;
    z-index: 50;
}

/* Surface Dimensions Display */
.surface-dimensions {
    position: absolute;
    top: 10px;
    left: 10px;
    background: rgba(255, 255, 255, 0.95);
    padding: 8px 12px;
    border-radius: var(--radius-md);
    font-size: var(--font-size-sm);
    font-weight: 600;
    color: var(--dark-color);
    box-shadow: var(--shadow-sm);
    pointer-events: none;
}

/* Animation for tile status changes */
@keyframes tileStatusChange {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.1); }
}

.tile.status-changed {
    animation: tileStatusChange 0.3s ease;
}

/* Print Styles */
@media print {
    /* Hide interactive controls */
    .sidebar {
        display: none !important;
    }

    .surface-controls {
        display: none !important;
    }

    .modal {
        display: none !important;
    }

    /* Adjust main content for printing */
    .main-content {
        margin-left: 0 !important;
        padding: 20px !important;
    }

    body {
        overflow: visible !important;
        height: auto !important;
    }

    /* Make containers printable */
    .container {
        page-break-inside: avoid;
        position: relative !important;
        overflow: visible !important;
        height: auto !important;
    }

    /* Fix structure for printing */
    #structure {
        position: relative !important;
        overflow: visible !important;
        height: auto !important;
        page-break-inside: avoid;
    }

    /* Tile grids */
    .tile-grid,
    .wall-tile-grid {
        position: relative !important;
        overflow: visible !important;
        cursor: default !important;
    }

    /* Furniture on canvas */
    #structure .furniture-item,
    .wall-canvas .furniture-item {
        position: absolute !important;
        cursor: default !important;
    }

    /* Wall sections - page breaks */
    .wall-section {
        page-break-before: always;
        page-break-inside: avoid;
        margin-bottom: 30px !important;
    }

    .wall-section:first-of-type {
        page-break-before: avoid;
    }

    .wall-canvas {
        position: relative !important;
        overflow: visible !important;
        page-break-inside: avoid;
    }

    /* Ensure tiles are visible */
    .tile {
        page-break-inside: avoid;
    }
}
