* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    background: linear-gradient(135deg, #1e3c72 0%, #2a5298 100%);
    min-height: 100vh;
    padding: 20px;
}

.container {
    max-width: 1800px;
    margin: 0 auto;
    display: grid;
    grid-template-columns: 250px 1fr 250px;
    grid-template-rows: auto 1fr;
    gap: 20px;
}

header {
    grid-column: 1 / -1;
    text-align: center;
    color: white;
    padding: 20px;
}

.left-pane {
    grid-column: 1;
    grid-row: 2;
    background: white;
    border-radius: 15px;
    padding: 25px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
    height: calc(100vh - 200px);
    overflow-y: auto;
    animation: fadeInLeft 0.8s ease;
}

.left-pane h3 {
    font-size: 1.5rem;
    margin-bottom: 20px;
    color: #1e3c72;
}

.left-pane .area-list,
.left-pane .device-list {
    display: block;
    margin-top: 0;
    max-height: none;
    height: auto;
}

h1 {
    font-size: 2.5rem;
    font-weight: 700;
    margin-bottom: 10px;
    animation: fadeInDown 0.8s ease;
}

.subtitle {
    font-size: 1.1rem;
    opacity: 0.9;
    animation: fadeInUp 0.8s ease;
}

.controls {
    grid-column: 3;
    grid-row: 2;
    background: white;
    border-radius: 15px;
    padding: 25px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
    height: calc(100vh - 200px);
    overflow-y: auto;
    animation: fadeInLeft 0.8s ease;
}

.controls h3 {
    font-size: 1.5rem;
    margin-bottom: 20px;
    color: #1e3c72;
}

.layer-controls {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.layer-toggle {
    display: flex;
    align-items: center;
    cursor: pointer;
    padding: 10px;
    border-radius: 8px;
    transition: background 0.2s ease;
}

.layer-toggle:hover {
    background: #f5f7fa;
}

.layer-toggle input[type="checkbox"] {
    width: 20px;
    height: 20px;
    margin-right: 12px;
    cursor: pointer;
}

.toggle-label {
    font-size: 1rem;
    color: #333;
    font-weight: 500;
}

main {
    grid-column: 2;
    grid-row: 2;
}

.floorplan-container {
    background: white;
    border-radius: 15px;
    padding: 30px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
    animation: fadeIn 0.8s ease;
}

.floorplan-wrapper {
    position: relative;
    width: 100%;
    max-width: 1200px;
    margin: 0 auto;
    aspect-ratio: 16 / 10;
}

.floorplan-base {
    width: 100%;
    height: 100%;
    object-fit: contain;
    border-radius: 10px;
    -webkit-user-drag: none;
    user-drag: none;
    user-select: none;
}

.layer {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    transition: opacity 0.3s ease;
}

.layer.hidden {
    opacity: 0;
}

.coverage-area {
    position: absolute;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(102, 126, 234, 0.3) 0%, rgba(102, 126, 234, 0) 70%);
    animation: pulse 3s ease-in-out infinite;
}

.area-1 {
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    width: 60%;
    height: 60%;
}

.area-2 {
    left: 20%;
    top: 30%;
    transform: translate(-50%, -50%);
    width: 40%;
    height: 40%;
}

.heat-zone {
    position: absolute;
    border-radius: 50%;
    filter: blur(30px);
}

.zone-1 {
    left: 25%;
    top: 35%;
    width: 30%;
    height: 30%;
    background: radial-gradient(circle, rgba(255, 100, 100, 0.4) 0%, rgba(255, 100, 100, 0) 70%);
}

.zone-2 {
    left: 55%;
    top: 55%;
    width: 35%;
    height: 35%;
    background: radial-gradient(circle, rgba(255, 200, 100, 0.4) 0%, rgba(255, 200, 100, 0) 70%);
}

.zone-3 {
    left: 70%;
    top: 30%;
    width: 25%;
    height: 25%;
    background: radial-gradient(circle, rgba(100, 255, 100, 0.4) 0%, rgba(100, 255, 100, 0) 70%);
}

.network-links {
    width: 100%;
    height: 100%;
}

.link {
    stroke: #667eea;
    stroke-width: 2;
    stroke-dasharray: 5, 5;
    animation: dash 2s linear infinite;
}

.device {
    position: absolute;
    transform: translate(-50%, -50%);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 3px;
    pointer-events: auto;
    cursor: pointer;
    animation: fadeIn 0.8s ease backwards;
}

.device:nth-child(1) { animation-delay: 0.2s; }
.device:nth-child(2) { animation-delay: 0.3s; }
.device:nth-child(3) { animation-delay: 0.4s; }
.device:nth-child(4) { animation-delay: 0.5s; }

.device .icon {
    font-size: 1.25rem;
    background: white;
    border-radius: 50%;
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
    transition: all 0.3s ease;
    overflow: hidden;
}

.device .icon img {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.device:hover .icon {
    transform: scale(1.2);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.3);
}

.device .label {
    background: rgba(0, 0, 0, 0.8);
    color: white;
    padding: 3px 8px;
    border-radius: 8px;
    font-size: 0.7rem;
    white-space: nowrap;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.device:hover .label {
    opacity: 1;
}

.device .protocol-icon {
    position: absolute;
    top: -20px;
    font-size: 0.9rem;
    background: white;
    border-radius: 50%;
    width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.15);
    border: 1px solid #ddd;
}

.control-btn {
    width: 100%;
    padding: 12px;
    margin-bottom: 10px;
    border: none;
    border-radius: 8px;
    background: #667eea;
    color: white;
    font-size: 1rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
}

.control-btn:hover {
    background: #5568d3;
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
}

.control-btn.secondary {
    background: #e74c3c;
    display: none;
}

.control-btn.secondary:hover {
    background: #c0392b;
}

.control-btn.active {
    background: #27ae60;
}

.control-btn.active:hover {
    background: #229954;
}

.area-list {
    margin-top: 15px;
    max-height: 200px;
    overflow-y: auto;
    display: none;
}

.area-item {
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 10px;
    margin-bottom: 10px;
    background: #f5f7fa;
    border-radius: 6px;
    font-size: 0.9rem;
    cursor: pointer;
    transition: background 0.2s ease;
}

.area-item:hover {
    background: #e8ebf0;
}

.area-item.selected {
    background: #d4dce8;
    border: 2px solid #667eea;
}

.area-name-input {
    border: none;
    background: white;
    font-size: 0.9rem;
    padding: 6px 8px;
    border-radius: 4px;
    width: 100%;
}

.opacity-control {
    display: flex;
    align-items: center;
    gap: 8px;
}

.opacity-slider {
    flex: 1;
    cursor: pointer;
}

.opacity-label {
    min-width: 40px;
    text-align: right;
    font-size: 0.85rem;
    color: #666;
}

.area-item button {
    background: #e74c3c;
    border: none;
    color: white;
    padding: 6px 12px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.8rem;
    align-self: flex-end;
}

.area-item button:hover {
    background: #c0392b;
}

.device-type-selector {
    margin-top: 15px;
    padding: 12px;
    background: #f5f7fa;
    border-radius: 8px;
}

.device-type-selector label {
    display: block;
    margin-bottom: 8px;
    font-weight: 500;
    color: #333;
}

.device-type-selector select {
    width: 100%;
    padding: 8px;
    border: 1px solid #ddd;
    border-radius: 6px;
    font-size: 0.9rem;
    cursor: pointer;
}

.device-list {
    margin-top: 15px;
    max-height: 200px;
    overflow-y: auto;
    display: none;
}

.device-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px;
    margin-bottom: 10px;
    background: #f5f7fa;
    border-radius: 6px;
    font-size: 0.9rem;
    cursor: pointer;
    transition: background 0.2s ease;
}

.device-item:hover {
    background: #e8ebf0;
}

.device-item.selected {
    background: #d4dce8;
    border: 2px solid #667eea;
}

.device-icon {
    font-size: 1.5rem;
    flex-shrink: 0;
}

.device-details {
    display: flex;
    flex-direction: column;
    gap: 6px;
    flex: 1;
}

.device-name-input {
    border: none;
    background: white;
    font-size: 0.9rem;
    padding: 6px 8px;
    border-radius: 4px;
    width: 100%;
}

.device-type-select {
    border: 1px solid #ddd;
    background: white;
    font-size: 0.85rem;
    padding: 4px 6px;
    border-radius: 4px;
    cursor: pointer;
    width: 100%;
}

.device-item button {
    background: #e74c3c;
    border: none;
    color: white;
    padding: 6px 12px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.8rem;
    flex-shrink: 0;
}

.device-item button:hover {
    background: #c0392b;
}

.device.custom-device {
    cursor: default;
    transform: translate(-50%, -50%);
    animation: none !important;
}

.device.custom-device .icon {
    transform: none !important;
    transition: none !important;
}

.device.custom-device.selected .icon {
    box-shadow: 0 0 0 3px #27ae60;
}

.draw-canvas {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    cursor: crosshair;
    pointer-events: none;
    z-index: 50;
}

.draw-canvas.drawing {
    pointer-events: auto;
}

.drawn-area {
    position: absolute;
    border: 2px solid #667eea;
    background: rgba(102, 126, 234, 0.2);
    transition: border-color 0.2s ease;
}

.drawn-area:hover {
    border-color: #27ae60;
}

.drawn-area.selected {
    border-color: #27ae60;
    border-width: 3px;
}

.drawn-area .area-label {
    position: absolute;
    top: -25px;
    left: 0;
    background: #667eea;
    color: white;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 0.75rem;
    white-space: nowrap;
}

.resize-handle {
    position: absolute;
    width: 10px;
    height: 10px;
    background: #667eea;
    border: 2px solid white;
    border-radius: 50%;
    opacity: 0;
    transition: opacity 0.2s ease;
    z-index: 10;
}

.drawn-area:hover .resize-handle {
    opacity: 1;
}

.resize-handle.nw {
    top: -5px;
    left: -5px;
    cursor: nw-resize;
}

.resize-handle.ne {
    top: -5px;
    right: -5px;
    cursor: ne-resize;
}

.resize-handle.sw {
    bottom: -5px;
    left: -5px;
    cursor: sw-resize;
}

.resize-handle.se {
    bottom: -5px;
    right: -5px;
    cursor: se-resize;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(30px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes fadeInDown {
    from {
        opacity: 0;
        transform: translateY(-30px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(30px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes fadeInLeft {
    from {
        opacity: 0;
        transform: translateX(-30px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

@keyframes pulse {
    0%, 100% {
        transform: translate(-50%, -50%) scale(1);
        opacity: 0.6;
    }
    50% {
        transform: translate(-50%, -50%) scale(1.1);
        opacity: 0.8;
    }
}

@keyframes dash {
    to {
        stroke-dashoffset: -10;
    }
}

@media (max-width: 1024px) {
    .container {
        grid-template-columns: 1fr;
    }
    
    .controls {
        grid-column: 1;
    }
    
    .layer-controls {
        flex-direction: row;
        flex-wrap: wrap;
    }
}

@media (max-width: 768px) {
    h1 {
        font-size: 2rem;
    }
    
    .subtitle {
        font-size: 1rem;
    }
    
    .floorplan-container {
        padding: 15px;
    }
    
    .device .icon {
        width: 45px;
        height: 45px;
        font-size: 1.8rem;
    }
}
