/* ======================
   CSS Variables & Reset
   ====================== */
:root {
    --primary-color: #2A98BD;
    --primary-dark: #1B3A6B;
    --secondary-color: #5A5A5A;
    --secondary-dark: #3D3D3D;
    --text-dark: #2C2C2C;
    --text-light: #6B6B6B;
    --bg-light: #F7F7F7;
    --white: #FFFFFF;
    --border-color: #DDDDDD;
    --shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    --shadow-hover: 0 4px 16px rgba(0, 0, 0, 0.15);
}

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

body {
    font-family: 'Roboto', sans-serif;
    background: #FFFFFF;
    min-height: 100vh;
    padding: 20px;
    color: var(--text-dark);
    line-height: 1.6;
}

/* Login Screen */
.login-screen {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(135deg, var(--primary-color), var(--primary-dark));
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 10000;
}

.login-container {
    background: var(--white);
    padding: 50px 40px;
    border-radius: 12px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    max-width: 400px;
    width: 90%;
}

.login-header {
    text-align: center;
    margin-bottom: 40px;
}

.login-header h1 {
    font-size: 2.5rem;
    color: var(--primary-color);
    margin-bottom: 10px;
    font-weight: 700;
}

.login-header p {
    color: var(--text-light);
    font-size: 1.1rem;
}

.login-form .form-group {
    margin-bottom: 25px;
}

.login-form .form-group label {
    display: block;
    margin-bottom: 10px;
    font-weight: 600;
    color: var(--text-dark);
}

.login-form .form-group input {
    width: 100%;
    padding: 15px;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    font-size: 1rem;
    transition: all 0.3s ease;
}

.login-form .form-group input:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(42, 152, 189, 0.1);
}

.login-form .btn {
    width: 100%;
    padding: 15px;
    font-size: 1.1rem;
}

.login-error {
    margin-top: 15px;
    text-align: center;
    color: #dc3545;
    font-size: 0.95rem;
    font-weight: 500;
}

.login-screen.hidden {
    display: none;
}

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    10%, 30%, 50%, 70%, 90% { transform: translateX(-10px); }
    20%, 40%, 60%, 80% { transform: translateX(10px); }
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    background: var(--white);
    border-radius: 8px;
    box-shadow: var(--shadow);
    overflow: hidden;
}

/* Header */
.admin-header {
    background: linear-gradient(135deg, var(--primary-color), var(--primary-dark));
    color: var(--white);
    padding: 40px;
}

.admin-header-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 20px;
}

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

.admin-header p {
    font-size: 1.1rem;
    opacity: 0.95;
    font-weight: 400;
}

.btn-back-home {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 12px 24px;
    background: rgba(255, 255, 255, 0.2);
    color: var(--white);
    border-radius: 6px;
    font-weight: 600;
    font-size: 1rem;
    transition: all 0.3s ease;
    border: 2px solid rgba(255, 255, 255, 0.3);
    text-decoration: none;
}

.btn-back-home:hover {
    background: var(--white);
    color: var(--primary-color);
    border-color: var(--white);
    transform: translateY(-2px);
}

.btn-back-home svg {
    stroke: currentColor;
}

/* Tabs */
.tabs {
    display: flex;
    background: var(--bg-light);
    border-bottom: 2px solid var(--border-color);
}

.tab-btn {
    flex: 1;
    padding: 20px;
    background: transparent;
    border: none;
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--text-light);
    cursor: pointer;
    transition: all 0.3s ease;
    border-bottom: 3px solid transparent;
}

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

.tab-btn.active {
    background: var(--white);
    color: var(--primary-color);
    border-bottom: 3px solid var(--primary-color);
}

/* Tab Content */
.tab-content {
    display: none;
    padding: 40px;
    animation: fadeIn 0.5s ease;
}

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

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Form Container */
.form-container {
    max-width: 900px;
    margin: 0 auto;
}

.form-container h2 {
    color: var(--primary-color);
    margin-bottom: 30px;
    font-size: 1.8rem;
    font-weight: 700;
}

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

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

.form-group.full-width {
    grid-column: 1 / -1;
    margin-bottom: 20px;
}

.form-group label {
    font-weight: 600;
    color: var(--text-dark);
    margin-bottom: 8px;
    font-size: 0.95rem;
}

.form-group input,
.form-group select,
.form-group textarea {
    padding: 12px 15px;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    font-size: 1rem;
    transition: all 0.3s ease;
    font-family: inherit;
    color: var(--text-dark);
}

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

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

/* Image Upload & Preview */
.image-preview {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
    gap: 15px;
    margin-top: 15px;
}

.image-preview-item {
    position: relative;
    border-radius: 6px;
    overflow: hidden;
    border: 2px solid var(--border-color);
    aspect-ratio: 1;
}

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

.image-preview-item .remove-image {
    position: absolute;
    top: 5px;
    right: 5px;
    background: var(--primary-color);
    color: var(--white);
    border: none;
    border-radius: 50%;
    width: 25px;
    height: 25px;
    cursor: pointer;
    font-size: 14px;
    line-height: 1;
    transition: all 0.3s ease;
}

.image-preview-item .remove-image:hover {
    background: var(--primary-dark);
    transform: scale(1.1);
}

/* Buttons */
.form-actions {
    display: flex;
    gap: 15px;
    margin-top: 30px;
    justify-content: center;
}

.btn {
    padding: 15px 40px;
    border: none;
    border-radius: 6px;
    font-size: 1.1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary-color), var(--primary-dark));
    color: var(--white);
    box-shadow: 0 4px 15px rgba(42, 152, 189, 0.3);
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 25px rgba(42, 152, 189, 0.4);
}

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

.btn-secondary:hover {
    background: var(--secondary-dark);
    transform: translateY(-2px);
}

.btn-refresh {
    background: #28a745;
    color: var(--white);
    padding: 10px 20px;
    font-size: 1rem;
}

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

.btn-danger {
    background: #dc3545;
    color: var(--white);
    padding: 8px 16px;
    font-size: 0.9rem;
}

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

.btn-edit {
    background: #ffc107;
    color: var(--text-dark);
    padding: 8px 16px;
    font-size: 0.9rem;
}

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

/* Car List */
.list-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 30px;
}

.list-header h2 {
    color: var(--primary-color);
    font-size: 1.8rem;
    font-weight: 700;
}

.search-bar {
    margin-bottom: 30px;
}

.search-bar input {
    width: 100%;
    padding: 15px 20px;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    font-size: 1.1rem;
    transition: all 0.3s ease;
}

.search-bar input:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(42, 152, 189, 0.1);
}

/* Cars Grid */
.cars-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(350px, 1fr));
    gap: 25px;
}

.car-card {
    background: var(--white);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 0;
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
}

.car-card:hover {
    transform: translateY(-5px);
    box-shadow: var(--shadow-hover);
    border-color: var(--primary-color);
}

.car-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 4px;
    background: linear-gradient(135deg, var(--primary-color), var(--primary-dark));
}

.car-images {
    width: 100%;
    height: 200px;
    overflow: hidden;
    position: relative;
    background: var(--bg-light);
}

.car-images img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.car-images-placeholder {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-light);
    color: var(--text-light);
    font-size: 3rem;
}

.car-content {
    padding: 25px;
}

.car-header {
    margin-bottom: 15px;
}

.car-title {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-dark);
    margin-bottom: 5px;
}

.car-year {
    color: var(--text-light);
    font-size: 1rem;
}

.car-price {
    font-size: 1.8rem;
    font-weight: 700;
    color: var(--primary-color);
    margin: 15px 0;
}

.car-details {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    margin: 15px 0;
    padding: 15px;
    background: var(--bg-light);
    border-radius: 6px;
}

.car-detail {
    font-size: 0.9rem;
    color: var(--text-light);
}

.car-detail strong {
    color: var(--text-dark);
    display: block;
    margin-bottom: 3px;
}

.car-description {
    color: var(--text-light);
    font-size: 0.95rem;
    line-height: 1.5;
    margin: 15px 0;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.car-actions {
    display: flex;
    gap: 10px;
    margin-top: 20px;
    padding-top: 15px;
    border-top: 1px solid var(--border-color);
}

/* Loading & Empty States */
.loading {
    text-align: center;
    padding: 60px;
    color: var(--text-light);
    font-size: 1.2rem;
}

.no-cars {
    text-align: center;
    padding: 60px;
    color: var(--text-light);
}

.no-cars h3 {
    color: var(--primary-color);
    margin-bottom: 10px;
}

/* Loading Overlay */
.loading-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 9999;
    justify-content: center;
    align-items: center;
}

.loading-overlay.active {
    display: flex;
}

.spinner {
    width: 60px;
    height: 60px;
    border: 5px solid rgba(255, 255, 255, 0.3);
    border-top-color: var(--white);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

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

/* Toast Notifications */
.toast {
    position: fixed;
    bottom: 30px;
    right: 30px;
    background: var(--text-dark);
    color: var(--white);
    padding: 20px 30px;
    border-radius: 6px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
    opacity: 0;
    transform: translateY(100px);
    transition: all 0.3s ease;
    z-index: 10000;
    max-width: 400px;
}

.toast.show {
    opacity: 1;
    transform: translateY(0);
}

.toast.success {
    background: #28a745;
}

.toast.error {
    background: #dc3545;
}

/* Modal */
.modal {
    display: none;
    position: fixed;
    z-index: 9999;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    animation: fadeIn 0.3s ease;
}

.modal.active {
    display: flex;
    justify-content: center;
    align-items: center;
}

.modal-content {
    background: var(--white);
    padding: 40px;
    border-radius: 8px;
    max-width: 700px;
    width: 90%;
    max-height: 90vh;
    overflow-y: auto;
    position: relative;
    animation: slideUp 0.3s ease;
}

@keyframes slideUp {
    from {
        transform: translateY(50px);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

.modal-content h2 {
    color: var(--primary-color);
    margin-bottom: 30px;
    font-weight: 700;
}

.close {
    position: absolute;
    top: 20px;
    right: 30px;
    font-size: 2rem;
    font-weight: bold;
    color: var(--text-light);
    cursor: pointer;
    transition: color 0.3s ease;
}

.close:hover {
    color: var(--text-dark);
}

/* Responsive */
@media (max-width: 768px) {
    .admin-header-content {
        flex-direction: column;
        text-align: center;
    }

    .admin-header h1 {
        font-size: 1.8rem;
    }

    .btn-back-home {
        width: 100%;
        justify-content: center;
    }

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

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

    .admin-header h1 {
        font-size: 1.8rem;
    }

    .form-actions {
        flex-direction: column;
    }

    .btn {
        width: 100%;
        justify-content: center;
    }

    .list-header {
        flex-direction: column;
        gap: 15px;
    }

    .btn-refresh {
        width: 100%;
    }

    .car-actions {
        flex-direction: column;
    }
}

/* Image Upload Preview */
.image-preview-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 15px;
    margin-top: 15px;
}

.image-preview-item {
    position: relative;
    border-radius: 8px;
    overflow: hidden;
    border: 2px solid var(--border-color);
    aspect-ratio: 4/3;
}

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

.image-preview-remove {
    position: absolute;
    top: 5px;
    right: 5px;
    background: rgba(220, 53, 69, 0.9);
    color: white;
    border: none;
    border-radius: 50%;
    width: 30px;
    height: 30px;
    cursor: pointer;
    font-size: 18px;
    line-height: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
}

.image-preview-remove:hover {
    background: #dc3545;
    transform: scale(1.1);
}

/* Car Images in Card */
.car-images {
    margin: 15px 0;
    border-radius: 8px;
    overflow: hidden;
}

.car-images img {
    width: 100%;
    height: 200px;
    object-fit: cover;
    border-radius: 8px;
}

.car-images-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
    gap: 8px;
    margin-top: 10px;
}

.car-images-grid img {
    width: 100%;
    height: 80px;
    object-fit: cover;
    border-radius: 6px;
    cursor: pointer;
    transition: transform 0.3s ease;
}

.car-images-grid img:hover {
    transform: scale(1.05);
}

/* Image management in edit modal */
.image-preview-item.is-main {
    border: 3px solid #2A98BD;
}

.main-badge {
    position: absolute;
    top: 6px;
    left: 6px;
    background: #2A98BD;
    color: #fff;
    font-size: 0.75rem;
    padding: 4px 10px;
    border-radius: 4px;
    font-weight: 600;
    z-index: 2;
}

.set-main-btn {
    position: absolute;
    bottom: 8px;
    left: 50%;
    transform: translateX(-50%);
    background: #2A98BD;
    color: #fff;
    border: none;
    font-size: 0.75rem;
    padding: 6px 12px;
    border-radius: 6px;
    cursor: pointer;
    opacity: 1;
    font-weight: 600;
    white-space: nowrap;
    z-index: 2;
    box-shadow: 0 2px 8px rgba(0,0,0,0.3);
}

.set-main-btn:hover {
    background: #1B3A6B;
}
