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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    line-height: 1.6;
    color: #1f2937;
    background: #f9fafb;
}

.container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 0 20px;
}

/* Header */
header {
    background: linear-gradient(135deg, #1e3a8a 0%, #3b82f6 100%);
    color: white;
    padding: 1.5rem 0;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
}

header h1 {
    font-size: 2rem;
    font-weight: 700;
    margin-bottom: 0.25rem;
}

.subtitle {
    font-size: 1rem;
    opacity: 0.95;
    font-weight: 500;
}

/* Quick Search Bar */
.quick-search-bar {
    background: white;
    padding: 1.5rem 0;
    box-shadow: 0 2px 8px rgba(0,0,0,0.05);
}

#globalSearch {
    width: 100%;
    padding: 1rem 1.5rem;
    font-size: 1.1rem;
    border: 3px solid #3b82f6;
    border-radius: 12px;
    outline: none;
    transition: all 0.3s ease;
}

#globalSearch:focus {
    border-color: #1e3a8a;
    box-shadow: 0 0 0 4px rgba(59, 130, 246, 0.1);
}

.search-hint {
    display: block;
    margin-top: 0.5rem;
    font-size: 0.9rem;
    color: #6b7280;
    font-style: italic;
}

/* Category Navigation */
.category-nav {
    background: white;
    padding: 1rem 0;
    border-bottom: 2px solid #e5e7eb;
    position: sticky;
    top: 0;
    z-index: 90;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

.category-nav .container {
    display: flex;
    gap: 0.75rem;
    flex-wrap: wrap;
    justify-content: center;
}

.cat-btn {
    padding: 0.75rem 1.5rem;
    background: #f3f4f6;
    border: 2px solid transparent;
    border-radius: 8px;
    cursor: pointer;
    font-size: 1rem;
    font-weight: 600;
    transition: all 0.3s ease;
    white-space: nowrap;
}

.cat-btn:hover {
    background: #e5e7eb;
    transform: translateY(-2px);
}

.cat-btn.active {
    background: #3b82f6;
    color: white;
    border-color: #2563eb;
    box-shadow: 0 4px 6px rgba(59, 130, 246, 0.3);
}

/* Main Content */
main {
    padding: 2rem 0;
    min-height: 60vh;
}

/* Cheat Sheet Section */
.cheat-sheet-section {
    background: white;
    border-radius: 12px;
    padding: 2rem;
    box-shadow: 0 2px 8px rgba(0,0,0,0.08);
}

.filter-header {
    margin-bottom: 1.5rem;
}

.back-btn {
    display: inline-block;
    padding: 0.75rem 1.5rem;
    background: #6b7280;
    color: white;
    border: none;
    border-radius: 8px;
    font-weight: 600;
    cursor: pointer;
    margin-bottom: 1rem;
    transition: all 0.3s ease;
}

.back-btn:hover {
    background: #4b5563;
    transform: translateX(-4px);
}

.filter-hint {
    color: #6b7280;
    font-size: 0.95rem;
    margin-bottom: 1rem;
    font-style: italic;
}

.section-title {
    font-size: 1.75rem;
    font-weight: 700;
    color: #1e3a8a;
    margin-bottom: 2rem;
    padding-bottom: 1rem;
    border-bottom: 3px solid #3b82f6;
}

/* Product Table Wrapper */
.product-table-wrapper {
    margin-bottom: 3rem;
}

.table-title {
    font-size: 1.4rem;
    font-weight: 700;
    color: #1f2937;
    margin-bottom: 1rem;
    padding: 0.75rem 1rem;
    background: linear-gradient(135deg, #f3f4f6 0%, #e5e7eb 100%);
    border-radius: 8px;
    border-left: 5px solid #3b82f6;
}

.sub-category {
    font-size: 1.1rem;
    font-weight: 600;
    color: #4b5563;
    margin: 1.5rem 0 0.75rem 0;
    padding-left: 1rem;
    border-left: 3px solid #9ca3af;
}

/* Table Styles */
.table-responsive {
    overflow-x: auto;
    margin-bottom: 1.5rem;
    border-radius: 8px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

.cheat-table {
    width: 100%;
    border-collapse: collapse;
    background: white;
    font-size: 0.95rem;
}

.cheat-table thead {
    background: linear-gradient(135deg, #1e3a8a 0%, #3b82f6 100%);
    color: white;
}

.cheat-table th {
    padding: 1rem;
    text-align: left;
    font-weight: 700;
    font-size: 1rem;
    white-space: nowrap;
}

.cheat-table th.color-col {
    width: 140px;
}

.cheat-table th.mfr-header:hover {
    background: rgba(255, 255, 255, 0.2);
    text-decoration: underline;
}

/* Unified Table (for manufacturer view) */
.unified-table {
    font-size: 0.9rem;
}

.unified-table th {
    font-size: 0.95rem;
    padding: 0.875rem 0.75rem;
}

.unified-table td {
    padding: 0.625rem 0.5rem;
}

.cheat-table tbody tr {
    border-bottom: 1px solid #e5e7eb;
    transition: background 0.2s ease;
}

.cheat-table tbody tr:hover {
    background: #f9fafb;
}

.cheat-table td {
    padding: 0.75rem 1rem;
    vertical-align: middle;
}

.color-cell {
    font-weight: 700;
    text-align: center;
    border-right: 2px solid #e5e7eb;
}

.empty-cell {
    color: #d1d5db;
    text-align: center;
    font-style: italic;
}

/* Part Number Styling */
.part-num {
    transition: all 0.2s ease;
    user-select: none;
}

.part-num:hover {
    transform: scale(1.05);
    box-shadow: 0 2px 8px rgba(0,0,0,0.15);
}

.part-num:active {
    transform: scale(0.98);
}

/* Copy Notification */
.copy-notification {
    position: fixed;
    top: 20px;
    right: -300px;
    background: #10b981;
    color: white;
    padding: 1rem 1.5rem;
    border-radius: 8px;
    font-weight: 600;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    z-index: 1000;
    transition: right 0.3s ease;
}

.copy-notification.show {
    right: 20px;
}

/* Compatibility Guide */
.compatibility-guide {
    background: #fef3c7;
    padding: 2rem 0;
    margin-top: 3rem;
    border-top: 3px solid #f59e0b;
}

.compatibility-guide h3 {
    font-size: 1.5rem;
    color: #92400e;
    margin-bottom: 1.5rem;
    font-weight: 700;
}

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

.compat-item {
    background: white;
    padding: 1rem;
    border-radius: 8px;
    border-left: 4px solid #f59e0b;
    font-size: 0.95rem;
    line-height: 1.5;
}

.compat-item strong {
    color: #92400e;
    display: block;
    margin-bottom: 0.25rem;
}

/* Search Results */
.search-results {
    background: white;
    border-radius: 12px;
    padding: 2rem;
    box-shadow: 0 2px 8px rgba(0,0,0,0.08);
}

.result-card {
    background: #f9fafb;
    border: 2px solid #e5e7eb;
    border-radius: 8px;
    padding: 1.5rem;
    margin-bottom: 1rem;
    transition: all 0.3s ease;
}

.result-card:hover {
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
    transform: translateY(-2px);
    border-color: #3b82f6;
}

.result-header {
    display: flex;
    gap: 1rem;
    align-items: center;
    margin-bottom: 1rem;
    flex-wrap: wrap;
}

.result-type {
    display: inline-block;
    padding: 0.25rem 0.75rem;
    background: #3b82f6;
    color: white;
    border-radius: 20px;
    font-weight: 600;
    font-size: 0.85rem;
}

.result-category {
    font-weight: 700;
    color: #1f2937;
    font-size: 1.1rem;
    flex: 1;
}

.result-color {
    display: inline-block;
    padding: 0.25rem 1rem;
    border-radius: 20px;
    font-weight: 600;
    font-size: 0.9rem;
    border: 2px solid currentColor;
}

.result-parts {
    display: grid;
    gap: 0.75rem;
}

.result-part {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 0.5rem;
    background: white;
    border-radius: 6px;
}

.mfr-label {
    font-weight: 600;
    color: #6b7280;
    min-width: 180px;
}

/* Messages */
.loading, .no-results, .error-message, .info-message {
    text-align: center;
    padding: 3rem;
    font-size: 1.1rem;
    color: #6b7280;
}

.error-message {
    color: #dc2626;
}

.error-message h3 {
    font-size: 1.5rem;
    margin-bottom: 1rem;
}

/* Footer */
footer {
    background: #1f2937;
    color: white;
    text-align: center;
    padding: 2rem 0;
    margin-top: 4rem;
}

footer p {
    font-weight: 500;
}

/* Responsive Design */
@media (max-width: 768px) {
    header h1 {
        font-size: 1.5rem;
    }

    .subtitle {
        font-size: 0.9rem;
    }

    #globalSearch {
        font-size: 1rem;
        padding: 0.75rem 1rem;
    }

    .category-nav .container {
        flex-direction: column;
    }

    .cat-btn {
        width: 100%;
        text-align: center;
    }

    .section-title {
        font-size: 1.4rem;
    }

    .table-title {
        font-size: 1.2rem;
    }

    .cheat-table {
        font-size: 0.85rem;
    }

    .cheat-table th,
    .cheat-table td {
        padding: 0.5rem;
    }

    .part-num {
        font-size: 0.8rem !important;
        padding: 3px 6px !important;
    }

    .compat-grid {
        grid-template-columns: 1fr;
    }

    .result-header {
        flex-direction: column;
        align-items: flex-start;
    }

    .result-part {
        flex-direction: column;
        align-items: flex-start;
    }

    .mfr-label {
        min-width: auto;
    }
}

@media (max-width: 480px) {
    .container {
        padding: 0 10px;
    }

    .cheat-sheet-section {
        padding: 1rem;
    }

    .copy-notification.show {
        right: 10px;
        left: 10px;
        text-align: center;
    }
}

/* Print Styles */
@media print {
    .quick-search-bar,
    .category-nav,
    .compatibility-guide,
    footer {
        display: none;
    }

    .cheat-sheet-section {
        box-shadow: none;
        padding: 0;
    }

    .cheat-table {
        page-break-inside: avoid;
    }

    .product-table-wrapper {
        page-break-inside: avoid;
    }
}
