/* ===== Reset & Base ===== */
*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html, body {
    width: 100%;
    min-height: 100%;
    background: #0D0D14;
    color: #e0e0e0;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    -webkit-font-smoothing: antialiased;
}

a { color: inherit; text-decoration: none; }

/* ===== Top Nav ===== */
#top-nav {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: 56px;
    z-index: 100;
    display: flex;
    align-items: center;
    padding: 0 24px;
    background: rgba(20, 20, 30, 0.65);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.nav-brand {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-shrink: 0;
}

.nav-brand svg {
    color: #4a9eff;
}

.nav-title {
    font-size: 16px;
    font-weight: 600;
    color: #ffffff;
    letter-spacing: 0.01em;
}

#breadcrumbs {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-left: 24px;
    font-size: 14px;
    color: rgba(255, 255, 255, 0.4);
    min-width: 0;
    overflow: hidden;
}

#breadcrumbs a {
    color: rgba(255, 255, 255, 0.4);
    transition: color 0.15s;
    white-space: nowrap;
}

#breadcrumbs a:hover {
    color: #ffffff;
}

#breadcrumbs .sep {
    color: rgba(255, 255, 255, 0.2);
    flex-shrink: 0;
}

#breadcrumbs .current {
    color: rgba(255, 255, 255, 0.8);
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

#nav-actions {
    margin-left: auto;
    display: flex;
    align-items: center;
    gap: 8px;
}

/* ===== Main Content ===== */
#app {
    max-width: 1200px;
    margin: 0 auto;
    padding: 80px 24px 40px;
    min-height: 100vh;
}

/* ===== Page Header ===== */
.page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 24px;
}

.page-title {
    font-size: 24px;
    font-weight: 600;
    color: #ffffff;
}

.page-subtitle {
    font-size: 14px;
    color: rgba(255, 255, 255, 0.4);
    margin-top: 2px;
}

/* ===== Project Cards Grid ===== */
.projects-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
    gap: 16px;
}

.project-card {
    display: block;
    padding: 20px;
    background: rgba(20, 20, 30, 0.6);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid rgba(255, 255, 255, 0.06);
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.15s ease;
}

.project-card:hover {
    background: rgba(30, 30, 45, 0.7);
    border-color: rgba(255, 255, 255, 0.12);
}

.project-card-name {
    font-size: 16px;
    font-weight: 600;
    color: #ffffff;
    margin-bottom: 4px;
}

.project-card-address {
    font-size: 13px;
    color: rgba(255, 255, 255, 0.4);
    margin-bottom: 16px;
}

.project-card-progress {
    margin-bottom: 8px;
}

.progress-bar-track {
    width: 100%;
    height: 4px;
    background: rgba(255, 255, 255, 0.08);
    border-radius: 2px;
    overflow: hidden;
}

.progress-bar-fill {
    height: 100%;
    background: linear-gradient(90deg, #4a9eff, #7b6fff);
    border-radius: 2px;
    transition: width 0.3s ease;
}

.project-card-stats {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 13px;
    color: rgba(255, 255, 255, 0.5);
}

.project-card-date {
    font-size: 12px;
    color: rgba(255, 255, 255, 0.25);
}

/* ===== Metrics Row ===== */
.metrics-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 12px;
    margin-bottom: 24px;
}

.metric-card {
    padding: 16px;
    background: rgba(20, 20, 30, 0.6);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid rgba(255, 255, 255, 0.06);
    border-radius: 12px;
    text-align: center;
}

.metric-label {
    font-size: 11px;
    color: rgba(255, 255, 255, 0.35);
    text-transform: uppercase;
    letter-spacing: 0.06em;
    font-weight: 600;
    margin-bottom: 6px;
}

.metric-value {
    font-size: 28px;
    font-weight: 700;
    color: #ffffff;
    font-variant-numeric: tabular-nums;
}

.metric-value.accent {
    background: linear-gradient(135deg, #4a9eff, #7b6fff);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

/* ===== Panel (glassmorphic container) ===== */
.panel {
    background: rgba(20, 20, 30, 0.6);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid rgba(255, 255, 255, 0.06);
    border-radius: 12px;
    margin-bottom: 16px;
    overflow: hidden;
}

.panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 18px;
    cursor: pointer;
    transition: background 0.15s;
}

.panel-header:hover {
    background: rgba(255, 255, 255, 0.03);
}

.panel-title {
    font-size: 14px;
    font-weight: 600;
    color: rgba(255, 255, 255, 0.9);
}

.panel-badge {
    font-size: 12px;
    color: rgba(255, 255, 255, 0.4);
    font-variant-numeric: tabular-nums;
}

.panel-chevron {
    color: rgba(255, 255, 255, 0.3);
    transition: transform 0.2s ease;
    font-size: 12px;
}

.panel-chevron.collapsed {
    transform: rotate(-90deg);
}

.panel-body {
    padding: 0 18px 14px;
}

.panel-body.collapsed {
    display: none;
}

/* ===== Room Table ===== */
.room-table {
    width: 100%;
}

.room-table-header {
    display: grid;
    grid-template-columns: 2fr 1fr 1fr 1fr 1fr 80px;
    gap: 8px;
    padding: 8px 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.room-table-header span {
    font-size: 11px;
    color: rgba(255, 255, 255, 0.3);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    font-weight: 600;
}

.room-row {
    display: grid;
    grid-template-columns: 2fr 1fr 1fr 1fr 1fr 80px;
    gap: 8px;
    padding: 10px 0;
    align-items: center;
    border-bottom: 1px solid rgba(255, 255, 255, 0.03);
    transition: background 0.15s;
}

.room-row:hover {
    background: rgba(255, 255, 255, 0.03);
}

.room-row:last-child {
    border-bottom: none;
}

.room-name {
    font-size: 14px;
    font-weight: 500;
    color: rgba(255, 255, 255, 0.9);
}

.room-name a {
    transition: color 0.15s;
}

.room-name a:hover {
    color: #4a9eff;
}

.room-type {
    font-size: 13px;
    color: rgba(255, 255, 255, 0.4);
}

.room-dim {
    font-size: 13px;
    color: rgba(255, 255, 255, 0.6);
    font-variant-numeric: tabular-nums;
}

.room-count {
    font-size: 13px;
    color: rgba(255, 255, 255, 0.5);
    font-variant-numeric: tabular-nums;
}

/* ===== Status Badge ===== */
.status-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    font-weight: 500;
}

.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    flex-shrink: 0;
}

.status-dot.completed { background: #44cc66; }
.status-dot.processing { background: #4a9eff; animation: pulse 1.5s infinite; }
.status-dot.uploading { background: #ffcc00; animation: pulse 1.5s infinite; }
.status-dot.failed { background: #ff4444; }
.status-dot.pending { background: rgba(255, 255, 255, 0.25); }

.status-text.completed { color: #44cc66; }
.status-text.processing { color: #4a9eff; }
.status-text.uploading { color: #ffcc00; }
.status-text.failed { color: #ff4444; }
.status-text.pending { color: rgba(255, 255, 255, 0.35); }

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.4; }
}

/* ===== View Button ===== */
.view-btn {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 6px 12px;
    background: rgba(74, 158, 255, 0.15);
    border: none;
    border-radius: 8px;
    color: #4a9eff;
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.15s;
    text-decoration: none;
}

.view-btn:hover {
    background: rgba(74, 158, 255, 0.25);
}

/* ===== Room Detail Layout ===== */
.room-detail-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
    align-items: start;
}

/* ===== Info Rows (takeoffs) ===== */
.info-section-title {
    font-size: 10px;
    color: rgba(255, 255, 255, 0.25);
    text-transform: uppercase;
    letter-spacing: 0.08em;
    font-weight: 600;
    padding-bottom: 4px;
}

.info-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 5px 0;
}

.info-row + .info-row {
    border-top: 1px solid rgba(255, 255, 255, 0.04);
    margin-top: 3px;
    padding-top: 8px;
}

.info-label {
    font-size: 13px;
    color: rgba(255, 255, 255, 0.45);
}

.info-value {
    font-size: 14px;
    color: rgba(255, 255, 255, 0.85);
    font-weight: 500;
    font-variant-numeric: tabular-nums;
}

/* ===== Scope Items ===== */
.scope-item {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 10px 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.04);
}

.scope-item:last-child {
    border-bottom: none;
}

.scope-status-icon {
    margin-top: 2px;
    font-size: 16px;
    flex-shrink: 0;
}

.scope-status-icon.completed { color: #44cc66; }
.scope-status-icon.pending { color: rgba(255, 255, 255, 0.25); }
.scope-status-icon.in_progress { color: #4a9eff; }

.scope-text {
    flex: 1;
    min-width: 0;
}

.scope-description {
    font-size: 14px;
    color: rgba(255, 255, 255, 0.85);
    line-height: 1.4;
}

.scope-description.completed {
    text-decoration: line-through;
    color: rgba(255, 255, 255, 0.35);
}

.trade-badge {
    display: inline-block;
    font-size: 11px;
    font-weight: 500;
    padding: 2px 8px;
    border-radius: 4px;
    margin-top: 4px;
    text-transform: capitalize;
}

/* Trade badge colors */
.trade-plumbing { background: rgba(59, 130, 246, 0.15); color: #60a5fa; }
.trade-electrical { background: rgba(234, 179, 8, 0.15); color: #facc15; }
.trade-hvac { background: rgba(6, 182, 212, 0.15); color: #22d3ee; }
.trade-framing { background: rgba(161, 98, 7, 0.15); color: #d97706; }
.trade-drywall { background: rgba(156, 163, 175, 0.15); color: #9ca3af; }
.trade-painting { background: rgba(168, 85, 247, 0.15); color: #a855f7; }
.trade-flooring { background: rgba(249, 115, 22, 0.15); color: #f97316; }
.trade-demolition { background: rgba(239, 68, 68, 0.15); color: #ef4444; }
.trade-general { background: rgba(255, 255, 255, 0.08); color: rgba(255, 255, 255, 0.6); }
.trade-default { background: rgba(255, 255, 255, 0.06); color: rgba(255, 255, 255, 0.5); }

/* ===== Annotation Items ===== */
.annotation-item {
    padding: 10px 12px;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.05);
    border-radius: 8px;
    margin-bottom: 8px;
}

.annotation-item-header {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 4px;
}

.annotation-type-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    flex-shrink: 0;
}

.annotation-type-dot.problem { background: #ff4444; }
.annotation-type-dot.trade { background: #4488ff; }
.annotation-type-dot.note { background: #ffcc00; }
.annotation-type-dot.measurement { background: #44cc66; }
.annotation-type-dot.photo { background: #aa66ff; }

.annotation-item-title {
    font-size: 13px;
    font-weight: 500;
    color: rgba(255, 255, 255, 0.85);
}

.annotation-item-meta {
    font-size: 11px;
    color: rgba(255, 255, 255, 0.35);
    margin-left: 16px;
    margin-top: 2px;
}

.annotation-item-details {
    font-size: 12px;
    color: rgba(255, 255, 255, 0.4);
    margin-left: 16px;
    margin-top: 4px;
    line-height: 1.4;
}

/* ===== Action Buttons ===== */
.action-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
    padding: 10px 14px;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(255, 255, 255, 0.06);
    border-radius: 8px;
    color: rgba(255, 255, 255, 0.7);
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.15s;
    text-decoration: none;
    margin-bottom: 6px;
}

.action-btn:hover {
    background: rgba(255, 255, 255, 0.08);
    color: #ffffff;
}

.action-btn.primary {
    background: linear-gradient(135deg, #4a9eff, #6b5fff);
    border: none;
    color: #ffffff;
}

.action-btn.primary:hover {
    opacity: 0.85;
}

.action-btn svg {
    flex-shrink: 0;
}

/* ===== Nav Action Button ===== */
.nav-btn {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 14px;
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 8px;
    color: rgba(255, 255, 255, 0.7);
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.15s;
    text-decoration: none;
}

.nav-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    color: #ffffff;
}

/* ===== Loading / Empty / Error ===== */
.state-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 300px;
    color: rgba(255, 255, 255, 0.35);
    text-align: center;
    gap: 12px;
}

.state-container svg {
    opacity: 0.3;
}

.state-container .state-title {
    font-size: 16px;
    font-weight: 500;
    color: rgba(255, 255, 255, 0.5);
}

.state-container .state-detail {
    font-size: 14px;
    color: rgba(255, 255, 255, 0.3);
    max-width: 400px;
}

.spinner {
    width: 32px;
    height: 32px;
    border: 3px solid rgba(255, 255, 255, 0.1);
    border-top-color: #4a9eff;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

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

/* ===== Responsive ===== */
@media (max-width: 1024px) {
    .room-detail-grid {
        grid-template-columns: 1fr;
    }

    .room-table-header,
    .room-row {
        grid-template-columns: 2fr 1fr 1fr 80px;
    }

    .room-table-header span:nth-child(4),
    .room-table-header span:nth-child(5),
    .room-row > *:nth-child(4),
    .room-row > *:nth-child(5) {
        display: none;
    }
}

@media (max-width: 600px) {
    #app {
        padding: 72px 16px 24px;
    }

    .projects-grid {
        grid-template-columns: 1fr;
    }

    .metrics-row {
        grid-template-columns: 1fr 1fr;
    }

    .room-table-header,
    .room-row {
        grid-template-columns: 2fr 1fr 80px;
    }

    .room-table-header span:nth-child(3),
    .room-table-header span:nth-child(4),
    .room-table-header span:nth-child(5),
    .room-row > *:nth-child(3),
    .room-row > *:nth-child(4),
    .room-row > *:nth-child(5) {
        display: none;
    }

    #breadcrumbs {
        display: none;
    }
}
