:root {
    font-size: 16px;
    color-scheme: light;
    --brand: #5a46ff;
    --brand-dark: #3b2fc7;
    --text-primary: #13111c;
    --text-muted: #4d4a5c;
    --bg-soft: #f7f7fb;
    --surface: #ffffff;
    --border: rgba(19, 17, 28, 0.08);
    --shadow: 0 25px 60px rgba(69, 42, 124, 0.12);
}

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

body {
    font-family: "Inter", "Segoe UI", -apple-system, BlinkMacSystemFont, "Helvetica Neue", Arial, sans-serif;
    background: var(--bg-soft);
    color: var(--text-primary);
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
}

a {
    text-decoration: none;
    color: inherit;
}

a:focus-visible,
button:focus-visible {
    outline: 2px solid var(--brand);
    outline-offset: 2px;
}

/* Telegram Mini App: force visible text cursor & text color.
   TMA WebView inherits caret-color from Telegram theme vars,
   making the cursor invisible on some themes. */
input,
textarea,
select,
[contenteditable="true"] {
    caret-color: #1e293b !important;
}

input[type="text"],
input[type="email"],
input[type="password"],
input[type="search"],
input[type="url"],
input[type="tel"],
input[type="number"],
textarea,
select {
    color: #1e293b !important;
    -webkit-text-fill-color: #1e293b;
}

input::placeholder,
textarea::placeholder {
    color: #94a3b8 !important;
    -webkit-text-fill-color: #94a3b8;
    opacity: 1;
}

input:disabled,
textarea:disabled,
select:disabled {
    color: #94a3b8 !important;
    -webkit-text-fill-color: #94a3b8;
}

.container {
    width: 100%;
    max-width: 1100px;
    margin: 0 auto;
    padding: 0 1.5rem;
}

.site-header {
    position: sticky;
    top: 0;
    z-index: 20;
    background: rgba(255, 255, 255, 0.94);
    backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--border);
}

.header-inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    min-height: 64px;
}

.logo {
    font-family: 'Unbounded', sans-serif;
    font-weight: 800;
    font-size: 1.2rem;
    letter-spacing: -0.02em;
    display: flex;
    align-items: center;
    gap: 8px;
    text-decoration: none;
    color: inherit;
}

.logo-icon {
    width: 32px;
    height: 32px;
    background: #6C3CE0;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 16px;
    font-weight: 900;
    transform: rotate(-3deg);
    flex-shrink: 0;
}

.main-nav {
    display: flex;
    align-items: center;
    gap: 1rem;
    font-weight: 500;
}

.main-nav a {
    padding: 0.4rem 0.8rem;
    border-radius: 999px;
    color: var(--text-muted);
    transition: color 0.15s ease, background 0.15s ease;
}

.main-nav a:hover {
    color: var(--brand);
    background: rgba(90, 70, 255, 0.08);
}

.site-main {
    padding-top: 2rem;
}

.main-wrapper {
    display: flex;
    flex-direction: column;
    gap: 2rem;
}

.hero {
    background: linear-gradient(135deg, rgba(90, 70, 255, 0.08), rgba(236, 229, 255, 0.7));
    border-radius: 32px;
    margin-top: 1rem;
    overflow: hidden;
}

.hero-inner {
    padding: 4rem 2rem;
}

.hero-content {
    text-align: center;
    max-width: 680px;
    margin: 0 auto;
}

.badge {
    display: inline-block;
    padding: 0.35rem 1rem;
    border-radius: 999px;
    font-size: 0.85rem;
    letter-spacing: 0.02em;
    background: rgba(19, 17, 28, 0.08);
    color: var(--brand);
    margin-bottom: 1.2rem;
}

.hero h1 {
    font-size: clamp(2.3rem, 5vw, 3.6rem);
    line-height: 1.2;
    margin-bottom: 1rem;
}

.hero .subtitle {
    font-size: 1.1rem;
    color: var(--text-muted);
    margin-bottom: 1.8rem;
}

.hero-actions {
    display: flex;
    justify-content: center;
}

.cta {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.9rem 2.8rem;
    border-radius: 999px;
    font-weight: 600;
    background: var(--brand);
    color: #fff;
    box-shadow: 0 18px 35px rgba(90, 70, 255, 0.3);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.cta:hover {
    transform: translateY(-2px);
    box-shadow: 0 25px 45px rgba(90, 70, 255, 0.35);
}

.section {
    padding: 2rem 0;
}

.section.alt {
    background: var(--surface);
    border-radius: 32px;
    box-shadow: var(--shadow);
}

.section-inner {
    padding: 2rem 0;
}

.section-heading {
    margin-bottom: 2rem;
}

.section-heading h2 {
    font-size: 2rem;
}

.cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 1.5rem;
}

.card {
    background: var(--surface);
    border-radius: 1.2rem;
    padding: 1.6rem;
    border: 1px solid rgba(255, 255, 255, 0.8);
    box-shadow: var(--shadow);
}

.card h3 {
    font-size: 1.2rem;
    margin-bottom: 0.75rem;
}

.card p,
.card li {
    color: var(--text-muted);
}

.benefits-list {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 0.9rem;
}

.paragraph-card {
    border-radius: 1.2rem;
    background: var(--surface);
    padding: 1.5rem;
    box-shadow: var(--shadow);
    color: var(--text-muted);
}

.faq {
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
}

.alert {
    padding: 0.75rem 1rem;
    border-radius: 0.6rem;
    margin-bottom: 1rem;
    font-size: 0.95rem;
    font-weight: 500;
}

.alert-error {
    background: #fee2e2;
    color: #991b1b;
}

.alert-info {
    background: #e0f2fe;
    color: #075985;
}

.auth-form label {
    display: block;
    margin-top: 1rem;
    margin-bottom: 0.3rem;
    font-weight: 600;
}

.auth-form input {
    width: 100%;
    padding: 0.7rem;
    border-radius: 0.6rem;
    border: 1px solid var(--border);
    font-size: 1rem;
    transition: border 0.15s ease, box-shadow 0.15s ease;
}

.auth-form input:focus {
    border-color: var(--brand);
    box-shadow: 0 0 0 3px rgba(90, 70, 255, 0.15);
    outline: none;
}

.site-footer {
    background: #0f0c1f;
    color: rgba(255, 255, 255, 0.8);
    margin-top: 3rem;
}

.footer-inner {
    padding: 2rem 0;
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
    text-align: center;
}

@media (max-width: 768px) {
    .header-inner {
        flex-direction: column;
        gap: 0.7rem;
        padding: 0.8rem 0;
    }

    .main-nav {
        flex-wrap: wrap;
        justify-content: center;
    }

    .hero-inner {
        padding: 3rem 1.5rem;
    }

    .section.alt {
        border-radius: 20px;
    }
}

@media (max-width: 600px) {
    .cards {
        grid-template-columns: 1fr;
    }

    .main-wrapper {
        gap: 1.5rem;
    }
}

/* ============================================ */
/* Mobile-Adaptive Responsive Styles */
/* ============================================ */

/* Mobile-specific styles for product detail page */
@media (max-width: 767px) {
    /* Touch-friendly tap targets */
    button, a, input, select, textarea {
        min-height: 44px;
    }

    /* Prevent text selection on buttons */
    button {
        -webkit-user-select: none;
        user-select: none;
        -webkit-tap-highlight-color: transparent;
    }

    /* Smooth scrolling */
    .overflow-y-auto {
        -webkit-overflow-scrolling: touch;
    }

    /* Hide scrollbar but keep functionality */
    .overflow-x-auto::-webkit-scrollbar {
        display: none;
    }
    .overflow-x-auto {
        -ms-overflow-style: none;
        scrollbar-width: none;
    }

    /* Safe area for iOS */
    .safe-area-bottom {
        padding-bottom: env(safe-area-inset-bottom, 0px);
    }

    /* iOS auto-zoom prevention — iOS Safari zooms into inputs with font < 16px */
    input[type="text"],
    input[type="email"],
    input[type="password"],
    input[type="search"],
    input[type="url"],
    input[type="tel"],
    input[type="number"],
    textarea,
    select {
        font-size: 16px !important;
    }
}

/* Animation utilities */
@keyframes slide-up {
    from { transform: translateY(100%); }
    to { transform: translateY(0); }
}

@keyframes slide-in-right {
    from { transform: translateX(100%); }
    to { transform: translateX(0); }
}

@keyframes fade-in {
    from { opacity: 0; }
    to { opacity: 1; }
}

.animate-slide-up {
    animation: slide-up 0.3s ease-out;
}

.animate-slide-in-right {
    animation: slide-in-right 0.3s ease-out;
}

.animate-fade-in {
    animation: fade-in 0.2s ease-out;
}

/* Mobile menu transitions */
#mobileMenuBackdrop {
    transition: opacity 0.3s ease;
}

#mobileMenuDrawer {
    transition: transform 0.3s ease;
}

/* Selection action bar mobile positioning */
@media (max-width: 767px) {
    #selectionActionBar {
        padding-bottom: env(safe-area-inset-bottom, 0px);
    }
}

/* ==========================================
   Balance Badge & Credit Styles
   ========================================== */

/* Tabular numbers for balance display */
.tabular-nums {
    font-variant-numeric: tabular-nums;
}

/* Balance badge hover effect */
.balance-badge:hover {
    transform: translateY(-1px);
}

/* Pulse animation for low balance indicator */
@keyframes pulse {
    0%, 100% {
        opacity: 1;
    }
    50% {
        opacity: 0.5;
    }
}

.animate-pulse {
    animation: pulse 2s cubic-bezier(0.4, 0, 0.6, 1) infinite;
}

/* Credit cost badge on buttons */
.credit-cost-badge {
    font-size: 0.7rem;
    white-space: nowrap;
}

/* Button with credit cost */
.btn-with-cost {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
}

/* Disabled state for zero balance */
.btn-disabled-no-credits {
    opacity: 0.5;
    cursor: not-allowed;
    pointer-events: none;
}

/* Low balance warning in sidebar */
.low-balance-warning {
    animation: pulse 2s cubic-bezier(0.4, 0, 0.6, 1) infinite;
}

/* Modal backdrop blur */
.backdrop-blur-sm {
    backdrop-filter: blur(4px);
}

/* ==========================================
   Generation Retry Notifications
   ========================================== */

/* Slide in animation for retry notification */
@keyframes slideInRight {
    from {
        transform: translateX(100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

#generation-retry-notification {
    animation: slideInRight 0.3s ease-out;
}

/* Generation loading states */
.generation-loading {
    position: relative;
    pointer-events: none;
}

.generation-loading::after {
    content: '';
    position: absolute;
    inset: 0;
    background: rgba(255, 255, 255, 0.8);
    border-radius: inherit;
}

.generation-loading-overlay {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 10;
    background: white;
    padding: 1rem 2rem;
    border-radius: 0.5rem;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

/* Spinner animation */
@keyframes spin {
    from {
        transform: rotate(0deg);
    }
    to {
        transform: rotate(360deg);
    }
}

.animate-spin {
    animation: spin 1s linear infinite;
}

/* Notification toast base styles */
.notification-toast {
    animation: slideInRight 0.3s ease-out;
    max-width: 400px;
}

/* Notification mobile adjustments */
@media (max-width: 767px) {
    #notification-container {
        top: 4.5rem; /* Clear mobile header */
        right: 0.75rem;
        left: auto;
        max-width: calc(100vw - 1.5rem);
    }

    #notification-container > div {
        width: 100%;
        max-width: 100%;
    }
}

/* ==========================================
   Balance Update Animations
   ========================================== */

@keyframes balance-pulse {
    0% { transform: scale(1); }
    50% { transform: scale(1.15); }
    100% { transform: scale(1); }
}

.balance-updated {
    animation: balance-pulse 0.4s ease-out;
}

.balance-decreased {
    color: #ef4444 !important; /* red-500 */
    transition: color 0.3s ease;
}

.balance-increased {
    color: #22c55e !important; /* green-500 */
    transition: color 0.3s ease;
}

/* Restore original color after animation */
.sidebar-balance-count,
#header-balance-count,
.mobile-balance-count {
    transition: color 0.3s ease 0.3s;
}

/* ==========================================
   Selection Action Bar Stacking Fix
   ========================================== */

/* Force selection bar to top of stacking order */
#selectionActionBar {
    /* Create a new stacking context at the root level */
    isolation: isolate;
    /* Use very high z-index */
    z-index: 9999 !important;
}

/* Ensure buttons inside are clickable */
#selectionActionBar button {
    position: relative;
    z-index: 1;
    cursor: pointer;
}

/* When hidden, don't intercept events */
#selectionActionBar.opacity-0 {
    pointer-events: none !important;
}

#selectionActionBar:not(.opacity-0) {
    pointer-events: auto !important;
}

/* ============================================ */
/* TMA / narrow viewport button fixes           */
/* ============================================ */
@media (max-width: 500px) {
    /* Action buttons: prevent text overflow */
    #apply-edit-btn,
    #generate-submit-btn,
    #video-generate-btn,
    [id$="-action-btn"],
    [id$="-generate-btn"] {
        font-size: 15px !important;
        padding-left: 12px !important;
        padding-right: 12px !important;
        flex-wrap: wrap !important;
        gap: 4px !important;
    }

    /* Credit badges: keep compact */
    #apply-edit-btn .credit-cost-badge,
    #generate-submit-btn .credit-cost-badge,
    #video-generate-btn .credit-cost-badge,
    [id$="-action-btn"] .credit-cost-badge {
        font-size: 12px !important;
        white-space: nowrap !important;
    }
}

