/* variables & Reset */
:root {
    --bg-dark: #090d16;
    --bg-card: rgba(18, 24, 38, 0.65);
    --border-color: rgba(255, 255, 255, 0.08);
    --text-primary: #f3f4f6;
    --text-secondary: #9ca3af;
    --color-primary: #00d2ff;
    --color-primary-glow: rgba(0, 210, 255, 0.4);
    --color-success: #10b981;
    --color-success-glow: rgba(16, 185, 129, 0.4);
    --color-warning: #f59e0b;
    --color-danger: #ef4444;
    --color-neon-purple: #bd00ff;
}

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

body {
    background-color: var(--bg-dark);
    color: var(--text-primary);
    font-family: 'Outfit', sans-serif;
    min-height: 100vh;
    overflow-x: hidden;
    background-image: 
        radial-gradient(circle at 10% 20%, rgba(0, 210, 255, 0.05) 0%, transparent 40%),
        radial-gradient(circle at 90% 80%, rgba(189, 0, 255, 0.05) 0%, transparent 40%);
}

/* Glassmorphism Card Style */
.glass-card {
    background: var(--bg-card);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    box-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.37);
}

/* Main Container Layout */
.app-container {
    max-width: 1600px;
    margin: 0 auto;
    padding: 20px;
    display: flex;
    flex-direction: column;
    height: 100vh;
}

/* Header */
.app-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding-bottom: 15px;
    border-bottom: 1px solid var(--border-color);
    margin-bottom: 20px;
}

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

.logo-icon {
    font-size: 2.2rem;
    filter: drop-shadow(0 0 10px var(--color-primary));
}

.logo-text h1 {
    font-family: 'Space Grotesk', sans-serif;
    font-weight: 700;
    font-size: 1.8rem;
    letter-spacing: -0.5px;
    background: linear-gradient(to right, var(--color-primary), var(--color-neon-purple));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.logo-text p {
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.header-status {
    display: flex;
    gap: 15px;
}

.status-item {
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--border-color);
    padding: 8px 16px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.status-label {
    color: var(--text-secondary);
    font-size: 0.9rem;
}

.status-val {
    font-weight: 600;
    color: var(--color-primary);
}

/* Main Gameplay Grid */
.game-main {
    display: grid;
    grid-template-columns: 420px 1fr;
    gap: 20px;
    flex-grow: 1;
    height: calc(100vh - 100px);
}

/* Sidebar */
.sidebar-panel {
    display: flex;
    flex-direction: column;
    padding: 20px;
    gap: 20px;
    overflow-y: auto;
}

.panel-section {
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    padding-bottom: 15px;
}

.panel-section:last-child {
    border-bottom: none;
    padding-bottom: 0;
}

.panel-section.flex-grow {
    flex-grow: 1;
    display: flex;
    flex-direction: column;
}

.section-title {
    font-family: 'Space Grotesk', sans-serif;
    font-size: 1.15rem;
    font-weight: 600;
    margin-bottom: 12px;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 8px;
}

.level-desc {
    font-size: 0.92rem;
    color: var(--text-secondary);
    line-height: 1.5;
}

.level-desc p {
    margin-bottom: 8px;
}

.level-desc ul {
    margin-left: 20px;
    margin-top: 5px;
}

.level-desc li {
    margin-bottom: 4px;
}

/* Buttons styling */
.control-buttons {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.btn {
    font-family: 'Outfit', sans-serif;
    font-weight: 600;
    font-size: 0.95rem;
    padding: 12px 20px;
    border-radius: 10px;
    cursor: pointer;
    border: none;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.btn-primary {
    background: linear-gradient(135deg, var(--color-primary), #0088ff);
    color: white;
    box-shadow: 0 4px 15px rgba(0, 210, 255, 0.2);
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(0, 210, 255, 0.35);
}

.btn-secondary {
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
}

.btn-secondary:hover {
    background: rgba(255, 255, 255, 0.1);
}

.btn-success {
    background: linear-gradient(135deg, var(--color-success), #059669);
    color: white;
    box-shadow: 0 4px 15px rgba(16, 185, 129, 0.2);
}

.btn-success:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(16, 185, 129, 0.35);
}

.btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
    transform: none !important;
    box-shadow: none !important;
}

/* Config Panel Inputs */
.config-panel {
    background: rgba(255, 255, 255, 0.02);
    border: 1px dashed var(--color-primary-glow);
    border-radius: 10px;
    padding: 12px;
}

.config-group {
    margin-bottom: 10px;
}

.config-group label {
    display: block;
    font-size: 0.82rem;
    color: var(--text-secondary);
    margin-bottom: 4px;
}

.form-select {
    width: 100%;
    background-color: #121826;
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    padding: 8px 12px;
    border-radius: 6px;
    font-family: inherit;
    font-size: 0.88rem;
    outline: none;
}

.form-select:focus {
    border-color: var(--color-primary);
}

.btn-sm {
    padding: 6px 12px;
    font-size: 0.85rem;
}

/* Terminal Log */
.terminal-container {
    background-color: #05070c;
    border: 1px solid rgba(255, 255, 255, 0.05);
    border-radius: 10px;
    padding: 12px;
    flex-grow: 1;
    font-family: 'Courier New', Courier, monospace;
    font-size: 0.82rem;
    line-height: 1.4;
    overflow-y: auto;
    color: #38bdf8;
    height: 120px;
}

.term-prompt {
    color: #a855f7;
    font-weight: bold;
}

.term-success {
    color: #4ade80;
}

.term-error {
    color: #f87171;
}

.term-warning {
    color: #fbbf24;
}

/* Arena Panel */
.arena-panel {
    display: flex;
    flex-direction: column;
    padding: 20px;
    position: relative;
    overflow: hidden;
}

.arena-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    padding-bottom: 12px;
    margin-bottom: 15px;
}

.arena-header h3 {
    font-size: 0.95rem;
    color: var(--text-secondary);
    font-weight: 400;
}

.network-legend {
    display: flex;
    gap: 12px;
    font-size: 0.85rem;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 6px;
    color: var(--text-secondary);
}

.legend-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    display: inline-block;
}

.legend-dot.green { background-color: var(--color-success); box-shadow: 0 0 6px var(--color-success); }
.legend-dot.gray { background-color: var(--text-secondary); }

/* SVG Cables Overlay */
.network-workspace {
    position: relative;
    width: 100%;
    flex-grow: 1;
    background-color: rgba(5, 8, 16, 0.5);
    border-radius: 12px;
    border: 1px solid rgba(255, 255, 255, 0.03);
    overflow: hidden;
}

.cables-svg {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 1;
}

/* Cable Line Styles */
@keyframes dash {
    to {
        stroke-dashoffset: -20;
    }
}

.cable-line {
    stroke-width: 3;
    fill: none;
    transition: stroke 0.3s, filter 0.3s;
}

.cable-line.inactive {
    stroke: #374151;
}

.cable-line.active {
    stroke: var(--color-primary);
    stroke-dasharray: 6, 4;
    animation: dash 1s linear infinite;
    filter: drop-shadow(0 0 4px var(--color-primary-glow));
}

.cable-line.success-flow {
    stroke: var(--color-success);
    stroke-dasharray: 6, 4;
    animation: dash 0.6s linear infinite;
    filter: drop-shadow(0 0 6px var(--color-success-glow));
}

/* Devices Container & Positioned Items */
.devices-container {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 2;
}

/* Network Node (Device) Card */
.net-device {
    position: absolute;
    width: 90px;
    height: 90px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    border-radius: 12px;
    background: rgba(18, 24, 38, 0.8);
    border: 1px solid rgba(255, 255, 255, 0.08);
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    user-select: none;
}

.net-device:hover {
    transform: translateY(-4px);
    border-color: var(--color-primary);
    box-shadow: 0 4px 15px var(--color-primary-glow);
    background: rgba(26, 34, 53, 0.95);
}

.net-device.selected {
    border-color: var(--color-neon-purple);
    box-shadow: 0 0 15px rgba(189, 0, 255, 0.5);
    background: rgba(30, 24, 46, 0.9);
}

.net-device.active-node {
    border-color: var(--color-success);
    box-shadow: 0 0 10px var(--color-success-glow);
}

.device-icon {
    font-size: 1.8rem;
    margin-bottom: 6px;
    filter: drop-shadow(0 2px 4px rgba(0,0,0,0.5));
}

.device-label {
    font-size: 0.72rem;
    font-weight: 600;
    text-align: center;
    color: var(--text-primary);
    white-space: nowrap;
}

.device-ip {
    font-size: 0.6rem;
    color: var(--text-secondary);
    margin-top: 1px;
}

/* Modal Styling */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(5, 7, 12, 0.8);
    backdrop-filter: blur(8px);
    z-index: 100;
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-content {
    width: 500px;
    padding: 30px;
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 15px;
}

.modal-icon {
    font-size: 3.5rem;
    margin-bottom: 10px;
    animation: bounce 2s infinite;
}

.modal-content h2 {
    font-family: 'Space Grotesk', sans-serif;
    font-size: 1.8rem;
    background: linear-gradient(to right, var(--color-success), var(--color-primary));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.modal-content p {
    font-size: 0.98rem;
    color: var(--text-secondary);
    line-height: 1.5;
}

.modal-fact {
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--border-color);
    padding: 15px;
    border-radius: 10px;
    font-size: 0.88rem;
    text-align: left;
}

.modal-fact strong {
    color: var(--color-primary);
    display: block;
    margin-bottom: 4px;
}

.modal-fact p {
    font-size: 0.85rem;
}

.hidden {
    display: none !important;
}

/* Animations */
@keyframes bounce {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-10px); }
}

.animate-pop {
    animation: popIn 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes popIn {
    0% { transform: scale(0.8); opacity: 0; }
    100% { transform: scale(1); opacity: 1; }
}

/* Utilities */
.status-connected {
    color: var(--color-success) !important;
}
