/* Reset and base styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    line-height: 1.6;
    color: #404E5C;
    background-color: #f7f6f2;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
}

/* Header styles */
header {
    text-align: center;
    margin-bottom: 30px;
    background: #404E5C;
    color: white;
    padding: 20px 15px;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

header h1 {
    font-size: 1.8em;
    margin-bottom: 5px;
    font-weight: 400;
}

header p {
    font-size: 0.95em;
    opacity: 0.9;
}

/* Search section */
.search-section {
    margin-bottom: 30px;
}

.search-box {
    display: flex;
    gap: 10px;
    margin-bottom: 20px;
    justify-content: center;
    position: relative;
}

#partNumberInput {
    flex: 1;
    max-width: 400px;
    padding: 12px 16px;
    border: 2px solid #B7C3F3;
    border-radius: 8px;
    font-size: 16px;
    transition: border-color 0.3s ease;
    background-color: #f7f6f2;
    color: #404E5C;
}

#partNumberInput:focus {
    outline: none;
    border-color: #4F6272;
    box-shadow: 0 0 0 3px rgba(183, 195, 243, 0.3);
}

#searchBtn {
    padding: 12px 24px;
    background: #D36D4A;
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 16px;
    cursor: pointer;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

#searchBtn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(211, 109, 74, 0.3);
    background: #B8593C;
}

#searchBtn:active {
    transform: translateY(0);
}

/* Candidate dropdown */
.candidate-dropdown {
    position: absolute;
    top: 100%;
    left: 0;
    right: 60px; /* Leave space for search button */
    background: #f7f6f2;
    border: 1px solid #B7C3F3;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(64, 78, 92, 0.15);
    z-index: 1000;
    max-height: 400px;
    overflow: hidden;
    display: none;
}

.candidate-header {
    padding: 10px 15px;
    background: #B7C3F3;
    border-bottom: 1px solid #A0B0E0;
    font-weight: 600;
    color: #404E5C;
    font-size: 0.9em;
}

.candidate-list {
    max-height: 350px;
    overflow-y: auto;
}

.candidate-item {
    padding: 12px 15px;
    border-bottom: 1px solid #E8F0F8;
    cursor: pointer;
    transition: background-color 0.2s ease;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.candidate-item:hover {
    background-color: #F0F4F8;
}

.candidate-item:last-child {
    border-bottom: none;
}

.candidate-part {
    font-weight: 600;
    color: #404E5C;
    flex: 1;
}

.candidate-file {
    font-size: 0.85em;
    color: #4F6272;
    font-family: 'Courier New', monospace;
    margin-left: 10px;
}

/* Scrollbar styling for candidate list */
.candidate-list::-webkit-scrollbar {
    width: 6px;
}

.candidate-list::-webkit-scrollbar-track {
    background: #f7f6f2;
}

.candidate-list::-webkit-scrollbar-thumb {
    background: #B7C3F3;
    border-radius: 3px;
}

.candidate-list::-webkit-scrollbar-thumb:hover {
    background: #A0B0E0;
}

.search-result {
    text-align: center;
    padding: 10px;
    border-radius: 6px;
    margin-top: 10px;
}

.search-result.success {
    background-color: #E8F4E8;
    color: #2D5A2D;
    border: 1px solid #B7C3F3;
}

.search-result.error {
    background-color: #F8E8E8;
    color: #8B3A3A;
    border: 1px solid #D36D4A;
}

/* Table container */
.table-container {
    background: #f7f6f2;
    border-radius: 10px;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    overflow: hidden;
    margin-top: 20px;
}

#mcuTitle {
    padding: 20px;
    margin: 0;
    background: #4F6272;
    color: white;
    text-align: center;
    font-size: 1.5em;
    font-weight: 400;
}

/* Filter info bar */
.filter-info {
    background: #B7C3F3;
    color: #404E5C;
    padding: 12px 20px;
    border-bottom: 1px solid #A0B0E0;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.9em;
}

#filterText {
    font-weight: 600;
}

.clear-filter-btn {
    background: #D36D4A;
    color: white;
    border: none;
    padding: 6px 12px;
    border-radius: 4px;
    font-size: 0.85em;
    cursor: pointer;
    transition: background-color 0.2s ease;
}

.clear-filter-btn:hover {
    background: #B8593C;
}

/* Table wrapper for frozen header */
.table-wrapper {
    max-height: 600px;
    overflow-y: auto;
    border: 1px solid #B7C3F3;
}

/* Table styles */
#pinTable {
    width: 100%;
    border-collapse: collapse;
    background: #f7f6f2;
}

#pinTable thead {
    position: sticky;
    top: 0;
    background: #B7C3F3;
    z-index: 10;
    box-shadow: 0 2px 4px rgba(64, 78, 92, 0.1);
}

#pinTable th {
    padding: 15px 12px;
    text-align: left;
    font-weight: 600;
    color: #404E5C;
    border-bottom: 2px solid #A0B0E0;
    background: #B7C3F3;
}

#pinTable td {
    padding: 12px;
    border-bottom: 1px solid #E8F0F8;
    transition: background-color 0.2s ease;
    color: #404E5C;
}

#pinTable tbody tr:hover {
    background-color: #F0F4F8;
}

#pinTable tbody tr:nth-child(even) {
    background-color: #f7f6f2;
}

#pinTable tbody tr:nth-child(odd) {
    background-color: #f0efeb;
}

/* Column specific styles */
#pinTable th:nth-child(1),
#pinTable td:nth-child(1) {
    font-weight: 600;
    color: #404E5C;
    min-width: 120px;
}

#pinTable th:nth-child(2),
#pinTable td:nth-child(2) {
    text-align: center;
    width: 80px;
}

#pinTable th:nth-child(3),
#pinTable td:nth-child(3) {
    width: 100px;
}

#pinTable th:nth-child(4),
#pinTable td:nth-child(4) {
    max-width: 400px;
    word-wrap: break-word;
}

/* Signal badges */
.signal-badge {
    display: inline-block;
    background: #E8F0F8;
    color: #404E5C;
    padding: 2px 8px;
    margin: 2px;
    border-radius: 12px;
    font-size: 0.85em;
    font-weight: 500;
    cursor: pointer;
    transition: background-color 0.2s ease, transform 0.1s ease;
    border: 1px solid transparent;
}

.signal-badge:hover {
    transform: translateY(-1px);
    box-shadow: 0 2px 4px rgba(64, 78, 92, 0.2);
}

.signal-badge.active {
    border-color: #4F6272;
    box-shadow: 0 0 0 2px rgba(79, 98, 114, 0.3);
}

.signal-badge.adc {
    background: #D1E8F1;
    color: #2C5460;
}

.signal-badge.timer {
    background: #E8F4E8;
    color: #2D5A2D;
}

.signal-badge.spi {
    background: #F8F0D1;
    color: #8B7104;
}

.signal-badge.i2c {
    background: #F8E8E8;
    color: #8B3A3A;
}

.signal-badge.usart {
    background: #E8E8E8;
    color: #4F6272;
}

.signal-badge.usb {
    background: #D1E8F1;
    color: #2C5460;
}

.signal-badge.power {
    background: #F0CCCC;
    color: #8B3A3A;
}

.signal-badge.system {
    background: #CCE5FF;
    color: #404E5C;
}

/* Loading indicator */
.loading {
    text-align: center;
    padding: 40px;
}

.spinner {
    width: 40px;
    height: 40px;
    border: 4px solid #f7f6f2;
    border-top: 4px solid #4F6272;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto 20px;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Error message */
.error-message {
    background-color: #F8E8E8;
    color: #8B3A3A;
    padding: 15px;
    border-radius: 8px;
    border: 1px solid #D36D4A;
    text-align: center;
    margin: 20px 0;
}

/* Responsive design */
@media (max-width: 768px) {
    .container {
        padding: 10px;
    }
    
    header h1 {
        font-size: 1.6em;
    }
    
    header p {
        font-size: 0.9em;
    }
    
    .search-box {
        flex-direction: column;
    }
    
    #partNumberInput {
        max-width: none;
    }
    
    .candidate-dropdown {
        right: 0; /* Full width on mobile */
    }
    
    .candidate-item {
        flex-direction: column;
        align-items: flex-start;
        padding: 10px 15px;
    }
    
    .candidate-file {
        margin-left: 0;
        margin-top: 4px;
        font-size: 0.8em;
    }
    
    .filter-info {
        flex-direction: column;
        gap: 8px;
        text-align: center;
    }
    
    .table-wrapper {
        max-height: 400px;
    }
    
    #pinTable th,
    #pinTable td {
        padding: 8px 6px;
        font-size: 0.9em;
    }
    
    #pinTable th:nth-child(4),
    #pinTable td:nth-child(4) {
        max-width: 200px;
    }
}

@media (max-width: 480px) {
    header {
        padding: 15px 10px;
    }
    
    header h1 {
        font-size: 1.4em;
    }
    
    header p {
        font-size: 0.85em;
    }
    
    .candidate-dropdown {
        max-height: 300px;
    }
    
    .candidate-item {
        padding: 8px 12px;
    }
    
    .candidate-part {
        font-size: 0.9em;
    }
    
    .candidate-file {
        font-size: 0.75em;
    }
    
    .table-wrapper {
        max-height: 300px;
    }
    
    #pinTable th,
    #pinTable td {
        padding: 6px 4px;
        font-size: 0.8em;
    }
}
