/* 
 * Variable Length Subnet Masking (VLSM) Planner
 * Premium Cybernetic Theme & Layout Stylesheet
 */

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

:root {
    --bg-dark: #070b13;
    --card-bg: rgba(13, 20, 35, 0.6);
    --border-color: rgba(255, 255, 255, 0.06);
    --border-hover: rgba(255, 255, 255, 0.12);
    
    /* Core Accent Palette */
    --primary: hsl(263, 85%, 64%);
    --primary-glow: hsla(263, 85%, 64%, 0.25);
    --primary-hover: hsl(263, 90%, 70%);
    
    --success: hsl(142, 76%, 45%);
    --success-glow: hsla(142, 76%, 45%, 0.3);
    
    --danger: hsl(346, 84%, 55%);
    --danger-glow: hsla(346, 84%, 55%, 0.3);
    
    --warning: hsl(40, 95%, 55%);
    --warning-glow: hsla(40, 95%, 55%, 0.3);
    
    /* Text Color */
    --text-primary: #f1f5f9;
    --text-secondary: #94a3b8;
    --text-muted: #64748b;
    
    /* Transition Speed */
    --transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Base resets & layout */
* {
    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;
    position: relative;
}

/* Ambient Radial Gradients Background */
body::before {
    content: '';
    position: fixed;
    top: -10%;
    left: -10%;
    width: 60vw;
    height: 60vh;
    background: radial-gradient(circle, rgba(99, 102, 241, 0.08) 0%, rgba(0, 0, 0, 0) 70%);
    z-index: -1;
    pointer-events: none;
}

body::after {
    content: '';
    position: fixed;
    bottom: -10%;
    right: -10%;
    width: 60vw;
    height: 60vh;
    background: radial-gradient(circle, rgba(167, 139, 250, 0.05) 0%, rgba(0, 0, 0, 0) 70%);
    z-index: -1;
    pointer-events: none;
}

header {
    background: rgba(7, 11, 19, 0.85);
    backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--border-color);
    padding: 1.25rem 2rem;
    position: sticky;
    top: 0;
    z-index: 100;
}

.header-container {
    max-width: 1400px;
    margin: 0 auto;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.brand {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.brand-icon {
    width: 2.2rem;
    height: 2.2rem;
    background: linear-gradient(135deg, var(--primary) 0%, #3b82f6 100%);
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 0 15px var(--primary-glow);
}

.brand-icon svg {
    width: 1.3rem;
    height: 1.3rem;
    fill: #fff;
}

.brand-info h1 {
    font-size: 1.3rem;
    font-weight: 700;
    letter-spacing: -0.02em;
    background: linear-gradient(to right, #fff, #cbd5e1);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.brand-info p {
    font-size: 0.8rem;
    color: var(--text-secondary);
}

.header-controls {
    display: flex;
    align-items: center;
    gap: 1rem;
}

/* Button & Switch Themes */
.mode-switch {
    background: rgba(15, 23, 42, 0.8);
    border: 1px solid var(--border-color);
    border-radius: 30px;
    display: flex;
    padding: 0.25rem;
}

.mode-btn {
    background: none;
    border: none;
    color: var(--text-secondary);
    padding: 0.5rem 1.25rem;
    border-radius: 20px;
    font-family: inherit;
    font-size: 0.85rem;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition);
}

.mode-btn:hover {
    color: var(--text-primary);
}

.mode-btn.active {
    background: var(--primary);
    color: #fff;
    box-shadow: 0 0 12px var(--primary-glow);
}

.preset-dropdown {
    background: rgba(15, 23, 42, 0.8);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    padding: 0.5rem 1rem;
    border-radius: 8px;
    font-family: inherit;
    font-size: 0.85rem;
    cursor: pointer;
    outline: none;
    transition: var(--transition);
}

.preset-dropdown:focus {
    border-color: var(--primary);
    box-shadow: 0 0 8px var(--primary-glow);
}

/* Main Layout Grid */
main {
    max-width: 1400px;
    margin: 2rem auto;
    padding: 0 1.5rem;
    display: grid;
    grid-template-columns: 340px 1fr;
    gap: 1.5rem;
}

@media (max-width: 1100px) {
    main {
        grid-template-columns: 1fr;
    }
}

/* Left Sidebar Card */
.sidebar {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.glass-card {
    background: var(--card-bg);
    backdrop-filter: blur(16px);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 1.5rem;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
}

.card-title {
    font-size: 1.05rem;
    font-weight: 600;
    letter-spacing: -0.01em;
    margin-bottom: 1.25rem;
    padding-bottom: 0.75rem;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.card-subtitle {
    font-size: 0.8rem;
    color: var(--text-muted);
    font-weight: normal;
}

/* Form Styles */
.form-group {
    margin-bottom: 1rem;
}

.form-group label {
    display: block;
    font-size: 0.8rem;
    color: var(--text-secondary);
    margin-bottom: 0.4rem;
    font-weight: 500;
}

.input-row {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 0.75rem;
}

.text-input, .select-input {
    background: rgba(15, 23, 42, 0.75);
    border: 1px solid var(--border-color);
    color: #fff;
    padding: 0.65rem 0.75rem;
    border-radius: 8px;
    font-family: inherit;
    font-size: 0.9rem;
    width: 100%;
    outline: none;
    transition: var(--transition);
}

.text-input:focus, .select-input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 8px var(--primary-glow);
}

.text-input.invalid {
    border-color: var(--danger);
    box-shadow: 0 0 8px var(--danger-glow);
}

/* Requirements Controls */
.subnets-list {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    max-height: 480px;
    overflow-y: auto;
    padding-right: 0.25rem;
}

.subnets-list::-webkit-scrollbar {
    width: 6px;
}

.subnets-list::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.1);
}

.subnets-list::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 4px;
}

.subnet-control-card {
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 0.75rem;
    transition: var(--transition);
}

.subnet-control-card:hover {
    border-color: var(--border-hover);
    background: rgba(255, 255, 255, 0.04);
}

.control-header {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.5rem;
}

.control-name-input {
    background: transparent;
    border: none;
    border-bottom: 1px solid transparent;
    color: #fff;
    font-family: inherit;
    font-size: 0.85rem;
    font-weight: 500;
    outline: none;
    flex-grow: 1;
    padding: 0.1rem 0;
    transition: var(--transition);
}

.control-name-input:focus {
    border-color: var(--primary);
}

.delete-subnet-btn {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 1.25rem;
    cursor: pointer;
    line-height: 1;
    transition: var(--transition);
}

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

.control-fields {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.5rem;
}

.field-item label {
    display: block;
    font-size: 0.7rem;
    color: var(--text-muted);
    margin-bottom: 0.2rem;
}

.field-item input {
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid var(--border-color);
    color: #fff;
    padding: 0.35rem 0.5rem;
    border-radius: 6px;
    font-family: inherit;
    font-size: 0.8rem;
    width: 100%;
    outline: none;
}

.field-item input:focus {
    border-color: var(--primary);
}

.sidebar-actions {
    display: flex;
    gap: 0.5rem;
    margin-top: 1rem;
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    padding: 0.65rem 1rem;
    border-radius: 8px;
    font-family: inherit;
    font-size: 0.85rem;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition);
    text-decoration: none;
}

.btn:hover {
    background: rgba(255, 255, 255, 0.1);
    border-color: var(--border-hover);
}

.btn-primary {
    background: var(--primary);
    color: #fff;
    border: none;
    box-shadow: 0 4px 15px var(--primary-glow);
}

.btn-primary:hover {
    background: var(--primary-hover);
    box-shadow: 0 4px 20px var(--primary-glow);
}

.btn-block {
    width: 100%;
}

.empty-state {
    text-align: center;
    color: var(--text-muted);
    font-size: 0.8rem;
    padding: 2rem 1rem;
    border: 1px dashed var(--border-color);
    border-radius: 8px;
}

/* Central Calculations Area */
.calculations-pane {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

/* Table Area styles */
.table-container {
    overflow-x: auto;
    margin: 0.5rem 0;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    background: rgba(7, 11, 19, 0.4);
}

table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.85rem;
    text-align: left;
    min-width: 900px;
}

th {
    background: rgba(13, 20, 35, 0.85);
    font-weight: 600;
    color: var(--text-secondary);
    padding: 1rem 0.75rem;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    border-bottom: 1px solid var(--border-color);
}

td {
    padding: 0.65rem 0.75rem;
    border-bottom: 1px solid var(--border-color);
    vertical-align: middle;
}

tr:last-child td {
    border-bottom: none;
}

tr.row-overcapacity {
    background: rgba(244, 63, 94, 0.05);
}

/* Table Column Widths */
.col-vlan { width: 14%; }
.col-mask { width: 13%; }
.col-cidr { width: 9%; }
.col-net { width: 13%; }
.col-gw { width: 13%; }
.col-first { width: 13%; }
.col-last { width: 13%; }
.col-broad { width: 12%; }

/* Custom badging for VLANs */
.row-vlan-info {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.vlan-badge {
    font-size: 0.7rem;
    font-weight: 700;
    padding: 0.25rem 0.45rem;
    border-radius: 4px;
    font-family: 'JetBrains Mono', monospace;
    display: inline-block;
}

.vlan-details {
    display: flex;
    flex-direction: column;
}

.vlan-name {
    font-weight: 500;
    color: #fff;
    font-size: 0.8rem;
    line-height: 1.2;
}

.vlan-hosts-req {
    font-size: 0.7rem;
    color: var(--text-muted);
}

/* Custom Neon Colors for VLAN Badges */
.vlan-color-cyan { background: rgba(34, 211, 238, 0.15); color: #22d3ee; border: 1px solid rgba(34, 211, 238, 0.3); }
.vlan-color-teal { background: rgba(45, 212, 191, 0.15); color: #2dd4bf; border: 1px solid rgba(45, 212, 191, 0.3); }
.vlan-color-amber { background: rgba(245, 158, 11, 0.15); color: #fbbf24; border: 1px solid rgba(245, 158, 11, 0.3); }
.vlan-color-purple { background: rgba(167, 139, 250, 0.15); color: #c084fc; border: 1px solid rgba(167, 139, 250, 0.3); }
.vlan-color-rose { background: rgba(244, 63, 94, 0.15); color: #fb7185; border: 1px solid rgba(244, 63, 94, 0.3); }
.vlan-color-indigo { background: rgba(129, 140, 248, 0.15); color: #818cf8; border: 1px solid rgba(129, 140, 248, 0.3); }
.vlan-color-orange { background: rgba(251, 146, 60, 0.15); color: #fb923c; border: 1px solid rgba(251, 146, 60, 0.3); }
.vlan-color-emerald { background: rgba(52, 211, 153, 0.15); color: #34d399; border: 1px solid rgba(52, 211, 153, 0.3); }
.vlan-color-sky { background: rgba(56, 189, 248, 0.15); color: #38bdf8; border: 1px solid rgba(56, 189, 248, 0.3); }
.vlan-color-pink { background: rgba(244, 114, 182, 0.15); color: #f472b6; border: 1px solid rgba(244, 114, 182, 0.3); }

/* Table cells interactive input styles */
.cell-input {
    background: rgba(15, 23, 42, 0.6);
    border: 1px solid rgba(255, 255, 255, 0.05);
    color: #fff;
    width: 100%;
    padding: 0.5rem;
    border-radius: 6px;
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.8rem;
    outline: none;
    transition: var(--transition);
}

.cell-input:focus:not([readonly]) {
    border-color: var(--primary);
    background: rgba(15, 23, 42, 0.9);
    box-shadow: 0 0 6px var(--primary-glow);
}

.cell-input[readonly] {
    background: transparent;
    border-color: transparent;
    color: #cbd5e1;
    cursor: default;
    padding-left: 0.25rem;
}

.text-center {
    text-align: center;
}

/* Practice Mode Validation Feedback states */
td {
    position: relative;
}

td.cell-correct .cell-input {
    border-color: var(--success) !important;
    background: rgba(16, 185, 129, 0.03) !important;
    color: #34d399 !important;
    padding-right: 1.5rem;
}

td.cell-incorrect .cell-input {
    border-color: var(--danger) !important;
    background: rgba(244, 63, 94, 0.03) !important;
    color: #f87171 !important;
    padding-right: 1.5rem;
}

.validation-icon {
    position: absolute;
    right: 1.15rem;
    top: 50%;
    transform: translateY(-50%);
    font-size: 0.75rem;
    font-weight: 700;
    pointer-events: auto;
    width: 1rem;
    height: 1rem;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: help;
}

.correct-icon {
    color: var(--success);
}

.incorrect-icon {
    background: var(--danger);
    color: #fff;
    font-size: 0.65rem;
    cursor: help;
}

/* Advanced Tooltip styling */
.incorrect-icon .tooltip-box {
    visibility: hidden;
    position: absolute;
    bottom: 125%;
    left: 50%;
    transform: translateX(-50%);
    background: #0f172a;
    color: #f87171;
    padding: 0.5rem 0.75rem;
    border-radius: 6px;
    border: 1px solid var(--danger);
    font-family: 'Outfit', sans-serif;
    font-size: 0.75rem;
    font-weight: normal;
    white-space: normal;
    width: 180px;
    z-index: 1000;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.5);
    opacity: 0;
    transition: opacity 0.2s, transform 0.2s;
}

.incorrect-icon:hover .tooltip-box {
    visibility: visible;
    opacity: 1;
    transform: translateX(-50%) translateY(-2px);
}

.incorrect-icon .tooltip-box::after {
    content: '';
    position: absolute;
    top: 100%;
    left: 50%;
    transform: translateX(-50%);
    border-width: 5px;
    border-style: solid;
    border-color: var(--danger) transparent transparent transparent;
}

/* Animations */
@keyframes wiggle {
    0%, 100% { transform: translateX(0); }
    15%, 45%, 75% { transform: translateX(-4px); }
    30%, 60%, 90% { transform: translateX(4px); }
}

.wiggle-animation {
    animation: wiggle 0.4s ease-in-out;
}

.slide-in {
    animation: slideIn 0.3s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

@keyframes slideIn {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
}

/* Allocation Capacity Bar */
.capacity-container {
    margin-top: 0.5rem;
}

.capacity-stats {
    display: flex;
    justify-content: space-between;
    font-size: 0.8rem;
    color: var(--text-secondary);
    margin-bottom: 0.4rem;
}

.progress-track {
    background: rgba(15, 23, 42, 0.8);
    height: 8px;
    border-radius: 10px;
    border: 1px solid var(--border-color);
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    width: 0;
    background: var(--primary);
    box-shadow: 0 0 10px var(--primary-glow);
    border-radius: 10px;
    transition: width 0.4s cubic-bezier(0.4, 0, 0.2, 1), background-color 0.3s;
}

.text-danger {
    color: var(--danger);
    font-weight: 600;
}

/* Visual IP Allocation Map */
.visual-map-panel {
    display: flex;
    flex-direction: column;
}

.map-timeline {
    height: 42px;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    background: rgba(15, 23, 42, 0.6);
    display: flex;
    overflow: hidden;
    margin-top: 0.5rem;
}

.map-block {
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.75rem;
    position: relative;
    cursor: default;
    border-right: 1px solid rgba(0, 0, 0, 0.25);
    transition: var(--transition);
}

.map-block:last-child {
    border-right: none;
}

.map-block:hover {
    filter: brightness(1.2);
}

.block-subnet {
    background: rgba(255, 255, 255, 0.03);
}

.block-subnet::before {
    content: '';
    position: absolute;
    inset: 0;
    opacity: 0.08;
    background: linear-gradient(135deg, var(--text-primary) 0%, transparent 100%);
    pointer-events: none;
}

.block-free {
    background: repeating-linear-gradient(
        45deg,
        rgba(100, 116, 139, 0.05),
        rgba(100, 116, 139, 0.05) 5px,
        rgba(100, 116, 139, 0.1) 5px,
        rgba(100, 116, 139, 0.1) 10px
    );
    color: var(--text-muted);
}

.block-content {
    display: flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0 0.5rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.block-badge {
    font-size: 0.6rem;
    font-weight: 700;
    padding: 0.15rem 0.3rem;
    border-radius: 3px;
    font-family: 'JetBrains Mono', monospace;
    flex-shrink: 0;
}

.block-name {
    font-weight: 500;
    color: #cbd5e1;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Map Tooltip */
.map-tooltip {
    visibility: hidden;
    position: absolute;
    bottom: 120%;
    left: 50%;
    transform: translateX(-50%);
    background: #0f172a;
    color: var(--text-primary);
    padding: 0.65rem 0.85rem;
    border-radius: 8px;
    border: 1px solid var(--border-color);
    font-size: 0.75rem;
    white-space: nowrap;
    z-index: 10;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.6);
    opacity: 0;
    transition: opacity 0.2s, transform 0.2s;
    pointer-events: none;
    line-height: 1.4;
    text-align: left;
}

.map-block:hover .map-tooltip {
    visibility: visible;
    opacity: 1;
    transform: translateX(-50%) translateY(-2px);
}

.map-legend {
    display: flex;
    gap: 1.5rem;
    margin-top: 0.75rem;
    font-size: 0.75rem;
    color: var(--text-secondary);
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 0.4rem;
}

.legend-color {
    width: 10px;
    height: 10px;
    border-radius: 2px;
}

.legend-subnet-color {
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid var(--border-color);
}

.legend-free-color {
    background: repeating-linear-gradient(
        45deg,
        rgba(100, 116, 139, 0.1),
        rgba(100, 116, 139, 0.1) 3px,
        rgba(100, 116, 139, 0.2) 3px,
        rgba(100, 116, 139, 0.2) 6px
    );
    border: 1px solid var(--border-color);
}

/* Cisco IOS Command Unlock Card */
.cisco-panel-card {
    transition: var(--transition);
    position: relative;
    overflow: hidden;
}

.cisco-panel-card.locked::before {
    content: '';
    position: absolute;
    inset: 0;
    background: rgba(7, 11, 19, 0.4);
    backdrop-filter: blur(2px);
    z-index: 5;
    pointer-events: none;
    transition: var(--transition);
}

.unlock-msg {
    text-align: center;
    padding: 2.5rem 1.5rem;
    color: var(--text-secondary);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.75rem;
    background: rgba(255, 255, 255, 0.01);
    border: 1px dashed var(--border-color);
    border-radius: 8px;
}

.unlock-icon {
    font-size: 1.75rem;
    color: var(--text-muted);
}

.code-wrapper {
    background: #030712;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 1rem;
    position: relative;
    max-height: 350px;
    overflow-y: auto;
}

.code-wrapper::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

.code-wrapper::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 4px;
}

.cisco-code {
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.8rem;
    color: #38bdf8;
    white-space: pre;
    line-height: 1.5;
}

/* Toast Notifications */
.toast-notification {
    position: fixed;
    bottom: 2rem;
    right: 2rem;
    background: #0f172a;
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    padding: 0.75rem 1.25rem;
    border-radius: 8px;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.5);
    z-index: 9999;
    font-size: 0.85rem;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    transform: translateY(100px);
    opacity: 0;
    transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1), opacity 0.3s;
    pointer-events: none;
}

.toast-notification.show {
    transform: translateY(0);
    opacity: 1;
}

.toast-success {
    border-left: 4px solid var(--success);
    box-shadow: 0 5px 20px hsla(142, 76%, 45%, 0.15);
}

.toast-error {
    border-left: 4px solid var(--danger);
    box-shadow: 0 5px 20px hsla(346, 84%, 55%, 0.15);
}

.toast-warning {
    border-left: 4px solid var(--warning);
    box-shadow: 0 5px 20px hsla(40, 95%, 55%, 0.15);
}

/* Success Confetti elements styling */
.confetti-particle {
    position: fixed;
    pointer-events: none;
    z-index: 9999;
    opacity: 0.85;
}
