/* ═══════════════════════════════════════════════
   S.H.E.E.P. Mesh Dashboard — Styles
   ═══════════════════════════════════════════════ */

:root {
    --bg-color: #000;
    --mesh-color: rgba(255, 255, 255, 0.15);
    --text-main: #e0e0e0;
    --neon-tool: #ff00cc;
}

body {
    margin: 0;
    padding: 0;
    background-color: #000;
    color: var(--text-main);
    font-family: 'Courier New', Courier, monospace;
    height: 100vh;
    overflow: hidden;
}

/* ── LAYOUT ── */

#dashboard {
    width: 100vw;
    height: 100vh;
    position: relative;
    z-index: 1;
    display: flex;
    justify-content: center;
    align-items: center;
    overflow: hidden;
    background: transparent;
}

#dashboard::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-image:
        linear-gradient(rgba(255, 255, 255, 0.18) 1px, transparent 1px),
        linear-gradient(90deg, rgba(255, 255, 255, 0.18) 1px, transparent 1px);
    background-size: 50px 50px;
    pointer-events: none;
    z-index: -1;
}

#main-svg {
    position: absolute;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
}

/* ── SIDE PANEL ── */

#side-panel {
    position: absolute;
    right: 0;
    top: 0;
    height: 100%;
    width: 350px;
    background: rgba(10, 10, 10, 0.85);
    border-left: 2px solid #333;
    display: flex;
    flex-direction: column;
    padding: 20px;
    box-shadow: -10px 0 30px rgba(0, 0, 0, 0.9);
    z-index: 100;
    backdrop-filter: blur(8px);
    transition: transform 0.3s ease;
}

#side-panel.collapsed {
    transform: translateX(350px);
}

/* ── TOGGLE BUTTON (Royal Blue) ── */

#toggle-panel-btn {
    position: absolute;
    left: -40px;
    top: 20px;
    width: 40px;
    height: 40px;
    background: rgba(65, 105, 225, 0.2);
    border: 1px solid #4169E1;
    border-right: none;
    border-radius: 8px 0 0 8px;
    color: #4169E1;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    transition: all 0.3s ease;
}

#toggle-panel-btn:hover {
    background: rgba(65, 105, 225, 0.4);
}

/* ── SVG ANATOMY ── */

svg {
    max-width: 100%;
    max-height: 100%;
    display: block;
}



.neon-part {
    fill: none;
    stroke: var(--glow-color, #333);
    stroke-width: 4;
    stroke-linecap: round;
    stroke-linejoin: round;
    cursor: pointer;
    transition: all 0.3s ease;
    filter: drop-shadow(0 0 2px #fff) drop-shadow(0 0 8px var(--glow-color)) drop-shadow(0 0 15px var(--glow-color));
    transform-origin: center;
    transform-box: fill-box;
}

.neon-part:hover {
    filter: drop-shadow(0 0 5px #fff) drop-shadow(0 0 20px var(--glow-color)) drop-shadow(0 0 40px var(--glow-color)) brightness(1.5);
    stroke-width: 8;
    transform: scale(1.02);
    transition: all 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

/* ── DAEMON LED CIRCLES ── */

.daemon-led {
    r: 3px !important;
    transform-box: fill-box;
    transform-origin: center;
    transition: r 0.25s ease, filter 0.25s ease;
    cursor: crosshair;
}

.daemon-led:hover {
    transform: scale(3) !important;
    filter: drop-shadow(0 0 10px #fff) drop-shadow(0 0 30px var(--glow-color));
    stroke-width: 1;
    z-index: 999;
}
.daemon-led.highlight-led {
    transform: scale(4) !important;
    filter: drop-shadow(0 0 15px #fff) !important;
    stroke-width: 1px;
    z-index: 1000;
}
/* ── KEYFRAME ANIMATIONS ── */

@keyframes pulse-anim {
    0%, 100% { opacity: 0.8; filter: drop-shadow(0 0 5px var(--glow-color)); }
    50%      { opacity: 1;   filter: drop-shadow(0 0 15px var(--glow-color)); }
}

@keyframes blink-anim {
    0%, 50%      { opacity: 1;   filter: drop-shadow(0 0 10px var(--glow-color)); }
    50.1%, 100%  { opacity: 0.1; filter: none; }
}

@keyframes breath-anim {
    0%, 100% { opacity: 0.3; filter: drop-shadow(0 0 2px #fff); }
    50%      { opacity: 1;   filter: drop-shadow(0 0 10px #fff); }
}

@keyframes blink-royal-blue {
    0%, 20%, 40%, 60%, 80%, 100% { opacity: 1;   filter: drop-shadow(0 0 15px #4169E1); }
    10%, 30%, 50%, 70%, 90%      { opacity: 0.2; filter: none; }
}

@keyframes blink-offline {
    0%, 100% { opacity: 0.35; }
    50%      { opacity: 0.1; }
}

@keyframes blink-red-loop {
    0%, 40%  { opacity: 1;    filter: drop-shadow(0 0 15px #ff0000); }
    50%, 90% { opacity: 0.15; filter: none; }
    100%     { opacity: 1;    filter: drop-shadow(0 0 15px #ff0000); }
}

@keyframes blink-yellow-maint {
    0%, 45%  { opacity: 1;   filter: drop-shadow(0 0 12px #ffff00); }
    50%, 95% { opacity: 0.1; filter: none; }
    100%     { opacity: 1;   filter: drop-shadow(0 0 12px #ffff00); }
}

@keyframes tight-orbit {
    0%   { transform: translate(0, 0); }
    25%  { transform: translate(1.5px, -1.5px); }
    50%  { transform: translate(-1px, 1px); }
    75%  { transform: translate(1px, 1.5px); }
    100% { transform: translate(0, 0); }
}

@keyframes pulse-ring {
    0%   { transform: scale(1);   opacity: 1; }
    50%  { transform: scale(1.5); opacity: 0.5; }
    100% { transform: scale(1);   opacity: 1; }
}

@keyframes pulse-purple-anim {
    0%, 100% { opacity: 0.8; filter: drop-shadow(0 0 5px #8a2be2);  stroke: #8a2be2; }
    50%      { opacity: 1;   filter: drop-shadow(0 0 20px #8a2be2); stroke: #aa66ff; }
}

@keyframes pulse-red-anim {
    0%, 100% { opacity: 0.8; filter: drop-shadow(0 0 10px #ff0000); stroke: #ff0000; }
    50%      { opacity: 1;   filter: drop-shadow(0 0 30px #ff3333); stroke: #ff3333; }
}

@keyframes alarm-flash-red {
    0%, 50%      { opacity: 1;   filter: drop-shadow(0 0 40px #ff0000); stroke: #ff0000; }
    50.1%, 100%  { opacity: 0.2; filter: none; stroke: #333; }
}

/* ── ANIMATION CLASSES ── */

.pulse        { animation: pulse-anim 2s infinite ease-in-out; }
.blink        { animation: blink-anim 4s infinite; }
.pulse-purple { animation: pulse-purple-anim 4s infinite ease-in-out !important; }
.pulse-red    { animation: pulse-red-anim 1s infinite ease-in-out !important; }
.alarm-red    { animation: alarm-flash-red 6s infinite; }

/* LED state classes */
.daemon-led.led-active   { animation: tight-orbit 0.8s infinite ease-in-out; }
.daemon-led.led-sleep    { animation: pulse-purple-anim 4s infinite ease-in-out; }
.daemon-led.led-complete { animation: blink-royal-blue 0.2s infinite linear; }
.daemon-led.led-looping  { animation: blink-red-loop 0.6s infinite; }
.daemon-led.led-pending  { animation: breath-anim 4s infinite ease-in-out !important; }
.daemon-led.led-maint    { animation: blink-yellow-maint 2s infinite ease-in-out; }
.daemon-led.led-waiting  { animation: none; }
.daemon-led.led-offline  { animation: blink-offline 3s infinite ease-in-out; fill: #333 !important; stroke: #444 !important; }

/* ── TAB BAR ── */

.tab-bar {
    display: flex;
    gap: 10px;
    margin-bottom: 15px;
    border-bottom: 1px solid #444;
    padding-bottom: 10px;
}

.tab-btn {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid #444;
    color: #666;
    padding: 6px 14px;
    cursor: pointer;
    font-family: monospace;
    font-size: 10px;
    text-transform: uppercase;
}

.tab-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    color: #fff;
    transform: translateY(-3px) scale(1.1);
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.3);
}

.tab-btn.active {
    background: rgba(255, 0, 204, 0.2);
    color: var(--neon-tool);
    border-color: var(--neon-tool);
}

/* ── MONITOR & LOGS ── */

#mesh-logs-container,
#daemon-monitor {
    flex: 1;
    overflow-y: auto;
}

.log-entry {
    padding: 8px;
    border-left: 3px solid;
    background: rgba(255, 255, 255, 0.05);
    margin-bottom: 5px;
    font-size: 12px;
}

.log-box-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
}

.log-box {
    border: 1px solid #444;
    padding: 10px;
    cursor: pointer;
    font-size: 10px;
    text-align: center;
}

.log-box:hover {
    background: rgba(255, 0, 204, 0.1);
    border-color: var(--neon-tool);
}

/* ── NEON SCRIPT CARDS ── */

.script-box {
    border: 1px solid #333;
    background: rgba(0, 0, 0, 0.6);
    margin-bottom: 5px;
    padding: 8px 12px;
    font-size: 11px;
    display: flex;
    flex-direction: column;
    gap: 4px;
    transition: all 0.3s ease;
    border-radius: 6px;
    position: relative;
    overflow: hidden;
    animation: card-pulse 4s infinite ease-in-out;
}

@keyframes card-pulse {
    0%, 100% { box-shadow: 0 0 5px rgba(0,0,0,0.5), inset 0 0 5px rgba(255,255,255,0.02); }
    50%      { box-shadow: 0 0 15px var(--card-glow, rgba(255,0,204,0.1)), inset 0 0 10px rgba(255,255,255,0.05); }
}

.script-box::before {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0;
    height: 2px;
    background: linear-gradient(90deg, transparent, var(--card-glow, #333), transparent);
    opacity: 0.6;
}

.script-box:hover {
    background: rgba(255, 255, 255, 0.08);
    border-color: var(--card-glow, var(--neon-tool));
    box-shadow: 0 0 15px var(--card-glow, rgba(255, 0, 204, 0.2)), inset 0 0 20px rgba(255, 255, 255, 0.02);
    transform: translateY(-5px) scale(1.02);
}

.script-box.online {
    border-left: 3px solid #00ff00;
    --card-glow: #00ff00;
    box-shadow: 0 0 8px rgba(0, 255, 0, 0.1);
}

.script-box.warning {
    border-left: 3px solid #ffff00;
    --card-glow: #ffff00;
    box-shadow: 0 0 8px rgba(255, 255, 0, 0.1);
}

.script-box.failed {
    border-left: 3px solid #ff0000;
    --card-glow: #ff0000;
    box-shadow: 0 0 8px rgba(255, 0, 0, 0.1);
}

.script-box.offline {
    border-left: 3px solid #555;
    --card-glow: #555;
    opacity: 0.5;
}

/* ── LIVE LOG CARDS ── */

@keyframes card-slide-in {
    from { opacity: 0; transform: translateY(-12px); }
    to   { opacity: 1; transform: translateY(0); }
}

.log-card {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: 6px;
    padding: 8px 10px;
    border: 1px solid var(--card-neon, #333);
    border-radius: 3px;
    background: rgba(0,0,0,0.7);
    margin-bottom: 6px;
    font-size: 10px;
    font-family: monospace;
    animation: card-slide-in 0.4s ease-out;
    cursor: pointer;
    box-shadow: 0 0 6px var(--card-neon, #333),
                inset 0 0 6px rgba(0,0,0,0.8);
    transition: box-shadow 0.2s ease;
    position: relative;
}

.log-card:hover {
    box-shadow: 0 0 14px var(--card-neon, #555),
                0 0 28px var(--card-neon, #333),
                inset 0 0 8px rgba(0,0,0,0.6);
}

.log-card.expanded {
    box-shadow: 0 0 18px var(--card-neon, #555),
                0 0 36px var(--card-neon, #333),
                inset 0 0 10px rgba(0,0,0,0.5);
}

.log-card.expanded .log-text {
    white-space: pre-wrap;
    word-break: break-all;
    width: 100%;
}

.log-badge {
    flex-shrink: 0;
    border: 1px solid;
    border-radius: 2px;
    padding: 2px 6px;
    font-size: 9px;
    font-weight: bold;
    letter-spacing: 0.5px;
}

.log-time {
    flex-shrink: 0;
    color: #444;
    font-size: 9px;
}

.log-text {
    color: #bbb;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    flex: 1;
    min-width: 0;
}

/* ── LOG CATEGORIES ── */

.log-category {
    margin-bottom: 15px;
    border: 1px solid #333;
    padding: 10px;
    background: rgba(0, 0, 0, 0.5);
}

.log-category h3 {
    margin: 0 0 10px 0;
    color: var(--neon-tool);
    font-size: 14px;
    border-bottom: 1px solid #444;
    padding-bottom: 5px;
    cursor: pointer;
}

.log-category h3:hover {
    color: #fff;
    transform: translateY(-2px) scale(1.02);
}

.log-items {
    display: none;
    max-height: 200px;
    overflow-y: auto;
}

.log-items.open {
    display: block;
}

/* ── CHAT ── */

#chat-button {
    position: fixed;
    bottom: 20px;
    left: 20px;
    width: 60px;
    height: 60px;
    background: rgba(255, 0, 204, 0.2);
    border: 2px solid var(--neon-tool);
    color: var(--neon-tool);
    border-radius: 50%;
    cursor: pointer;
    z-index: 1000;
    transition: all 0.3s ease;
}

#chat-button:hover {
    background: rgba(255, 0, 204, 0.4);
    transform: translateY(-5px) scale(1.1);
    box-shadow: 0 0 20px var(--neon-tool);
}

#chat-window {
    position: fixed;
    bottom: 100px;
    left: 20px;
    width: 350px;
    height: 400px;
    background: rgba(10, 10, 10, 0.95);
    border: 2px solid var(--neon-tool);
    z-index: 999;
    display: none;
    flex-direction: column;
}

#chat-header {
    padding: 10px;
    background: rgba(255, 0, 204, 0.1);
    border-bottom: 1px solid var(--neon-tool);
    display: flex;
    justify-content: space-between;
}

#chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 10px;
    font-size: 12px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

#chat-input-container {
    display: flex;
    padding: 10px;
    border-top: 1px solid #333;
}

#chat-input {
    flex: 1;
    background: #000;
    border: 1px solid #444;
    color: #fff;
    padding: 5px;
    font-family: monospace;
}

.user-msg {
    align-self: flex-end;
    color: #00ffcc;
    border-right: 2px solid #00ffcc;
    padding-right: 8px;
}

.beast-msg {
    align-self: flex-start;
    color: var(--neon-tool);
    border-left: 2px solid var(--neon-tool);
    padding-left: 8px;
}

/* ── TITLE OVERLAY ── */

.title-overlay {
    position: absolute;
    top: 20px;
    left: 30px;
    z-index: 5;
    pointer-events: none;
}

.title-overlay h1 {
    margin: 0;
    font-size: 2em;
    color: #fff;
    text-shadow: 0 0 10px #fff;
}

/* ── TOOLTIP ── */

#tooltip {
    position: absolute;
    display: none;
    background: rgba(0, 0, 0, 0.9);
    border: 1px solid var(--neon-tool);
    padding: 10px;
    color: #fff;
    z-index: 1000;
    font-family: monospace;
    font-size: 12px;
    pointer-events: none;
    box-shadow: 0 0 10px var(--neon-tool);
    min-width: 150px;
}
