:root {
    --bg-color: #0b0f19;
    --card-bg: rgba(17, 24, 39, 0.7);
    --card-border: rgba(255, 255, 255, 0.08);
    --text-primary: #f3f4f6;
    --text-muted: #9ca3af;
    --primary-glow: rgba(59, 130, 246, 0.5);
    
    --primary: #3b82f6;
    --primary-hover: #2563eb;
    --accent: #8b5cf6;
    --success: #10b981;
    --warning: #f59e0b;
    --danger: #ef4444;
    
    --font-heading: 'Outfit', sans-serif;
    --font-mono: 'Space Grotesk', 'Courier New', monospace;
}

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

body {
    background-color: var(--bg-color);
    color: var(--text-primary);
    font-family: var(--font-heading);
    overflow-x: hidden;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* Background Glowing Accents */
.glow-bg {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 600px;
    height: 600px;
    background: radial-gradient(circle, var(--primary-glow) 0%, rgba(11,15,25,0) 70%);
    z-index: -1;
    pointer-events: none;
    filter: blur(80px);
    opacity: 0.6;
}

/* Header styling */
.app-header {
    text-align: center;
    padding: 2rem 1.5rem 1rem;
    z-index: 10;
}

.logo {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
    margin-bottom: 0.5rem;
}

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

.app-header h1 {
    font-size: 2.25rem;
    font-weight: 800;
    letter-spacing: -0.025em;
}

.gradient-text {
    background: linear-gradient(135deg, #60a5fa 0%, #a78bfa 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.subtitle {
    color: var(--text-muted);
    font-size: 1.05rem;
    max-width: 600px;
    margin: 0 auto;
    font-weight: 300;
}

/* Main Layout Grid */
.app-container {
    display: grid;
    grid-template-columns: 320px 1fr 450px;
    gap: 1.5rem;
    padding: 1rem 1.5rem 2rem;
    max-width: 1700px;
    margin: 0 auto;
    width: 100%;
    flex: 1;
}

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

/* Cards & Containers */
.card {
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    backdrop-filter: blur(16px);
    border-radius: 16px;
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
}

.card h2 {
    font-size: 1.35rem;
    font-weight: 700;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    padding-bottom: 0.75rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.card-inner {
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.05);
    border-radius: 12px;
    padding: 1rem;
}

.card-inner h3 {
    font-size: 1.05rem;
    margin-bottom: 0.5rem;
    color: #e5e7eb;
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.625rem 1.25rem;
    font-family: var(--font-heading);
    font-weight: 600;
    border-radius: 8px;
    border: none;
    cursor: pointer;
    transition: all 0.2s ease;
    gap: 0.5rem;
    font-size: 0.9rem;
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-hover) 100%);
    color: white;
    box-shadow: 0 4px 12px rgba(59, 130, 246, 0.3);
}

.btn-primary:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 16px rgba(59, 130, 246, 0.4);
}

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

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

.btn-sm {
    padding: 0.4rem 0.8rem;
    font-size: 0.8rem;
    border-radius: 6px;
}

/* Scenario Sidebar */
.scenario-list {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.scenario-btn {
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.06);
    border-radius: 10px;
    padding: 0.75rem 1rem;
    text-align: left;
    cursor: pointer;
    transition: all 0.25s ease;
    color: var(--text-muted);
}

.scenario-btn:hover {
    background: rgba(255, 255, 255, 0.06);
    border-color: rgba(255, 255, 255, 0.15);
    color: var(--text-primary);
}

.scenario-btn.active {
    background: rgba(59, 130, 246, 0.12);
    border-color: var(--primary);
    color: white;
    box-shadow: inset 0 0 10px rgba(59, 130, 246, 0.15);
}

.scenario-btn h4 {
    font-size: 0.95rem;
    font-weight: 600;
    margin-bottom: 0.25rem;
    display: flex;
    justify-content: space-between;
}

.scenario-btn.completed h4::after {
    content: "✓";
    color: var(--success);
    font-weight: 800;
}

.scenario-btn p {
    font-size: 0.8rem;
    line-height: 1.3;
}

#scenario-details p {
    font-size: 0.85rem;
    color: var(--text-muted);
    line-height: 1.4;
}

.objective-item {
    font-size: 0.85rem;
    margin-top: 0.5rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.objective-item.done {
    color: var(--success);
    text-decoration: line-through;
}

/* Traffic Generators */
.packet-spawners {
    display: grid;
    grid-template-columns: 1fr;
    gap: 0.5rem;
    margin-bottom: 0.75rem;
}

.spawner-btn {
    background: rgba(255,255,255,0.04);
    border: 1px solid rgba(255,255,255,0.06);
    color: var(--text-primary);
    padding: 0.5rem 0.75rem;
    border-radius: 8px;
    cursor: pointer;
    text-align: left;
    font-size: 0.8rem;
    transition: background 0.2s;
    font-family: var(--font-mono);
}

.spawner-btn:hover {
    background: rgba(255,255,255,0.08);
}

#btn-clear-traffic {
    width: 100%;
}

/* Map Simulation area */
.simulation-area {
    min-height: 550px;
}

.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.status-indicator {
    font-size: 0.8rem;
    background: rgba(255,255,255,0.05);
    padding: 0.25rem 0.75rem;
    border-radius: 20px;
    display: flex;
    align-items: center;
    gap: 0.4rem;
}

.status-dot {
    width: 8px;
    height: 8px;
    background-color: var(--primary);
    border-radius: 50%;
    box-shadow: 0 0 8px var(--primary);
}

.canvas-container {
    background: rgba(0, 0, 0, 0.4);
    border: 1px solid rgba(255,255,255,0.05);
    border-radius: 12px;
    overflow: hidden;
    position: relative;
    flex-grow: 1;
}

#networkCanvas {
    display: block;
    width: 100%;
    height: 100%;
}

/* Console logs styling */
.console-log {
    background: #05070c;
    border: 1px solid rgba(255,255,255,0.05);
    border-radius: 10px;
    font-family: var(--font-mono);
    font-size: 0.85rem;
    display: flex;
    flex-direction: column;
    height: 160px;
}

.console-header {
    background: rgba(255,255,255,0.02);
    border-bottom: 1px solid rgba(255,255,255,0.05);
    padding: 0.4rem 0.75rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    color: var(--text-muted);
    font-size: 0.75rem;
}

.console-clear {
    background: transparent;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
}

.console-clear:hover {
    color: var(--text-primary);
}

.console-lines {
    padding: 0.5rem 0.75rem;
    overflow-y: auto;
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.console-line {
    line-height: 1.4;
}

.console-line.system { color: #3b82f6; }
.console-line.allow { color: var(--success); }
.console-line.deny { color: var(--danger); }
.console-line.match { color: var(--warning); }

/* Right Panel: ACL rules styling */
.acl-rules-container {
    border: 1px solid rgba(255, 255, 255, 0.05);
    border-radius: 12px;
    background: rgba(0, 0, 0, 0.2);
    overflow: hidden;
}

.acl-headers, .rule-item, .implicit-deny-banner {
    display: grid;
    grid-template-columns: 35px 80px 70px 100px 100px 1fr 35px;
    align-items: center;
    gap: 0.25rem;
    padding: 0.75rem 0.5rem;
    font-size: 0.8rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.acl-headers {
    background: rgba(255,255,255,0.03);
    color: var(--text-muted);
    font-weight: 600;
}

.col-seq {
    color: var(--text-muted);
    text-align: center;
    font-weight: bold;
}

.badge {
    padding: 0.2rem 0.5rem;
    border-radius: 4px;
    font-weight: 700;
    font-size: 0.75rem;
    text-align: center;
    letter-spacing: 0.05em;
    display: inline-block;
}

.badge-allow {
    background: rgba(16, 185, 129, 0.15);
    color: var(--success);
    border: 1px solid rgba(16, 185, 129, 0.3);
}

.badge-deny {
    background: rgba(239, 68, 68, 0.15);
    color: var(--danger);
    border: 1px solid rgba(239, 68, 68, 0.3);
}

.rules-list {
    min-height: 150px;
    background: rgba(0,0,0,0.1);
}

.rule-item {
    background: rgba(255, 255, 255, 0.01);
    cursor: grab;
    user-select: none;
    transition: background-color 0.2s, transform 0.2s;
}

.rule-item:hover {
    background: rgba(255, 255, 255, 0.03);
}

.rule-item.dragging {
    opacity: 0.5;
    background: rgba(59, 130, 246, 0.1);
    border: 1px dashed var(--primary);
}

.rule-delete {
    background: transparent;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 1rem;
    display: flex;
    justify-content: center;
    align-items: center;
}

.rule-delete:hover {
    color: var(--danger);
}

.implicit-deny-banner {
    background: rgba(239, 68, 68, 0.03);
    color: var(--text-muted);
    border-bottom: none;
    font-style: italic;
}

/* Modal Form Styles */
.rule-builder-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(5, 7, 12, 0.85); /* Slightly darker solid backdrop */
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 9999; /* Ensure it is on top of all containers */
}

.modal-content {
    background: #0f172a !important; /* Force distinct dark background */
    border: 1px solid rgba(255, 255, 255, 0.15) !important;
    width: 450px;
    max-width: 90%;
    padding: 2rem;
    border-radius: 16px;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.6);
    animation: zoomIn 0.3s ease;
    z-index: 10000;
}


.form-group {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
    margin-bottom: 1rem;
}

.form-group label {
    font-size: 0.85rem;
    color: var(--text-muted);
}

.form-group select {
    background: #111827;
    border: 1px solid rgba(255,255,255,0.1);
    color: white;
    padding: 0.6rem;
    border-radius: 8px;
    font-family: var(--font-heading);
}

.modal-buttons {
    display: flex;
    justify-content: flex-end;
    gap: 0.75rem;
    margin-top: 1.25rem;
}

/* Objective Indicators */
.objective-box {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.objective-indicator {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: rgba(255,255,255,0.02);
    border: 1px solid rgba(255,255,255,0.04);
    padding: 0.5rem 0.75rem;
    border-radius: 8px;
    font-size: 0.8rem;
}

.indicator-bullet {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: var(--text-muted);
}

.indicator-bullet.met {
    background: var(--success);
    box-shadow: 0 0 6px var(--success);
}

.indicator-bullet.failed {
    background: var(--danger);
    box-shadow: 0 0 6px var(--danger);
}

/* App Footer styling */
.app-footer {
    text-align: center;
    padding: 1.5rem;
    font-size: 0.8rem;
    color: var(--text-muted);
    border-top: 1px solid var(--card-border);
    background: rgba(11, 15, 25, 0.8);
    margin-top: auto;
}

/* Print Styles for Certificate */
@media print {
    body * {
        visibility: hidden;
    }
    #cert-modal, #cert-modal * {
        visibility: visible;
    }
    #cert-modal {
        position: absolute;
        left: 0;
        top: 0;
        width: 100%;
        height: auto;
        background: white !important;
        backdrop-filter: none;
    }
    .cert-modal-content {
        border: none !important;
        background: white !important;
        box-shadow: none !important;
        margin: 0;
        padding: 0;
        width: 100%;
        max-width: 100%;
    }
    #print-area {
        background: white !important;
        color: black !important;
        border: 4px double black !important;
        box-shadow: none !important;
    }
    #student-name {
        color: black !important;
        border-bottom: 2px solid black !important;
    }
    .modal-buttons {
        display: none !important; /* Hide close/print buttons during printing */
    }
}


/* Animations */
@keyframes zoomIn {
    from { transform: scale(0.95); opacity: 0; }
    to { transform: scale(1); opacity: 1; }
}
