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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    padding: 20px;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    background: white;
    border-radius: 20px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.3);
    overflow: hidden;
}

header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 30px;
    text-align: center;
}

header h1 {
    font-size: 2.5em;
    margin-bottom: 10px;
    font-weight: 700;
}

.subtitle {
    font-size: 1.1em;
    opacity: 0.9;
}

/* TABS */
.tabs {
    display: flex;
    background: #f8f9fa;
    border-bottom: 2px solid #e9ecef;
}

.tab-btn {
    flex: 1;
    padding: 15px 20px;
    border: none;
    background: transparent;
    font-size: 1em;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s;
    color: #6c757d;
}

.tab-btn:hover {
    background: #e9ecef;
}

.tab-btn.active {
    background: white;
    color: #667eea;
    border-bottom: 3px solid #667eea;
}

.tab-content {
    display: none;
    padding: 30px;
}

.tab-content.active {
    display: block;
}

/* FORM STYLES */
.form-section {
    margin-bottom: 30px;
    padding: 20px;
    background: #f8f9fa;
    border-radius: 10px;
}

.form-section h2 {
    color: #667eea;
    margin-bottom: 20px;
    font-size: 1.5em;
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    margin-bottom: 20px;
}

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

.form-group label {
    font-weight: 600;
    margin-bottom: 8px;
    color: #495057;
}

.form-group input,
.form-group select {
    padding: 12px;
    border: 2px solid #dee2e6;
    border-radius: 8px;
    font-size: 1em;
    transition: border-color 0.3s;
}

.form-group input:focus,
.form-group select:focus {
    outline: none;
    border-color: #667eea;
}

.helper-text {
    font-size: 0.9em;
    color: #6c757d;
    margin-top: 10px;
}

/* PHOTO UPLOAD */
input[type="file"] {
    padding: 15px;
    border: 2px dashed #667eea;
    border-radius: 10px;
    cursor: pointer;
    width: 100%;
}

.photo-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 15px;
    margin-top: 20px;
}

.photo-item {
    position: relative;
    aspect-ratio: 1;
    border-radius: 10px;
    overflow: hidden;
    border: 2px solid #dee2e6;
    cursor: pointer;
    transition: transform 0.3s;
}

.photo-item:hover {
    transform: scale(1.05);
}

.photo-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.photo-item .edit-badge {
    position: absolute;
    top: 5px;
    right: 5px;
    background: #667eea;
    color: white;
    padding: 5px 10px;
    border-radius: 5px;
    font-size: 0.8em;
}

.photo-item .remove-btn {
    position: absolute;
    top: 5px;
    left: 5px;
    background: #dc3545;
    color: white;
    border: none;
    width: 25px;
    height: 25px;
    border-radius: 50%;
    cursor: pointer;
    font-size: 1em;
}

/* BUTTONS */
.btn-primary {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 15px 30px;
    border: none;
    border-radius: 10px;
    font-size: 1.1em;
    font-weight: 600;
    cursor: pointer;
    transition: transform 0.3s;
    width: 100%;
    margin-top: 20px;
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(102, 126, 234, 0.4);
}

.btn-secondary {
    background: #6c757d;
    color: white;
    padding: 12px 24px;
    border: none;
    border-radius: 8px;
    font-size: 1em;
    cursor: pointer;
}

.btn-control {
    background: #f8f9fa;
    border: 2px solid #dee2e6;
    padding: 10px 15px;
    border-radius: 8px;
    cursor: pointer;
    font-weight: 600;
    transition: all 0.3s;
}

.btn-control:hover {
    background: #667eea;
    color: white;
    border-color: #667eea;
}

/* MODAL */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.7);
    z-index: 1000;
    align-items: center;
    justify-content: center;
}

.modal.active {
    display: flex;
}

.modal-content {
    background: white;
    border-radius: 15px;
    max-width: 90%;
    max-height: 90%;
    overflow: auto;
}

.modal-header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-header h2 {
    margin: 0;
    font-size: 1.5em;
}

.close-btn {
    background: transparent;
    border: none;
    color: white;
    font-size: 2em;
    cursor: pointer;
    line-height: 1;
}

.modal-body {
    padding: 20px;
}

.modal-footer {
    padding: 20px;
    border-top: 1px solid #dee2e6;
    display: flex;
    gap: 10px;
    justify-content: flex-end;
}

/* CANVAS EDITOR */
.canvas-container {
    text-align: center;
    background: #f8f9fa;
    padding: 20px;
    border-radius: 10px;
    margin: 20px 0;
}

#photoCanvas {
    max-width: 100%;
    border: 2px solid #dee2e6;
    border-radius: 8px;
    cursor: crosshair;
}

.editor-controls {
    display: flex;
    gap: 10px;
    justify-content: center;
    margin-top: 15px;
}

.editor-instructions {
    background: #fff3cd;
    border: 1px solid #ffc107;
    padding: 15px;
    border-radius: 8px;
    margin-bottom: 15px;
}

/* MESSAGE BOX */
.message-box {
    background: #f8f9fa;
    padding: 20px;
    border-radius: 10px;
    border: 2px solid #667eea;
    font-family: monospace;
    white-space: pre-wrap;
    margin-bottom: 15px;
    max-height: 400px;
    overflow-y: auto;
}

/* LISTINGS */
.search-bar {
    margin-bottom: 20px;
}

.search-bar input {
    width: 100%;
    padding: 15px;
    border: 2px solid #dee2e6;
    border-radius: 10px;
    font-size: 1em;
}

.listings-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 20px;
}

.listing-card {
    background: #f8f9fa;
    border-radius: 10px;
    padding: 20px;
    border: 2px solid #dee2e6;
    transition: transform 0.3s;
}

.listing-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 5px 15px rgba(0,0,0,0.1);
}

.listing-id {
    background: #667eea;
    color: white;
    padding: 5px 10px;
    border-radius: 5px;
    font-weight: 600;
    display: inline-block;
    margin-bottom: 10px;
}

.listing-title {
    font-size: 1.3em;
    font-weight: 700;
    margin-bottom: 10px;
    color: #212529;
}

.listing-details {
    font-size: 0.9em;
    color: #6c757d;
    line-height: 1.6;
}

.listing-actions {
    margin-top: 15px;
    display: flex;
    gap: 10px;
}

.listing-actions button {
    flex: 1;
    padding: 10px;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-weight: 600;
}

.view-btn {
    background: #667eea;
    color: white;
}

.delete-btn {
    background: #dc3545;
    color: white;
}


/* 3-column layout only for Car Details on larger screens */
.form-row.car-details-row {
    grid-template-columns: repeat(3, 1fr);
}

/* Slightly more compact spacing for that row */
.form-row.car-details-row .form-group {
    margin-bottom: 0;
}

/* On small screens, force Car Details back to 1 column */
@media (max-width: 768px) {
    .form-row {
        grid-template-columns: 1fr;
    }
    
    .form-row.car-details-row {
        grid-template-columns: 1fr;
    }
    
    header h1 {
        font-size: 1.8em;
    }
    
    .listings-grid {
        grid-template-columns: 1fr;
    }
    
    .editor-controls {
        flex-wrap: wrap;
    }
}
