/* Memory Allocation Simulator — OS debugger theme */

.memsim {
    font-family: "Consolas", "SFMono-Regular", Menlo, monospace;
}

/* Panels (lightweight cards for the debugger look) */
.panel {
    background: #0b1220;
    border: 1px solid #1f2d40;
    border-radius: 8px;
    padding: 1rem 1.1rem;
    box-shadow: 0 4px 18px rgba(0, 0, 0, 0.45);
}

.panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-bottom: 0.9rem;
}

.panel-header h2 {
    font-size: 0.95rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: #cbd5e1;
}

.panel-badge {
    font-size: 0.72rem;
    font-weight: 700;
    padding: 0.2rem 0.55rem;
    border-radius: 4px;
    background: #142033;
    border: 1px solid #2a3b54;
    color: #7dd3fc;
    letter-spacing: 0.05em;
}

/* Module navigation hub */
.module-nav {
    display: flex;
    justify-content: center;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-bottom: 0.5rem;
}

.module-link {
    padding: 0.45rem 1rem;
    border-radius: var(--radius-pill);
    background: var(--bg-card);
    border: 1px solid var(--border);
    color: var(--text-muted);
    text-decoration: none;
    font-size: 0.85rem;
    font-weight: 600;
    transition: all 0.2s ease;
}

.module-link:hover {
    border-color: var(--primary);
    color: var(--text);
    background: var(--primary-soft);
}

.module-link.active {
    background: var(--primary);
    color: #fff;
    border-color: transparent;
}

/* Memory visualization */
.mem-wrapper {
    position: relative;
    width: 100%;
}

/* Memory scale — professional OS memory-map ruler */
.memory-scale {
    display: flex;
    flex-direction: column;
    gap: 4px;
    width: 100%;
    margin-bottom: 6px;
    overflow: hidden;
}

.addr-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 8px;
    width: 100%;
    font-size: 0.7rem;
    font-family: "Consolas", "SFMono-Regular", Menlo, monospace;
    color: #94a3b8;
    letter-spacing: 0;
    padding: 0 2px;
    overflow: hidden;
}

.addr-bar span {
    flex: 1;
    text-align: center;
    white-space: nowrap;
    font-weight: 600;
}

/* Major tick marks aligned with the scale labels */
.memory-ticks {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 8px;
    width: 100%;
    padding: 0 2px;
}

.memory-ticks span {
    flex: 1;
    text-align: center;
    height: 8px;
    border-left: 1px solid #334155;
    font-size: 0;
}

.memory-ticks span:last-child {
    border-right: none;
}

.mem-rail {
    display: flex;
    width: 100%;
    height: 84px;
    border: 1px solid #1f2d40;
    border-radius: 8px;
    overflow: hidden;
    background: #0d1524;
    box-shadow: inset 0 2px 8px rgba(0, 0, 0, 0.4);
}

.memseg {
    height: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    font-size: 0.68rem;
    font-weight: 700;
    color: #e2e8f0;
    border-right: 1px solid rgba(0, 0, 0, 0.35);
    text-align: center;
    overflow: hidden;
    white-space: nowrap;
    transition: filter 0.2s ease, transform 0.2s ease;
    cursor: pointer;
    position: relative;
}

.memseg:last-child {
    border-right: none;
}

.memseg .seg-name {
    font-size: 0.72rem;
    font-weight: 700;
}

.memseg .seg-size {
    font-size: 0.6rem;
    opacity: 0.75;
    font-weight: 400;
}

.memseg.free {
    background: #1a2333;
    color: #64748b;
    border-left: 1px dashed #2a3b54;
    border-right: 1px dashed #2a3b54;
}

.memseg.scanning {
    outline: 2px solid #f59e0b;
    outline-offset: -2px;
    filter: brightness(1.35);
}

.memseg.pulsing {
    animation: memPulse 1s ease-in-out 3;
}

.memseg.fading {
    animation: memFade 0.8s ease forwards;
}

@keyframes memPulse {
    0%, 100% { filter: brightness(1); }
    50% { filter: brightness(1.6); }
}

@keyframes memFade {
    from { filter: brightness(1); opacity: 1; }
    to { filter: brightness(0.4); opacity: 0.6; }
}

.memseg.selected {
    box-shadow: inset 0 0 0 2px #7dd3fc;
}

.mem-footer {
    display: flex;
    justify-content: space-between;
    font-size: 0.68rem;
    color: #64748b;
    margin-top: 4px;
    padding: 0 2px;
}

/* Tooltip */
.memsim-tooltip {
    position: fixed;
    z-index: 200;
    background: #0f1a2e;
    border: 1px solid #2a3b54;
    border-radius: 6px;
    padding: 0.6rem 0.8rem;
    font-size: 0.72rem;
    color: #cbd5e1;
    line-height: 1.5;
    pointer-events: none;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.5);
    min-width: 150px;
    display: none;
}

.memsim-tooltip .tt-title {
    font-weight: 700;
    margin-bottom: 0.3rem;
    color: #e2e8f0;
}

.memsim-tooltip .tt-row {
    display: flex;
    justify-content: space-between;
    gap: 1rem;
}

.memsim-tooltip .tt-row span:first-child {
    color: #94a3b8;
}

.memsim-tooltip .tt-row span:last-child {
    color: #e2e8f0;
}

/* Grid layout */
.memsim-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.25rem;
}

@media (max-width: 900px) {
    .memsim-grid {
        grid-template-columns: 1fr;
    }
}

/* Controls */
.memsim-free-form,
.memsim-actions {
    margin-top: 1rem;
    padding-top: 1rem;
    border-top: 1px solid #1f2d40;
}

.btn-info {
    background: #0ea5e9;
    color: #fff;
}
.btn-info:hover {
    background: #0284c7;
}

.btn-warning {
    background: #d97706;
    color: #fff;
}
.btn-warning:hover {
    background: #b45309;
}

/* Stats */
.memsim-stats {
    grid-template-columns: repeat(2, 1fr);
}

.memsim-stats .stat {
    background: #0d1524;
    border: 1px solid #1f2d40;
    border-radius: 6px;
    padding: 0.7rem 0.5rem;
}

.memsim-stats .stat-value {
    font-size: 1.15rem;
    font-family: "Consolas", monospace;
}

.memsim-stats .stat-label {
    font-size: 0.65rem;
}

/* Memory table */
.memsim-table th,
.memsim-table td {
    font-size: 0.78rem;
}

.memsim-table td {
    font-family: "Consolas", monospace;
}

.memsim-table .dot {
    display: inline-block;
    width: 9px;
    height: 9px;
    border-radius: 2px;
    margin-right: 0.4rem;
    vertical-align: middle;
}

/* Log */
.memsim-log li {
    font-family: "Consolas", monospace;
    font-size: 0.78rem;
}

.memsim-log li.scan { border-left-color: #f59e0b; }
.memsim-log li.merge { border-left-color: #06b6d4; }

/* Responsive memory scale */
@media (max-width: 900px) {
    .addr-bar {
        font-size: 0.62rem;
        gap: 4px;
    }
    .memory-ticks span {
        height: 6px;
    }
}

@media (max-width: 600px) {
    .memory-scale {
        overflow-x: auto;
        padding-bottom: 4px;
    }
    .addr-bar {
        min-width: 420px;
        font-size: 0.6rem;
    }
    .memory-ticks {
        min-width: 420px;
    }
}
