/**
 * Dealer Portal Styles
 */

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

:root {
    --primary: #E85D04;
    --primary-dark: #d64d00;
    --dark: #1a1a1a;
    --gray: #6b6b6b;
    --light-gray: #f5f5f5;
    --border: #e5e0db;
    --success: #22c55e;
    --warning: #f59e0b;
    --danger: #ef4444;
    --info: #3b82f6;
}

body {
    font-family: 'DM Sans', sans-serif;
    background: var(--light-gray);
    min-height: 100vh;
}

/* Mobile sidebar toggle */
.mobile-sidebar-toggle {
    display: none;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    gap: 5px;
    background: white;
    border: 1px solid var(--border);
    border-radius: 8px;
    cursor: pointer;
    padding: 10px;
    width: 44px;
    height: 44px;
    margin-right: 1rem;
}

.mobile-sidebar-toggle span {
    display: block;
    width: 20px;
    height: 2px;
    background-color: var(--dark);
    border-radius: 2px;
    transition: all 0.3s ease;
}

.mobile-sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 99;
}

.mobile-sidebar-overlay.show {
    display: block;
}

/* Sidebar */
.sidebar {
    position: fixed;
    left: 0;
    top: 0;
    bottom: 0;
    width: 250px;
    background: var(--dark);
    color: white;
    padding: 1.5rem;
    z-index: 100;
    transition: transform 0.3s ease;
}

.sidebar-logo {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    font-size: 1.25rem;
    font-weight: 700;
    margin-bottom: 2rem;
    padding-bottom: 1.5rem;
    border-bottom: 1px solid rgba(255,255,255,0.1);
}

.sidebar-nav { list-style: none; }

.sidebar-nav li { margin-bottom: 0.5rem; }

.sidebar-nav a {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 1rem;
    color: rgba(255,255,255,0.7);
    text-decoration: none;
    border-radius: 8px;
    transition: all 0.2s;
}

.sidebar-nav a:hover,
.sidebar-nav a.active {
    background: rgba(255,255,255,0.1);
    color: white;
}

.sidebar-nav a.active {
    background: var(--primary);
}

.sidebar-footer {
    position: absolute;
    bottom: 1.5rem;
    left: 1.5rem;
    right: 1.5rem;
}

.dealer-info {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem;
    background: rgba(255,255,255,0.05);
    border-radius: 8px;
    margin-bottom: 0.75rem;
}

.dealer-avatar {
    width: 36px;
    height: 36px;
    background: var(--primary);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
}

.dealer-name {
    font-size: 0.9rem;
    font-weight: 500;
}

.dealer-company {
    font-size: 0.75rem;
    color: rgba(255,255,255,0.5);
}

.logout-btn {
    width: 100%;
    padding: 0.75rem;
    background: transparent;
    border: 1px solid rgba(255,255,255,0.2);
    color: rgba(255,255,255,0.7);
    border-radius: 8px;
    cursor: pointer;
    font-family: inherit;
    font-size: 0.9rem;
    transition: all 0.2s;
}

.logout-btn:hover {
    background: rgba(255,255,255,0.1);
    color: white;
}

/* Main Content */
.main-content {
    margin-left: 250px;
    padding: 2rem;
}

.page-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2rem;
}

.page-title {
    font-size: 1.75rem;
    font-weight: 700;
    color: var(--dark);
}

/* Stats Cards */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1.5rem;
    margin-bottom: 2rem;
}

.stat-card {
    background: white;
    padding: 1.5rem;
    border-radius: 12px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.04);
}

.stat-label {
    font-size: 0.85rem;
    color: var(--gray);
    margin-bottom: 0.5rem;
}

.stat-value {
    font-size: 2rem;
    font-weight: 700;
    color: var(--dark);
}

.stat-value.pending { color: var(--warning); }
.stat-value.active { color: var(--success); }

/* Table */
.table-container {
    background: white;
    border-radius: 12px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.04);
    overflow: hidden;
}

/* Table wrapper for horizontal scroll on small screens */
.table-wrapper {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.table-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1.25rem 1.5rem;
    border-bottom: 1px solid var(--border);
}

.table-title {
    font-size: 1.1rem;
    font-weight: 600;
}

.table-actions {
    display: flex;
    gap: 0.75rem;
    align-items: center;
}

.search-input {
    padding: 0.5rem 1rem;
    border: 1px solid var(--border);
    border-radius: 6px;
    font-size: 0.9rem;
    font-family: inherit;
    width: 280px;
}

.search-input:focus {
    outline: none;
    border-color: var(--primary);
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    border-radius: 6px;
    font-size: 0.9rem;
    font-weight: 500;
    font-family: inherit;
    cursor: pointer;
    transition: all 0.2s;
    border: none;
}

.btn-primary {
    background: var(--primary);
    color: white;
}

.btn-primary:hover {
    background: var(--primary-dark);
}

.btn-secondary {
    background: var(--light-gray);
    color: var(--dark);
}

.btn-secondary:hover {
    background: var(--border);
}

.btn-success {
    background: var(--success);
    color: white;
}

.btn-success:hover {
    background: #16a34a;
}

.btn-sm {
    padding: 0.35rem 0.75rem;
    font-size: 0.8rem;
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Table Styles */
table {
    width: 100%;
    border-collapse: collapse;
    min-width: 900px; /* Ensures table doesn't compress too much */
}

th, td {
    padding: 1rem 1rem;
    text-align: left;
    white-space: nowrap;
}

th:first-child, td:first-child {
    white-space: normal; /* Allow car info to wrap */
}

th:last-child, td:last-child {
    white-space: normal; /* Allow action buttons to wrap */
}

th {
    background: var(--light-gray);
    font-weight: 600;
    font-size: 0.85rem;
    color: var(--gray);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

tr {
    border-bottom: 1px solid var(--border);
}

tr:hover {
    background: #fafafa;
}

/* Car info display */
.car-info {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.car-thumb {
    width: 60px;
    height: 45px;
    object-fit: cover;
    border-radius: 6px;
    background: var(--light-gray);
}

.car-name {
    font-weight: 500;
}

.car-plate {
    font-size: 0.8rem;
    color: var(--gray);
}

.car-year {
    font-size: 0.8rem;
    color: var(--gray);
}

/* Bid status */
.bid-status {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.bid-amount {
    font-weight: 600;
    color: var(--dark);
}

.bid-label {
    font-size: 0.75rem;
    color: var(--gray);
}

.no-bid {
    color: var(--gray);
    font-style: italic;
}

/* Deadline display */
.deadline-info {
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
}

.deadline-date {
    font-weight: 500;
    font-size: 0.9rem;
}

.deadline-remaining {
    font-size: 0.75rem;
}

.deadline-ok .deadline-remaining {
    color: var(--success);
}

.deadline-soon .deadline-remaining {
    color: var(--warning);
}

.deadline-urgent .deadline-remaining {
    color: var(--danger);
    font-weight: 600;
}

.deadline-expired .deadline-remaining {
    color: var(--danger);
}

.deadline-inactive .deadline-remaining {
    color: var(--gray);
}

/* Info banner */
.info-banner {
    background: #eff6ff;
    border: 1px solid #bfdbfe;
    border-radius: 8px;
    padding: 1rem 1.5rem;
    margin-bottom: 1.5rem;
    color: #1e40af;
}

.info-banner p {
    margin: 0;
    font-size: 0.9rem;
}

/* Winning bid display */
.winning-bid {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.bid-amount-large {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--success);
}

.winner-label {
    font-size: 0.75rem;
    color: var(--warning);
    font-weight: 500;
}

/* Contact info */
.contact-info {
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
    font-size: 0.9rem;
}

.contact-info a {
    color: var(--primary);
    text-decoration: none;
}

.contact-info a:hover {
    text-decoration: underline;
}

.contact-hidden {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    color: var(--gray);
}

/* Settings page */
.settings-container {
    display: flex;
    flex-direction: column;
    gap: 2rem;
}

.settings-section {
    background: white;
    border-radius: 12px;
    padding: 1.5rem 2rem;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.settings-section-title {
    font-size: 1.1rem;
    font-weight: 600;
    margin: 0 0 0.5rem 0;
    color: var(--dark);
}

.settings-description {
    color: var(--gray);
    font-size: 0.9rem;
    margin: 0 0 1.5rem 0;
}

.settings-form {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    margin-top: 1rem;
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
}

@media (max-width: 600px) {
    .form-row {
        grid-template-columns: 1fr;
    }
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
}

.form-group label {
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--dark);
}

.form-group input,
.form-group select,
.form-group textarea {
    padding: 0.65rem 0.85rem;
    border: 1px solid #ddd;
    border-radius: 6px;
    font-size: 0.95rem;
    font-family: inherit;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(232, 119, 34, 0.1);
}

.form-group input.readonly {
    background: #f5f5f5;
    color: var(--gray);
    cursor: not-allowed;
}

.form-hint {
    font-size: 0.75rem;
    color: var(--gray);
}

.form-actions {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-top: 0.5rem;
}

.save-status {
    font-size: 0.85rem;
    font-weight: 500;
}

.save-status.success {
    color: var(--success);
}

.save-status.error {
    color: var(--danger);
}

/* Checkbox grid for car makes */
.checkbox-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 0.5rem;
    margin-top: 0.5rem;
}

.checkbox-label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem;
    background: #f9fafb;
    border-radius: 6px;
    cursor: pointer;
    transition: background 0.2s;
    font-size: 0.9rem;
}

.checkbox-label:hover {
    background: #f3f4f6;
}

.checkbox-label input[type="checkbox"] {
    width: 16px;
    height: 16px;
    accent-color: var(--primary);
}

/* Email Preferences */
.settings-description {
    color: var(--gray);
    font-size: 0.9rem;
    margin-bottom: 1rem;
}

.email-preferences-list {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.email-preference-item {
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
    padding: 1rem;
    background: #f9fafb;
    border-radius: 8px;
    cursor: pointer;
    transition: background 0.2s;
}

.email-preference-item:hover {
    background: #f3f4f6;
}

.email-preference-item input[type="checkbox"] {
    width: 18px;
    height: 18px;
    margin-top: 2px;
    accent-color: var(--primary);
    flex-shrink: 0;
}

.email-preference-info {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.email-preference-name {
    font-weight: 500;
    color: #1f2937;
}

.email-preference-desc {
    font-size: 0.85rem;
    color: var(--gray);
}

/* Status badges */
.status-badge {
    display: inline-block;
    padding: 0.25rem 0.75rem;
    border-radius: 50px;
    font-size: 0.8rem;
    font-weight: 500;
}

.bid-status-PENDING {
    background: #fef3c7;
    color: #92400e;
}

.bid-status-ACCEPTED {
    background: #d1fae5;
    color: #065f46;
}

.bid-status-REJECTED {
    background: #fee2e2;
    color: #991b1b;
}

/* Action buttons */
.action-btns {
    display: flex;
    gap: 0.5rem;
}

/* Modal */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: 2rem;
}

.modal-overlay.show {
    display: flex;
}

.modal {
    background: white;
    border-radius: 16px;
    width: 100%;
    max-width: 500px;
    max-height: 90vh;
    overflow-y: auto;
}

.modal-large {
    max-width: 700px;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1.5rem;
    border-bottom: 1px solid var(--border);
}

.modal-title {
    font-size: 1.25rem;
    font-weight: 600;
}

.modal-close {
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: var(--gray);
    line-height: 1;
}

.modal-body {
    padding: 1.5rem;
}

.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 0.75rem;
    padding: 1.5rem;
    border-top: 1px solid var(--border);
}

/* Car summary in modal */
.car-summary {
    background: var(--light-gray);
    border-radius: 8px;
    padding: 1rem;
    margin-bottom: 1.5rem;
}

.car-summary-header {
    display: flex;
    gap: 1rem;
    margin-bottom: 1rem;
}

.car-summary-thumb {
    width: 80px;
    height: 60px;
    object-fit: cover;
    border-radius: 6px;
    background: white;
}

.car-summary-info h4 {
    margin-bottom: 0.25rem;
}

.car-summary-info p {
    font-size: 0.85rem;
    color: var(--gray);
}

.car-summary-details {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 0.75rem;
    font-size: 0.85rem;
}

.car-summary-detail {
    text-align: center;
}

.car-summary-detail .label {
    color: var(--gray);
    font-size: 0.75rem;
    margin-bottom: 0.25rem;
}

.car-summary-detail .value {
    font-weight: 500;
}

/* Forms */
.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
}

.form-group {
    margin-bottom: 1rem;
}

.form-label {
    display: block;
    font-weight: 500;
    margin-bottom: 0.5rem;
    font-size: 0.9rem;
}

.form-input,
.form-select,
.form-textarea {
    width: 100%;
    padding: 0.625rem 0.875rem;
    border: 1px solid var(--border);
    border-radius: 6px;
    font-size: 0.9rem;
    font-family: inherit;
}

.form-input:focus,
.form-select:focus,
.form-textarea:focus {
    outline: none;
    border-color: var(--primary);
}

.form-textarea {
    resize: vertical;
    min-height: 80px;
}

/* Pagination */
.pagination {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 1.5rem;
    border-top: 1px solid var(--border);
}

.pagination-info {
    color: var(--gray);
    font-size: 0.9rem;
}

.pagination-btns {
    display: flex;
    gap: 0.5rem;
}

/* Loading */
.loading {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 3rem;
    color: var(--gray);
}

.spinner {
    width: 24px;
    height: 24px;
    border: 3px solid var(--border);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-right: 0.75rem;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* Empty state */
.empty-state {
    text-align: center;
    padding: 3rem;
    color: var(--gray);
}

.empty-state-icon {
    font-size: 3rem;
    margin-bottom: 1rem;
}

/* Car details in modal */
.car-details-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
}

.car-details-section {
    margin-bottom: 1.5rem;
}

.car-details-section h4 {
    font-size: 0.85rem;
    color: var(--gray);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 0.75rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid var(--border);
}

.car-details-row {
    display: flex;
    justify-content: space-between;
    padding: 0.5rem 0;
    font-size: 0.9rem;
}

.car-details-row .label {
    color: var(--gray);
}

.car-details-row .value {
    font-weight: 500;
}

.car-images-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 0.5rem;
    margin-bottom: 1.5rem;
}

.car-images-grid img {
    width: 100%;
    aspect-ratio: 4/3;
    object-fit: cover;
    border-radius: 6px;
    cursor: pointer;
}

/* Responsive */
@media (max-width: 768px) {
    .mobile-sidebar-toggle {
        display: flex;
    }
    
    .page-header {
        display: flex;
        align-items: center;
        padding: 1rem 0;
    }
    
    .sidebar {
        transform: translateX(-100%);
        position: fixed;
        z-index: 1000;
    }
    
    .sidebar.open {
        transform: translateX(0);
    }
    
    .main-content {
        margin-left: 0;
        padding: 1rem;
    }
    
    .page-title {
        font-size: 1.5rem;
    }
    
    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 0.75rem;
    }
    
    .stat-card {
        padding: 1rem;
    }
    
    .stat-value {
        font-size: 1.5rem;
    }
    
    .table-container {
        border-radius: 8px;
        margin: 0 -0.5rem;
    }
    
    .table-header {
        flex-direction: column;
        gap: 1rem;
        align-items: stretch;
        padding: 1rem;
    }
    
    .search-input {
        width: 100%;
    }
    
    .table-wrapper {
        margin: 0;
    }
    
    table {
        min-width: 700px;
    }
    
    th, td {
        padding: 0.75rem 0.5rem;
        font-size: 0.85rem;
    }
    
    .car-thumb {
        width: 50px;
        height: 38px;
    }
    
    .car-name {
        font-size: 0.9rem;
    }
    
    .action-btns {
        flex-direction: column;
        gap: 0.5rem;
    }
    
    .action-btns .btn {
        width: 100%;
        justify-content: center;
    }
    
    .form-row {
        grid-template-columns: 1fr;
    }
    
    /* Modal responsive */
    .modal {
        width: 95%;
        max-width: none;
        margin: 1rem;
        max-height: 90vh;
    }
    
    .modal-large {
        width: 95%;
    }
    
    .modal-body {
        padding: 1rem;
    }
    
    /* Scroll hint for tables */
    .table-wrapper::after {
        content: '← Scroll for mere →';
        display: block;
        text-align: center;
        padding: 0.5rem;
        font-size: 0.75rem;
        color: var(--gray);
        background: linear-gradient(to right, rgba(255,255,255,0), rgba(255,255,255,1) 20%, rgba(255,255,255,1) 80%, rgba(255,255,255,0));
    }
}

@media (max-width: 480px) {
    .stats-grid {
        grid-template-columns: 1fr;
    }
    
    table {
        min-width: 600px;
    }
    
    .car-info {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.5rem;
    }
    
    .car-thumb {
        width: 100%;
        height: 60px;
        max-width: 80px;
    }
}

/* Equipment grid */
.equipment-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.equipment-tag {
    display: inline-block;
    padding: 0.35rem 0.75rem;
    background: var(--light-gray);
    border-radius: 4px;
    font-size: 0.85rem;
    color: var(--dark);
}

/* Image lightbox */
.lightbox {
    position: fixed;
    inset: 0;
    z-index: 2000;
    display: none;
}

.lightbox.show {
    display: block;
}

.lightbox-overlay {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.95);
}

.lightbox-content {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
}

.lightbox-img {
    max-width: 90vw;
    max-height: 90vh;
    object-fit: contain;
    border-radius: 4px;
}

.lightbox-close {
    position: absolute;
    top: 1rem;
    right: 1rem;
    background: rgba(255, 255, 255, 0.1);
    border: none;
    color: white;
    font-size: 2rem;
    width: 50px;
    height: 50px;
    border-radius: 50%;
    cursor: pointer;
    transition: background 0.2s;
    z-index: 10;
}

.lightbox-close:hover {
    background: rgba(255, 255, 255, 0.2);
}

.lightbox-prev,
.lightbox-next {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    background: rgba(255, 255, 255, 0.1);
    border: none;
    color: white;
    font-size: 1.5rem;
    width: 50px;
    height: 50px;
    border-radius: 50%;
    cursor: pointer;
    transition: background 0.2s;
    z-index: 10;
}

.lightbox-prev {
    left: 1rem;
}

.lightbox-next {
    right: 1rem;
}

.lightbox-prev:hover,
.lightbox-next:hover {
    background: rgba(255, 255, 255, 0.2);
}

.lightbox-counter {
    position: absolute;
    bottom: 1.5rem;
    left: 50%;
    transform: translateX(-50%);
    color: white;
    font-size: 0.9rem;
    background: rgba(0, 0, 0, 0.5);
    padding: 0.5rem 1rem;
    border-radius: 4px;
}

/* Car images in details modal */
.car-images-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 0.5rem;
    margin-bottom: 1.5rem;
}

.car-images-grid img {
    width: 100%;
    aspect-ratio: 4/3;
    object-fit: cover;
    border-radius: 6px;
    cursor: pointer;
    transition: opacity 0.2s;
}

.car-images-grid img:hover {
    opacity: 0.8;
}

@media (max-width: 600px) {
    .car-images-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .lightbox-prev,
    .lightbox-next {
        width: 40px;
        height: 40px;
        font-size: 1.2rem;
    }
}

/* Won bids table styling */
.row-accepted {
    background: #f0fdf4;
}

.row-rejected {
    background: #fef2f2;
    opacity: 0.7;
}

.contact-info {
    line-height: 1.5;
}

.contact-info a {
    color: var(--primary);
    text-decoration: none;
}

.contact-info a:hover {
    text-decoration: underline;
}

.contact-hidden {
    text-align: center;
    padding: 0.5rem;
}

.winning-bid {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.bid-amount-large {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--success);
}

.winner-label {
    font-size: 0.8rem;
    color: var(--gray);
}

