/* Enhanced Modern Mobile-First Design */

* {
    box-sizing: border-box;
}

.ai-pet-cartoon-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
}

/* Section Headers */
h2 {
    font-family: 'Chonky', sans-serif;
    color: #f87736;
    font-size: 28px;
    margin: 40px 0 20px;
    text-align: center;
}

#ai-pet-cartoon-form {
    display: flex;
    flex-direction: column;
    gap: 40px;
}

/* Image Upload Section */
.upload-section {
    background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
    padding: 30px;
    border-radius: 16px;
    box-shadow: 0 4px 6px rgba(0,0,0,0.05);
}

#image-upload-container {
    display: flex;
    flex-direction: column;
    gap: 15px;
    max-width: 600px;
    margin: 0 auto;
}

.upload-group {
    position: relative;
    background: white;
    border-radius: 12px;
    padding: 20px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.08);
    transition: all 0.3s ease;
}

.upload-group:hover {
    box-shadow: 0 4px 12px rgba(0,0,0,0.12);
    transform: translateY(-2px);
}

.upload-group input[type="file"] {
    width: 100%;
    padding: 15px;
    border: 2px dashed #d0d7de;
    border-radius: 8px;
    background: #f6f8fa;
    cursor: pointer;
    font-size: 14px;
    transition: all 0.3s ease;
}

.upload-group input[type="file"]:hover {
    border-color: #f87736;
    background: #fff5f0;
}

.remove-image-btn {
    position: absolute;
    right: 10px;
    top: 10px;
    background: #dc3545;
    color: white;
    border: none;
    border-radius: 50%;
    width: 32px;
    height: 32px;
    cursor: pointer;
    font-size: 18px;
    line-height: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    box-shadow: 0 2px 4px rgba(0,0,0,0.2);
}

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

.add-image-btn {
    background: linear-gradient(135deg, #f87736 0%, #ff8f5e 100%);
    color: white;
    border: none;
    padding: 14px 28px;
    border-radius: 25px;
    cursor: pointer;
    margin: 15px auto;
    display: block;
    transition: all 0.3s ease;
    font-size: 16px;
    font-weight: 600;
    box-shadow: 0 4px 12px rgba(248, 119, 54, 0.3);
}

.add-image-btn:hover {
    background: linear-gradient(135deg, #57948C 0%, #6ba89f 100%);
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(87, 148, 140, 0.4);
}

.add-image-btn:active {
    transform: translateY(0);
}

/* Style Selection Cards */
.style-cards-container {
    background: white;
    padding: 30px;
    border-radius: 16px;
    box-shadow: 0 4px 6px rgba(0,0,0,0.05);
}

.style-cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 20px;
    max-width: 800px;
    margin: 0 auto;
}

.style-card {
    position: relative;
    border: 3px solid #e9ecef;
    border-radius: 16px;
    overflow: hidden;
    cursor: pointer;
    transition: all 0.3s ease;
    background: white;
}

.style-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 8px 20px rgba(0,0,0,0.12);
}

.style-card input[type="radio"] {
    position: absolute;
    opacity: 0;
    width: 0;
    height: 0;
}

.style-card-content {
    padding: 20px;
    text-align: center;
}

.style-card img {
    width: 100%;
    height: 200px;
    object-fit: cover;
    border-radius: 12px;
    margin-bottom: 15px;
}

.style-title {
    font-weight: 700;
    font-size: 18px;
    color: #333;
    margin-bottom: 5px;
}

.style-description {
    font-size: 13px;
    color: #666;
    margin-top: 5px;
}

.style-card input[type="radio"]:checked + .style-card-content {
    border-radius: 12px;
}

.style-card input[type="radio"]:checked ~ .style-card-content::before {
    content: '✓';
    position: absolute;
    top: 15px;
    right: 15px;
    background: #4CAF50;
    color: white;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    font-size: 18px;
    box-shadow: 0 2px 8px rgba(76, 175, 80, 0.4);
}

.style-card input[type="radio"]:checked {
    & + .style-card-content {
        background: linear-gradient(135deg, #f0fdf4 0%, #dcfce7 100%);
    }
}

.style-card:has(input[type="radio"]:checked) {
    border-color: #4CAF50;
    box-shadow: 0 0 0 3px rgba(76, 175, 80, 0.2);
}

/* Generate Button & Preview */
#ai-generate-btn {
    background: linear-gradient(135deg, #4CAF50 0%, #66BB6A 100%);
    color: white;
    border: none;
    padding: 16px 32px;
    border-radius: 25px;
    cursor: pointer;
    margin: 25px auto;
    display: block;
    transition: all 0.3s ease;
    font-size: 18px;
    font-weight: 600;
    box-shadow: 0 4px 12px rgba(76, 175, 80, 0.3);
}

#ai-generate-btn:hover:not(:disabled) {
    background: linear-gradient(135deg, #388E3C 0%, #4CAF50 100%);
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(76, 175, 80, 0.4);
}

#ai-generate-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

#ai-generated-preview {
    max-width: 600px;
    margin: 20px auto;
    text-align: center;
    min-height: 100px;
}

#ai-generated-preview img {
    max-width: 100%;
    border-radius: 16px;
    margin: 20px 0;
}

/* Product Toggle */
.product-toggle {
    margin: 30px 0;
    display: flex;
    gap: 10px;
    justify-content: center;
    flex-wrap: wrap;
}

.toggle-btn {
    padding: 14px 32px;
    border: 2px solid #e9ecef;
    border-radius: 25px;
    background: white;
    color: #495057;
    cursor: pointer;
    transition: all 0.3s ease;
    font-weight: 600;
    font-size: 16px;
}

.toggle-btn:hover {
    border-color: #f87736;
    color: #f87736;
    transform: translateY(-2px);
}

.toggle-btn.active {
    background: linear-gradient(135deg, #f87736 0%, #ff8f5e 100%);
    color: white;
    border-color: #f87736;
    box-shadow: 0 4px 12px rgba(248, 119, 54, 0.3);
}

/* Product Cards */
.product-category {
    display: none;
}

.product-card-group {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 24px;
    margin-top: 30px;
}

.product-card {
    position: relative;
    border: 2px solid #e9ecef;
    border-radius: 16px;
    overflow: hidden;
    transition: all 0.3s ease;
    background: white;
    cursor: pointer;
}

.product-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 8px 20px rgba(0,0,0,0.1);
}

.product-card input[type="checkbox"] {
    position: absolute;
    opacity: 0;
    width: 0;
    height: 0;
}

.card-content {
    padding: 24px;
    text-align: center;
    position: relative;
}

.product-card input:checked + .card-content {
    background: linear-gradient(135deg, #f0fdf4 0%, #dcfce7 100%);
}

.product-card input:checked + .card-content::before {
    content: '✓';
    position: absolute;
    top: 15px;
    right: 15px;
    background: #4CAF50;
    color: white;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    font-size: 18px;
    box-shadow: 0 2px 8px rgba(76, 175, 80, 0.4);
}

.product-card:has(input:checked) {
    border-color: #4CAF50;
    box-shadow: 0 0 0 3px rgba(76, 175, 80, 0.2);
}

.product-card img {
    width: 180px;
    height: 180px;
    object-fit: contain;
    margin: 0 auto 15px;
    transition: transform 0.3s ease;
}

.product-card:hover img {
    transform: scale(1.05);
}

.product-title {
    margin: 15px 0;
    font-weight: 700;
    font-size: 18px;
    color: #333;
}

/* Product Options */
.product-options {
    margin-top: 20px;
    padding: 20px;
    background: white;
    border-radius: 12px;
    border: 1px solid #e9ecef;
}

.product-options label {
    display: block;
    margin: 15px 0;
    font-size: 14px;
    text-align: left;
    font-weight: 600;
    color: #495057;
}

.product-options select {
    width: 100%;
    padding: 12px 16px;
    border: 2px solid #e9ecef;
    border-radius: 8px;
    background: white;
    font-size: 14px;
    margin-top: 8px;
    transition: all 0.3s ease;
    cursor: pointer;
}

.product-options select:focus {
    outline: none;
    border-color: #f87736;
    box-shadow: 0 0 0 3px rgba(248, 119, 54, 0.1);
}

/* Submit Button */
button[type="submit"] {
    background: linear-gradient(135deg, #4CAF50 0%, #66BB6A 100%);
    color: white;
    border: none;
    padding: 18px 48px;
    border-radius: 30px;
    cursor: pointer;
    margin: 40px auto;
    display: block;
    transition: all 0.3s ease;
    font-size: 20px;
    font-weight: 700;
    box-shadow: 0 6px 20px rgba(76, 175, 80, 0.4);
}

button[type="submit"]:hover:not(:disabled) {
    background: linear-gradient(135deg, #388E3C 0%, #4CAF50 100%);
    transform: translateY(-3px);
    box-shadow: 0 8px 24px rgba(76, 175, 80, 0.5);
}

button[type="submit"]:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

/* Response Messages */
#ai-cartoon-response {
    margin-top: 25px;
    min-height: 50px;
}

.loading-spinner {
    width: 50px;
    height: 50px;
    margin: 20px auto;
    border: 5px solid #f3f3f3;
    border-top: 5px solid #4CAF50;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

.error-message {
    color: #dc3545;
    text-align: center;
    padding: 16px 20px;
    background: #fff5f5;
    border: 2px solid #fed7d7;
    border-radius: 12px;
    margin: 20px auto;
    max-width: 600px;
    font-weight: 600;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Mobile Responsive */
@media (max-width: 768px) {
    .ai-pet-cartoon-container {
        padding: 15px;
    }
    
    h2 {
        font-size: 24px;
        margin: 30px 0 15px;
    }
    
    .upload-section {
        padding: 20px;
    }
    
    .style-cards {
        grid-template-columns: 1fr;
        gap: 15px;
    }
    
    .style-card img {
        height: 180px;
    }
    
    .product-card-group {
        grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
        gap: 16px;
    }
    
    .product-card img {
        width: 140px;
        height: 140px;
    }
    
    .card-content {
        padding: 16px;
    }
    
    .product-title {
        font-size: 15px;
    }
    
    .toggle-btn {
        padding: 12px 24px;
        font-size: 14px;
    }
    
    button[type="submit"] {
        width: 100%;
        padding: 16px;
        font-size: 18px;
    }
    
    #ai-generate-btn {
        width: 100%;
        padding: 14px;
        font-size: 16px;
    }
}

@media (max-width: 480px) {
    .product-card-group {
        grid-template-columns: 1fr 1fr;
    }
    
    .product-card img {
        width: 100%;
        height: auto;
        max-width: 140px;
    }
    
    .style-cards {
        padding: 0 10px;
    }
}

/* === Mockup Layers (Base + Design[displaced] + Wrinkles) === */
.ai-mockup-wrap{max-width:900px;margin:30px auto;padding:20px;background:#fff;border-radius:12px;box-shadow:0 8px 24px rgba(0,0,0,.06)}
.ai-mockup-title{margin:0 0 14px;font-size:20px;font-weight:700}
.ai-mockup-toolbar{display:flex;gap:10px;align-items:center;margin-bottom:12px;flex-wrap:wrap}
.ai-mockup-toolbar .swatch{width:26px;height:26px;border-radius:50%;border:1px solid #ddd;cursor:pointer}
.ai-mockup-stage{position:relative;width:100%;max-width:520px;aspect-ratio:1/1.2;margin:0 auto;background:#f7f7f7;border-radius:12px;overflow:hidden}
.ai-mockup-stage .layer{position:absolute;left:50%;top:50%;transform:translate(-50%,-50%);max-width:92%;max-height:92%;pointer-events:none;user-select:none}
.ai-mockup-stage .base{z-index:1;object-fit:contain;width:92%;height:auto;filter:none}
.ai-mockup-stage .tint{z-index:2;mix-blend-mode:multiply;width:92%;height:92%;border-radius:2px}
.ai-mockup-stage .design{z-index:3;opacity:0;transition:opacity .2s ease}
.ai-mockup-stage .wrinkles{z-index:4;mix-blend-mode:soft-light;width:92%;height:auto;opacity:.65}
.ai-filters{position:absolute}
.ai-mockup-hint{font-size:12px;color:#666;margin-top:10px}


/* === Simple Color-Switch Mockup === */
.ai-mockup-wrap{max-width:940px;margin:30px auto;padding:20px;background:#fff;border-radius:12px;box-shadow:0 8px 24px rgba(0,0,0,.06)}
.ai-mockup-title{margin:0 0 14px;font-size:20px;font-weight:700}
.ai-mockup-toolbar{display:flex;gap:10px;flex-wrap:wrap;margin-bottom:12px}
.ai-mockup-toolbar .swatch{width:28px;height:28px;border-radius:50%;border:1px solid #ddd;cursor:pointer}
.ai-mockup-stage{position:relative;width:100%;max-width:520px;aspect-ratio:1/1.2;margin:0 auto;background:#f7f7f7;border-radius:12px;overflow:hidden}
.ai-mockup-stage .layer{position:absolute;left:50%;top:50%;transform:translate(-50%,-50%);max-width:92%;max-height:92%;pointer-events:none;user-select:none}
.ai-mockup-stage .base{z-index:1;width:92%;height:auto;object-fit:contain}
.ai-mockup-stage .design{z-index:3;opacity:0;transition:opacity .2s ease}
.ai-mockup-stage .wrinkles{z-index:4;mix-blend-mode:soft-light;width:92%;height:auto;opacity:.65}
.ai-filters{position:absolute}
.ai-mockup-hint{font-size:12px;color:#666;margin-top:10px}
