*,
*::before,
*::after {
    box-sizing: border-box;
}

body {
    margin: 0;
    background-color: #f4f6f8;
    display: flex;
    font-family: Arial, sans-serif;
}

.sidebar {
    width: 250px;
    height: 100vh;
    background-color: #1f2937;
    padding: 20px;
}

.sidebar nav {
    display: flex;
    flex-direction: column;
}

.sidebar h2 {
    color: white;
}

.sidebar a {
    color: white;
    text-decoration: none;
    margin-bottom: 15px;
}

.main-content {
    padding: 30px;
    flex: 1;
    min-width: 0;
}

.dashboard-cards {
    display: grid;
    /* auto-fit instead of a fixed column count: with the current 3 stat
       cards, repeat(4, 1fr) left an empty, unevenly-sized 4th column.
       auto-fit also means this keeps working if a card is added/removed
       later without editing the CSS again. */
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 20px;
    margin-top: 30px;
}

.card {
    background-color: white;
    padding: 20px;
    border-radius: 10px;
    border: 1px solid #e5e7eb;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.05);
    transition: transform 0.18s ease, box-shadow 0.18s ease;
}

.card h3 {
    margin-top: 0;
}

.card p {
    font-size: 32px;
    font-weight: bold;
    margin-bottom: 0;
}

.section-title {
    margin-top: 35px;
}

.shop-cards {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 20px;
}

.card:hover {
    transform: translateY(-3px);
    box-shadow: 0 6px 18px rgba(0, 0, 0, 0.10);
}

.total-card {
    border-top: 4px solid #64748b;
}

.active-card {
    border-top: 4px solid #22c55e;
}

.dealer-card {
    border-top: 4px solid #f59e0b;
}

.shop-card {
    border-top: 4px solid #3b82f6;
}

.sidebar a {
    padding: 10px 12px;
    border-radius: 6px;
    transition: 0.2s;
}

.sidebar a:hover {
    background-color: #334155;
}

.units-toolbar {
    display: flex;
    flex-wrap: wrap;
    gap: 15px;
    margin-top: 30px;
    margin-bottom: 25px;
}

.units-toolbar input,
.units-toolbar select {
    padding: 12px;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    font-size: 14px;
}

.units-toolbar input {
    width: 250px;
}

.add-unit-button {
    margin-left: auto;
    background-color: #2563eb;
    color: white;
    padding: 12px 18px;
    border-radius: 6px;
    text-decoration: none;
    transition: background-color 0.2s ease;
}

.add-unit-button:hover {
    background-color: #1d4ed8;
}

.units-table {
    background-color: white;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    /* overflow: hidden clipped the table on narrow screens - the table
       has 9 columns and doesn't fit on smaller widths. overflow-x: auto
       lets it scroll horizontally while overflow-y: hidden keeps the
       rounded corners on the header row intact. */
    overflow-x: auto;
    overflow-y: hidden;
}

.units-table table {
    width: 100%;
    min-width: 800px;
    border-collapse: collapse;
}

.units-table th,
.units-table td {
    text-align: left;
    padding: 15px;
    border-bottom: 1px solid #e5e7eb;
}

.units-table th {
    background-color: #f9fafb;
}

/* ADD UNIT PAGE */

.page-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 12px;
}

.back-btn {
    text-decoration: none;
    color: #2563eb;
    font-weight: 600;
}

.unit-form {
    background-color: white;
    margin-top: 35px;
    padding: 30px;
    border-radius: 10px;
    border: 1px solid #e5e7eb;
}

.unit-form h2 {
    margin-top: 30px;
    margin-bottom: 20px;
}

.unit-form h2:first-child {
    margin-top: 0;
}

.form-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 20px;
}

.form-group {
    display: flex;
    flex-direction: column;
}

.form-group label {
    font-weight: 600;
    margin-bottom: 8px;
}

.form-group input,
.form-group select {
    padding: 12px;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    font-size: 16px;
}

.field-hint {
    color: #6b7280;
    font-size: 13px;
    margin: 8px 0 0;
}

.vin-input {
    display: flex;
    gap: 10px;
}

.vin-input input {
    flex: 1;
    min-width: 0;
}

.decode-btn {
    background-color: #374151;
    color: white;
    border: none;
    border-radius: 6px;
    padding: 0 20px;
    cursor: pointer;
    transition: background-color 0.2s ease;
}

.decode-btn:hover {
    background-color: #1f2937;
}

.decode-btn:disabled,
.save-unit-btn:disabled,
.primary-btn:disabled,
.secondary-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.form-actions {
    display: flex;
    justify-content: flex-end;
    align-items: center;
    gap: 15px;
    margin-top: 35px;
    flex-wrap: wrap;
}

.cancel-btn {
    text-decoration: none;
    color: #374151;
    padding: 12px 20px;
}

.save-unit-btn {
    background-color: #2563eb;
    color: white;
    border: none;
    border-radius: 6px;
    padding: 12px 25px;
    font-size: 16px;
    cursor: pointer;
    transition: background-color 0.2s ease;
}

.save-unit-btn:hover {
    background-color: #1d4ed8;
}

/* ========================= */
/* UNIT PROFILE */
/* ========================= */

.unit-profile-header {
    background-color: white;
    border: 1px solid #e5e7eb;
    border-radius: 10px;
    padding: 25px 30px;
}

.unit-profile-header h1 {
    margin-bottom: 5px;
}

.unit-profile-subtitle {
    color: #6b7280;
    font-size: 17px;
    margin-top: 0;
}

.unit-profile-badges {
    display: flex;
    gap: 10px;
    margin-top: 15px;
    flex-wrap: wrap;
}

.unit-badge,
.status-badge {
    display: inline-block;
    padding: 7px 12px;
    border-radius: 20px;
    font-size: 14px;
    font-weight: 600;
}

.unit-badge {
    background-color: #e5e7eb;
    color: #374151;
}

/* Default/unknown status: neutral, not a false "all good" green.
   Same color set as .status-pill in units.html so a unit's status reads
   the same way here as it does in the Units table. JS sets one of these
   modifier classes based on currentUnit.status. */
.status-badge {
    background-color: #f3f4f6;
    color: #374151;
}

.status-badge.active-on-road {
    background-color: #dcfce7;
    color: #166534;
}

.status-badge.ready {
    background-color: #dbeafe;
    color: #1d4ed8;
}

.status-badge.in-dealer {
    background-color: #fef3c7;
    color: #92400e;
}

.status-badge.shop {
    background-color: #fee2e2;
    color: #991b1b;
}


/* TABS */

.unit-tabs {
    display: flex;
    gap: 5px;
    margin-top: 25px;
    border-bottom: 1px solid #d1d5db;
    overflow-x: auto;
}

.unit-tab {
    background: none;
    border: none;
    padding: 14px 16px;
    font-size: 15px;
    cursor: pointer;
    color: #6b7280;
    white-space: nowrap;
    transition: color 0.18s ease, border-color 0.18s ease;
}

.unit-tab:hover {
    color: #2563eb;
}

.unit-tab.active {
    color: #2563eb;
    border-bottom: 3px solid #2563eb;
    font-weight: 600;
}


/* TAB CONTENT */

.tab-content {
    display: none;
}

.tab-content.active {
    display: block;
}


/* PROFILE CARD */

.profile-card {
    background-color: white;
    margin-top: 25px;
    padding: 30px;
    border: 1px solid #e5e7eb;
    border-radius: 10px;
}

.profile-card h2 {
    margin-top: 0;
}


/* PROFILE DATA */

.profile-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 25px;
    margin-top: 25px;
}

.profile-field {
    display: flex;
    flex-direction: column;
}

.profile-field span {
    color: #6b7280;
    font-size: 14px;
    margin-bottom: 6px;
}

.profile-field strong {
    font-size: 16px;
}


/* ASSIGNED TRAILER */

.assigned-asset {
    margin-top: 20px;
    padding: 20px;
    background-color: #f9fafb;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
}

.assigned-label {
    display: block;
    color: #6b7280;
    font-size: 14px;
    margin-bottom: 7px;
}

.assignment-controls {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-top: 20px;
}

.assignment-controls select {
    min-width: 280px;
    padding: 11px;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    font-size: 15px;
}

.primary-btn {
    background-color: #2563eb;
    color: white;
    border: none;
    border-radius: 6px;
    padding: 11px 18px;
    cursor: pointer;
    transition: background-color 0.2s ease;
}

.primary-btn:hover {
    background-color: #1d4ed8;
}

.secondary-btn {
    background-color: white;
    color: #374151;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    padding: 11px 18px;
    cursor: pointer;
    transition: background-color 0.2s ease;
}

.secondary-btn:hover {
    background-color: #f3f4f6;
}


/* ========================= */
/* SMALL SCREENS             */
/* ========================= */
/* Sidebar stays fixed-width by design for now - a real collapsible
   sidebar needs a JS toggle, not just CSS, so it's left as a known
   limitation rather than guessed at here. This only keeps the grids
   from squeezing into unreadably narrow columns. */
@media (max-width: 760px) {

    .shop-cards {
        grid-template-columns: 1fr;
    }

    .form-grid {
        grid-template-columns: 1fr;
    }

    .profile-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .units-toolbar input {
        width: 100%;
    }

    .add-unit-button {
        margin-left: 0;
    }

}

@media (max-width: 480px) {

    .profile-grid {
        grid-template-columns: 1fr;
    }

}
