/* Reset and base styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    /* Layer color scheme - OSI layers from 7 to 1 */
    --layer-7-application: linear-gradient(135deg, #6f42c1, #5a32a3);
    --layer-6-presentation: linear-gradient(135deg, #dc3545, #c82333);
    --layer-5-session: linear-gradient(135deg, #fd7e14, #ff6b35);
    --layer-4-transport: linear-gradient(135deg, #ffc107, #ffb300);
    --layer-3-network: linear-gradient(135deg, #28a745, #20c997);
    --layer-2-datalink: linear-gradient(135deg, #17a2b8, #138496);
    --layer-1-physical: linear-gradient(135deg, #2a5298, #1e3c72);

    /* Solid colors for borders */
    --color-application: #6f42c1;
    --color-presentation: #dc3545;
    --color-session: #fd7e14;
    --color-transport: #ffc107;
    --color-network: #28a745;
    --color-datalink: #17a2b8;
    --color-physical: #2a5298;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen',
        'Ubuntu', 'Cantarell', 'Fira Sans', 'Droid Sans', 'Helvetica Neue',
        sans-serif;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    background: linear-gradient(135deg, #1e3c72 0%, #2a5298 100%);
    min-height: 100vh;
    padding: 20px;
    color: #333;
}

/* Main container */
.visualizer-container {
    max-width: 1400px;
    margin: 0 auto;
    background: white;
    border-radius: 20px;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.1);
    overflow: hidden;
}

/* Header */
.visualizer-header {
    background: linear-gradient(135deg, #2a5298, #1e3c72);
    color: white;
    padding: 40px 30px;
    text-align: center;
}

.visualizer-header h1 {
    font-size: 2.5rem;
    font-weight: 700;
    margin-bottom: 10px;
}

.subtitle {
    font-size: 1.1rem;
    opacity: 0.9;
}

/* Navigation */
.navigation-container {
    padding: 30px;
    background: #f8f9fa;
    border-bottom: 2px solid #e9ecef;
}

.step-controls {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 20px;
    margin-bottom: 30px;
}

.step-indicator {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 5px;
}

.step-number {
    font-weight: 600;
    color: #2a5298;
    font-size: 1rem;
}

.step-title {
    font-size: 1.2rem;
    font-weight: 700;
    color: #333;
}

.nav-button {
    background: linear-gradient(135deg, #2a5298, #1e3c72);
    color: white;
    border: none;
    padding: 12px 24px;
    border-radius: 8px;
    cursor: pointer;
    font-weight: 600;
    font-size: 1rem;
    transition: all 0.3s ease;
    box-shadow: 0 4px 15px rgba(42, 82, 152, 0.3);
}

.nav-button:hover:not(:disabled) {
    background: linear-gradient(135deg, #1e3c72, #2a5298);
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(42, 82, 152, 0.4);
}

.nav-button:active:not(:disabled) {
    transform: translateY(0);
    box-shadow: 0 2px 10px rgba(42, 82, 152, 0.3);
}

.nav-button:disabled {
    background: #ccc;
    cursor: not-allowed;
    box-shadow: none;
}

/* Layer tabs */
.layer-tabs {
    display: flex;
    justify-content: center;
    gap: 10px;
    flex-wrap: wrap;
}

.layer-tab {
    background: white;
    color: #495057;
    border: 2px solid #e9ecef;
    padding: 10px 20px;
    border-radius: 8px;
    cursor: pointer;
    font-weight: 600;
    transition: all 0.3s ease;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    font-size: 0.9rem;
}

.layer-tab:hover {
    background: #e9ecef;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.layer-tab.layer-application.active {
    background: var(--layer-7-application);
    color: white;
    border-color: var(--color-application);
}

.layer-tab.layer-presentation.active {
    background: var(--layer-6-presentation);
    color: white;
    border-color: var(--color-presentation);
}

.layer-tab.layer-session.active {
    background: var(--layer-5-session);
    color: white;
    border-color: var(--color-session);
}

.layer-tab.layer-transport.active {
    background: var(--layer-4-transport);
    color: #333;
    border-color: var(--color-transport);
}

.layer-tab.layer-network.active {
    background: var(--layer-3-network);
    color: white;
    border-color: var(--color-network);
}

.layer-tab.layer-datalink.active {
    background: var(--layer-2-datalink);
    color: white;
    border-color: var(--color-datalink);
}

.layer-tab.layer-physical.active {
    background: var(--layer-1-physical);
    color: white;
    border-color: var(--color-physical);
}

.layer-tab.active {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.2);
}

/* Main content */
.main-content {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 30px;
    padding: 30px;
}

/* Visualization panel */
.visualization-panel {
    background: #f8f9fa;
    border-radius: 12px;
    padding: 30px;
}

.visualization-area {
    min-height: 400px;
}

.layer-stack {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 15px;
    margin-bottom: 30px;
}

.layer-box {
    width: 100%;
    max-width: 500px;
    border: 4px solid;
    border-radius: 10px;
    padding: 20px;
    background: white;
    transition: all 0.3s ease;
    cursor: pointer;
    position: relative;
}

.layer-box:hover {
    transform: scale(1.02);
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.15);
}

.layer-box.selected {
    box-shadow: 0 0 0 4px rgba(42, 82, 152, 0.3);
}

.layer-box.layer-application {
    border-color: var(--color-application);
}

.layer-box.layer-presentation {
    border-color: var(--color-presentation);
}

.layer-box.layer-session {
    border-color: var(--color-session);
}

.layer-box.layer-transport {
    border-color: var(--color-transport);
}

.layer-box.layer-network {
    border-color: var(--color-network);
}

.layer-box.layer-datalink {
    border-color: var(--color-datalink);
}

.layer-box.layer-physical {
    border-color: var(--color-physical);
}

.layer-header-label {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 10px;
    font-weight: 700;
}

.layer-number {
    background: rgba(0, 0, 0, 0.1);
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 0.85rem;
}

.layer-name {
    font-size: 1.1rem;
}

.layer-description {
    color: #666;
    font-size: 0.9rem;
    margin-bottom: 8px;
}

.layer-size {
    color: #999;
    font-size: 0.85rem;
    font-style: italic;
}

.core-message {
    background: linear-gradient(135deg, #f8f9fa, #e9ecef);
    border: 3px dashed #6c757d;
    border-radius: 10px;
    padding: 20px;
    text-align: center;
    max-width: 500px;
    width: 100%;
}

.message-label {
    font-weight: 600;
    color: #6c757d;
    font-size: 0.85rem;
    margin-bottom: 8px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.message-content {
    font-size: 1.5rem;
    font-weight: 700;
    color: #2a5298;
    font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', monospace;
}

.step-description {
    margin-top: 30px;
    padding: 20px;
    background: white;
    border-radius: 8px;
    border-left: 4px solid #2a5298;
}

.step-description h3 {
    color: #2a5298;
    margin-bottom: 10px;
    font-size: 1.2rem;
}

.step-description p {
    color: #666;
    line-height: 1.6;
}

/* Inspector panel */
.inspector-panel {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.inspector-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
}

.inspector-header h3 {
    color: #2a5298;
    font-size: 1.2rem;
}

/* Data inspector */
.data-inspector {
    background: white;
    border: 1px solid #e9ecef;
    border-radius: 10px;
    padding: 20px;
    overflow: hidden;
}

.view-controls {
    display: flex;
    gap: 10px;
}

.view-button {
    background: white;
    border: 2px solid #e9ecef;
    padding: 8px 16px;
    border-radius: 6px;
    cursor: pointer;
    font-weight: 600;
    transition: all 0.2s ease;
    font-size: 0.9rem;
}

.view-button:hover {
    background: #f8f9fa;
}

.view-button.active {
    background: #2a5298;
    color: white;
    border-color: #2a5298;
}

.data-view {
    background: #1e1e1e;
    color: #d4d4d4;
    border-radius: 8px;
    padding: 15px;
    margin-top: 15px;
    overflow-x: auto;
    max-height: 300px;
    overflow-y: auto;
}

.data-view pre {
    margin: 0;
    font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', monospace;
    font-size: 0.85rem;
    line-height: 1.5;
}

.truncation-notice {
    color: #999;
    font-style: italic;
    font-size: 0.85rem;
    margin-top: 10px;
    text-align: center;
}

/* Header inspector */
.header-inspector {
    background: white;
    border: 1px solid #e9ecef;
    border-radius: 10px;
    padding: 20px;
}

.header-content {
    margin-top: 15px;
}

.layer-info {
    color: #2a5298;
    margin-bottom: 15px;
    padding-bottom: 15px;
    border-bottom: 2px solid #e9ecef;
}

.layer-timing {
    color: #6c757d;
    font-weight: normal;
}

.header-fields {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.header-field {
    border-bottom: 1px solid #e9ecef;
    padding-bottom: 10px;
}

.header-field:last-child {
    border-bottom: none;
}

.field-header {
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    padding: 8px 12px;
    border-radius: 6px;
    transition: background 0.2s;
}

.field-header:hover {
    background: #f8f9fa;
}

.expand-icon {
    color: #6c757d;
    font-size: 0.8rem;
    width: 15px;
}

.field-name {
    font-weight: 600;
    color: #333;
    flex: 0 0 auto;
}

.field-value {
    color: #2a5298;
    font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', monospace;
    font-size: 0.9rem;
    margin-left: auto;
}

.field-details {
    padding: 12px 20px 12px 35px;
    background: #f8f9fa;
    border-left: 3px solid #2a5298;
    margin-top: 8px;
    border-radius: 4px;
}

.field-description {
    color: #666;
    margin-bottom: 10px;
    line-height: 1.5;
}

.field-meta {
    color: #999;
    font-size: 0.85rem;
    margin-bottom: 10px;
}

.field-tooltip {
    background: #fff;
    border: 1px solid #e9ecef;
    padding: 10px;
    border-radius: 4px;
    color: #666;
    font-size: 0.9rem;
}

.no-layer-selected {
    text-align: center;
    padding: 40px 20px;
    color: #999;
}

.no-layer-selected p {
    font-size: 1rem;
}

/* Timing display */
.timing-display {
    background: white;
    border: 1px solid #e9ecef;
    border-radius: 10px;
    padding: 20px;
}

.timing-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.total-time {
    font-weight: 600;
    color: #2a5298;
    background: #e9ecef;
    padding: 6px 12px;
    border-radius: 6px;
}

.timing-breakdown {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.timing-item {
    opacity: 0.5;
    transition: opacity 0.3s;
}

.timing-item.current,
.timing-item.completed {
    opacity: 1;
}

.timing-item-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 5px;
}

.timing-layer-name {
    font-weight: 600;
    font-size: 0.9rem;
}

.timing-value {
    color: #6c757d;
    font-size: 0.85rem;
}

.timing-bar-container {
    height: 8px;
    background: #e9ecef;
    border-radius: 4px;
    overflow: hidden;
}

.timing-bar {
    height: 100%;
    transition: width 0.3s ease;
    border-radius: 4px;
}

.timing-bar.layer-application {
    background: var(--layer-7-application);
}

.timing-bar.layer-presentation {
    background: var(--layer-6-presentation);
}

.timing-bar.layer-session {
    background: var(--layer-5-session);
}

.timing-bar.layer-transport {
    background: var(--layer-4-transport);
}

.timing-bar.layer-network {
    background: var(--layer-3-network);
}

.timing-bar.layer-datalink {
    background: var(--layer-2-datalink);
}

.timing-bar.layer-physical {
    background: var(--layer-1-physical);
}

.timing-legend {
    margin-top: 15px;
    padding-top: 15px;
    border-top: 1px solid #e9ecef;
}

.timing-note {
    color: #999;
    font-size: 0.85rem;
    font-style: italic;
}

/* Footer */
.footer-info {
    background: #f8f9fa;
    padding: 20px 30px;
    border-top: 2px solid #e9ecef;
    text-align: center;
}

.footer-info p {
    color: #666;
    font-size: 0.9rem;
    line-height: 1.6;
}

/* Responsive design */
@media (max-width: 1024px) {
    .main-content {
        grid-template-columns: 1fr;
    }
}

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

    .visualizer-header {
        padding: 30px 20px;
    }

    .visualizer-header h1 {
        font-size: 2rem;
    }

    .subtitle {
        font-size: 1rem;
    }

    .navigation-container {
        padding: 20px;
    }

    .step-controls {
        flex-direction: column;
        gap: 15px;
    }

    .nav-button {
        width: 100%;
    }

    .layer-tabs {
        gap: 8px;
    }

    .layer-tab {
        padding: 8px 12px;
        font-size: 0.8rem;
    }

    .main-content {
        padding: 20px;
        gap: 20px;
    }

    .visualization-panel {
        padding: 20px;
    }

    .layer-box {
        padding: 15px;
    }
}

@media (max-width: 480px) {
    .visualizer-header h1 {
        font-size: 1.5rem;
    }

    .subtitle {
        font-size: 0.9rem;
    }

    .step-title {
        font-size: 1rem;
    }

    .layer-tabs {
        gap: 5px;
    }

    .layer-tab {
        padding: 6px 10px;
        font-size: 0.75rem;
    }

    .main-content {
        padding: 15px;
    }

    .message-content {
        font-size: 1.2rem;
    }
}
