/* ═══════════════════════════════════════════════════════════════
   BRICKLAYER-β — Digital Habitat Stylesheet
   Matches the Lovable mockup: cyberpunk/neon CRT aesthetic
   ═══════════════════════════════════════════════════════════════ */

@import url('https://fonts.googleapis.com/css2?family=Share+Tech+Mono&family=Orbitron:wght@400;500;600;700&display=swap');

/* ── Tokens ── */
:root {
    --bg: hsl(240, 20%, 4%);
    --fg: hsl(180, 100%, 90%);
    --card: hsl(240, 18%, 7%);
    --card-end: hsl(240, 20%, 5%);
    --border: hsl(240, 15%, 15%);
    --muted: hsl(240, 15%, 12%);
    --muted-fg: hsl(220, 10%, 50%);

    --teal: hsl(168, 100%, 50%);
    --purple: hsl(270, 100%, 65%);
    --amber: hsl(40, 100%, 50%);
    --green: hsl(120, 100%, 60%);
    --blue: hsl(210, 100%, 60%);
    --red: hsl(0, 100%, 60%);

    --glow-teal: 0 0 8px hsl(168 100% 50% / 0.6), 0 0 20px hsl(168 100% 50% / 0.3);
    --glow-purple: 0 0 8px hsl(270 100% 65% / 0.6), 0 0 20px hsl(270 100% 65% / 0.3);
    --glow-amber: 0 0 8px hsl(40 100% 50% / 0.6), 0 0 20px hsl(40 100% 50% / 0.3);

    --radius: 3px;
}

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

html {
    font-size: 14px;
}

body {
    font-family: 'Share Tech Mono', monospace;
    background: var(--bg);
    color: var(--fg);
    min-height: 100vh;
    overflow-x: hidden;
}

/* ── Typography ── */
.font-display {
    font-family: 'Orbitron', sans-serif;
}

.neon-text-teal {
    color: var(--teal);
    text-shadow: var(--glow-teal);
}

.neon-text-purple {
    color: var(--purple);
    text-shadow: var(--glow-purple);
}

.neon-text-amber {
    color: var(--amber);
    text-shadow: var(--glow-amber);
}

/* ── Overlays ── */
.particles-canvas {
    position: fixed;
    inset: 0;
    pointer-events: none;
    z-index: 0;
}

.crt-overlay {
    pointer-events: none;
    position: fixed;
    inset: 0;
    z-index: 9999;
    background: repeating-linear-gradient(0deg,
            transparent, transparent 2px,
            hsl(0 0% 0% / 0.08) 2px,
            hsl(0 0% 0% / 0.08) 4px);
    opacity: 0.4;
}

/* ── App shell ── */
.app-shell {
    position: relative;
    z-index: 10;
    max-width: 1400px;
    margin: 0 auto;
    padding: 12px 16px;
}

/* ── Header ── */
.header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 16px;
    animation: fadeSlideDown 0.4s ease-out;
}

.header-left {
    display: flex;
    align-items: center;
    gap: 12px;
}

.header-icon {
    width: 32px;
    height: 32px;
    border-radius: var(--radius);
    border: 1px solid var(--border);
    background: var(--card);
    display: flex;
    align-items: center;
    justify-content: center;
}

.beta-symbol {
    font-size: 14px;
}

.header-title {
    font-family: 'Orbitron', sans-serif;
    font-size: 14px;
    letter-spacing: 0.15em;
}

.header-subtitle {
    font-size: 10px;
    color: var(--muted-fg);
    letter-spacing: 0.12em;
}

.header-right {
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 10px;
    color: var(--muted-fg);
}

.status-dot {
    color: var(--teal);
    font-size: 14px;
}

.status-dot.offline {
    color: var(--red);
}

/* Header badge pill */
.header-badge-pill {
    font-family: 'Share Tech Mono', monospace;
    font-size: 10px;
    color: var(--teal);
    border: 1px solid hsl(168 100% 50% / 0.3);
    border-radius: 12px;
    padding: 2px 8px;
    background: hsl(168 100% 50% / 0.08);
    white-space: nowrap;
}

/* ── Panel base ── */
.panel {
    background: linear-gradient(135deg, var(--card) 0%, var(--card-end) 100%);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 12px;
    box-shadow: inset 0 1px 0 hsl(168 100% 50% / 0.1), 0 0 20px hsl(0 0% 0% / 0.5);
    transition: border-color 0.4s ease, box-shadow 0.4s ease;
}

.panel:hover {
    border-color: hsl(168 100% 50% / 0.2);
    box-shadow: inset 0 1px 0 hsl(168 100% 50% / 0.15), 0 0 30px hsl(168 100% 50% / 0.08);
}

.panel-header {
    font-family: 'Orbitron', sans-serif;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.15em;
    color: hsl(168 100% 50% / 0.7);
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 8px;
    padding-bottom: 6px;
    border-bottom: 1px solid var(--border);
}

.header-badge {
    margin-left: auto;
    font-size: 10px;
}

/* ── Dots ── */
.dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    display: inline-block;
    flex-shrink: 0;
}

.dot-teal {
    background: var(--teal);
}

.dot-amber {
    background: var(--amber);
}

.dot-green {
    background: var(--green);
}

.dot-blue {
    background: var(--blue);
}

.dot-purple {
    background: var(--purple);
}

/* ── Main grid ── */
.main-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 12px;
}

@media (min-width: 1024px) {
    .main-grid {
        grid-template-columns: 3fr 5fr 4fr;
        gap: 16px;
    }
}

/* ── Activity Panel ── */
.activity-panel {
    height: 500px;
    display: flex;
    flex-direction: column;
}

.current-action {
    font-size: 12px;
    padding: 4px 6px;
    margin-bottom: 8px;
    border-radius: var(--radius);
    background: hsl(240 15% 12% / 0.3);
    border: 1px solid var(--border);
}

.action-arrow {
    font-size: 10px;
}

.activity-log {
    flex: 1;
    overflow-y: auto;
    font-size: 11px;
}

.activity-entry {
    display: flex;
    gap: 6px;
    padding: 2px 0;
    animation: slideInLeft 0.3s ease-out;
}

.activity-entry .ts {
    color: var(--muted-fg);
    white-space: nowrap;
}

.activity-entry .tag {
    white-space: nowrap;
}

.activity-entry .msg {
    color: hsl(180 100% 90% / 0.7);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.tag-work {
    color: var(--teal);
}

.tag-sleep {
    color: var(--purple);
}

.tag-learn {
    color: var(--amber);
}

.tag-idle {
    color: var(--muted-fg);
}

.tag-deco {
    color: var(--purple);
}

.tag-task {
    color: var(--blue);
}

.tag-cron {
    color: var(--green);
}

/* ── Agent Room ── */
.agent-room-panel {
    min-height: 320px;
}

.agent-room-body {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: calc(100% - 32px);
    gap: 16px;
    position: relative;
}

/* Avatar */
.avatar-container {
    position: relative;
}

.avatar-glow {
    position: absolute;
    inset: -12px;
    border-radius: 50%;
    background: radial-gradient(circle, hsl(168 100% 50% / 0.15) 0%, transparent 70%);
    animation: glowPulse 3s ease-in-out infinite;
}

.avatar-core {
    width: 80px;
    height: 80px;
    border-radius: 8px;
    border: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    overflow: hidden;
    background: linear-gradient(135deg, hsl(240 18% 10%), hsl(240 18% 6%));
    box-shadow: 0 0 20px hsl(168 100% 50% / 0.2);
    animation: avatarFloat 3s ease-in-out infinite;
}

.avatar-eyes {
    display: flex;
    gap: 8px;
    align-items: center;
}

.eye {
    width: 12px;
    height: 12px;
    border-radius: 2px;
    background: var(--teal);
    animation: blink 4s ease-in-out infinite;
}

.eye-right {
    animation-delay: 0.1s;
}

.avatar-desk {
    position: absolute;
    bottom: 4px;
    left: 50%;
    transform: translateX(-50%);
    width: 48px;
    height: 3px;
    border-radius: 2px;
    background: var(--teal);
    opacity: 0;
    transition: opacity 0.5s;
}

/* State-specific overrides applied via JS data-state attribute */
.avatar-core[data-state="sleeping"] {
    box-shadow: 0 0 20px hsl(270 100% 65% / 0.2);
    animation: avatarSleep 4s ease-in-out infinite;
}

.avatar-core[data-state="sleeping"] .eye {
    background: var(--purple);
    animation: sleepEyes 3s ease-in-out infinite;
}

.avatar-core[data-state="sleeping"] .avatar-glow {
    background: radial-gradient(circle, hsl(270 100% 65% / 0.15) 0%, transparent 70%);
}

.avatar-core[data-state="working"] .avatar-desk {
    opacity: 0.6;
    animation: deskPulse 1s ease-in-out infinite;
}

.avatar-core[data-state="working"] {
    animation: avatarWork 3s ease-in-out infinite;
}

.avatar-core[data-state="learning"] {
    animation: avatarLearn 3s ease-in-out infinite;
}

.avatar-core[data-state="learning"] .eye {
    background: var(--amber);
}

.avatar-core[data-state="redecorating"] {
    animation: avatarDeco 2s ease-in-out infinite;
}

.avatar-core[data-state="chatting"] {
    animation: avatarFloat 2s ease-in-out infinite;
    box-shadow: 0 0 24px hsl(168 100% 50% / 0.35);
}

.avatar-core[data-state="chatting"] .eye {
    animation: blink 1.5s ease-in-out infinite;
}

.avatar-core[data-state="monitoring"] {
    animation: avatarLearn 4s ease-in-out infinite;
    box-shadow: 0 0 20px hsl(40 100% 50% / 0.2);
}

.avatar-core[data-state="monitoring"] .eye {
    background: var(--amber);
}

.state-label {
    font-family: 'Orbitron', sans-serif;
    font-size: 13px;
    letter-spacing: 0.12em;
}

.room-action {
    font-size: 12px;
    color: var(--muted-fg);
    text-align: center;
    max-width: 200px;
}

.room-furniture {
    position: absolute;
    bottom: 8px;
    left: 8px;
    right: 8px;
    display: flex;
    justify-content: space-between;
    font-size: 8px;
    color: var(--muted-fg);
}

/* ── Agent Network ── */
.agent-network-panel {}

.network-map {
    position: relative;
    height: 160px;
    overflow: hidden;
    border-radius: var(--radius);
    background: hsl(240 15% 12% / 0.15);
}

.network-svg {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
}

.network-node {
    position: absolute;
    display: flex;
    flex-direction: column;
    align-items: center;
    transition: left 1s ease, top 1s ease;
}

.network-node .node-dot {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: var(--teal);
    box-shadow: 0 0 8px hsl(168 100% 50% / 0.5);
    animation: nodePulse 2s ease-in-out infinite;
}

.network-node .node-dot.inactive {
    background: hsl(220 10% 50% / 0.3);
    box-shadow: none;
    animation: none;
}

.network-node .node-name {
    font-size: 8px;
    margin-top: 2px;
    white-space: nowrap;
    color: var(--muted-fg);
}

.network-node .node-name.primary {
    color: var(--teal);
    text-shadow: var(--glow-teal);
}

/* ── Vitals Panel ── */
.vitals-panel {}

.vitals-status-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 8px;
}

.vitals-state {
    font-size: 10px;
    letter-spacing: 0.12em;
}

.vitals-uptime {
    font-size: 10px;
    color: var(--muted-fg);
}

/* ECG */
.ecg-container {
    position: relative;
    height: 32px;
    overflow: hidden;
    border-radius: var(--radius);
    background: hsl(240 15% 12% / 0.3);
    margin-bottom: 12px;
}

.ecg-svg {
    position: absolute;
    top: 0;
    left: 0;
    width: 200%;
    height: 100%;
    animation: ecgScroll 2s linear infinite;
    filter: drop-shadow(0 0 3px hsl(168 100% 50% / 0.5));
}

.ecg-bpm {
    position: absolute;
    right: 4px;
    top: 3px;
    font-size: 10px;
}

/* Stat bars */
.stat-bar-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.stat-bar-label {
    display: flex;
    justify-content: space-between;
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--muted-fg);
    margin-bottom: 4px;
}

.stat-bar-track {
    height: 8px;
    background: hsl(240 15% 12% / 0.3);
    border-radius: var(--radius);
    overflow: hidden;
}

.stat-bar-fill {
    height: 100%;
    border-radius: var(--radius);
    transition: width 1s ease-out;
}

.bar-teal {
    background: linear-gradient(90deg, hsl(168 100% 40%), hsl(168 100% 50%));
    box-shadow: 0 0 8px hsl(168 100% 50% / 0.4);
}

.bar-amber {
    background: linear-gradient(90deg, hsl(40 100% 40%), hsl(40 100% 50%));
    box-shadow: 0 0 8px hsl(40 100% 50% / 0.4);
}

.bar-purple {
    background: linear-gradient(90deg, hsl(270 100% 55%), hsl(270 100% 65%));
    box-shadow: 0 0 8px hsl(270 100% 65% / 0.4);
}

/* ── Terminal Panel ── */
.terminal-panel {
    display: flex;
    flex-direction: column;
    height: 280px;
}

.terminal-log {
    flex: 1;
    overflow-y: auto;
    font-size: 12px;
    margin-bottom: 8px;
}

.terminal-msg {
    padding: 2px 0;
    animation: slideInLeft 0.3s ease-out;
}

.terminal-msg .ts {
    font-size: 10px;
    color: var(--muted-fg);
}

.terminal-msg .sender-user {
    color: var(--amber);
    text-shadow: var(--glow-amber);
}

.terminal-msg .sender-agent {
    color: var(--teal);
    text-shadow: var(--glow-teal);
}

.terminal-msg .body {
    white-space: pre-wrap;
    color: hsl(180 100% 90% / 0.8);
}

.terminal-msg .body-typing {
    color: hsl(180 100% 90% / 0.6);
}

.terminal-input-row {
    display: flex;
    gap: 6px;
}

.terminal-input-wrap {
    flex: 1;
    display: flex;
    align-items: center;
    gap: 6px;
    background: hsl(240 15% 12% / 0.3);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 0 8px;
}

.terminal-input-wrap input {
    flex: 1;
    background: transparent;
    border: none;
    outline: none;
    color: var(--fg);
    font-family: 'Share Tech Mono', monospace;
    font-size: 12px;
    padding: 6px 0;
}

.terminal-input-wrap input::placeholder {
    color: var(--muted-fg);
}

.mic-btn {
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: hsl(240 15% 12% / 0.3);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--muted-fg);
    cursor: pointer;
    transition: color 0.2s, border-color 0.2s;
}

.mic-btn:hover {
    color: var(--teal);
    border-color: hsl(168 100% 50% / 0.3);
}

/* ── Scrollbar ── */
.retro-scrollbar::-webkit-scrollbar {
    width: 6px;
}

.retro-scrollbar::-webkit-scrollbar-track {
    background: var(--muted);
}

.retro-scrollbar::-webkit-scrollbar-thumb {
    background: hsl(168 100% 50% / 0.3);
    border-radius: 0;
}

/* ── Footer ── */
.footer {
    margin-top: 16px;
    text-align: center;
    font-size: 9px;
    letter-spacing: 0.15em;
    color: var(--muted-fg);
    opacity: 0.5;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0;
    flex-wrap: wrap;
}

.footer-sep {
    margin: 0 6px;
}

/* ═══════════ Animations ═══════════ */
@keyframes fadeSlideDown {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes slideInLeft {
    from {
        opacity: 0;
        transform: translateX(-10px);
    }

    to {
        opacity: 1;
        transform: translateX(0);
    }
}

@keyframes glowPulse {

    0%,
    100% {
        transform: scale(1);
        opacity: 0.5;
    }

    50% {
        transform: scale(1.15);
        opacity: 0.8;
    }
}

@keyframes blink {

    0%,
    90%,
    100% {
        transform: scaleY(1);
    }

    95% {
        transform: scaleY(0.1);
    }
}

@keyframes sleepEyes {

    0%,
    100% {
        transform: scaleY(0.1);
        opacity: 0.3;
    }

    50% {
        transform: scaleY(0.1);
        opacity: 0.5;
    }
}

@keyframes avatarFloat {

    0%,
    100% {
        transform: translateY(0);
    }

    50% {
        transform: translateY(-3px);
    }
}

@keyframes avatarSleep {

    0%,
    100% {
        transform: translateY(0) scale(1);
    }

    50% {
        transform: translateY(4px) scale(0.98);
    }
}

@keyframes avatarWork {

    0%,
    100% {
        transform: translateY(0);
    }

    50% {
        transform: translateY(-2px);
    }
}

@keyframes avatarLearn {

    0%,
    100% {
        transform: rotate(0deg);
    }

    25% {
        transform: rotate(1deg);
    }

    75% {
        transform: rotate(-1deg);
    }
}

@keyframes avatarDeco {
    0% {
        transform: translateX(0);
    }

    20% {
        transform: translateX(-8px);
    }

    40% {
        transform: translateX(8px);
    }

    60% {
        transform: translateX(-4px);
    }

    80% {
        transform: translateX(4px);
    }

    100% {
        transform: translateX(0);
    }
}

@keyframes deskPulse {

    0%,
    100% {
        opacity: 0.3;
    }

    50% {
        opacity: 0.8;
    }
}

@keyframes ecgScroll {
    from {
        transform: translateX(0);
    }

    to {
        transform: translateX(-50%);
    }
}

@keyframes nodePulse {

    0%,
    100% {
        transform: scale(1);
    }

    50% {
        transform: scale(1.2);
    }
}

@keyframes pulseGlow {

    0%,
    100% {
        opacity: 0.6;
    }

    50% {
        opacity: 1;
    }
}

@keyframes blinkCursor {

    0%,
    100% {
        opacity: 1;
    }

    50% {
        opacity: 0;
    }
}

@keyframes pulseSlow {

    0%,
    100% {
        opacity: 0.5;
    }

    50% {
        opacity: 1;
    }
}

.pulse-glow {
    animation: pulseGlow 2s ease-in-out infinite;
}

.blink-cursor {
    animation: blinkCursor 1s step-end infinite;
}

.pulse-text {
    animation: pulseSlow 2s ease-in-out infinite;
}

.pulse-slow {
    animation: pulseSlow 3s ease-in-out infinite;
}

/* ── Responsive ── */
@media (max-width: 1023px) {
    .activity-panel {
        height: 300px;
    }

    .col-center {
        order: -1;
    }

    .network-map {
        height: 120px;
    }
}

@media (max-width: 600px) {
    .app-shell {
        padding: 6px;
    }

    .header {
        flex-wrap: wrap;
        gap: 8px;
    }

    .header-title {
        font-size: 11px;
    }

    .header-right {
        font-size: 9px;
    }

    .panel {
        padding: 8px;
    }

    .panel-header {
        font-size: 9px;
    }

    .terminal-panel {
        height: 220px;
    }

    .avatar-core {
        width: 60px;
        height: 60px;
    }

    .footer {
        font-size: 7px;
        flex-direction: column;
        gap: 2px;
    }

    .footer-sep {
        display: none;
    }
}
