/* =========================================================
   2.08 IP Addressing — Interactive Explorer
   ========================================================= */

.concept-equation {
    margin: 1.2rem 0;
    padding: 1rem 1.25rem;
    border-radius: 18px;
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    color: #0f172a;
    font-size: 1.08rem;
    line-height: 1.7;
    text-align: center;
}

/* ===== Main widget shell ===== */

.ip-address-widget {
    margin: 1.5rem 0;
    padding: 1.25rem;
    border: 1px solid #e2e8f0;
    border-radius: 24px;
    background: #ffffff;
    box-shadow: 0 14px 36px rgba(15, 23, 42, 0.07);
}

.ip-widget-tabs {
    display: flex;
    flex-wrap: wrap;
    gap: 0.6rem;
    margin-bottom: 1.25rem;
}

.ip-widget-tab {
    appearance: none;
    border: 1px solid #cbd5e1;
    border-radius: 999px;
    padding: 0.62rem 1rem;
    background: #f8fafc;
    color: #334155;
    font-size: 0.92rem;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.2s ease;
}

.ip-widget-tab:hover {
    background: #e2e8f0;
}

.ip-widget-tab.active {
    background: #0f172a;
    border-color: #0f172a;
    color: #ffffff;
}

.ip-widget-panel {
    display: none;
}

.ip-widget-panel.active {
    display: block;
    animation: ipPanelFade 0.25s ease;
}

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

.ip-widget-panel h3 {
    margin-top: 0;
}

.ip-widget-error {
    min-height: 1.4rem;
    margin: 0.65rem 0;
    color: #b91c1c;
    font-weight: 700;
}

/* ===== Shared controls ===== */

.ip-input-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(90px, 1fr));
    gap: 0.8rem;
    margin: 1rem 0;
}

.ip-input-grid label,
.cidr-input-row label,
.subnet-input-row label {
    display: grid;
    gap: 0.35rem;
    color: #475569;
    font-size: 0.9rem;
    font-weight: 700;
}

.ip-input-grid input,
.cidr-input-row input,
.subnet-input-row input[type="text"] {
    width: 100%;
    box-sizing: border-box;
    padding: 0.7rem 0.8rem;
    border: 1px solid #cbd5e1;
    border-radius: 14px;
    background: #ffffff;
    color: #0f172a;
    font-size: 1rem;
}

.ip-input-grid input:focus,
.cidr-input-row input:focus,
.subnet-input-row input[type="text"]:focus {
    outline: 2px solid #93c5fd;
    border-color: #60a5fa;
}

.ip-result-card {
    display: grid;
    gap: 0.2rem;
    margin: 1rem 0;
    padding: 1rem 1.1rem;
    border-radius: 18px;
    background: #eff6ff;
    border: 1px solid #bfdbfe;
}

.ip-result-card span,
.ip-mini-card span {
    color: #475569;
    font-size: 0.82rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
}

.ip-result-card strong {
    color: #1e3a8a;
    font-size: 1.45rem;
}

/* ===== IPv4 notation panel ===== */

.byte-conversion-row {
    display: grid;
    grid-template-columns: repeat(4, minmax(140px, 1fr));
    gap: 0.8rem;
    margin-top: 1rem;
}

.byte-card {
    padding: 0.95rem;
    border-radius: 18px;
    background: #f8fafc;
    border: 1px solid #e2e8f0;
}

.byte-card span {
    display: block;
    color: #64748b;
    font-size: 0.82rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.byte-card strong {
    display: block;
    margin-top: 0.35rem;
    color: #0f172a;
    font-size: 1.15rem;
    letter-spacing: 0.08em;
}

/* ===== CIDR panel ===== */

.cidr-input-row {
    display: grid;
    grid-template-columns: minmax(220px, 1.5fr) minmax(100px, 0.5fr);
    gap: 0.8rem;
    align-items: end;
    margin: 1rem 0;
}

.cidr-summary-row,
.subnet-summary-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
    gap: 0.8rem;
    margin: 1rem 0;
}

.ip-mini-card {
    display: grid;
    gap: 0.25rem;
    padding: 0.9rem;
    border-radius: 18px;
    background: #f8fafc;
    border: 1px solid #e2e8f0;
}

.ip-mini-card strong {
    color: #0f172a;
    font-size: 1.2rem;
}

.bit-strip,
.subnet-bit-strip {
    display: flex;
    flex-wrap: wrap;
    gap: 0.26rem;
    margin: 1rem 0 0.8rem;
}

.bit-cell {
    width: 1.55rem;
    height: 2rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 9px;
    font-size: 0.92rem;
    font-weight: 800;
    transition: transform 0.2s ease;
}

.bit-cell:hover {
    transform: translateY(-2px);
}

.bit-cell.byte-break {
    margin-right: 0.5rem;
}

.net-bit {
    background: #dbeafe;
    border: 1px solid #93c5fd;
    color: #1d4ed8;
}

.host-bit {
    background: #fef3c7;
    border: 1px solid #fcd34d;
    color: #92400e;
}

.cidr-legend {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    color: #475569;
    font-size: 0.9rem;
    font-weight: 700;
}

.cidr-legend span {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
}

.legend-swatch {
    width: 1rem;
    height: 1rem;
    display: inline-block;
    border-radius: 999px;
}

.net-swatch {
    background: #dbeafe;
    border: 1px solid #93c5fd;
}

.host-swatch {
    background: #fef3c7;
    border: 1px solid #fcd34d;
}

/* ===== Sub-netting panel ===== */

.subnet-input-row {
    display: grid;
    grid-template-columns: minmax(180px, 1fr) minmax(240px, 1fr);
    gap: 1rem;
    align-items: end;
    margin: 1rem 0;
}

.subnet-input-row label:last-child {
    grid-template-columns: 1fr;
}

.subnet-input-row input[type="range"] {
    width: 100%;
    accent-color: #0f172a;
}

.subnet-lan-bit {
    background: #dcfce7;
    border: 1px solid #86efac;
    color: #166534;
}

.subnet-host-bit {
    background: #f3e8ff;
    border: 1px solid #d8b4fe;
    color: #6b21a8;
}

.subnet-lan-swatch {
    background: #dcfce7;
    border: 1px solid #86efac;
}

.subnet-host-swatch {
    background: #f3e8ff;
    border: 1px solid #d8b4fe;
}

/* ===== NAT panel ===== */

.nat-layout {
    display: grid;
    grid-template-columns: 1.25fr 0.75fr 0.9fr;
    gap: 1rem;
    align-items: stretch;
    margin: 1.1rem 0;
}

.nat-private-network,
.nat-box-card,
.nat-internet-card {
    border-radius: 22px;
    border: 1px solid #e2e8f0;
    padding: 1rem;
    background: #f8fafc;
}

.nat-private-network {
    display: grid;
    gap: 0.65rem;
}

.nat-private-network h4 {
    margin: 0 0 0.3rem;
    color: #334155;
}

.nat-device {
    appearance: none;
    border: 1px solid #cbd5e1;
    border-radius: 16px;
    padding: 0.7rem;
    text-align: left;
    background: #ffffff;
    color: #0f172a;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.2s ease;
}

.nat-device span {
    color: #64748b;
    font-size: 0.88rem;
}

.nat-device:hover {
    border-color: #94a3b8;
}

.nat-device.active {
    background: #eff6ff;
    border-color: #60a5fa;
}

.nat-box-card,
.nat-internet-card {
    display: grid;
    align-content: center;
    justify-items: center;
    text-align: center;
    gap: 0.25rem;
}

.nat-box-card strong,
.nat-internet-card strong {
    color: #0f172a;
    font-size: 1.05rem;
}

.nat-box-card span,
.nat-internet-card span {
    color: #64748b;
    font-size: 0.85rem;
    font-weight: 700;
}

.nat-box-card b,
.nat-internet-card b {
    color: #334155;
}

.nat-action-row {
    display: flex;
    flex-wrap: wrap;
    gap: 0.55rem;
    margin: 0.8rem 0;
}

.ip-secondary-btn {
    background: transparent;
    color: #334155;
    border: 1px solid #cbd5e1;
}

.ip-secondary-btn:hover {
    background: #f8fafc;
    box-shadow: none;
}

.nat-packet-track {
    position: relative;
    height: 3.6rem;
    margin-top: 1rem;
    border-radius: 999px;
    background: #f8fafc;
    border: 1px dashed #cbd5e1;
    overflow: hidden;
}

.nat-packet {
    position: absolute;
    top: 0.55rem;
    left: 0.65rem;
    display: inline-flex;
    align-items: center;
    gap: 0.45rem;
    padding: 0.55rem 0.75rem;
    border-radius: 999px;
    background: #0f172a;
    color: #ffffff;
    font-size: 0.85rem;
    font-weight: 700;
    box-shadow: 0 8px 18px rgba(15, 23, 42, 0.16);
}

.nat-packet.hidden {
    display: none;
}

.nat-packet.moving-to-nat {
    animation: moveToNat 1.8s ease forwards;
}

.nat-packet.moving-to-internet {
    animation: moveToInternet 1.8s ease forwards;
}

.nat-packet.returning-to-nat {
    animation: returnToNat 1.8s ease forwards;
}

.nat-packet.returning-home {
    animation: returnHome 1.8s ease forwards;
}

@keyframes moveToNat {
    from { left: 0.65rem; }
    to { left: calc(42% - 1.2rem); }
}

@keyframes moveToInternet {
    from { left: calc(42% - 1.2rem); }
    to { left: calc(100% - 15rem); }
}

@keyframes returnToNat {
    from { left: calc(100% - 15rem); }
    to { left: calc(42% - 1.2rem); }
}

@keyframes returnHome {
    from { left: calc(42% - 1.2rem); }
    to { left: 0.65rem; }
}

.nat-explanation {
    min-height: 2rem;
    margin: 0.9rem 0 0;
    padding: 0.9rem 1rem;
    border-radius: 18px;
    background: #f0fdf4;
    border: 1px solid #bbf7d0;
    color: #14532d;
    font-weight: 700;
}

/* ===== Responsive ===== */

@media (max-width: 760px) {
    .ip-input-grid,
    .byte-conversion-row,
    .cidr-input-row,
    .subnet-input-row,
    .nat-layout {
        grid-template-columns: 1fr;
    }

    .bit-cell.byte-break {
        margin-right: 0;
    }

    .nat-packet-track {
        height: 4.4rem;
    }

    .nat-packet {
        font-size: 0.76rem;
    }
}

/* ===== NAT step explanation list ===== */

.nat-step-list {
    margin: 1rem 0 0;
    padding: 0;
    list-style: none;

    display: grid;
    gap: 0.65rem;
}

.nat-step {
    padding: 0.85rem 1rem;
    border-radius: 16px;

    background: #f8fafc;
    border: 1px solid #e2e8f0;

    color: #475569;
    line-height: 1.55;

    opacity: 0.72;
    transition:
        background 0.25s ease,
        border-color 0.25s ease,
        color 0.25s ease,
        opacity 0.25s ease,
        transform 0.25s ease;
}

.nat-step.active {
    background: #eff6ff;
    border-color: #60a5fa;
    color: #1e3a8a;

    opacity: 1;
    transform: translateY(-2px);

    box-shadow: 0 10px 24px rgba(37, 99, 235, 0.1);
}

.nat-step.active strong {
    color: #1d4ed8;
}