/* Reset and Base Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: #000;
    color: #fff;
    overflow: hidden;
}

#app {
    position: relative;
    width: 100vw;
    height: 100vh;
}

/* Video Feed (Full Screen Background) */
#videoFeed {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    z-index: 1;
}

/* Detection Canvas Overlay */
#detectionCanvas {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 2;
    pointer-events: none;
}

/* 3D Preview (Small Corner View) */
#preview3D {
    position: absolute;
    top: 20px;
    right: 20px;
    width: 200px;
    height: 200px;
    background: rgba(0, 0, 0, 0.7);
    border: 2px solid #00ff88;
    border-radius: 10px;
    z-index: 10;
}

/* Control Panel */
#controlPanel {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    background: linear-gradient(to top, rgba(0,0,0,0.95), rgba(0,0,0,0.7));
    padding: 20px;
    z-index: 20;
    max-height: 50vh;
    overflow-y: auto;
}

#controlPanel h2 {
    color: #00ff88;
    margin-bottom: 10px;
    font-size: 1.5em;
}

#status {
    background: rgba(255, 255, 255, 0.1);
    padding: 10px;
    border-radius: 5px;
    margin-bottom: 15px;
    text-align: center;
}

/* Buttons */
button {
    padding: 12px 20px;
    margin: 5px;
    border: none;
    border-radius: 5px;
    font-size: 1em;
    cursor: pointer;
    transition: all 0.3s;
}

.btn-primary {
    background: #00ff88;
    color: #000;
    font-weight: bold;
}
.btn-primary:hover {
    background: #00cc6a;
    transform: scale(1.05);
}
.btn-secondary {
    background: #4a5568;
    color: #fff;
}
.btn-secondary:hover {
    background: #2d3748;
}
.btn-success {
    background: #38b2ac;
    color: #fff;
}
button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Texture Panel */
#texturePanel {
    margin-top: 15px;
    padding: 15px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 8px;
}
.texture-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
    gap: 10px;
    margin-top: 10px;
}
.texture-btn {
    background: rgba(255, 255, 255, 0.2);
    padding: 15px 10px;
    border: 2px solid transparent;
    color: #fff;
}
.texture-btn:hover,
.texture-btn.selected {
    border-color: #00ff88;
    background: rgba(0, 255, 136, 0.2);
}

/* Detection Info */
#detectionInfo {
    position: absolute;
    top: 20px;
    left: 20px;
    background: rgba(0, 0, 0, 0.8);
    padding: 15px;
    border-radius: 8px;
    max-width: 250px;
    z-index: 15;
}
#detectionInfo h4 {
    color: #00ff88;
    margin-bottom: 10px;
}
#detectionList {
    list-style: none;
}
#detectionList li {
    padding: 5px 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

/* Mobile Optimization */
@media (max-width: 768px) {
    #preview3D {
        width: 150px;
        height: 150px;
    }
    #controlPanel h2 {
        font-size: 1.2em;
    }
    button {
        padding: 10px 15px;
        font-size: 0.9em;
    }
}

/* Success Toast Animation */
.success-toast {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: linear-gradient(135deg, #00ff88, #00cc6a);
    color: #000;
    padding: 20px 40px;
    border-radius: 15px;
    font-size: 1.2em;
    font-weight: bold;
    box-shadow: 0 10px 30px rgba(0, 255, 136, 0.5);
    z-index: 9999;
    animation: popIn 0.3s ease-out;
}

@keyframes popIn {
    0% {
        transform: translate(-50%, -50%) scale(0.5);
        opacity: 0;
    }
    100% {
        transform: translate(-50%, -50%) scale(1);
        opacity: 1;
    }
}

/* Loading Spinner */
.spinner {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 50px;
    height: 50px;
    border: 5px solid rgba(255, 255, 255, 0.3);
    border-top: 5px solid #00ff88;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    z-index: 9999;
}

@keyframes spin {
    0% { transform: translate(-50%, -50%) rotate(0deg); }
    100% { transform: translate(-50%, -50%) rotate(360deg); }
}

/* Detection Counter Badge */
#detectionCounter {
    position: absolute;
    top: 240px;
    right: 20px;
    background: rgba(0, 255, 136, 0.9);
    color: #000;
    padding: 10px 20px;
    border-radius: 20px;
    font-weight: bold;
    font-size: 0.9em;
    z-index: 15;
}

/* Dimension Display */
#dimensionDisplay {
    position: absolute;
    bottom: calc(50vh + 20px);
    left: 20px;
    background: rgba(0, 0, 0, 0.8);
    padding: 15px;
    border-radius: 8px;
    border: 2px solid #00ff88;
    min-width: 200px;
    z-index: 15;
}
#dimensionDisplay h4 {
    color: #00ff88;
    margin-bottom: 10px;
    font-size: 1em;
}
#dimensionValues p {
    margin: 5px 0;
    font-size: 0.95em;
}
#dimensionValues span {
    color: #00ff88;
    font-weight: bold;
    font-size: 1.1em;
}

/* Room Statistics */
#roomStats {
    margin-top: 15px;
    padding: 15px;
    background: rgba(0, 255, 136, 0.1);
    border-radius: 8px;
    border: 1px solid #00ff88;
}
#roomStats h3 {
    color: #00ff88;
    margin-bottom: 10px;
    font-size: 1.1em;
}
.stats-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
}
.stat-item {
    text-align: center;
}
.stat-label {
    display: block;
    font-size: 0.8em;
    color: #aaa;
    margin-bottom: 5px;
}
.stat-value {
    display: block;
    font-size: 1.5em;
    font-weight: bold;
    color: #00ff88;
}

/* Export Panel */
#exportPanel {
    margin-top: 15px;
    padding: 15px;
    background: rgba(56, 178, 172, 0.1);
    border-radius: 8px;
    border: 1px solid #38b2ac;
}
#exportPanel h3 {
    color: #38b2ac;
    margin-bottom: 10px;
    font-size: 1.1em;
}
.export-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
    margin-top: 10px;
}
.btn-export {
    background: rgba(56, 178, 172, 0.2);
    color: #38b2ac;
    border: 2px solid #38b2ac;
    padding: 12px 8px;
    font-size: 0.9em;
    font-weight: bold;
    transition: all 0.3s;
}
.btn-export:hover {
    background: rgba(56, 178, 172, 0.4);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(56, 178, 172, 0.3);
}

/* Error Toast */
.error-toast {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: linear-gradient(135deg, #ff6b6b, #ee5a52);
    color: #fff;
    padding: 20px 40px;
    border-radius: 15px;
    font-size: 1.2em;
    font-weight: bold;
    box-shadow: 0 10px 30px rgba(255, 107, 107, 0.5);
    z-index: 9999;
    animation: popIn 0.3s ease-out;
}

@media (max-width: 768px) {
    .stats-grid, .export-grid {
        grid-template-columns: 1fr;
    }
    .btn-export {
        padding: 15px;
        font-size: 1em;
    }
}
/* Floor Plan Viewer */
.floor-plan-btn {
    background: rgba(0, 255, 136, 0.2);
    color: #00ff88;
    border: 1px solid #00ff88;
    padding: 8px 16px;
    border-radius: 5px;
    font-size: 0.9em;
    cursor: pointer;
    transition: all 0.3s;
}

.floor-plan-btn:hover {
    background: rgba(0, 255, 136, 0.4);
    transform: translateY(-1px);
}

#floorPlanContainer {
    backdrop-filter: blur(10px);
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.8);
}

#floorPlanContainer canvas {
    border-radius: 0 0 10px 10px;
}

/* Responsive floor plan */
@media (max-width: 768px) {
    #floorPlanContainer {
        width: 95vw;
        height: 90vh;
    }
    
    .floor-plan-btn {
        padding: 12px;
        font-size: 0.8em;
    }
}/* Cost 
Calculator */
.cost-btn {
    background: rgba(255, 217, 61, 0.2);
    color: #ffd93d;
    border: 1px solid #ffd93d;
    padding: 8px 16px;
    border-radius: 5px;
    font-size: 0.9em;
    cursor: pointer;
    transition: all 0.3s;
}

.cost-btn:hover {
    background: rgba(255, 217, 61, 0.4);
    transform: translateY(-1px);
}

.material-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(255, 217, 61, 0.3);
}

/* Responsive cost calculator */
@media (max-width: 768px) {
    #costPanel {
        width: 95vw;
        height: 90vh;
    }
    
    #materialGrid {
        grid-template-columns: 1fr !important;
    }
    
    .cost-btn {
        padding: 12px;
        font-size: 0.8em;
    }
}