:root {
    --primary-color: #2c3e50;
    --secondary-color: #3498db;
    --background-color: #ecf0f1;
    --surface-color: #ffffff;
    --text-color: #34495e;
    --border-color: #bdc3c7;
    --gold-highlight: #f1c40f;
    --green-highlight: #2ecc71;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    margin: 0;
    background-color: var(--background-color);
    color: var(--text-color);
    line-height: 1.6;
}

header {
    background-color: var(--primary-color);
    color: white;
    padding: 1rem 0;
    box-shadow: 0 2px 5px rgba(0,0,0,0.1);
    position: sticky;
    top: 0;
    z-index: 1000;
}

.header-container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 0 2rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.logo {
    display: flex;
    align-items: center;
}

.logo-image {
    height: 40px;
    width: auto;
    object-fit: contain;
}

nav {
    display: flex;
    gap: 2rem;
}

nav a {
    color: white;
    text-decoration: none;
    font-size: 1.1rem;
    font-weight: 500;
    padding: 0.5rem 1rem;
    border-radius: 5px;
    transition: background-color 0.3s ease;
}

nav a:hover, nav a.active {
    background-color: var(--secondary-color);
}

main {
    max-width: 1400px;
    margin: 2rem auto;
    padding: 0 2rem;
}

h1 {
    text-align: center;
    color: var(--primary-color);
    margin-bottom: 2rem;
}

/* Generic Table Styles */
table {
    width: 100%;
    border-collapse: collapse;
    background-color: var(--surface-color);
    box-shadow: 0 4px 8px rgba(0,0,0,0.05);
    border-radius: 8px;
    overflow: hidden;
}

table th, table td {
    border: 1px solid var(--border-color);
    padding: 12px 15px;
    text-align: left;
    vertical-align: middle;
}

table thead {
    background-color: #f2f2f2; /* Lighter than primary for less emphasis */
}

table th {
    font-weight: 600;
}

table tbody tr:nth-child(even) {
    background-color: #f9f9f9;
}

table tbody tr:hover {
    background-color: #f1f1f1;
}

/* Reviews Page Specific */
.controls-container {
    background: var(--surface-color);
    padding: 1.5rem;
    border-radius: 8px;
    margin-bottom: 2rem;
    box-shadow: 0 4px 8px rgba(0,0,0,0.05);
}

.filters {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    justify-content: center;
    margin-bottom: 1rem;
}

.filters input, .filters select {
    padding: 8px 12px;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    font-size: 14px;
}

.edit-controls {
    text-align: center;
    padding-top: 1rem;
    border-top: 1px solid var(--border-color);
}

.review-image {
    width: 100px;
    height: 100px;
    object-fit: cover;
    border-radius: 4px;
}

.group-start td {
    border-top: 2px solid var(--primary-color);
}

.sortable {
    cursor: pointer;
    position: relative;
}

.highlight-gold { background-color: var(--gold-highlight) !important; }
.highlight-green { background-color: var(--green-highlight) !important; }

.legend {
    text-align: center;
    margin-bottom: 1rem;
}

.legend-item {
    display: inline-flex;
    align-items: center;
    margin-right: 15px;
}

.legend-color {
    display: inline-block;
    width: 15px;
    height: 15px;
    margin-right: 5px;
    border: 1px solid #ccc;
}

/* Hide mobile-specific elements on desktop */
.mobile-details {
    display: none;
}

.mobile-variations {
    display: none;
}

#clasp-codes-table td[data-col="variations"] {
    display: none;
}

/* Tooltip Styles */
.tooltip {
    position: relative;
    cursor: help;
}

.tooltip::after {
    content: attr(data-tooltip);
    position: absolute;
    bottom: 125%;
    left: 50%;
    transform: translateX(-50%);
    background-color: var(--primary-color);
    color: white;
    padding: 8px 12px;
    border-radius: 6px;
    font-size: 14px;
    white-space: nowrap;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s, visibility 0.3s;
    z-index: 1000;
    box-shadow: 0 2px 8px rgba(0,0,0,0.15);
}

.tooltip::before {
    content: '';
    position: absolute;
    bottom: 115%;
    left: 50%;
    transform: translateX(-50%);
    border: 5px solid transparent;
    border-top-color: var(--primary-color);
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s, visibility 0.3s;
    z-index: 1000;
}

.tooltip:hover::after,
.tooltip:hover::before {
    opacity: 1;
    visibility: visible;
}

/* Dealers Page Specific */
#dealers-table a {
    color: var(--secondary-color);
    text-decoration: none;
    font-weight: 500;
}

#dealers-table a:hover {
    text-decoration: underline;
}

/* =============================================================================
   Responsive Styles for Mobile
   ========================================================================== */
@media screen and (max-width: 768px) {
    main {
        padding: 0 1rem;
    }

    table thead {
        display: none; /* Hide table headers on mobile */
    }

    table, table tbody, table tr, table td {
        display: block;
        width: 100%;
    }

    table tr {
        margin-bottom: 1.5rem;
        border: 1px solid var(--border-color);
        border-radius: 8px;
        overflow: hidden;
        box-shadow: 0 2px 4px rgba(0,0,0,0.05);
    }

    table td {
        display: flex;
        justify-content: space-between; /* Pushes label and value to opposite ends */
        align-items: center;
        padding: 10px 15px;
        border: none;
        border-bottom: 1px solid var(--border-color);
        gap: 1rem;
    }

    table tr td:last-of-type {
        border-bottom: none;
    }

    table td::before {
        content: attr(data-label);
        font-weight: 600;
        color: var(--primary-color);
        text-align: left;
        flex-shrink: 0; /* Prevents the label from shrinking */
    }

    table td > span {
        text-align: right;
        word-break: break-word;
        min-width: 0; /* CRITICAL for preventing flexbox overflow */
    }

    table td a {
        text-align: right;
        word-break: break-all;
    }

    /* Specific adjustments for the reviews table */
    #reviews-table td[data-col="image_url"] {
        padding: 10px;
        justify-content: center;
    }

    #reviews-table td[data-col="image_url"]::before {
        display: none;
    }

    .review-image {
        width: 120px;
        height: 120px;
    }

    /* Hide redundant columns on mobile */
    #reviews-table td[data-col="brand"],
    #reviews-table td[data-col="model"],
    #reviews-table td[data-col="reference_number"] {
        display: none;
    }
}
