/* Reset all elements */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

/* Main body styling */
body {
    font-family: "Oxygen", sans-serif;
    min-height: 100vh;
    padding: 20px;
    color: #333;
    line-height: 1.6;
}

/* Main container */
.container {
    max-width: 1400px;
    margin: 0 auto;
    background: white;
    overflow: hidden;
}

/* Page header */
h1 {
    padding: 10px;
    text-align: center;
    font-size: 1.8em;
    font-weight: 700;
    font-family: "Oxygen", sans-serif;
}

/* Control panel layout */
.control-panel {
    display: flex;
    gap: 24px;
    padding: 24px;
}

/* Input section styling */
.input-section {
    flex: 1;
}

.input-section h2 {
    margin-bottom: 12px;
    color: #6c757d;
    font-size: 1.1em;
    font-weight: 500;
    font-family: "Oxygen", sans-serif;
}

/* Instructions textarea */
#instructions {
    width: 100%;
    height: 280px;
    padding: 12px;
    border: 1px solid #ddd;
    font-family: "Hack", monospace;
    font-size: 14px;
    resize: vertical;
    margin-bottom: 12px;
    background: white;
    color: #333;
}

#instructions:focus {
    outline: none;
    border-color: #6c757d;
}

/* Button styling */
button {
    background: #e0e0e0;
    color: black;
    border: none;
    padding: 8px 16px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 400;
    font-family: "Oxygen", sans-serif;
    margin-right: 12px;
    margin-bottom: 12px;
    transition: all 0.2s ease;
}

button:hover {
    background: #d0d0d0;
    transform: translateY(-1px);
}

button:active {
    transform: translateY(0);
}

button:disabled {
    background: #f0f0f0;
    color: #999;
    cursor: not-allowed;
    transform: none;
}

/* Running state button */
button.running {
    background: #ffcccc;
    color: #cc0000;
}

button.running:hover {
    background: #ffb3b3;
}

/* Clock section */
.clock-section {
    text-align: center;
    min-width: 150px;
}

.clock-section h2 {
    margin-bottom: 12px;
    color: #6c757d;
    font-size: 1.1em;
    font-weight: 500;
    font-family: "Oxygen", sans-serif;
}

/* Clock display */
#clock {
    font-size: 2.2em;
    font-weight: 300;
    font-family: "Oxygen", sans-serif;
    color: #6c757d;
    background: white;
    padding: 16px;
    border: 1px solid #e0e0e0;
    margin-bottom: 24px;
}


/* Section containers */
.section {
    padding: 16px;
}

.section h2 {
    margin-bottom: 12px;
    color: #6c757d;
    font-size: 1.1em;
    font-weight: 500;
    font-family: "Oxygen", sans-serif;
}

/* Table container */
.table-container {
    overflow-x: auto;
    border: 1px solid #e0e0e0;
}

/* Table styling */
table {
    width: 100%;
    border-collapse: collapse;
    background: white;
}

th, td {
    padding: 8px 12px;
    text-align: left;
    border-bottom: 1px solid #e0e0e0;
    font-size: 13px;
}

/* Table data uses monospace font */
td {
    font-family: "Hack", monospace;
}

/* Table headers */
th {
    background: #e0e0e0;
    color: black;
    font-weight: 700;
    position: sticky;
    top: 0;
    font-size: 12px;
    font-family: "Oxygen", sans-serif;
    letter-spacing: 0.3px;
}

/* Table row hover effect */
tr:hover {
    background-color: #f8f9fa;
}

tr:last-child td {
    border-bottom: none;
}

/* Highlight styles for station hover */
.station-highlight {
    background-color: #fff3cd !important;
    outline: 2px solid #ffc107 !important;
    outline-offset: -2px;
    transition: background-color 0.2s ease;
}

.instruction-highlight {
    background-color: #fff3cd !important;
    outline: 2px solid #ffc107 !important;
    outline-offset: -2px;
    transition: background-color 0.2s ease;
}

.register-highlight {
    background-color: #d4edda !important;
    outline: 2px solid #28a745 !important;
    outline-offset: -2px;
    transition: background-color 0.2s ease;
}

.register-value-highlight {
    background-color: #e2d9f3 !important;
    outline: 2px solid #6f42c1 !important;
    outline-offset: -2px;
    transition: background-color 0.2s ease;
}

/* Compact table styles */
#instruction-table th,
#instruction-table td,
#reservation-table th,
#reservation-table td,
#register-table th,
#register-table td {
    padding: 6px 10px;
    font-size: 12px;
}

#instruction-table th,
#reservation-table th,
#register-table th {
    font-size: 11px;
    padding: 8px 10px;
    font-weight: 700;
}

/* Fixed column widths for reservation station table to prevent jumping */
#reservation-table {
    table-layout: fixed;
}

#reservation-table th,
#reservation-table td {
    text-align: center;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Specific column widths for reservation station table */
#reservation-table th:nth-child(1), /* Name */
#reservation-table td:nth-child(1) {
    min-width: 80px;
    max-width: 80px;
}

#reservation-table th:nth-child(2), /* Busy */
#reservation-table td:nth-child(2) {
    min-width: 50px;
    max-width: 50px;
}

#reservation-table th:nth-child(3), /* Op */
#reservation-table td:nth-child(3) {
    min-width: 60px;
    max-width: 60px;
}

#reservation-table th:nth-child(4), /* Vj */
#reservation-table td:nth-child(4) {
    min-width: 60px;
    max-width: 60px;
}

#reservation-table th:nth-child(5), /* Vk */
#reservation-table td:nth-child(5) {
    min-width: 60px;
    max-width: 60px;
}

#reservation-table th:nth-child(6), /* Qj */
#reservation-table td:nth-child(6) {
    min-width: 80px;
    max-width: 80px;
}

#reservation-table th:nth-child(7), /* Qk */
#reservation-table td:nth-child(7) {
    min-width: 80px;
    max-width: 80px;
}

#reservation-table th:nth-child(8), /* A */
#reservation-table td:nth-child(8) {
    min-width: 60px;
    max-width: 60px;
}

/* Fixed column widths for instruction table to prevent jumping */
#instruction-table {
    table-layout: fixed;
}

#instruction-table th,
#instruction-table td {
    text-align: center;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Specific column widths for instruction table */
#instruction-table th:nth-child(1), /* Instruction */
#instruction-table td:nth-child(1) {
    min-width: 120px;
    max-width: 120px;
    text-align: left;
}

#instruction-table th:nth-child(2), /* Issue */
#instruction-table td:nth-child(2) {
    min-width: 60px;
    max-width: 60px;
}

#instruction-table th:nth-child(3), /* Exec */
#instruction-table td:nth-child(3) {
    min-width: 80px;
    max-width: 80px;
}

#instruction-table th:nth-child(4), /* Write Back */
#instruction-table td:nth-child(4) {
    min-width: 80px;
    max-width: 80px;
}

#instruction-table th:nth-child(5), /* Status */
#instruction-table td:nth-child(5) {
    min-width: 100px;
    max-width: 100px;
}

/* Memory table horizontal layout */
#memory-table {
    table-layout: fixed;
}

#memory-table th,
#memory-table td {
    text-align: center;
    min-width: 40px;
    max-width: 50px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 11px;
    padding: 4px 2px;
}

#memory-table th:first-child,
#memory-table td:first-child {
    min-width: 50px;
    max-width: 60px;
    text-align: center;
}

/* Further compact table containers */
#instruction-table,
#reservation-table,
#register-table {
    font-size: 12px;
}

/* Optimize table row height */
#instruction-table tr,
#reservation-table tr,
#register-table tr {
    line-height: 1.3;
}

/* Compact table headers */
#instruction-table th,
#reservation-table th,
#register-table th {
    line-height: 1.2;
    font-weight: 700;
}

/* Status indicators */
.status-issue {
    background-color: #fff3cd;
    color: #856404;
    font-weight: 500;
    padding: 2px 6px;
    font-size: 11px;
    border-radius: 3px;
}

.status-exec {
    background-color: #d1ecf1;
    color: #0c5460;
    font-weight: 500;
    padding: 2px 6px;
    font-size: 11px;
    border-radius: 3px;
}

.status-writeback {
    background-color: #d4edda;
    color: #155724;
    font-weight: 500;
    padding: 2px 6px;
    font-size: 11px;
    border-radius: 3px;
}

.status-complete {
    background-color: #cce5ff;
    color: #004085;
    font-weight: 500;
    padding: 2px 6px;
    font-size: 11px;
    border-radius: 3px;
}

/* Busy status indicators */
.busy-true {
    background-color: #f8d7da;
    color: #721c24;
    font-weight: 500;
    padding: 2px 6px;
    font-size: 11px;
    border-radius: 3px;
}

.busy-false {
    background-color: #d4edda;
    color: #155724;
    font-weight: 500;
    padding: 2px 6px;
    font-size: 11px;
    border-radius: 3px;
}

/* Log container */
.log-container {
    border: 1px solid #e0e0e0;
    padding: 16px;
    height: 200px;
    overflow-y: auto;
    font-family: "Hack", monospace;
    font-size: 13px;
    line-height: 1.5;
}

/* Log entry styling */
.log-entry {
    margin-bottom: 6px;
    padding: 4px 8px;
    border-left: 3px solid transparent;
    border-radius: 3px;
}

.log-info {
    background-color: #d1ecf1;
    color: #0c5460;
    border-left-color: #17a2b8;
}

.log-success {
    background-color: #d4edda;
    color: #155724;
    border-left-color: #28a745;
}

.log-warning {
    background-color: #fff3cd;
    color: #856404;
    border-left-color: #ffc107;
}

.log-error {
    background-color: #f8d7da;
    color: #721c24;
    border-left-color: #dc3545;
}

/* Highlight animation */
.highlight {
    background-color: #fff3cd;
    animation: pulse 1.5s ease-in-out infinite;
}

@keyframes pulse {
    0% { background-color: #fff3cd; }
    50% { background-color: #ffeaa7; }
    100% { background-color: #fff3cd; }
}

/* Latency info styling - similar to table containers */
.latency-info {
    border: 1px solid #e0e0e0;
    background: white;
    padding: 0;
    font-family: "Hack", monospace;
    font-size: 12px;
    line-height: 1.3;
    margin-top: 8px;
}

.latency-info th,
.latency-info td {
    padding: 6px 10px;
    font-size: 12px;
    text-align: center;
    border-bottom: 1px solid #e0e0e0;
}

.latency-info th {
    font-size: 11px;
    padding: 8px 10px;
    font-weight: 700;
    line-height: 1.2;
    background: #e0e0e0;
    color: black;
}

.latency-info tr {
    line-height: 1.3;
}

.latency-info tr:last-child td {
    border-bottom: none;
}

/* Responsive design for mobile devices */
@media (max-width: 768px) {
    body {
        padding: 12px;
    }
    
    .control-panel {
        flex-direction: column;
        gap: 16px;
    }
    
    .clock-section {
        min-width: auto;
    }
    
    h1 {
        font-size: 1.8em;
        padding: 20px;
    }
    
    button {
        width: 100%;
        margin-right: 0;
    }
    
    th, td {
        padding: 6px 8px;
        font-size: 12px;
    }
    
    .section {
        padding: 12px;
    }
    
    #clock {
        font-size: 1.8em;
        padding: 12px;
    }
    
    .latency-info {
        margin-top: 12px;
        padding: 10px;
    }
    
    .latency-info h4 {
        font-size: 0.85em;
    }
    
    .latency-info li {
        font-size: 0.75em;
    }
}

/* Top section layout */
.top-section {
    display: flex;
    gap: 16px;
    padding: 16px;
}

.reservation-section {
    flex: 1;
    border-bottom: none;
    padding: 0;
}

.instruction-section {
    flex: 1;
    border-bottom: none;
    padding: 0;
}

.register-section {
    border-bottom: none;
}

/* Register table horizontal layout */
#register-table {
    table-layout: fixed;
}

#register-table th,
#register-table td {
    text-align: center;
    min-width: 60px;
    max-width: 80px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

#register-table th:first-child,
#register-table td:first-child {
    min-width: 80px;
    max-width: 100px;
    text-align: center;
}

/* Specific column widths for register table to prevent jumping */
#register-table th:nth-child(1), /* Type */
#register-table td:nth-child(1) {
    min-width: 80px;
    max-width: 80px;
    text-align: center;
}

/* All register columns (R0-R15) have consistent width */
#register-table th:not(:first-child),
#register-table td:not(:first-child) {
    min-width: 70px;
    max-width: 70px;
}

/* Responsive design for medium screens */
@media (max-width: 1200px) {
    .top-section {
        flex-direction: column;
        gap: 16px;
    }
    
    .reservation-section,
    .instruction-section {
        flex: none;
    }
}
