@import url('https://fonts.googleapis.com/css2?family=Outfit:wght@300;400;500;600;700;800&family=Plus+Jakarta+Sans:wght@400;500;600;700&display=swap');

:root {
    --bg-color: #000000;
    --surface-color: #101010;
    --surface-hover: #181818;
    --primary-color: #38BDF8;
    --primary-glow: rgba(56, 189, 248, 0.35);
    --accent-color: #60A5FA;
    --text-primary: #FFFFFF;
    --text-secondary: #B8B8B8;
    --border-color: rgba(255, 255, 255, 0.08);
    --border-hover: rgba(56, 189, 248, 0.35);
    --gradient-main: linear-gradient(135deg, #38BDF8 0%, #2563EB 100%);
    --gradient-premium: linear-gradient(135deg, #D4AF37 0%, #FFD700 100%);
    --radius: 16px;
    --radius-sm: 8px;
    --glass: rgba(18, 18, 20, 0.8);
    --glass-border: rgba(255, 255, 255, 0.1);
    --shadow-sm: 0 4px 12px rgba(0, 0, 0, 0.5);
    --shadow-lg: 0 12px 32px rgba(0, 0, 0, 0.8);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

body {
    font-family: 'Plus Jakarta Sans', 'Outfit', sans-serif;
    background-color: var(--bg-color);
    color: var(--text-primary);
    min-height: 100vh;
    overflow-x: hidden;
    line-height: 1.6;
    /* Luxury Grainy Background */
    background-image:
        radial-gradient(at 0% 0%, rgba(0, 229, 255, 0.05) 0px, transparent 50%),
        radial-gradient(at 100% 100%, rgba(212, 175, 55, 0.05) 0px, transparent 50%);
}

.grain {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 9999;
    pointer-events: none;
    opacity: 0.04;
    background-image: url("https://grainy-gradients.vercel.app/noise.svg");
}

/* Typography Hierarchy */
h1,
h2,
h3,
.app-logo-text {
    font-family: 'Outfit', sans-serif;
    letter-spacing: -0.02em;
}

.app-container {
    display: flex;
    flex-direction: column;
    width: 100%;
    max-width: 1400px;
    margin: 0 auto;
    position: relative;
    z-index: 1;
}

/* --- App Header (Glass) --- */
.app-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1.25rem 1.5rem;
    padding-top: calc(1.25rem + env(safe-area-inset-top));
    background: var(--glass);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    position: sticky;
    top: 0;
    z-index: 1000;
    border-bottom: 1px solid var(--border-color);
}

.app-logo-text {
    font-size: 1.25rem;
    font-weight: 800;
    background: var(--gradient-main);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

.header-logo {
    height: 48px;
    width: auto;
    object-fit: contain;
    display: block;
}

.user-profile-btn {
    display: flex;
    align-items: center;
    gap: 10px;
    background: rgba(255, 255, 255, 0.05);
    padding: 6px 14px;
    border-radius: 100px;
    border: 1px solid var(--border-color);
    cursor: pointer;
    transition: all 0.3s;
}

.user-profile-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    border-color: var(--primary-color);
}

.user-avatar {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: var(--gradient-main);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 0.8rem;
    color: white;
}

/* --- Tab Navigation (Floating Pill) --- */
.tab-nav {
    display: flex;
    background: var(--glass);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    margin: 0;
    padding: 8px 1.5rem;
    padding-bottom: calc(8px + env(safe-area-inset-bottom));
    border-top: 1px solid var(--border-color);
    gap: 8px;
    overflow-x: auto;
    scrollbar-width: none;
    position: fixed;
    bottom: 0;
    left: 0;
    width: 100%;
    z-index: 1000;
}

.tab-nav::-webkit-scrollbar {
    display: none;
}

.tab-btn {
    flex: 1;
    padding: 8px 4px;
    color: var(--text-secondary);
    font-size: 0.75rem;
    font-weight: 600;
    border-radius: 12px;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 4px;
    white-space: nowrap;
    transition: all 0.4s cubic-bezier(0.23, 1, 0.32, 1);
}

.tab-btn i {
    font-size: 1rem;
    opacity: 0.7;
}

.tab-btn.active {
    background: rgba(255, 255, 255, 0.08);
    color: var(--primary-color);
    box-shadow: inset 0 0 12px rgba(56, 189, 248, 0.2);
}

.tab-btn.active i {
    opacity: 1;
}

.tab-content {
    display: none;
    animation: slideUp 0.6s cubic-bezier(0.23, 1, 0.32, 1);
}

.tab-content.active {
    display: block;
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* --- Global Mobile Header Fixes --- */
@media only screen and (max-width: 768px) {

    .header-container,
    .nav-container,
    .app-header {
        padding: 0 16px !important;
        height: 60px !important;
    }

    .logo span,
    .app-logo-text span {
        display: none !important;
    }

    .logo i,
    .app-logo-text i {
        font-size: 1.8rem !important;
    }

    .logo,
    .header-left {
        display: flex !important;
        align-items: center !important;
        justify-content: flex-start !important;
        max-width: fit-content !important;
        flex-shrink: 0 !important;
    }

    .header-logo {
        height: 40px !important;
        width: auto !important;
        display: block !important;
        object-fit: contain !important;
    }
}

.premium-badge {
    background: var(--gradient-premium);
    color: black;
    padding: 4px 10px;
    border-radius: 4px;
    font-size: 0.7rem;
    font-weight: 800;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    display: inline-block;
}

/* --- Cards & Grid --- */
.mobile-input-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 1.5rem;
    padding: 1.5rem;
    padding-bottom: 12rem;
}

.mobile-card {
    background: linear-gradient(180deg, rgba(12, 13, 16, 0.88) 0%, rgba(8, 9, 12, 0.9) 100%);
    border: 1px solid rgba(255, 255, 255, 0.16);
    border-radius: 28px;
    overflow: hidden;
    position: relative;
    box-shadow: var(--shadow-sm);
    transition: all 0.4s cubic-bezier(0.23, 1, 0.32, 1);
}

.mobile-card:hover {
    border-color: rgba(255, 255, 255, 0.15);
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}

.mobile-card-header {
    padding: 1.25rem 1.5rem;
    background: linear-gradient(90deg, rgba(255, 255, 255, 0.06) 0%, rgba(255, 255, 255, 0.02) 55%, rgba(255, 255, 255, 0.06) 100%);
    border-bottom: 1px solid rgba(255, 255, 255, 0.14);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.mobile-card-header span {
    font-size: 0.9rem;
    font-weight: 700;
    color: var(--text-primary);
    letter-spacing: 0.02em;
}

.mobile-preview-area {
    height: 380px;
    background: #08080A;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

.placeholder-content {
    text-align: center;
    color: var(--text-secondary);
}

.empty-state-icon {
    font-size: 3rem;
    color: var(--primary-color);
    opacity: 0.2;
    margin-bottom: 1rem;
}

.preview-img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    animation: fadeIn 0.5s ease-out;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: scale(0.98);
    }

    to {
        opacity: 1;
        transform: scale(1);
    }
}

/* --- Slots Selection --- */
.slots-container {
    display: flex;
    padding: 1.25rem;
    gap: 12px;
    background: rgba(0, 0, 0, 0.2);
}

.slot-item {
    flex: 1;
    padding: 1rem 0.5rem;
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.06) 0%, rgba(255, 255, 255, 0.02) 100%);
    border: 1px solid rgba(255, 255, 255, 0.14);
    border-radius: 999px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    color: var(--text-secondary);
    transition: all 0.3s cubic-bezier(0.23, 1, 0.32, 1);
    cursor: pointer;
    position: relative;
}

.slot-item.active {
    background: linear-gradient(135deg, #38BDF8 0%, #2563EB 100%);
    border-color: rgba(96, 165, 250, 0.8);
    color: #F3F9FF;
    box-shadow: 0 8px 22px rgba(37, 99, 235, 0.35);
}

.slot-item span {
    font-size: 0.75rem;
    font-weight: 700;
}

.slot-badge {
    position: absolute;
    top: -6px;
    right: -6px;
    background: var(--primary-color);
    color: black;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.7rem;
    font-weight: 800;
    box-shadow: 0 0 10px var(--primary-glow);
}

/* --- Action Buttons --- */
.action-buttons-row {
    display: flex;
    padding: 1.25rem;
    gap: 12px;
}

.action-btn-secondary {
    flex: 1;
    padding: 0.85rem 1rem;
    background: linear-gradient(90deg, rgba(255, 255, 255, 0.07) 0%, rgba(255, 255, 255, 0.03) 50%, rgba(255, 255, 255, 0.07) 100%);
    border: 1px solid rgba(255, 255, 255, 0.18);
    border-radius: 999px;
    color: var(--text-primary);
    font-weight: 700;
    font-size: 0.86rem;
    letter-spacing: 0.01em;
    text-transform: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: all 0.3s;
    backdrop-filter: blur(12px) saturate(140%);
    -webkit-backdrop-filter: blur(12px) saturate(140%);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.14), 0 8px 18px rgba(0, 0, 0, 0.28);
}

.action-btn-secondary:active {
    transform: scale(0.96);
    background: rgba(255, 255, 255, 0.1);
}

.btn-generate {
    background: linear-gradient(135deg, #38BDF8 0%, #2563EB 100%);
    color: #F3F9FF;
    border: 1px solid rgba(147, 197, 253, 0.85);
    padding: 1.15rem 2rem;
    border-radius: 999px;
    font-size: 0.98rem;
    font-weight: 700;
    letter-spacing: 0.01em;
    text-transform: none;
    cursor: pointer;
    box-shadow: 0 10px 28px rgba(37, 99, 235, 0.42), 0 0 24px rgba(56, 189, 248, 0.28);
    transition: all 0.4s cubic-bezier(0.23, 1, 0.32, 1);
    display: flex;
    align-items: center;
    gap: 10px;
    justify-content: center;
    position: relative;
    overflow: hidden;
    backdrop-filter: blur(6px) saturate(120%);
    -webkit-backdrop-filter: blur(6px) saturate(120%);
}

.btn-generate::after {
    content: '';
    position: absolute;
    top: -50%;
    left: -60%;
    width: 20%;
    height: 200%;
    background: rgba(255, 255, 255, 0.2);
    transform: rotate(30deg);
    transition: all 0.6s;
    animation: shine 3s infinite;
}

@keyframes shine {
    0% {
        left: -60%;
    }

    20% {
        left: 120%;
    }

    100% {
        left: 120%;
    }
}

.btn-generate:hover {
    transform: translateY(-3px) scale(1.02);
    box-shadow: 0 14px 34px rgba(37, 99, 235, 0.5), 0 0 28px rgba(56, 189, 248, 0.35);
    border-color: rgba(191, 219, 254, 0.95);
}

.btn-generate:active {
    transform: translateY(-1px) scale(0.98);
    box-shadow: 0 4px 12px rgba(203, 255, 46, 0.35);
}

.btn-generate:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

/* --- AI Stilist --- */
.prompt-input {
    width: 100%;
    background: #000;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    color: white;
    padding: 1.25rem;
    font-family: inherit;
    font-size: 0.95rem;
    line-height: 1.5;
    resize: none;
    outline: none;
    transition: border-color 0.3s;
}

.prompt-input:focus {
    border-color: var(--primary-color);
}

/* --- Global Result --- */
#result-section {
    border: 2px solid rgba(56, 189, 248, 0.2);
}

.loading-overlay {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.85);
    backdrop-filter: blur(8px);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 100;
}

.spinner {
    width: 44px;
    height: 44px;
    border: 3px solid rgba(255, 255, 255, 0.05);
    border-top: 3px solid var(--primary-color);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    box-shadow: 0 0 15px var(--primary-glow);
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

/* --- User Menu Modal --- */
.user-menu-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    backdrop-filter: blur(10px);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 2000;
    padding: 1.5rem;
}

.user-menu-content {
    background: var(--surface-color);
    width: 100%;
    max-width: 400px;
    border-radius: var(--radius);
    border: 1px solid var(--border-color);
    padding: 2rem;
    animation: modalPop 0.4s cubic-bezier(0.23, 1, 0.32, 1);
}

@keyframes modalPop {
    from {
        opacity: 0;
        transform: scale(0.9) translateY(20px);
    }

    to {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

.menu-item {
    display: flex;
    align-items: center;
    padding: 1rem;
    border-radius: var(--radius-sm);
    background: rgba(255, 255, 255, 0.02);
    margin-bottom: 0.75rem;
    color: white;
    text-decoration: none;
    cursor: pointer;
    transition: all 0.3s;
    border: 1px solid transparent;
}

.menu-item:hover {
    background: rgba(255, 255, 255, 0.05);
    border-color: var(--border-color);
}

.menu-item i {
    width: 32px;
    font-size: 1.1rem;
    color: var(--primary-color);
}

.menu-item.logout {
    color: #FF4B4B;
}

.menu-item.logout i {
    color: #FF4B4B;
}

/* Sticky Action Bar */
.action-bar {
    position: fixed;
    bottom: calc(70px + env(safe-area-inset-bottom));
    left: 0;
    width: 100%;
    padding: 0 1.5rem 1.25rem;
    background: transparent;
    pointer-events: none;
    z-index: 100;
}

.action-bar .btn-generate {
    pointer-events: auto;
    box-shadow: 0 10px 32px rgba(0, 0, 0, 0.5), 0 0 20px rgba(56, 189, 248, 0.25), inset 0 1px 0 rgba(255, 255, 255, 0.18);
}

/* Background Grid Items */
.bg-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
    padding: 1.5rem;
}

.bg-item {
    aspect-ratio: 4/5;
    background: #111;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    overflow: hidden;
    position: relative;
    cursor: pointer;
    transition: all 0.3s;
}

.bg-item.selected {
    border-width: 2px;
    border-color: var(--primary-color);
}

.bg-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.bg-label {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    padding: 0.5rem;
    background: rgba(0, 0, 0, 0.7);
    font-size: 0.7rem;
    font-weight: 700;
    text-align: center;
}

/* --- Toast System --- */
.toast-container {
    position: fixed;
    top: 90px;
    right: 20px;
    z-index: 10000;
    display: flex;
    flex-direction: column;
    gap: 12px;
    pointer-events: none;
}

.toast {
    background: var(--glass);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid var(--glass-border);
    border-left: 4px solid var(--accent-color);
    color: white;
    padding: 1.15rem 1.75rem;
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow-lg);
    font-size: 0.9rem;
    font-weight: 500;
    min-width: 300px;
    max-width: 400px;
    pointer-events: auto;
    animation: toastSlideIn 0.6s cubic-bezier(0.23, 1, 0.32, 1);
    display: flex;
    align-items: center;
    gap: 15px;
}

.toast i {
    font-size: 1.2rem;
}

.toast.error {
    border-left-color: #FF4B4B;
}

.toast.success {
    border-left-color: #4ADE80;
}

@keyframes toastSlideIn {
    from {
        opacity: 0;
        transform: translateX(50px) scale(0.9);
    }

    to {
        opacity: 1;
        transform: translateX(0) scale(1);
    }
}

.toast-fade-out {
    opacity: 0;
    transform: translateX(50px);
    transition: all 0.5s ease;
}

/* Mobile Overrides for wide desktop */
@media (min-width: 1024px) {
    .mobile-input-grid {
        grid-template-columns: 1fr 1fr;
        max-width: 1200px;
        margin: 0 auto;
    }
}
