/* === ORDER MODAL - FORCE CORRECT LAYOUT === */
.order-modal {
    max-width: 1200px !important;
    max-height: 90vh;
    overflow-y: auto;
    padding: 3rem !important;
}

/* CRITICAL: Override any grid layout from styles.css */
#order-form {
    display: flex !important;
    flex-direction: column !important;
    gap: 1.5rem !important;
    grid-template-columns: unset !important;
}

/* Smooth scroll behavior */
.order-modal {
    scrollbar-width: thin;
    scrollbar-color: var(--primary) var(--bg-tertiary);
}

.order-modal::-webkit-scrollbar {
    width: 8px;
}

.order-modal::-webkit-scrollbar-track {
    background: var(--bg-tertiary);
    border-radius: 10px;
}

.order-modal::-webkit-scrollbar-thumb {
    background: var(--primary);
    border-radius: 10px;
}

/* === FORM LAYOUT === */
#order-form {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

/* Form sections */
#order-form-content {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

/* === FORM SECTION - CARD STYLE === */
.form-section {
    background: linear-gradient(135deg, rgba(99, 102, 241, 0.03), rgba(30, 41, 59, 0.5));
    border: 1px solid rgba(99, 102, 241, 0.2);
    border-radius: 16px;
    padding: 2rem;
    margin-bottom: 0 !important;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    overflow: hidden;
}

.form-section::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 4px;
    height: 100%;
    background: linear-gradient(180deg, var(--primary), var(--primary-dark));
    opacity: 0;
    transition: opacity 0.3s ease;
}

.form-section:hover {
    border-color: var(--primary);
    box-shadow: 0 8px 30px rgba(99, 102, 241, 0.15);
    transform: translateY(-2px);
}

.form-section:hover::before {
    opacity: 1;
}

.form-section h3 {
    font-size: 1.35rem;
    font-weight: 700;
    margin-bottom: 1.5rem;
    color: var(--primary-light);
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.form-section h3::before {
    content: '';
    width: 6px;
    height: 6px;
    background: var(--primary);
    border-radius: 50%;
    animation: pulse 2s ease-in-out infinite;
}

@keyframes pulse {

    0%,
    100% {
        opacity: 1;
        transform: scale(1);
    }

    50% {
        opacity: 0.5;
        transform: scale(1.2);
    }
}

/* === PRICE SUMMARY - AT BOTTOM === */
.price-summary {
    background: linear-gradient(135deg, rgba(99, 102, 241, 0.1), rgba(30, 41, 59, 0.8)) !important;
    border: 2px solid var(--primary);
    padding: 2rem !important;
    border-radius: 20px !important;
    box-shadow: 0 20px 60px rgba(99, 102, 241, 0.2);
    backdrop-filter: blur(10px);
    margin-bottom: 0 !important;
    margin-top: 1rem !important;
}

.price-summary::before {
    content: '';
    position: absolute;
    top: -2px;
    left: -2px;
    right: -2px;
    bottom: -2px;
    background: linear-gradient(135deg, var(--primary), var(--primary-dark), var(--primary));
    border-radius: 20px;
    z-index: -1;
    opacity: 0.1;
    filter: blur(10px);
}

.price-row {
    display: flex;
    justify-content: space-between;
    padding: 1rem 0 !important;
    border-bottom: 1px solid rgba(99, 102, 241, 0.2) !important;
    font-size: 1.05rem;
    transition: all 0.3s ease;
}

.price-row:hover {
    padding-left: 0.5rem;
    color: var(--primary-light);
}

.price-row span:last-child {
    font-weight: 600;
    color: var(--primary-light);
}

.price-row.total {
    font-size: 1.75rem !important;
    font-weight: 800 !important;
    color: white !important;
    padding-top: 1.5rem !important;
    margin-top: 1rem !important;
    border-top: 2px solid var(--primary) !important;
    border-bottom: none !important;
    background: linear-gradient(135deg, rgba(99, 102, 241, 0.2), transparent);
    padding: 1.5rem !important;
    margin: 1rem -1rem 0 !important;
    border-radius: 12px;
}

.price-row.total span:last-child {
    color: var(--secondary);
    text-shadow: 0 0 20px rgba(245, 158, 11, 0.5);
    animation: priceGlow 2s ease-in-out infinite;
}

@keyframes priceGlow {

    0%,
    100% {
        text-shadow: 0 0 20px rgba(245, 158, 11, 0.5);
    }

    50% {
        text-shadow: 0 0 30px rgba(245, 158, 11, 0.8), 0 0 40px rgba(245, 158, 11, 0.4);
    }
}

/* === FORM ACTIONS BUTTONS === */
.form-actions {
    grid-column: 1 / -1;
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
    margin-top: 2rem;
}

.form-actions button {
    padding: 1.125rem 2rem;
    font-size: 1.05rem;
    font-weight: 600;
    border-radius: 12px;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    overflow: hidden;
}

.form-actions button::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 0;
    height: 0;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.2);
    transform: translate(-50%, -50%);
    transition: width 0.6s, height 0.6s;
}

.form-actions button:hover::before {
    width: 300px;
    height: 300px;
}

.form-actions button:hover {
    transform: translateY(-3px);
    box-shadow: 0 10px 30px rgba(99, 102, 241, 0.4);
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    border: none;
    color: white;
}

.btn-secondary {
    background: var(--bg-tertiary);
    border: 2px solid var(--border-color);
    color: var(--text-primary);
}

.btn-secondary:hover {
    border-color: var(--primary);
    background: rgba(99, 102, 241, 0.1);
}

.btn-success {
    background: linear-gradient(135deg, #10b981, #059669);
    border: none;
    color: white;
}

/* === UPLOAD AREA ENHANCEMENTS === */
.upload-area {
    border: 3px dashed rgba(99, 102, 241, 0.3) !important;
    border-radius: 16px !important;
    padding: 3.5rem 2rem !important;
    background: linear-gradient(135deg, rgba(99, 102, 241, 0.03), transparent);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
}

.upload-area::after {
    content: '';
    position: absolute;
    inset: 0;
    border-radius: 16px;
    background: radial-gradient(circle at center, rgba(99, 102, 241, 0.1), transparent);
    opacity: 0;
    transition: opacity 0.3s ease;
}

.upload-area:hover {
    border-color: var(--primary) !important;
    background: linear-gradient(135deg, rgba(99, 102, 241, 0.08), rgba(99, 102, 241, 0.03));
    transform: scale(1.02);
}

.upload-area:hover::after {
    opacity: 1;
}

.upload-area i {
    font-size: 4rem !important;
    animation: float 3s ease-in-out infinite;
}

@keyframes float {

    0%,
    100% {
        transform: translateY(0);
    }

    50% {
        transform: translateY(-10px);
    }
}

.upload-area p {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--text-primary);
}

.upload-area span {
    font-size: 0.9rem;
    color: var(--text-muted);
}

/* === UPLOADED FILES GRID === */
.uploaded-files {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
    gap: 1.25rem;
    margin-top: 1.5rem;
}

.file-preview {
    border: 2px solid var(--border-color) !important;
    border-radius: 12px !important;
    padding: 0.75rem !important;
    background: var(--bg-tertiary) !important;
    transition: all 0.3s ease;
    position: relative;
}

.file-preview:hover {
    border-color: var(--primary);
    transform: translateY(-5px);
    box-shadow: 0 10px 25px rgba(99, 102, 241, 0.2);
}

.file-preview img {
    border-radius: 8px !important;
    height: 120px !important;
}

.file-remove {
    width: 28px !important;
    height: 28px !important;
    border-radius: 50% !important;
    background: var(--danger) !important;
    transition: all 0.3s ease;
}

.file-remove:hover {
    transform: rotate(90deg) scale(1.1);
    box-shadow: 0 4px 12px rgba(239, 68, 68, 0.4);
}

/* === RESPONSIVE - MOBILE === */
@media (max-width: 1024px) {
    #order-form {
        grid-template-columns: 1fr;
    }

    .price-summary {
        position: relative;
        top: 0;
        order: -1;
        /* Show price summary at top on mobile */
    }

    .form-actions {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 768px) {
    .order-modal {
        padding: 1.5rem !important;
    }

    .form-section {
        padding: 1.5rem;
    }

    .price-summary {
        padding: 1.5rem !important;
    }

    .form-actions button {
        padding: 1rem 1.5rem;
    }

    .uploaded-files {
        grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
    }
}

/* =============================================
   MODEL GALLERY (NEW LAYOUT)
   Large preview on left, thumbnail grid on right
   ============================================= */

.model-gallery-container {
    display: flex;
    flex-direction: row;
    gap: 1.25rem;
    margin-top: 1rem;
    width: 100%;
    align-items: flex-start;
    overflow: hidden;
}

/* ===== LEFT: LARGE PREVIEW SECTION ===== */
.model-preview-section {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.model-preview-image-wrapper {
    position: relative;
    width: 100%;
    aspect-ratio: 1;
    border-radius: 10px;
    overflow: hidden;
    background: var(--bg-secondary);
    border: 2px solid var(--border-color);
}

.model-preview-image {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: opacity 0.3s ease;
}

/* Info Badge (Bottom-left overlay) */
.model-info-badge {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    background: linear-gradient(to top, rgba(0, 0, 0, 0.9), rgba(0, 0, 0, 0.7), transparent);
    padding: 1.25rem 1rem 1rem;
    color: #fff;
}

.model-info-badge h4 {
    margin: 0 0 0.25rem 0;
    font-size: 1.1rem;
    font-weight: 600;
}

.model-info-badge p {
    margin: 0.15rem 0;
    font-size: 0.8rem;
    opacity: 0.9;
}

.model-info-badge .price-tag {
    font-size: 1.2rem;
    font-weight: 700;
    color: var(--secondary);
    margin-top: 0.35rem;
}

/* Quantity Controls for Preview */
.preview-quantity-section {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.65rem 0.85rem;
    background: var(--bg-secondary);
    border-radius: 8px;
    border: 1px solid var(--border-color);
}

.preview-quantity-section label {
    font-weight: 600;
    font-size: 0.9rem;
}

.quantity-controls-large {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-left: auto;
}

.qty-btn-large {
    width: 36px;
    height: 36px;
    border-radius: 6px;
    border: 2px solid var(--primary);
    background: transparent;
    color: var(--primary);
    font-size: 1.2rem;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.2s ease;
}

.qty-btn-large:hover {
    background: var(--primary);
    color: #fff;
    transform: scale(1.05);
}

.qty-display-large {
    font-size: 1.2rem;
    font-weight: 600;
    min-width: 40px;
    text-align: center;

}

/* ===== LEFT: LARGE PREVIEW FIXED WIDTH ===== */
.model-preview-section {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    flex: 0 0 280px;
    min-width: 220px;
    max-width: 320px;
}

/* ===== RIGHT: THUMBNAIL GRID ===== */
.model-thumbnails-section {
    flex: 1;
    min-width: 0;
    overflow-x: auto;
    overflow-y: hidden;
    /* Custom scrollbar */
    scrollbar-width: thin;
    scrollbar-color: var(--primary) var(--bg-secondary);
}

.model-thumbnails-section::-webkit-scrollbar {
    height: 5px;
}

.model-thumbnails-section::-webkit-scrollbar-track {
    background: var(--bg-secondary);
    border-radius: 3px;
}

.model-thumbnails-section::-webkit-scrollbar-thumb {
    background: var(--primary);
    border-radius: 3px;
}

.thumbnails-grid {
    /* 2 rows, columns grow rightward — user scrolls horizontally */
    display: grid;
    grid-template-rows: repeat(2, 130px);
    grid-auto-flow: column;
    grid-auto-columns: 130px;
    gap: 0.65rem;
    /* Do NOT overflow here — parent .model-thumbnails-section scrolls */
    padding-bottom: 4px;
    width: max-content;
}

/* Remove old scrollbar styles from grid (moved to section) */
.thumbnails-grid::-webkit-scrollbar {
    width: 5px;
}

.thumbnails-grid::-webkit-scrollbar-track {
    background: var(--bg-secondary);
    border-radius: 3px;
}

.thumbnails-grid::-webkit-scrollbar-thumb {
    background: var(--primary);
    border-radius: 3px;
}

/* Individual Thumbnail */
.model-thumbnail {
    position: relative;
    cursor: pointer;
    border-radius: 8px;
    overflow: hidden;
    background: var(--bg-secondary);
    border: 2px solid var(--border-color);
    transition: all 0.3s ease;
}

.model-thumbnail:hover {
    transform: translateY(-3px);
    box-shadow: 0 6px 15px rgba(0, 0, 0, 0.2);
    border-color: var(--primary);
}

.model-thumbnail.active {
    border-color: var(--primary);
    box-shadow: 0 0 0 2px rgba(99, 102, 241, 0.2);
}

.thumbnail-image-wrapper {
    aspect-ratio: 1;
    overflow: hidden;
}

.thumbnail-image {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.3s ease;
}

.model-thumbnail:hover .thumbnail-image {
    transform: scale(1.08);
}

/* Thumbnail Label (Bottom overlay) */
.thumbnail-label {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    background: linear-gradient(to top, rgba(0, 0, 0, 0.9), rgba(0, 0, 0, 0.6));
    padding: 0.6rem 0.4rem 0.4rem;
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
}

.thumbnail-name {
    font-size: 0.75rem;
    font-weight: 600;
    color: #fff;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.thumbnail-price {
    font-size: 0.8rem;
    font-weight: 700;
    color: var(--secondary);
}

/* ===== RESPONSIVE ===== */
@media (max-width: 768px) {
    .model-gallery-container {
        flex-direction: column;
        gap: 1rem;
    }

    .model-preview-section {
        flex: none;
        width: 100%;
        max-width: none;
    }

    .thumbnails-grid {
        grid-template-rows: repeat(2, 110px);
        grid-auto-columns: 110px;
    }

    .model-info-badge h4 {
        font-size: 1rem;
    }

    .model-info-badge .price-tag {
        font-size: 1.1rem;
    }
}

@media (max-width: 480px) {
    .thumbnails-grid {
        grid-template-columns: repeat(2, 120px);
        gap: 0.6rem;
        overflow-x: auto;
    }

    .qty-btn-large {
        width: 32px;
        height: 32px;
        font-size: 1.1rem;
    }

    .qty-display-large {
        font-size: 1.1rem;
    }
}