/* Main Styles */
:root {
    --primary-color: #3498db;
    --secondary-color: #2c3e50;
    --accent-color: #e74c3c;
    --light-color: #ecf0f1;
    --dark-color: #2c3e50;
    --success-color: #2ecc71;
    --warning-color: #f39c12;
    --error-color: #e74c3c;
    --border-radius: 4px;
    --box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    --transition: all 0.3s ease;
}

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

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    line-height: 1.6;
    color: var(--dark-color);
    background-color: #f8f9fa;
}

.container {
    width: 100%;
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px;
}

/* Typography */
h1, h2, h3, h4, h5, h6 {
    margin-bottom: 1rem;
    font-weight: 600;
    line-height: 1.2;
}

h1 {
    font-size: 2.5rem;
}

h2 {
    font-size: 2rem;
    color: var(--secondary-color);
    border-bottom: 2px solid var(--primary-color);
    padding-bottom: 0.5rem;
    margin-bottom: 1.5rem;
}

h3 {
    font-size: 1.5rem;
    color: var(--secondary-color);
}

h4 {
    font-size: 1.25rem;
    color: var(--secondary-color);
}

p {
    margin-bottom: 1rem;
}

a {
    color: var(--primary-color);
    text-decoration: none;
    transition: var(--transition);
}

a:hover {
    color: var(--accent-color);
}

ul, ol {
    margin-bottom: 1rem;
    padding-left: 1.5rem;
}

code {
    font-family: 'Courier New', Courier, monospace;
    background-color: #f1f1f1;
    padding: 0.2rem 0.4rem;
    border-radius: var(--border-radius);
    font-size: 0.9rem;
}

pre {
    background-color: #f1f1f1;
    padding: 1rem;
    border-radius: var(--border-radius);
    overflow-x: auto;
    margin-bottom: 1rem;
    font-family: 'Courier New', Courier, monospace;
}

/* Header */
header {
    background-color: var(--secondary-color);
    color: white;
    padding: 1.5rem 0;
    box-shadow: var(--box-shadow);
}

header h1 {
    margin-bottom: 0.5rem;
}

header h2 {
    font-size: 1.2rem;
    font-weight: 400;
    color: #bdc3c7;
    border: none;
    padding: 0;
    margin-bottom: 1.5rem;
}

nav ul {
    display: flex;
    list-style: none;
    padding: 0;
    margin: 0;
}

nav ul li {
    margin-right: 1.5rem;
}

nav ul li:last-child {
    margin-right: 0;
}

nav ul li a {
    color: white;
    text-decoration: none;
    padding: 0.5rem 0;
    position: relative;
    font-weight: 500;
}

nav ul li a:after {
    content: '';
    position: absolute;
    width: 0;
    height: 2px;
    bottom: 0;
    left: 0;
    background-color: var(--primary-color);
    transition: var(--transition);
}

nav ul li a:hover:after,
nav ul li a.active:after {
    width: 100%;
}

nav ul li a.active {
    color: var(--primary-color);
}

/* Main Content */
main {
    padding: 2rem 0;
}

.section {
    padding: 3rem 0;
    border-bottom: 1px solid #e1e1e1;
}

.section:last-child {
    border-bottom: none;
}

/* Buttons */
.btn {
    display: inline-block;
    background-color: var(--primary-color);
    color: white;
    padding: 0.75rem 1.5rem;
    border: none;
    border-radius: var(--border-radius);
    cursor: pointer;
    font-size: 1rem;
    font-weight: 500;
    text-align: center;
    transition: var(--transition);
}

.btn:hover {
    background-color: #2980b9;
    color: white;
}

.btn-secondary {
    background-color: #95a5a6;
}

.btn-secondary:hover {
    background-color: #7f8c8d;
}

.btn-small {
    padding: 0.5rem 1rem;
    font-size: 0.9rem;
}

/* Tutorial Section */
.tutorial-nav {
    display: flex;
    flex-wrap: wrap;
    margin-bottom: 2rem;
    border-bottom: 1px solid #e1e1e1;
}

.tutorial-nav-btn {
    background: none;
    border: none;
    padding: 0.75rem 1.5rem;
    cursor: pointer;
    font-size: 1rem;
    font-weight: 500;
    color: var(--dark-color);
    transition: var(--transition);
    position: relative;
}

.tutorial-nav-btn:after {
    content: '';
    position: absolute;
    width: 0;
    height: 3px;
    bottom: -1px;
    left: 0;
    background-color: var(--primary-color);
    transition: var(--transition);
}

.tutorial-nav-btn:hover:after,
.tutorial-nav-btn.active:after {
    width: 100%;
}

.tutorial-nav-btn.active {
    color: var(--primary-color);
}

.tutorial-section {
    display: none;
}

.tutorial-section.active {
    display: block;
}

.example-box {
    background-color: #f8f9fa;
    border-left: 4px solid var(--primary-color);
    padding: 1.5rem;
    margin-bottom: 1.5rem;
    border-radius: 0 var(--border-radius) var(--border-radius) 0;
}

.comparison-table {
    overflow-x: auto;
    margin-bottom: 1.5rem;
}

table {
    width: 100%;
    border-collapse: collapse;
    margin-bottom: 1.5rem;
}

table th, table td {
    padding: 0.75rem;
    text-align: left;
    border: 1px solid #e1e1e1;
}

table th {
    background-color: #f1f1f1;
    font-weight: 600;
}

table tr:nth-child(even) {
    background-color: #f8f9fa;
}

.next-section {
    margin-top: 2rem;
    text-align: right;
}

.steps-container {
    margin-bottom: 2rem;
}

.step {
    display: flex;
    margin-bottom: 1.5rem;
}

.step-number {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    background-color: var(--primary-color);
    color: white;
    border-radius: 50%;
    font-weight: 600;
    margin-right: 1rem;
    flex-shrink: 0;
}

.step-content {
    flex-grow: 1;
}

.step-content h5 {
    margin-bottom: 0.5rem;
}

/* Calculator Section */
.calculator-container {
    display: flex;
    flex-wrap: wrap;
    gap: 2rem;
    margin-bottom: 2rem;
}

.calculator-input {
    flex: 1;
    min-width: 300px;
}

.calculator-output {
    flex: 1;
    min-width: 300px;
    background-color: #f8f9fa;
    padding: 1.5rem;
    border-radius: var(--border-radius);
    box-shadow: var(--box-shadow);
}

.input-group {
    margin-bottom: 1.5rem;
}

.input-group label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 500;
}

.input-group input,
.input-group select {
    width: 100%;
    padding: 0.75rem;
    border: 1px solid #e1e1e1;
    border-radius: var(--border-radius);
    font-size: 1rem;
}

.input-hint {
    font-size: 0.8rem;
    color: #7f8c8d;
    margin-top: 0.25rem;
}

.subnet-input-container {
    display: flex;
    gap: 1rem;
}

.subnet-input-container select {
    flex-grow: 1;
}

.cidr-input {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.cidr-input input {
    width: 60px;
}

.advanced-options {
    margin-top: 2rem;
    padding-top: 1.5rem;
    border-top: 1px solid #e1e1e1;
}

.result-group {
    margin-bottom: 1.5rem;
}

.result-item {
    display: flex;
    justify-content: space-between;
    padding: 0.5rem 0;
    border-bottom: 1px solid #e1e1e1;
}

.result-item:last-child {
    border-bottom: none;
}

.result-label {
    font-weight: 500;
}

.result-value {
    font-family: 'Courier New', Courier, monospace;
}

.binary-visualization {
    margin-top: 2rem;
    padding-top: 1.5rem;
    border-top: 1px solid #e1e1e1;
}

.binary-container {
    margin-top: 1rem;
}

.binary-row {
    display: flex;
    align-items: center;
    margin-bottom: 0.75rem;
}

.binary-label {
    width: 120px;
    font-weight: 500;
}

.binary-blocks {
    display: flex;
    flex-wrap: wrap;
    gap: 0.25rem;
}

.binary-block {
    display: inline-block;
    width: 20px;
    height: 20px;
    text-align: center;
    line-height: 20px;
    font-size: 0.8rem;
    font-family: 'Courier New', Courier, monospace;
    border-radius: 2px;
}

.binary-block.network {
    background-color: rgba(52, 152, 219, 0.2);
    border: 1px solid rgba(52, 152, 219, 0.5);
}

.binary-block.host {
    background-color: rgba(46, 204, 113, 0.2);
    border: 1px solid rgba(46, 204, 113, 0.5);
}

.subnet-results {
    margin-top: 2rem;
    padding-top: 1.5rem;
    border-top: 1px solid #e1e1e1;
    display: none;
}

.subnet-list {
    margin-top: 1rem;
}

.subnet-item {
    background-color: white;
    padding: 1rem;
    margin-bottom: 1rem;
    border-radius: var(--border-radius);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.subnet-item h5 {
    margin-bottom: 0.5rem;
    color: var(--primary-color);
}

.subnet-details {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 0.5rem;
}

.subnet-detail {
    font-size: 0.9rem;
}

.subnet-detail span {
    font-weight: 500;
}

.action-buttons {
    display: flex;
    gap: 1rem;
    margin-top: 2rem;
}

.network-diagram {
    margin-top: 3rem;
}

.diagram-container {
    background-color: white;
    padding: 1.5rem;
    border-radius: var(--border-radius);
    box-shadow: var(--box-shadow);
    height: 400px;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Live Test Section */
.test-controls {
    display: flex;
    flex-wrap: wrap;
    gap: 1.5rem;
    margin-bottom: 2rem;
    align-items: flex-end;
}

.difficulty-selector,
.question-type-selector {
    flex-grow: 1;
}

.test-container {
    background-color: white;
    padding: 2rem;
    border-radius: var(--border-radius);
    box-shadow: var(--box-shadow);
}

.test-intro,
.test-question,
.test-results {
    display: none;
}

.test-intro.active,
.test-question.active,
.test-results.active {
    display: block;
}

.question-header {
    display: flex;
    justify-content: space-between;
    margin-bottom: 1.5rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid #e1e1e1;
}

.timer {
    font-weight: 600;
    color: var(--accent-color);
}

.question-text {
    margin-bottom: 1.5rem;
}

.answer-options {
    margin-bottom: 2rem;
}

.answer-option {
    display: block;
    padding: 1rem;
    margin-bottom: 0.75rem;
    border: 1px solid #e1e1e1;
    border-radius: var(--border-radius);
    cursor: pointer;
    transition: var(--transition);
}

.answer-option:hover {
    background-color: #f8f9fa;
}

.answer-option.selected {
    border-color: var(--primary-color);
    background-color: rgba(52, 152, 219, 0.1);
}

.answer-option.correct {
    border-color: var(--success-color);
    background-color: rgba(46, 204, 113, 0.1);
}

.answer-option.incorrect {
    border-color: var(--error-color);
    background-color: rgba(231, 76, 60, 0.1);
}

.question-controls {
    display: flex;
    justify-content: flex-end;
    gap: 1rem;
}

.score-summary {
    display: flex;
    align-items: center;
    gap: 2rem;
    margin-bottom: 2rem;
}

.score-circle {
    width: 120px;
    height: 120px;
    border-radius: 50%;
    background-color: var(--primary-color);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 2rem;
    font-weight: 600;
}

.score-details {
    flex-grow: 1;
}

.result-breakdown {
    margin-bottom: 2rem;
}

.question-breakdown {
    margin-top: 1rem;
}

.breakdown-item {
    display: flex;
    align-items: center;
    padding: 0.75rem;
    margin-bottom: 0.5rem;
    background-color: #f8f9fa;
    border-radius: var(--border-radius);
}

.breakdown-status {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    margin-right: 1rem;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 0.8rem;
}

.breakdown-status.correct {
    background-color: var(--success-color);
}

.breakdown-status.incorrect {
    background-color: var(--error-color);
}

.breakdown-question {
    flex-grow: 1;
}

.breakdown-answer {
    font-weight: 500;
    margin-left: 1rem;
}

.test-actions {
    display: flex;
    gap: 1rem;
}

/* Animations Section */
.animation-controls {
    margin-bottom: 2rem;
}

.animation-selector {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
}

.animation-btn {
    background: none;
    border: 2px solid var(--primary-color);
    padding: 0.75rem 1.5rem;
    cursor: pointer;
    font-size: 1rem;
    font-weight: 500;
    color: var(--primary-color);
    border-radius: var(--border-radius);
    transition: var(--transition);
}

.animation-btn:hover,
.animation-btn.active {
    background-color: var(--primary-color);
    color: white;
}

.animation {
    display: none;
}

.animation.active {
    display: block;
}

.animation-input {
    display: flex;
    flex-wrap: wrap;
    gap: 1.5rem;
    margin-bottom: 1.5rem;
    align-items: flex-end;
}

.animation-input .input-group {
    flex-grow: 1;
    margin-bottom: 0;
}

.animation-stage {
    background-color: white;
    padding: 1.5rem;
    border-radius: var(--border-radius);
    box-shadow: var(--box-shadow);
    margin-bottom: 1.5rem;
    display: flex;
    justify-content: center;
}

.animation-explanation {
    background-color: #f8f9fa;
    padding: 1.5rem;
    border-radius: var(--border-radius);
}

.topology-container {
    width: 100%;
    height: 400px;
    position: relative;
}

/* Resources Section */
.resources-container {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 2rem;
}

.resource-category {
    margin-bottom: 2rem;
}

.resource-list {
    list-style: none;
    padding: 0;
}

.resource-list li {
    margin-bottom: 0.75rem;
}

.resource-list li a {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.glossary {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 1.5rem;
}

.glossary-item {
    background-color: white;
    padding: 1.5rem;
    border-radius: var(--border-radius);
    box-shadow: var(--box-shadow);
}

.glossary-item h4 {
    margin-bottom: 0.5rem;
    color: var(--primary-color);
}

/* Footer */
footer {
    background-color: var(--secondary-color);
    color: white;
    padding: 2rem 0;
    text-align: center;
}

footer p {
    margin-bottom: 0.5rem;
}

footer i {
    color: var(--accent-color);
}

/* Responsive Design */
@media (max-width: 768px) {
    h1 {
        font-size: 2rem;
    }
    
    h2 {
        font-size: 1.75rem;
    }
    
    h3 {
        font-size: 1.25rem;
    }
    
    nav ul {
        flex-wrap: wrap;
    }
    
    nav ul li {
        margin-right: 1rem;
        margin-bottom: 0.5rem;
    }
    
    .calculator-container {
        flex-direction: column;
    }
    
    .subnet-input-container {
        flex-direction: column;
    }
    
    .test-controls {
        flex-direction: column;
        align-items: stretch;
    }
    
    .animation-input {
        flex-direction: column;
        align-items: stretch;
    }
    
    .resources-container {
        grid-template-columns: 1fr;
    }
}

/* Animations */
@keyframes fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

.fade-in {
    animation: fadeIn 0.5s ease-in-out;
}

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

.slide-in {
    animation: slideIn 0.5s ease-in-out;
}

/* Dark Mode */
.dark-mode {
    --primary-color: #3498db;
    --secondary-color: #2c3e50;
    --accent-color: #e74c3c;
    --light-color: #2c3e50;
    --dark-color: #ecf0f1;
    
    background-color: #1a1a1a;
    color: #ecf0f1;
}

.dark-mode header {
    background-color: #2c3e50;
}

.dark-mode .section {
    border-bottom-color: #333;
}

.dark-mode table th, 
.dark-mode table td {
    border-color: #333;
}

.dark-mode table th {
    background-color: #2c3e50;
}

.dark-mode table tr:nth-child(even) {
    background-color: #222;
}

.dark-mode .example-box,
.dark-mode .calculator-output,
.dark-mode .test-container,
.dark-mode .animation-stage,
.dark-mode .glossary-item {
    background-color: #222;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.3);
}

.dark-mode .input-group input,
.dark-mode .input-group select {
    background-color: #333;
    border-color: #444;
    color: #ecf0f1;
}

.dark-mode code, 
.dark-mode pre {
    background-color: #333;
    color: #ecf0f1;
}

.dark-mode .result-item {
    border-bottom-color: #333;
}

.dark-mode .binary-block.network {
    background-color: rgba(52, 152, 219, 0.3);
    border-color: rgba(52, 152, 219, 0.7);
}

.dark-mode .binary-block.host {
    background-color: rgba(46, 204, 113, 0.3);
    border-color: rgba(46, 204, 113, 0.7);
}

.dark-mode .subnet-item {
    background-color: #222;
}

.dark-mode .answer-option {
    background-color: #222;
    border-color: #444;
}

.dark-mode .answer-option:hover {
    background-color: #333;
}

.dark-mode .answer-option.selected {
    background-color: rgba(52, 152, 219, 0.2);
}

.dark-mode .answer-option.correct {
    background-color: rgba(46, 204, 113, 0.2);
}

.dark-mode .answer-option.incorrect {
    background-color: rgba(231, 76, 60, 0.2);
}

.dark-mode .breakdown-item {
    background-color: #222;
}

.dark-mode .animation-explanation {
    background-color: #222;
}

/* Accessibility */
.visually-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    margin: -1px;
    padding: 0;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    border: 0;
}

:focus {
    outline: 2px solid var(--primary-color);
    outline-offset: 2px;
}

.skip-link {
    position: absolute;
    top: -40px;
    left: 0;
    background: var(--primary-color);
    color: white;
    padding: 8px;
    z-index: 100;
}

.skip-link:focus {
    top: 0;
}

/* Print Styles */
@media print {
    header, footer, nav, .btn, .animation-controls, .test-controls {
        display: none;
    }
    
    body {
        font-size: 12pt;
        line-height: 1.5;
        color: #000;
        background: #fff;
    }
    
    .container {
        width: 100%;
        max-width: none;
        padding: 0;
        margin: 0;
    }
    
    h1, h2, h3, h4, h5, h6 {
        page-break-after: avoid;
        page-break-inside: avoid;
    }
    
    img, table, pre, blockquote, .example-box {
        page-break-inside: avoid;
    }
    
    a {
        color: #000;
        text-decoration: underline;
    }
    
    a[href^="http"]:after {
        content: " (" attr(href) ")";
        font-size: 90%;
    }
}
