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

body.ai-body {
    font-family: 'Anuphan', sans-serif;
    background-color: #f9f9f9;
    color: #333333;
    line-height: 1.6;
}

/* Typography & Colors */
.text-green { color: #22c55e; }
.text-orange { color: #f97316; }
.text-cyan { color: #06b6d4; }
.text-red { color: #ef4444; }
.text-purple { color: #a855f7; }

/* Navbar */
.ai-navbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background-color: #333333;
    color: #ffffff;
    padding: 16px 24px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
}

.ai-logo {
    display: flex;
    align-items: center;
    gap: 12px;
}

.ai-logo-icon {
    color: #d0ff2c;
    font-size: 28px;
}

.ai-logo h1 {
    font-size: 18px;
    font-weight: 700;
    margin: 0;
}

.ai-nav-actions {
    display: flex;
    align-items: center;
    gap: 20px;
}

.ai-coord-wrapper {
    display: flex;
    align-items: center;
}

.ai-coord-link {
    color: #ffffff;
    text-decoration: underline;
    text-decoration-style: dotted;
    text-underline-offset: 4px;
    font-weight: 600;
    transition: color 0.2s;
}

.ai-coord-link:hover {
    color: #fc5b08;
}

.ai-coord-input {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 14px;
    color: #cccccc;
    background: #444444;
    padding: 8px 16px;
    border-radius: 8px;
}

.ai-icon-btn {
    background: transparent;
    border: none;
    color: #cccccc;
    cursor: pointer;
    display: flex;
    align-items: center;
    padding: 2px;
    border-radius: 4px;
    transition: all 0.2s;
    margin-left: 8px;
}

.ai-icon-btn:hover {
    color: #ffffff;
    background: #555555;
}

.ai-icon-btn .material-symbols-outlined {
    font-size: 16px;
}

.ai-coord-edit {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 14px;
    color: #cccccc;
    background: #444444;
    padding: 6px 12px;
    border-radius: 8px;
}

.ai-input-coord {
    width: 80px;
    background: #ffffff;
    border: 1px solid #555555;
    border-radius: 4px;
    padding: 2px 6px;
    font-size: 13px;
    font-family: inherit;
    color: #333333;
    outline: none;
}

.ai-input-coord:focus {
    border-color: #fc5b08;
}

.ai-btn-save-coord {
    background: #fc5b08;
    color: white;
    border: none;
    border-radius: 4px;
    padding: 4px 10px;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    font-family: inherit;
    margin-left: 4px;
}

.ai-btn-save-coord:hover {
    background: #e04f05;
}

.ai-btn-upload {
    display: flex;
    align-items: center;
    gap: 8px;
    background-color: #fc5b08;
    color: #ffffff;
    padding: 10px 20px;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: background-color 0.2s;
}

.ai-btn-upload:hover {
    background-color: #e04f05;
}

/* Layout */
.ai-container {
    display: grid;
    grid-template-columns: 320px 1fr 340px;
    gap: 24px;
    padding: 24px;
    max-width: 1600px;
    margin: 0 auto;
    align-items: start;
}

/* Cards */
.ai-card {
    background: #ffffff;
    border-radius: 16px;
    padding: 20px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.04);
    border: 1px solid #f1f5f9;
    margin-bottom: 24px;
}

.ai-card-title {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 16px;
    font-weight: 700;
    color: #333333;
    margin-bottom: 20px;
}

.ai-card-title .material-symbols-outlined {
    color: #666666;
    font-size: 20px;
}

.ai-icon-primary { color: #fc5b08 !important; }
.ai-icon-accent { color: #f97316 !important; }

/* Left Sidebar - Score */
.ai-overall-score {
    text-align: center;
    margin-bottom: 24px;
}

.ai-score-value {
    font-size: 48px;
    font-weight: 700;
    color: #333333;
    line-height: 1;
}

.ai-score-max {
    font-size: 16px;
    color: #999999;
}

.ai-score-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.ai-score-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 14px;
}

.ai-score-label {
    color: #666666;
    font-weight: 500;
}

.ai-score-num {
    font-weight: 700;
}

/* Left Sidebar - Layers */
.ai-layer-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.ai-layer-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px;
    border-radius: 12px;
    border: 1px solid #e5e7eb;
    cursor: pointer;
    transition: all 0.2s;
}

.ai-layer-item:hover {
    background-color: #f9f9f9;
}

.ai-layer-item.active {
    background-color: #fff1ec;
    border-color: #fc5b08;
}

.ai-layer-item.active .material-symbols-outlined,
.ai-layer-item.active .ai-layer-text strong {
    color: #fc5b08;
}

.ai-layer-item .material-symbols-outlined {
    color: #666666;
    font-size: 24px;
}

.ai-layer-text {
    display: flex;
    flex-direction: column;
}

.ai-layer-text strong {
    font-size: 14px;
    color: #333333;
}

.ai-layer-text span {
    font-size: 12px;
    color: #999999;
}

/* Center - Map */
.ai-map-container {
    display: flex;
    flex-direction: column;
    align-items: center;
}

.ai-map-header {
    width: 100%;
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 24px;
}

.ai-map-controls {
    display: flex;
    align-items: center;
    gap: 12px;
}

.ai-toggle-group {
    display: flex;
    background: #f1f5f9;
    border-radius: 8px;
    padding: 3px;
}

.ai-toggle-btn {
    background: transparent;
    border: none;
    padding: 4px 16px;
    border-radius: 6px;
    font-size: 13px;
    font-weight: 600;
    color: #666666;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
}

.ai-toggle-btn.active {
    background: #ffffff;
    color: #333333;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

.ai-badge {
    background: #f1f5f9;
    color: #333333;
    padding: 6px 12px;
    border-radius: 20px;
    font-size: 13px;
    font-weight: 600;
}

.ai-map-area {
    position: relative;
    width: 100%;
    max-width: 600px;
    aspect-ratio: 1;
    background-color: #f1f5f9;
    border-radius: 16px;
    border: 2px dashed #cccccc;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: visible;
    margin-bottom: 24px;
    transition: transform 0.8s cubic-bezier(0.2, 0.8, 0.2, 1), box-shadow 0.8s ease;
    transform-style: preserve-3d;
}

/* True 3D Container */
.ai-three-container {
    position: absolute;
    inset: 0;
    z-index: 20;
    border-radius: 16px;
    overflow: hidden;
    background-color: #f1f5f9;
}

.ai-grid-cell {
    border-radius: 12px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    transition: all 0.5s cubic-bezier(0.2, 0.8, 0.2, 1);
    border: 1px solid rgba(255,255,255,0.2);
    transform-style: preserve-3d;
}

.ai-room-dropped {
    margin-top: 8px;
    background: rgba(255,255,255,0.95);
    color: #333333;
    padding: 6px 12px;
    border-radius: 8px;
    font-size: 12px;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 6px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.2);
    transition: transform 0.5s;
}

/* Duplicate .ai-map-area removed */

.ai-compass {
    position: absolute;
    top: 16px;
    left: 16px;
    background: rgba(255,255,255,0.9);
    padding: 4px 12px;
    border-radius: 8px;
    font-weight: 700;
    font-size: 14px;
    color: #333333;
    z-index: 10;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

.ai-loading-overlay {
    position: absolute;
    inset: 0;
    background: rgba(51, 51, 51, 0.8);
    backdrop-filter: blur(4px);
    z-index: 50;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: white;
}

.ai-spin {
    font-size: 48px;
    animation: spin 2s linear infinite;
    margin-bottom: 16px;
}

@keyframes spin { 100% { transform: rotate(360deg); } }

/* Grid */
.ai-grid {
    position: absolute;
    inset: 12px;
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    grid-template-rows: repeat(3, 1fr);
    gap: 8px;
    z-index: 5;
}

.ai-grid-cell {
    border-radius: 12px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    border: 1px solid rgba(255,255,255,0.2);
}

.ai-grid-cell.drag-over {
    border: 3px dashed #333333;
    opacity: 0.8;
}

.ai-cell-value {
    font-size: 32px;
    font-weight: 700;
    text-shadow: 0 2px 4px rgba(0,0,0,0.2);
}

.ai-room-dropped {
    margin-top: 8px;
    background: rgba(255,255,255,0.95);
    color: #333333;
    padding: 6px 12px;
    border-radius: 8px;
    font-size: 12px;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 6px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.2);
}

/* Legend */
.ai-map-legend {
    display: flex;
    align-items: center;
    gap: 16px;
    width: 100%;
    max-width: 600px;
}

.ai-legend-bar {
    flex: 1;
    height: 12px;
    border-radius: 6px;
}

.ai-legend-labels {
    display: flex;
    justify-content: space-between;
    width: 100%;
    font-size: 12px;
    color: #666666;
    margin-top: 4px;
}

.ai-legend-wrap {
    flex: 1;
}

.ai-map-hint {
    font-size: 13px;
    color: #999999;
    margin-top: 24px;
}

/* Right Sidebar */
.ai-card-header-icon {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 8px;
}

.ai-card-header-icon h2 {
    font-size: 16px;
    font-weight: 700;
    color: #333333;
}

.ai-subtitle {
    font-size: 13px;
    color: #666666;
    margin-bottom: 24px;
}

.ai-comfort-score-box {
    background: #333333;
    border-radius: 12px;
    padding: 16px;
    text-align: center;
    color: #ffffff;
    margin-bottom: 24px;
    display: flex;
    flex-direction: column;
}

.ai-comfort-score-box span {
    font-size: 12px;
    color: #cccccc;
}

.ai-comfort-score-box strong {
    font-size: 40px;
    font-weight: 700;
    color: #d0ff2c;
    line-height: 1.1;
}

.ai-room-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.ai-room-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px;
    background: #f9f9f9;
    border: 1px solid #e5e7eb;
    border-radius: 12px;
    cursor: grab;
    transition: all 0.2s;
}

.ai-room-item:active {
    cursor: grabbing;
}

.ai-room-item:hover {
    border-color: #fc5b08;
    background: #fff1ec;
}

.ai-room-item .material-symbols-outlined {
    font-size: 24px;
    color: #666666;
    background: #ffffff;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
    border: 1px solid #e5e7eb;
}

.ai-room-info {
    display: flex;
    flex-direction: column;
}

.ai-room-info strong {
    font-size: 14px;
    color: #333333;
}

.ai-room-info span {
    font-size: 11px;
    color: #999999;
}

.ai-room-item.dragged {
    opacity: 0.5;
}

.ai-btn-outline {
    background: transparent;
    border: 1px solid #e5e7eb;
    color: #666666;
    padding: 10px;
    border-radius: 8px;
    font-family: inherit;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.ai-btn-outline:hover {
    border-color: #333333;
    color: #333333;
}

/* AI Recommendation */
.ai-recommendation {
    background: #fafafa;
}

.ai-rec-content {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.ai-rec-item {
    font-size: 13px;
    color: #666666;
}

.ai-rec-item strong {
    color: #333333;
    display: block;
    margin-bottom: 4px;
}

.ai-tag {
    display: inline-block;
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 11px;
    font-weight: 600;
    margin-right: 4px;
}

.ai-tag-green { background: #dcfce7; color: #166534; }
.ai-tag-orange { background: #ffedd5; color: #9a3412; }
.ai-tag-cyan { background: #cffafe; color: #155e75; }
.ai-tag-purple { background: #f3e8ff; color: #6b21a8; }

/* Responsive */
@media (max-width: 1200px) {
    .ai-container {
        grid-template-columns: 1fr;
    }
}

/* Finance dashboard theme alignment: AI/status tags only */
.ai-tag-green,
.ai-tag-orange,
.ai-tag-cyan,
.ai-tag-purple,
.ai-tag {
    background: var(--synto-primary-soft, #FFF4E6) !important;
    color: var(--synto-primary-strong, #e04f05) !important;
}

.ai-card,
.solar-card,
.insight-card,
.metric-card {
    background: var(--synto-surface, #ffffff) !important;
    border-color: var(--synto-line, rgba(102, 102, 102, 0.22)) !important;
    box-shadow: var(--synto-shadow-card, 0 4px 20px -2px rgba(0, 0, 0, 0.05)) !important;
}
