/**
 * AI Fashion Studio - Clean Premium SaaS UI
 * Scope: .aifs-container
 */

:root {
    --studio-bg-dark: #1e1e2d;
    --studio-card-bg: #1f2a37;
    --studio-content-bg: #2c3a4a;
    --studio-accent: #00bcd4;
    --studio-accent-hover: #00acc1;
    --studio-text-light: #ffffff;
    --studio-text-muted: #a0a8b4;
    --studio-border: rgba(255, 255, 255, 0.1);
    --studio-shadow: 0 20px 25px -5px rgba(0,0,0,0.3), 0 10px 10px -5px rgba(0,0,0,0.1);
    --radius: 16px;
    --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* 1. MAIN CONTAINER & GLOBAL RESET */
.aifs-container, 
.aifs-container * {
    box-sizing: border-box;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

.aifs-container {
    background: var(--studio-bg-dark);
    color: var(--studio-text-light);
    width: 100%;
    max-width: 1200px;
    margin: 2rem auto;
    padding: 30px 15px; /* Fixed padding logic */
    border-radius: var(--radius);
    box-shadow: var(--studio-shadow);
    overflow-x: hidden; /* Prevent horizontal scroll */
    position: relative;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen-Sans, Ubuntu, Cantarell, "Helvetica Neue", sans-serif;
}

/* 1. HEADER & CREDITS */
.aifs-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 30px;
    border-bottom: 1px solid var(--studio-border);
    padding-bottom: 25px;
    gap: 20px;
}

.aifs-title {
    font-size: 2rem;
    font-weight: 800;
    margin: 0;
    background: linear-gradient(90deg, #fff, var(--studio-accent));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.aifs-subtitle {
    color: var(--studio-text-muted);
    margin-top: 5px;
    font-size: 0.95rem;
}

.aifs-header-right {
    display: flex;
    align-items: center;
    gap: 15px;
}

.aifs-credit-badge {
    background: rgba(0, 188, 212, 0.1);
    border: 1px solid var(--studio-accent);
    padding: 8px 16px;
    border-radius: 50px;
    display: flex;
    align-items: center;
    gap: 8px;
    box-shadow: 0 0 15px rgba(0, 188, 212, 0.1);
}

.aifs-credit-badge .dashicons {
    color: var(--studio-accent);
    font-size: 18px;
    width: 18px;
    height: 18px;
}

#aifs-credit-count {
    font-weight: 800;
    font-size: 1.1rem;
    color: #fff;
}

.aifs-credit-label {
    font-size: 11px;
    text-transform: uppercase;
    font-weight: 600;
    color: var(--studio-accent);
    letter-spacing: 0.5px;
}

.aifs-guest-hero{
    padding:34px;
    margin-bottom:22px;
    border-radius:22px;
    background:linear-gradient(135deg,#111827,#1f2937);
    color:#fff;
    text-align:center;
}

.aifs-guest-hero h2{
    font-size:34px;
    margin-bottom:12px;
    font-weight:700;
}

.aifs-guest-hero p{
    max-width:760px;
    margin:0 auto 26px;
    opacity:.88;
    line-height:1.6;
}

.aifs-pricing-grid{
    display:grid;
    grid-template-columns:repeat(3,1fr);
    gap:18px;
    margin-top:20px;
}

.aifs-price-card{
    background:rgba(255,255,255,.04);
    border:1px solid rgba(255,255,255,.08);
    border-radius:18px;
    padding:24px;
    text-align:center;
    transition:.25s ease;
}

.aifs-price-card:hover{
    transform:translateY(-4px);
    border-color:#6366f1;
}

.aifs-price-card.featured{
    border:1px solid #6366f1;
    box-shadow:0 20px 40px rgba(99,102,241,.15);
}

.aifs-badge{
    display:inline-block;
    padding:6px 12px;
    border-radius:999px;
    background:#4f46e5;
    font-size:12px;
    font-weight:700;
    margin-bottom:14px;
}

.aifs-price-card h3{
    font-size:24px;
    margin-bottom:8px;
}

.aifs-price{
    font-size:32px;
    font-weight:800;
    margin-bottom:8px;
}

.aifs-price-card p{
    margin-bottom:18px;
    opacity:.85;
}

.aifs-plan-btn{
    display:inline-flex;
    justify-content:center;
    align-items:center;
    width:100%;
    padding:12px 18px;
    border-radius:12px;
    background:#4f46e5;
    color:#fff;
    text-decoration:none;
    font-weight:700;
}

.aifs-plan-btn:hover{
    opacity:.92;
}

.aifs-credit-note{
    display:block;
    margin-top:18px;
    opacity:.7;
}

/* 3. DASHBOARD LAYOUT */
.aifs-dashboard-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    align-items: start;
}

/* 4. LEFT PANEL (CONTROLS) */
.aifs-column-controls {
    display: flex;
    flex-direction: column;
    gap: 20px;
    max-height: 85vh;
    overflow-y: auto;
    padding-right: 12px;
}

/* Custom Scrollbar for Controls */
.aifs-column-controls::-webkit-scrollbar {
    width: 5px;
}
.aifs-column-controls::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 10px;
}

/* 5. RIGHT PANEL (RESULT) */
.aifs-column-result {
    position: sticky;
    top: 20px;
    width: 100%;
    min-width: 0; /* Fixes grid overflow */
}

/* RESULT AREA FIXED SIZE */
.aifs-result-area {
    height: 500px; /* 🔥 FIXED HEIGHT */
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    position: relative;
}

/* IMAGE FIT INSIDE */
.aifs-output img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain; /* 🔥 KEY */
    border-radius: 12px;
}

.aifs-empty-state {
    text-align: center;
    color: var(--studio-text-muted);
    max-width: 280px;
}

.aifs-empty-state .dashicons {
    font-size: 48px;
    width: 48px;
    height: 48px;
    margin-bottom: 15px;
    color: var(--studio-accent);
}

.aifs-empty-state h3 {
    color: #fff;
    font-size: 18px;
    margin-bottom: 8px;
}

.aifs-empty-state p {
    font-size: 13px;
    line-height: 1.4;
}

/* 6. COMMON PANELS */
.aifs-panel {
    background: var(--studio-card-bg);
    border: 1px solid var(--studio-border);
    border-radius: var(--radius);
    padding: 24px;
    width: auto;
}

.aifs-panel-title {
    font-size: 1.1rem;
    font-weight: 600;
    margin-bottom: 18px;
    color: #fff;
    display: flex;
    align-items: center;
    gap: 10px;
}

/* 7. MODELS GRID (2 Columns) */
.aifs-models-grid {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 14px;
}

/* HEADER FLEX */
.aifs-panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
    gap: 10px;
}

.aifs-buy-credit-btn{
    display:inline-flex;
    align-items:center;
    justify-content:center;
    padding:10px 16px;
    border-radius:12px;
    background:#4f46e5;
    color:#fff;
    text-decoration:none;
    font-weight:700;
}

/* TOGGLE GROUP */
.aifs-mode-selector {
    display: flex;
    gap: 6px;
}

.aifs-mode-selector button {
    padding: 6px 12px;
    font-size: 12px;
    border-radius: 8px;
    border: 1px solid var(--studio-border);
    background: var(--studio-content-bg);
    color: var(--studio-text-muted);
    cursor: pointer;
    transition: 0.2s ease;
}

.aifs-mode-selector button:hover {
    border-color: var(--studio-accent);
    color: #fff;
}

 /*ACTIVE */
.aifs-bg-mode-btn.active, .aifs-mode-btn.active {
    background: var(--studio-accent);
    color: #fff;
    border-color: var(--studio-accent);
}

/* CIRCLE MODEL STYLE */
.aifs-model-circle {
    background: transparent;
    border: none;
    padding: 0;
    align-items: center;
}

/* Avatar */
.aifs-model-avatar {
    width: 70px;
    height: 70px;
    border-radius: 50%;
    overflow: hidden;
    border: 3px solid transparent;
    transition: all 0.25s ease;
    position: relative;
}

/* Image */
.aifs-model-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* Hover */
.aifs-model-circle:hover .aifs-model-avatar {
    transform: scale(1.05);
    border-color: rgba(0,188,212,0.4);
}

/* Active */
.aifs-model-card.active .aifs-model-avatar {
    border-color: var(--studio-accent);
    box-shadow: 0 0 0 3px rgba(0,188,212,0.2);
}

/* Parent needs relative positioning */
.aifs-model-card {
    position: relative;
}

/* Check badge (hidden by default) */
.aifs-model-check {
    position: absolute;
    top: -6px;
    right: -6px;
    width: 22px;
    height: 22px;
    background: var(--studio-accent);
    color: #fff;
    font-size: 12px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transform: scale(0.7);
    transition: all 0.25s ease;
    box-shadow: 0 0 0 2px #1e1e2d;
}

/* Show when active */
.aifs-model-card.active .aifs-model-check {
    opacity: 1;
    transform: scale(1);
}

/* Add tick */
.aifs-model-check::after {
    content: "✓";
}
.aifs-model-card {
    background: transparent; /* 🔥 remove square */
    border: none;
    padding: 0;
    cursor: pointer;
    display: flex;
    justify-content: center;
}

.aifs-model-card:hover {
    transform: translateY(-3px);
    border-color: rgba(0, 188, 212, 0.3);
}

.aifs-model-thumb {
    width: 100%;
    aspect-ratio: 3/4;
    border-radius: 8px;
    overflow: hidden;
    margin-bottom: 8px;
}

.aifs-model-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.aifs-model-label {
    font-size: 0.8rem;
    font-weight: 500;
    color: var(--studio-text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    width: 100%;
}

/* 8. BACKGROUND GRID */
.aifs-background-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
}

.aifs-bg-card {
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--studio-border);
    border-radius: 10px;
    padding: 12px 5px;
    text-align: center;
    cursor: pointer;
    transition: var(--transition);
    position: relative;
}

.aifs-bg-card:hover {
    background: rgba(255, 255, 255, 0.06);
    border-color: var(--studio-accent);
}

.aifs-bg-card.active {
    border-color: var(--studio-accent);
    background: rgba(0, 188, 212, 0.1);
}

.aifs-bg-icon span {
    font-size: 20px;
    margin-bottom: 5px;
    display: block;
    color: var(--studio-accent);
}

.aifs-bg-label {
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* 9. UPLOAD ZONE */
.aifs-upload-zone {
    border: 2px dashed var(--studio-border);
    border-radius: 12px;
    padding: 25px;
    text-align: center;
    cursor: pointer;
    transition: var(--transition);
    background: rgba(255,255,255,0.02);
    display: flex;
    flex-direction: column;
    align-items: center;
}

.aifs-upload-zone:hover {
    border-color: var(--studio-accent);
    background: rgba(0, 188, 212, 0.05);
}

.aifs-upload-preview-area img {
    max-width: 100%;
    max-height: 200px;
    border-radius: 8px;
    object-fit: contain;
    margin-top: 5px;
}

/* 10. GENERATE BUTTON */
.aifs-button-wrapper {
    margin-top: 10px;
}

.aifs-generate-btn {
    width: 100%;
    padding: 18px;
    background: var(--studio-accent);
    color: #fff;
    border: none;
    border-radius: 14px;
    font-size: 1rem;
    font-weight: 700;
    cursor: pointer;
    box-shadow: 0 4px 15px rgba(0, 188, 212, 0.3);
    transition: var(--transition);
}

.aifs-generate-btn:hover:not(:disabled) {
    background: var(--studio-accent-hover);
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(0, 188, 212, 0.4);
}

.aifs-generate-btn:disabled {
    background: var(--studio-content-bg);
    color: var(--studio-text-muted);
    cursor: not-allowed;
    box-shadow: none;
}

/* 11. RESULT DISPLAY */
.aifs-result-display {
    min-height: 500px;
    background: var(--studio-card-bg);
    border: 1px solid var(--studio-border);
    border-radius: var(--radius);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.aifs-result-card {
    width: 100%;
    max-width: 500px;
    text-align: center;
}

.aifs-result-card img {
    width: 100%;
    height: auto;
    border-radius: 12px;
    box-shadow: var(--studio-shadow);
}

/* 12. HISTORY GRID (5 Desktop, 2 Mobile) */
.aifs-history-container {
    margin-top: 40px;
    padding-top: 30px;
    border-top: 1px solid var(--studio-border);
}

.aifs-history-container h3{
    color: #FFFFFF;
}

/* HISTORY GRID (5 items in 1 row desktop) */
.aifs-history-grid {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 12px;
}

/* Card */
.aifs-history-card {
    background: var(--studio-card-bg);
    border: 1px solid var(--studio-border);
    border-radius: 12px;
    padding: 6px;
    transition: all 0.25s ease;
    cursor: pointer;
}

/* Square container */
.aifs-history-thumb {
    width: 100%;
    aspect-ratio: 1 / 1; /* 🔥 perfect square */
    overflow: hidden;
    border-radius: 8px;
}

/* Image */
.aifs-history-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover; /* 🔥 no distortion */
    display: block;
    transition: transform 0.3s ease;
}

/* Hover effect */
.aifs-history-card:hover img {
    transform: scale(1.05);
}

.aifs-history-card:hover {
    border-color: var(--studio-accent);
    transform: translateY(-3px);
}

/* 13. UI EXTRAS */
.aifs-spinner {
    width: 45px;
    height: 45px;
    border: 4px solid rgba(0, 188, 212, 0.1);
    border-top: 4px solid var(--studio-accent);
    border-radius: 50%;
    animation: spin 1s cubic-bezier(0.4, 0, 0.2, 1) infinite;
}

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

.aifs-fade {
    animation: aifsFadeIn 0.5s ease forwards;
}

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

.aifs-model-card {
    width: 100%;
    min-width: 0;
}

/* STYLE SETTINGS DROPDOWNS */
.aifs-style-settings-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 10px;
}

.aifs-style-settings-grid select {
    width: 100%;
    padding: 10px;
    border-radius: 8px;
    border: 1px solid var(--studio-border);
    background: var(--studio-content-bg);
    color: #fff;
    font-size: 13px;

    appearance: none;

    background-image: url("data:image/svg+xml,%3Csvg fill='%23a0a8b4' height='20' viewBox='0 0 20 20' width='20' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M5 7l5 5 5-5H5z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 10px center;
    background-size: 14px;

    padding-right: 30px;
}

.aifs-style-settings-grid select:hover {
    border-color: var(--studio-accent);
}

.aifs-style-settings-grid select:focus {
    border-color: var(--studio-accent);
    box-shadow: 0 0 0 2px rgba(0,188,212,0.2);
}

/* FIELD WRAPPER */
.aifs-field {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

/* LABEL STYLE */
.aifs-field label {
    font-size: 11px;
    color: var(--studio-text-muted);
    font-weight: 600;
    letter-spacing: 0.5px;
    text-transform: uppercase;
}

/* User Instruction */
#aifs-garment-instruction {
    width: 100%;
    min-height: 90px;
    padding: 12px;
    border-radius: 10px;
    border: 1px solid var(--studio-border);
    background: var(--studio-content-bg);
    color: #fff;
    font-size: 14px;
    resize: none;
    transition: 0.2s ease;
}

#aifs-garment-instruction:focus {
    border-color: var(--studio-accent);
    box-shadow: 0 0 0 2px rgba(0,188,212,0.2);
    outline: none;
}

#aifs-garment-instruction::placeholder {
    color: var(--studio-text-muted);
}

.aifs-helper-text {
    display: block;
    font-size: 12px;
    color: var(--studio-text-muted);
    margin-top: 5px;
}

.aifs-char-count {
    text-align: right;
    font-size: 12px;
    color: var(--aifs-text-muted);
    margin-top: 4px;
}

.aifs-loading-state {
    display: flex;
    flex-direction: column;
    align-items: center;
}

.aifs-error-box {
    color: #FFFFFF;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.aifs-error-box h4{
    color: #FFFFFF;
}

/* 14. RESPONSIVE QUERIES */

/* Large Tablets & Small Desktops */
@media (max-width: 1024px) {
    .aifs-dashboard-grid {
        grid-template-columns: 1fr;
    }
    
    .aifs-column-controls {
        max-height: none;
        max-height: 70vh;
        overflow-y: auto;
    }

    .aifs-column-result {
        position: relative;
        top: 0;
    }

    .aifs-history-grid {
        grid-template-columns: repeat(3, 1fr);
    }
}

/* Mobile Devices */
@media (max-width: 768px) {
    .aifs-container {
        margin: 0;
        border-radius: 0;
        padding: 20px 12px;
    }

    .aifs-dashboard-grid {
        gap: 20px;
    }

    .aifs-panel {
        padding: 18px;
    }

    .aifs-models-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 10px;
    }

    .aifs-background-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .aifs-history-grid {
        grid-template-columns: repeat(5, 1fr);
        gap: 2px;
    }
    
    .aifs-history-card img {
        height: 80px;
        object-fit: cover;
    }

    .aifs-result-display {
        min-height: 350px;
    }
    
    .aifs-header {
        flex-direction: column;
    }

    .aifs-title {
        text-align: center;
    }

    .aifs-subtitle {
        text-align: center;
    }
    
    .aifs-panel-header {
        flex-direction: column;
    }
    
    .aifs-dashboard-grid {
        grid-template-columns: 1fr;
    }
    
    .aifs-style-settings-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .aifs-models-grid {
        grid-template-columns: repeat(4, 1fr);
    }

    .aifs-model-avatar {
        width: 60px;
        height: 60px;
    }
    
    .aifs-pricing-grid{
        grid-template-columns:1fr;
    }
    
}

/* Fix for WordPress Admin Overlap */
#wpadminbar {
    z-index: 99999 !important;
}