/* ===== Base Styles ===== */
body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    margin: 0;
    padding: 20px;
    color: white;
    min-height: 100vh;
}

a:focus-visible,
button:focus-visible,
select:focus-visible {
    outline: 3px solid #f1c40f;
    outline-offset: 3px;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 15px;
    padding: 30px;
    backdrop-filter: blur(10px);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.1);
}

/* ===== Navigation ===== */
.back-button {
    background: rgba(255, 255, 255, 0.2);
    color: white;
    border: 2px solid rgba(255, 255, 255, 0.3);
    padding: 12px 24px;
    border-radius: 25px;
    cursor: pointer;
    font-size: 16px;
    transition: all 0.3s ease;
    text-decoration: none;
    display: inline-block;
    margin-bottom: 20px;
}

.back-button:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: translateY(-2px);
}

/* ===== Typography ===== */
h1 {
    text-align: center;
    margin-bottom: 20px;
    font-size: 2.5em;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.3);
}

h2 {
    margin-top: 30px;
    margin-bottom: 15px;
    font-size: 1.8em;
    color: #f0f0f0;
}

.highlight {
    color: #f1c40f;
    font-weight: bold;
}

/* ===== Buttons ===== */
.btn {
    background: rgba(255, 255, 255, 0.2);
    color: white;
    border: 2px solid rgba(255, 255, 255, 0.3);
    padding: 12px 24px;
    margin: 0 10px;
    border-radius: 25px;
    cursor: pointer;
    font-size: 16px;
    transition: all 0.3s ease;
    backdrop-filter: blur(5px);
}

.btn:hover:not(:disabled) {
    background: rgba(255, 255, 255, 0.3);
    transform: translateY(-2px);
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* ===== Form Controls ===== */
select {
    background: rgba(255, 255, 255, 0.2);
    color: white;
    border: 2px solid rgba(255, 255, 255, 0.3);
    padding: 10px 15px;
    border-radius: 5px;
    font-size: 16px;
    backdrop-filter: blur(5px);
}

/* ===== Layout ===== */
.controls {
    text-align: center;
    margin: 20px 0;
}

.step-controls {
    display: flex;
    justify-content: center;
    margin-top: 15px;
}

.phase-indicator {
    display: flex;
    justify-content: center;
    margin: 20px 0;
}

.phase {
    width: 120px;
    height: 40px;
    background: rgba(255, 255, 255, 0.2);
    margin: 0 5px;
    border-radius: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
}

.phase.active {
    background: rgba(46, 204, 113, 0.5);
    transform: scale(1.1);
}

/* ===== Demo Area ===== */
.demo-area {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin: 20px 0;
    min-height: 400px;
}

.device-icon {
    font-size: 4em;
    margin-bottom: 15px;
}

/* ===== Status Indicators ===== */
.status {
    text-align: center;
    font-size: 1.2em;
    margin: 20px 0;
    padding: 10px;
    border-radius: 5px;
    font-weight: bold;
}

.status.idle {
    background: rgba(149, 165, 166, 0.3);
}

.status.transmitting,
.status.routing,
.status.encapsulating,
.status.establishing {
    background: rgba(241, 196, 15, 0.3);
}

.status.receiving,
.status.forwarding,
.status.active {
    background: rgba(46, 204, 113, 0.3);
}

/* ===== Wireshark / Code Display ===== */
.wireshark-packet {
    background: rgba(0, 0, 0, 0.4);
    border: 1px solid rgba(255, 255, 255, 0.3);
    border-radius: 8px;
    padding: 16px 20px;
    margin: 12px 0;
    font-family: 'Courier New', monospace;
    font-size: 1.15em;
    color: #00ff00;
    white-space: pre-wrap;
    word-wrap: break-word;
    overflow-wrap: break-word;
    line-height: 1.6;
    min-height: 120px;
    max-height: 250px;
    overflow-x: auto;
    overflow-y: auto;
    width: 100%;
    box-sizing: border-box;
}

.wireshark-example {
    background: rgba(0, 0, 0, 0.5);
    border: 1px solid rgba(255, 255, 255, 0.3);
    border-radius: 8px;
    padding: 12px;
    margin: 12px 0;
    font-family: 'Courier New', monospace;
    color: #00ff00;
    font-size: 0.9em;
}

.packet-explanation {
    background: rgba(41, 128, 185, 0.3);
    padding: 10px;
    border-radius: 5px;
    margin: 5px 0;
    font-size: 0.9em;
    border-left: 4px solid #3498db;
}

.step-counter {
    background: rgba(0, 0, 0, 0.3);
    padding: 5px 15px;
    border-radius: 15px;
    margin: 10px 0;
    font-weight: bold;
}

/* ===== Content Sections ===== */
.content-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(350px, 1fr));
    gap: 30px;
    margin: 30px 0;
}

.content-box {
    background: rgba(0, 0, 0, 0.3);
    padding: 25px;
    border-radius: 15px;
    border-left: 4px solid #3498db;
}

.protocols-list {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 20px;
    margin: 20px 0;
}

.protocol-card {
    background: rgba(52, 152, 219, 0.3);
    padding: 20px;
    border-radius: 12px;
    border: 1px solid rgba(255, 255, 255, 0.2);
}

.example-box {
    background: rgba(41, 128, 185, 0.3);
    padding: 20px;
    border-radius: 10px;
    margin: 20px 0;
    border-left: 4px solid #3498db;
}

.demo-section {
    background: rgba(142, 68, 173, 0.3);
    padding: 25px;
    border-radius: 15px;
    margin: 30px 0;
}

.protocol-info {
    background: rgba(0, 0, 0, 0.3);
    padding: 20px;
    border-radius: 10px;
    margin: 20px 0;
}

.protocol-selector,
.medium-selector {
    margin: 20px 0;
    text-align: center;
}

.characteristic {
    background: rgba(0, 0, 0, 0.2);
    padding: 15px;
    margin: 5px;
    border-radius: 10px;
    width: calc(50% - 30px);
    box-sizing: border-box;
}

/* ===== Tables ===== */
table {
    width: 100%;
    border-collapse: collapse;
    margin: 20px 0;
    background: rgba(0, 0, 0, 0.2);
}

th, td {
    padding: 12px;
    border: 1px solid rgba(255, 255, 255, 0.2);
    text-align: left;
}

th {
    background: rgba(52, 152, 219, 0.6);
    font-weight: bold;
}

/* ===== Dark Mode Toggle ===== */
.dark-mode-toggle {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 1000;
    background: rgba(255, 255, 255, 0.2);
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-radius: 25px;
    padding: 10px 20px;
    cursor: pointer;
    backdrop-filter: blur(10px);
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 16px;
    color: white;
}

.dark-mode-toggle:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: translateY(-2px);
}

/* ===== Dark Mode ===== */
body.dark-mode {
    background: linear-gradient(135deg, #1a1a1a 0%, #2d2d2d 100%) !important;
}

body.dark-mode .container {
    background: rgba(0, 0, 0, 0.4);
}

body.dark-mode .content-box,
body.dark-mode .protocol-info,
body.dark-mode .example-box,
body.dark-mode .demo-section {
    background: rgba(0, 0, 0, 0.5);
}

/* ===== Footer ===== */
.site-footer {
    background: rgba(0, 0, 0, 0.3);
    padding: 20px;
    margin-top: 40px;
    border-top: 2px solid rgba(255, 255, 255, 0.1);
    text-align: center;
    border-radius: 10px;
    max-width: 1200px;
    margin-left: auto;
    margin-right: auto;
}

.site-footer p {
    margin: 0;
    font-size: 0.9em;
    line-height: 1.6;
    color: white;
}

.site-footer .support-text {
    margin: 10px 0 0 0;
    font-size: 0.85em;
    opacity: 0.7;
}

.site-footer a {
    color: #3498db;
    text-decoration: none;
}

/* ===== Collapsible Sections ===== */
details {
    margin: 20px 0;
}

details > summary {
    cursor: pointer;
    padding: 15px 20px;
    background: rgba(0, 0, 0, 0.2);
    border-radius: 10px;
    font-size: 1.1em;
    font-weight: bold;
    transition: background 0.3s ease;
    list-style: none;
}

details > summary::-webkit-details-marker {
    display: none;
}

details > summary::before {
    content: '▶ ';
    display: inline-block;
    transition: transform 0.3s ease;
}

details[open] > summary::before {
    transform: rotate(90deg);
}

details > summary:hover {
    background: rgba(0, 0, 0, 0.3);
}

details[open] > summary {
    margin-bottom: 15px;
    border-radius: 10px 10px 0 0;
}

/* ===== Responsive ===== */
@media (max-width: 768px) {
    body {
        padding: 10px;
    }

    .container {
        padding: 15px;
    }

    .demo-area {
        flex-direction: column;
        min-height: auto;
        gap: 20px;
    }

    .demo-area > div {
        width: 100% !important;
        height: auto !important;
        min-height: 150px;
    }

    .signal-line,
    .data-link,
    .network-path,
    .session-line {
        width: 100% !important;
    }

    .signal-info,
    .link-info,
    .routing-info,
    .session-info {
        width: 100% !important;
        box-sizing: border-box;
    }

    h1 {
        font-size: 1.8em;
    }

    h2 {
        font-size: 1.4em;
    }

    .content-grid {
        grid-template-columns: 1fr;
    }

    .protocols-list {
        grid-template-columns: 1fr;
    }

    .phase-indicator {
        flex-wrap: wrap;
    }

    .phase {
        width: 90px;
        font-size: 0.85em;
    }

    .step-controls {
        flex-direction: column;
        gap: 10px;
        align-items: center;
    }

    .characteristic {
        width: 100%;
    }

    .controls .btn {
        margin: 5px;
    }

    .dark-mode-toggle {
        top: 10px;
        right: 10px;
        padding: 8px 12px;
        font-size: 14px;
    }
}
