/* Reset and Base Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --primary-color: #2c3e50;
    --secondary-color: #34495e;
    --accent-color: #3498db;
    --success-color: #27ae60;
    --warning-color: #f39c12;
    --danger-color: #e74c3c;
    --bg-color: #ecf0f1;
    --text-color: #2c3e50;
    --border-color: #bdc3c7;
    --toolbar-width: 200px;
    --panel-width: 350px;
    --header-height: 60px;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    color: var(--text-color);
    background: var(--bg-color);
    overflow: hidden;
}

/* Header */
header {
    height: var(--header-height);
    background: var(--primary-color);
    color: white;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 20px;
    box-shadow: 0 2px 5px rgba(0,0,0,0.1);
}

.header-title-bar {
    display: flex;
    align-items: center;
    gap: 20px;
    width: 100%;
}

.header-title-bar h1 {
    flex: 1;
}

.header-title-bar h1 {
    font-size: 1.5rem;
    margin: 0;
}

.header-title-bar .mobile-panel-toggle {
    display: none;
}

header h1 {
    font-size: 1.5rem;
}

.header-controls {
    display: flex;
    gap: 10px;
    align-items: center;
}

.header-controls button {
    padding: 8px 15px;
    background: var(--accent-color);
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.9rem;
    transition: background 0.3s;
}

.header-controls button:hover {
    background: #2980b9;
}

.mobile-panel-toggle {
    display: none;
    font-size: 1.5rem;
    padding: 5px 5px !important;
}

/* Mobile Vertical Tabs Sidebar - hidden by default on desktop */
.mobile-tabs-sidebar {
    display: none;
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 50px;
    background: var(--secondary-color);
    z-index: 950;
    box-shadow: 2px 0 5px rgba(0,0,0,0.2);
    height: fit-content;
}

.mobile-tab {
    position: relative;
}

.mobile-tab-label {
    width: 50px;
    height: 50px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    cursor: pointer;
    background: var(--secondary-color);
    border-bottom: 1px solid rgba(255,255,255,0.1);
    transition: background 0.3s;
}

.mobile-tab-label:hover {
    background: rgba(255,255,255,0.1);
}

.mobile-tab-content {
    position: absolute;
    left: 50px;
    top: 0;
    min-width: 200px;
    background: white;
    box-shadow: 2px 2px 8px rgba(0,0,0,0.3);
    border-radius: 0 4px 4px 0;
    z-index: 951;
    display: none;
}

/* Submenus shown only when opened via click (no hover on mobile) */
.mobile-tab-content.open {
    display: block;
}

.mobile-tab-title {
    padding: 12px 16px;
    background: var(--secondary-color);
    color: white;
    font-weight: bold;
    border-bottom: 1px solid rgba(255,255,255,0.2);
}

.mobile-tab-content a {
    color: var(--text-color);
    padding: 12px 16px;
    text-decoration: none;
    display: block;
    cursor: pointer;
    transition: background 0.2s;
    border-bottom: 1px solid var(--border-color);
}

.mobile-tab-content a:hover {
    background-color: var(--bg-color);
}

.mobile-tab-content a:last-child {
    border-bottom: none;
}

.desktop-controls {
    display: flex;
}

.header-controls label {
    display: flex;
    align-items: center;
    gap: 5px;
    cursor: pointer;
}

/* Main Layout */
.main-layout {
    display: flex;
    flex-direction: row;
    height: calc(100vh - var(--header-height)); /* Full height minus header */
    position: relative;
    padding-bottom: 200px; /* Reserve space for console */
    transition: padding-bottom 0.3s ease;
    z-index: 1;
}

.main-layout.console-collapsed {
    padding-bottom: 35px; /* Reserve less space when console is collapsed */
}

/* Toolbar - vertical on desktop */
.toolbar {
    width: var(--toolbar-width);
    background: var(--secondary-color);
    color: white;
    padding: 15px;
    overflow-y: auto;
    box-shadow: 2px 0 5px rgba(0,0,0,0.1);
    flex-shrink: 0;
}

.toolbar h3, .toolbar h4 {
    margin-bottom: 10px;
    font-size: 1rem;
    border-bottom: 2px solid var(--accent-color);
    padding-bottom: 5px;
}

.component-list {
    display: grid;
    grid-template-columns: 1fr;
    gap: 10px;
    margin-bottom: 20px;
}

.component-item {
    background: rgba(255, 255, 255, 0.1);
    padding: 10px;
    border-radius: 4px;
    cursor: grab;
    display: flex;
    align-items: center;
    gap: 10px;
    transition: background 0.3s;
}

.component-item:hover {
    background: rgba(255, 255, 255, 0.2);
}

.component-item:active {
    cursor: grabbing;
}

.component-icon {
    font-size: 1.5rem;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    flex-shrink: 0;
}

.component-icon img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
}

.component-item span {
    font-size: 0.9rem;
}

.toolbar-actions {
    margin-top: 20px;
}

.toolbar-actions button {
    width: 100%;
    padding: 10px;
    margin-bottom: 8px;
    background: var(--danger-color);
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    transition: background 0.3s;
}

.toolbar-actions button:hover {
    background: #c0392b;
}

.toolbar-actions button:hover {
    background: #2980b9;
}

.zoom-controls {
    display: flex;
    gap: 5px;
}

.zoom-controls button {
    flex: 1;
    padding: 8px;
    background: rgba(255, 255, 255, 0.1);
    color: white;
    border: 1px solid rgba(255, 255, 255, 0.3);
    border-radius: 4px;
    cursor: pointer;
    transition: background 0.3s;
}

.zoom-controls button:hover {
    background: rgba(255, 255, 255, 0.2);
}

/* Content Wrapper (canvas + overlay) */
.content-wrapper {
    flex: 1;
    position: relative;
    display: flex;
    flex-direction: column;
}

/* Canvas Container */
.canvas-container {
    flex: 1;
    position: relative;
    background: #f8f9fa;
    overflow: hidden;
}

#network-canvas {
    width: 100%;
    height: 100%;
    cursor: default;
}

/* Context Menu */
.context-menu {
    position: fixed;
    background: white;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.2);
    z-index: 1000;
    min-width: 150px;
}

.context-menu.hidden {
    display: none;
}

.context-menu .menu-item {
    padding: 10px 15px;
    cursor: pointer;
    transition: background 0.2s;
}

.context-menu .menu-item:hover {
    background: var(--bg-color);
}

/* Right Panel */
.right-panel {
    width: var(--panel-width);
    background: white;
    box-shadow: -2px 0 5px rgba(0,0,0,0.1);
    display: flex;
    flex-direction: column;
    position: absolute;
    right: 0;
    top: 0;
    bottom: 0;
    z-index: 900;
    transition: transform 0.3s ease;
    height: 100%;
    max-height: 100%;
}

@media screen and (min-width: 1025px) {
    .right-panel {
        position: relative;
    }
    
    .mobile-tabs-sidebar {
        display: none !important;
    }
}

/* Mobile Overlay */
.mobile-overlay {
    display: none;
    position: fixed;
    top: var(--header-height);
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 898;
}

.panel-tabs {
    display: flex;
    background: var(--secondary-color);
}

.tab-btn {
    flex: 1;
    padding: 12px;
    background: transparent;
    color: rgba(255, 255, 255, 0.7);
    border: none;
    cursor: pointer;
    transition: all 0.3s;
    border-bottom: 3px solid transparent;
}

.tab-btn:hover {
    background: rgba(255, 255, 255, 0.1);
}

.tab-btn.active {
    color: white;
    border-bottom-color: var(--accent-color);
}

.panel-content {
    flex: 1;
    overflow-y: auto;
    padding: 15px;
}

.tab-panel {
    display: none;
}

.tab-panel.active {
    display: block;
}

.placeholder {
    color: #95a5a6;
    text-align: center;
    padding: 20px;
}

/* Configuration Panel */
.config-form {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.config-form h3 {
    color: var(--primary-color);
    margin-bottom: 5px;
    font-size: 1.2rem;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.form-group label {
    font-weight: 600;
    font-size: 0.9rem;
    display: flex;
    align-items: center;
    gap: 5px;
}

.form-group input[type="text"],
.form-group input[type="number"],
.form-group select {
    padding: 8px;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    font-size: 0.9rem;
}

.form-group input[type="checkbox"] {
    width: 20px;
    height: 20px;
    cursor: pointer;
}

.help-icon {
    cursor: help;
    color: var(--accent-color);
    font-size: 0.8rem;
}

.section-divider {
    border-top: 2px solid var(--border-color);
    margin: 10px 0;
}

.action-buttons {
    display: flex;
    gap: 10px;
    margin-top: 10px;
}

.action-buttons button {
    flex: 1;
    padding: 10px;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-weight: 600;
    transition: opacity 0.3s;
}

.btn-primary {
    background: var(--accent-color);
    color: white;
}

.btn-success {
    background: var(--success-color);
    color: white;
}

.btn-danger {
    background: var(--danger-color);
    color: white;
}

.action-buttons button:hover {
    opacity: 0.8;
}

/* Console Panel */
.console-header {
    margin-bottom: 10px;
}

.console-header button {
    padding: 6px 12px;
    background: var(--secondary-color);
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
}

.console-output {
    background: #1e1e1e;
    color: #d4d4d4;
    padding: 10px;
    border-radius: 4px;
    font-family: 'Courier New', monospace;
    font-size: 0.85rem;
    line-height: 1.4;
    max-height: calc(100vh - 250px);
    overflow-y: auto;
}

.console-line {
    margin-bottom: 5px;
    word-wrap: break-word;
}

.console-line.ping {
    color: #4ec9b0;
}

.console-line.dhcp {
    color: #ce9178;
}

.console-line.web {
    color: #569cd6;
}

.console-line.dns {
    color: #c586c0;
}

.console-line.error {
    color: #f48771;
}

.console-line.success {
    color: #89d185;
}

/* Diagnostics Panel */
#diagnostics-content {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.diagnostic-item {
    padding: 12px;
    border-radius: 4px;
    border-left: 4px solid;
}

.diagnostic-item.error {
    background: #fee;
    border-color: var(--danger-color);
}

.diagnostic-item.warning {
    background: #ffc;
    border-color: var(--warning-color);
}

.diagnostic-item.success {
    background: #efe;
    border-color: var(--success-color);
}

.diagnostic-item h4 {
    margin-bottom: 5px;
    font-size: 1rem;
}

.diagnostic-item p {
    font-size: 0.9rem;
    color: #555;
}

/* Modal */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2000;
}

.modal.hidden {
    display: none;
}

.modal-content {
    background: white;
    padding: 30px;
    border-radius: 8px;
    max-width: 600px;
    max-height: 80vh;
    overflow-y: auto;
    position: relative;
    box-shadow: 0 5px 20px rgba(0,0,0,0.3);
}

.close-modal {
    position: absolute;
    top: 10px;
    right: 15px;
    font-size: 2rem;
    cursor: pointer;
    color: #999;
}

.close-modal:hover {
    color: #333;
}

/* Exercises */
#exercises-list {
    display: flex;
    flex-direction: column;
    gap: 15px;
    margin-top: 20px;
}

.exercise-item {
    padding: 15px;
    border: 2px solid var(--border-color);
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.3s;
}

.exercise-item:hover {
    border-color: var(--accent-color);
    background: #f8f9fa;
}

.exercise-item h3 {
    color: var(--primary-color);
    margin-bottom: 5px;
}

.exercise-item p {
    font-size: 0.9rem;
    color: #666;
}

/* Scrollbar Styling */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: #f1f1f1;
}

::-webkit-scrollbar-thumb {
    background: #888;
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: #555;
}

/* Glossary */
.glossary-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-top: 15px;
}

.glossary-item {
    padding: 12px;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.3s;
}

.glossary-item:hover {
    background: #f8f9fa;
    border-color: var(--accent-color);
}

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

.glossary-item p {
    font-size: 0.9rem;
    color: #666;
}

.example-box {
    background: #f8f9fa;
    padding: 10px;
    border-left: 3px solid var(--accent-color);
    margin-top: 10px;
    border-radius: 4px;
}

.level-badge {
    display: inline-block;
    padding: 4px 12px;
    border-radius: 12px;
    font-size: 0.9em;
    font-weight: 600;
    margin-left: 8px;
}

.level-badge.level-discovery {
    background: #d4edda;
    color: #155724;
}

.level-badge.level-advanced {
    background: #fff3cd;
    color: #856404;
}

.level-badge.level-expert {
    background: #f8d7da;
    color: #721c24;
}

.example-box code {
    background: #e9ecef;
    padding: 2px 6px;
    border-radius: 3px;
    font-family: 'Courier New', monospace;
}

.level-débutant {
    color: var(--success-color);
    font-weight: bold;
}

.level-intermédiaire {
    color: var(--warning-color);
    font-weight: bold;
}

.level-avancé {
    color: var(--danger-color);
    font-weight: bold;
}

/* Bottom Console Panel */
.console-bottom {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: 200px;
    background: #1e1e1e;
    border-top: 1px solid #444;
    display: flex;
    flex-direction: column;
    z-index: 100;
    transition: height 0.3s ease;
}

.console-bottom.collapsed {
    height: 35px;
}

.console-bottom .console-header {
    background: #2d2d2d;
    padding: 8px 15px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid #444;
}

.console-bottom .console-title {
    color: #cccccc;
    font-weight: bold;
    font-size: 0.9rem;
}

.console-bottom .console-actions {
    display: flex;
    gap: 5px;
}

.console-bottom .console-actions button {
    background: transparent;
    color: #cccccc;
    border: none;
    padding: 4px 8px;
    cursor: pointer;
    border-radius: 3px;
    transition: background 0.2s;
}

.console-bottom .console-actions button:hover {
    background: rgba(255, 255, 255, 0.1);
}

.console-bottom .console-output {
    flex: 1;
    overflow-y: auto;
    padding: 10px;
    font-family: 'Courier New', monospace;
    font-size: 0.85rem;
    color: #cccccc;
}

.console-bottom.collapsed .console-output {
    display: none;
}

/* Component hover effect */
.component-item:not(:disabled):hover {
    transform: translateX(5px);
}

/* Selected component highlight */
.component-selected {
    outline: 3px solid var(--accent-color);
    outline-offset: 2px;
}

/* Dialog System */
.dialog-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.6);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10000;
    animation: fadeIn 0.2s ease;
}

.dialog-overlay.hidden {
    display: none;
}

.dialog-box {
    background: white;
    border-radius: 8px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
    min-width: 400px;
    max-width: 600px;
    max-height: 80vh;
    display: flex;
    flex-direction: column;
    animation: slideIn 0.3s ease;
}

.dialog-header {
    padding: 20px 25px;
    border-bottom: 1px solid #e0e0e0;
    background: linear-gradient(to bottom, #f8f9fa, #ffffff);
}

.dialog-header h3 {
    color: #2c3e50;
    font-size: 1.3em;
}

.dialog-body {
    padding: 25px;
    overflow-y: auto;
    flex: 1;
}

.dialog-body p {
    line-height: 1.6;
    color: #34495e;
    margin: 0;
}

.dialog-input {
    width: 100%;
    padding: 10px;
    border: 2px solid #ddd;
    border-radius: 4px;
    font-size: 14px;
    transition: border-color 0.2s;
}

.dialog-input:focus {
    outline: none;
    border-color: #3498db;
}

.dialog-footer {
    padding: 15px 25px;
    border-top: 1px solid #e0e0e0;
    display: flex;
    gap: 10px;
    justify-content: flex-end;
    background: #f8f9fa;
}

.dialog-footer button {
    padding: 10px 20px;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 14px;
    transition: all 0.2s;
}

.web-preview {
    background: white;
    border: 1px solid #ddd;
    border-radius: 4px;
    padding: 15px;
    max-height: 400px;
    overflow-y: auto;
}

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

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

/* Exercise Panel Styles */
.exercise-item {
    display: flex;
    align-items: center;
    gap: 15px;
    padding: 15px;
    background: white;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    margin-bottom: 10px;
    transition: all 0.2s;
    cursor: pointer;
}

.exercise-item:hover {
    border-color: var(--accent-color);
    box-shadow: 0 2px 8px rgba(52, 152, 219, 0.15);
    transform: translateY(-1px);
}

.exercise-number {
    min-width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--accent-color);
    color: white;
    font-weight: bold;
    font-size: 1.2rem;
    border-radius: 50%;
}

.exercise-info {
    flex: 1;
}

.exercise-info h4 {
    margin: 0 0 5px 0;
    color: var(--primary-color);
    font-size: 1rem;
}

.exercise-info p {
    margin: 0;
    color: #666;
    font-size: 0.9rem;
    line-height: 1.4;
}

.btn-start-exercise {
    padding: 8px 16px;
    background: var(--accent-color);
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.9rem;
    font-weight: 500;
    transition: all 0.2s;
}

.btn-start-exercise:hover {
    background: #2980b9;
    transform: scale(1.05);
}

#exercise-detail-view {
    padding: 20px;
}

#exercise-detail-view h3 {
    margin: 0 0 15px 0;
    color: var(--primary-color);
    font-size: 1.3rem;
}

.exercise-section {
    margin-bottom: 20px;
}

.exercise-section h4 {
    margin: 0 0 10px 0;
    color: var(--secondary-color);
    font-size: 1rem;
    display: flex;
    align-items: center;
    gap: 8px;
}

.exercise-section ol {
    margin: 0;
    padding-left: 20px;
}

.exercise-section li {
    margin-bottom: 8px;
    line-height: 1.5;
}

.help-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

.help-list li {
    padding: 8px 12px;
    background: #e8f4f8;
    border-left: 3px solid var(--accent-color);
    margin-bottom: 8px;
    border-radius: 4px;
}

.hints-section {
    margin-top: 15px;
}

.hint-item {
    margin-bottom: 10px;
}

.hint-toggle {
    width: 100%;
    text-align: left;
    padding: 10px 15px;
    background: #fff3cd;
    border: 1px solid #ffc107;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.95rem;
    transition: all 0.2s;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.hint-toggle:hover {
    background: #ffe69c;
}

.hint-simple {
    padding: 10px 15px;
    background: #fff3cd;
    border: 1px solid #ffc107;
    border-radius: 4px;
    font-size: 0.95rem;
}

.toggle-icon {
    font-size: 0.8rem;
    color: #856404;
}

.hint-detail {
    margin-top: 8px;
    padding: 12px;
    background: white;
    border: 1px solid #ffc107;
    border-radius: 4px;
    color: #666;
    line-height: 1.5;
}

.exercise-controls {
    display: flex;
    gap: 10px;
    margin-top: 20px;
    padding-top: 20px;
    border-top: 2px solid #e0e0e0;
}

.exercise-controls button {
    flex: 1;
    padding: 12px;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 1rem;
    font-weight: 500;
    transition: all 0.2s;
}

#btn-back-to-list {
    background: #95a5a6;
    color: white;
}

#btn-back-to-list:hover {
    background: #7f8c8d;
}

#btn-validate-exercise {
    background: var(--success-color);
    color: white;
}

#btn-validate-exercise:hover {
    background: #229954;
}

.validation-success {
    padding: 15px;
    background: #d4edda;
    border: 1px solid #c3e6cb;
    border-radius: 4px;
    margin-top: 15px;
}

.validation-success h4 {
    margin: 0 0 10px 0;
    color: #155724;
}

.validation-error {
    padding: 15px;
    background: #f8d7da;
    border: 1px solid #f5c6cb;
    border-radius: 4px;
    margin-top: 15px;
}

.validation-error h4 {
    margin: 0 0 10px 0;
    color: #721c24;
}

.validation-errors, .validation-checks {
    margin: 10px 0 0 20px;
    padding: 0;
}

.validation-errors li, .validation-checks li {
    margin-bottom: 5px;
}

/* Utility Classes */
.hidden {
    display: none !important;
}

.disabled {
    opacity: 0.5;
    pointer-events: none;
}

/* ========================================
   PACKET TRACE MODAL
   ======================================== */

.trace-modal-content {
    max-width: 1400px;
    width: 95vw;
    height: 90vh;
    max-height: 900px;
    display: flex;
    flex-direction: column;
    padding: 0;
    overflow: hidden;
}

.trace-header {
    padding: 20px;
    border-bottom: 2px solid #e0e0e0;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
}

.trace-header h2 {
    margin: 0 0 10px 0;
    font-size: 1.8em;
}

.trace-summary {
    font-size: 0.95em;
    opacity: 0.95;
}

.trace-navigation {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 15px;
    padding: 15px 20px;
    background: #f8f9fa;
    border-bottom: 1px solid #e0e0e0;
}

.trace-btn {
    padding: 8px 16px;
    border: 1px solid #ccc;
    background: white;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.9em;
    transition: all 0.2s;
}

.trace-btn:hover:not(:disabled) {
    background: #3498db;
    color: white;
    border-color: #3498db;
}

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

.trace-progress {
    font-weight: 600;
    color: #2c3e50;
    min-width: 120px;
    text-align: center;
}

.trace-body {
    display: flex;
    flex: 1;
    overflow: hidden;
    background: #fafafa;
}

.trace-canvas-container {
    flex: 0 0 55%;
    position: relative;
    background: white;
    border-right: 2px solid #e0e0e0;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

#trace-canvas {
    max-width: 100%;
    max-height: 100%;
    display: block;
}

.trace-details {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
}

.step-title h3 {
    color: #2c3e50;
    margin-bottom: 20px;
    padding-bottom: 10px;
    border-bottom: 2px solid #3498db;
}

/* Couches OSI */
.layer-stack {
    margin: 20px 0;
}

.layer {
    margin: 12px 0;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    transition: all 0.2s;
}

.layer:hover {
    box-shadow: 0 4px 8px rgba(0,0,0,0.15);
}

.layer-header {
    padding: 14px 16px;
    cursor: pointer;
    font-weight: 600;
    font-size: 0.95em;
    transition: all 0.2s;
    user-select: none;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.layer-header::after {
    content: '▼';
    font-size: 0.8em;
    transition: transform 0.2s;
}

.layer-header.collapsed::after {
    transform: rotate(-90deg);
}

.layer-1 {
    border-left: 5px solid #9b59b6;
}

.layer-1 .layer-header {
    background: #f4ecf7;
    color: #6c3483;
}

.layer-2 {
    border-left: 5px solid #f39c12;
}

.layer-2 .layer-header {
    background: #fef5e7;
    color: #b9770e;
}

.layer-3 {
    border-left: 5px solid #27ae60;
}

.layer-3 .layer-header {
    background: #eafaf1;
    color: #1e8449;
}

.layer-4 {
    border-left: 5px solid #3498db;
}

.layer-4 .layer-header {
    background: #ebf5fb;
    color: #21618c;
}

.layer-content {
    padding: 16px;
    background: white;
    display: none;
    animation: slideDown 0.2s ease-out;
}

.layer-content.expanded {
    display: block;
}

@keyframes slideDown {
    from {
        opacity: 0;
        max-height: 0;
    }
    to {
        opacity: 1;
        max-height: 500px;
    }
}

.layer-content table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9em;
}

.layer-content table tr {
    border-bottom: 1px solid #f0f0f0;
}

.layer-content table td {
    padding: 8px 10px;
}

.layer-content table td:first-child {
    font-weight: 600;
    color: #555;
    width: 40%;
}

.layer-content table td:last-child {
    color: #2c3e50;
    font-family: 'Courier New', monospace;
}

.flag-explanation {
    margin-top: 12px;
    padding: 12px;
    background: #e8f4f8;
    border-radius: 4px;
    font-size: 0.9em;
    border-left: 3px solid #3498db;
}

.flag-explanation strong {
    color: #2980b9;
}

/* Explication pédagogique */
.step-explanation {
    margin-top: 25px;
    padding: 18px;
    background: #fff9e6;
    border-left: 4px solid #f39c12;
    border-radius: 6px;
    line-height: 1.7;
}

.step-explanation h4 {
    color: #d68910;
    margin-bottom: 10px;
    font-size: 1.05em;
}

.step-explanation p {
    color: #2c3e50;
    font-size: 0.95em;
}

.glossary-links {
    margin-top: 15px;
    padding-top: 12px;
    border-top: 1px solid #f5d894;
    font-size: 0.9em;
}

.glossary-link {
    color: #3498db;
    text-decoration: none;
    font-weight: 600;
    transition: color 0.2s;
}

.glossary-link:hover {
    color: #2980b9;
    text-decoration: underline;
}

/* Table consultée */
.table-access {
    margin-top: 20px;
    padding: 16px;
    background: #f0f0f0;
    border-radius: 6px;
    border-left: 4px solid #95a5a6;
}

.table-access h4 {
    color: #34495e;
    margin-bottom: 12px;
    font-size: 1em;
}

.mini-table {
    width: 100%;
    border-collapse: collapse;
    background: white;
    border-radius: 4px;
    overflow: hidden;
    font-size: 0.85em;
}

.mini-table th {
    background: #34495e;
    color: white;
    padding: 10px;
    text-align: left;
    font-weight: 600;
}

.mini-table td {
    padding: 8px 10px;
    border-bottom: 1px solid #ecf0f1;
}

.mini-table tr.highlight {
    background: #fff3cd;
    font-weight: 600;
}

.view-full-table {
    margin-top: 10px;
    padding: 6px 12px;
    background: #3498db;
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.85em;
    transition: background 0.2s;
}

.view-full-table:hover {
    background: #2980b9;
}

/* Footer */
.trace-footer {
    padding: 15px 20px;
    border-top: 1px solid #e0e0e0;
    background: #f8f9fa;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

/* ============================================
   SUPPORT TACTILE
   ============================================ */

/* Améliorer la taille des zones tactiles */
@media (pointer: coarse) {
    /* Boutons plus grands sur tactile */
    button, .btn, .component-item {
        min-height: 44px;
        min-width: 44px;
        padding: 10px 16px;
    }
    
    .header-controls button {
        padding: 10px 18px;
        font-size: 1rem;
    }
    
    /* Composants toolbar plus espacés */
    .component-item {
        padding: 12px;
        margin-bottom: 12px;
    }
    
    /* Onglets plus grands */
    .dialog-tabs button {
        padding: 12px 20px;
        font-size: 1rem;
    }
    
    /* Inputs plus grands */
    input[type="text"],
    input[type="number"],
    select,
    textarea {
        min-height: 44px;
        padding: 10px 12px;
        font-size: 16px; /* Évite le zoom automatique sur iOS */
    }
    
    /* Ports de connexion plus grands */
    .port {
        width: 20px;
        height: 20px;
    }
    
    /* Actions des composants plus accessibles */
    .component-actions button {
        min-height: 44px;
        padding: 8px 12px;
    }
}

/* Désactiver le hover sur tactile */
@media (hover: none) {
    .component-item:hover,
    button:hover,
    .config-btn:hover {
        background: inherit;
        transform: none;
    }
    
    /* Ajouter un feedback tactile visuel */
    .component-item:active,
    button:active,
    .config-btn:active {
        opacity: 0.7;
        transform: scale(0.98);
    }
}

/* Touch-action pour améliorer les performances */
body {
    touch-action: pan-x pan-y;
}

canvas {
    touch-action: none; /* Le canvas gère ses propres événements tactiles */
}

/* ============================================
   RESPONSIVE DESIGN
   ============================================ */

/* Tablettes et petits écrans (< 1024px) */
@media screen and (max-width: 1024px) {
    :root {
        --panel-width: 100vw;
        --header-height: auto;
    }
    
    /* Hide desktop controls, show mobile tabs */
    .desktop-controls {
        display: none !important;
    }
    
    .header-title-bar .mobile-panel-toggle {
        display: block !important;
        font-size: 1.5rem;
        padding: 5px 5px;
        background: transparent;
        color: white;
        border: none;
        cursor: pointer;
    }
    
    /* Show mobile tabs vertical sidebar under 1024px */
    .mobile-tabs-sidebar {
        display: block !important;
    }
    
    /* No margin on content - sidebar overlays canvas */
    .content-wrapper {
        margin-left: 0;
    }
    
    /* Hide desktop toolbar */
    .toolbar {
        display: none !important;
    }
    
    /* Header compact */
    header {
        padding: 10px 15px;
        height: auto;
        min-height: 50px;
    }
    
    .header-title-bar h1 {
        font-size: 1.5rem;
    }
    
    /* Recalculate main layout height for mobile */
    .main-layout {
        height: calc(100vh - 50px);
        min-height: calc(100vh - 50px);
        padding-bottom: 0 !important; /* Console is fixed, doesn't need padding */
    }
    
    /* Right panel slides from right, below mobile tabs */
    .right-panel {
        width: 100vw;
        transform: translateX(100%);
        box-shadow: -5px 0 15px rgba(0,0,0,0.3);
        z-index: 1000;
        position: fixed;
        top: 60px;
        bottom: 200px;
        height: auto;
        max-height: none;
        overflow-y: auto;
    }
    
    .right-panel.mobile-open {
        transform: translateX(0);
    }
    
    /* Canvas takes full available space */
    .canvas-container {
        flex: 1;
        width: 100%;
        height: 100%;
    }
    
    #network-canvas {
        width: 100% !important;
        height: 100% !important;
    }
    
    /* Console réduite sur mobile */
    .console {
        height: 150px;
        font-size: 0.8rem;
    }
    
    .main-layout {
        padding-bottom: 150px;
    }
    
    .main-layout.console-collapsed {
        padding-bottom: 25px;
    }
    
    .console-header h3 {
        font-size: 0.9rem;
    }
    
    /* Dialog plein écran sur mobile */
    .dialog {
        width: 95vw;
        max-width: 95vw;
        max-height: 90vh;
    }
    
    .dialog-tabs {
        overflow-x: auto;
        scrollbar-width: thin;
    }
    
    .dialog-tabs button {
        padding: 10px 15px;
        font-size: 0.9rem;
        white-space: nowrap;
    }
    
    /* Tables responsive */
    .routing-table,
    .dhcp-list {
        font-size: 0.85rem;
    }
    
    .routing-table th,
    .routing-table td,
    .dhcp-list th,
    .dhcp-list td {
        padding: 6px 8px;
    }
    
    /* Form fields stack verticalement */
    .form-group {
        margin-bottom: 12px;
    }
    
    .form-group label {
        display: block;
        margin-bottom: 5px;
    }
    
    .form-row {
        flex-direction: column;
        gap: 10px;
    }
}

/* Mode paysage sur smartphone */
@media screen and (max-width: 900px) and (orientation: landscape) {
    .console {
        height: 120px;
    }
    
    .main-layout {
        padding-bottom: 120px;
    }
    
    .config-panel {
        max-height: 60vh;
    }
}

/* Très petits écrans (< 400px) */
@media screen and (max-width: 400px) {
    header h1 {
        font-size: 1rem;
    }
    
    .header-controls button {
        font-size: 0.7rem;
        padding: 4px 6px;
    }
    
    .component-item {
        font-size: 0.85rem;
    }
    
    .component-icon img {
        width: 30px;
        height: 30px;
    }
}

/* Support pour les écrans à haute densité */
@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) {
    /* Améliorer le rendu des bordures fines */
    .component,
    .port,
    button {
        border-width: 0.5px;
    }
}

/* Accessibilité: préférences de mouvement réduit */
@media (prefers-reduced-motion: reduce) {
    * {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* Mode sombre (si souhaité dans le futur) */
@media (prefers-color-scheme: dark) {
    /* Préparé pour un futur mode sombre */
    /* :root {
        --bg-color: #1a1a1a;
        --text-color: #e0e0e0;
    } */
}
