/* Reset & Base Styles */
@import url('https://fonts.googleapis.com/css2?family=IBM+Plex+Sans:wght@700;800&display=swap');
/* IRANYekan font faces */
@font-face {
    font-family: 'IRANYekan';
    src: url('../fonts/IRANYekan-Regular.woff2') format('woff2'),
         url('../fonts/IRANYekan-Regular.woff') format('woff'),
         url('../fonts/IRANYekan-Regular.ttf') format('truetype');
    font-weight: 400;
    font-style: normal;
    font-display: swap;
}

@font-face {
    font-family: 'IRANYekan';
    src: url('../fonts/IRANYekan-Bold.woff2') format('woff2'),
         url('../fonts/IRANYekan-Bold.woff') format('woff'),
         url('../fonts/IRANYekan-Bold.ttf') format('truetype');
    font-weight: 700;
    font-style: normal;
    font-display: swap;
}

/* Map 800 to Bold file (use ExtraBold file instead if you add it) */
@font-face {
    font-family: 'IRANYekan';
    src: url('../fonts/IRANYekan-Bold.woff2') format('woff2'),
         url('../fonts/IRANYekan-Bold.woff') format('woff'),
         url('../fonts/IRANYekan-Bold.ttf') format('truetype');
    font-weight: 800;
    font-style: normal;
    font-display: swap;
}
/* Map 500 to Regular file */
@font-face {
    font-family: 'IRANYekan';
    src: url('../fonts/IRANYekan-Regular.woff2') format('woff2'),
         url('../fonts/IRANYekan-Regular.woff') format('woff'),
         url('../fonts/IRANYekan-Regular.ttf') format('truetype');
    font-weight: 500;
    font-style: normal;
    font-display: swap;
}
/* Map 600 to Bold file */
@font-face {
    font-family: 'IRANYekan';
    src: url('../fonts/IRANYekan-Bold.woff2') format('woff2'),
         url('../fonts/IRANYekan-Bold.woff') format('woff'),
         url('../fonts/IRANYekan-Bold.ttf') format('truetype');
    font-weight: 600;
    font-style: normal;
    font-display: swap;
}
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --bg-primary: #0f0f1e;
    --bg-secondary: #1a1a2e;
    --bg-tertiary: #252540;
    --bg-card: #2d2d44;
    --text-primary: #ffffff;
    --text-secondary: #a0a0c0;
    --accent-primary: #8b5cf6;
    --accent-secondary: #6366f1;
    --accent-hover: #7c3aed;
    --border-color: #3d3d5c;
    --success: #10b981;
    --error: #ef4444;
    --shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.3), 0 2px 4px -1px rgba(0, 0, 0, 0.2);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.4), 0 4px 6px -2px rgba(0, 0, 0, 0.3);
}

body {
    font-family: 'IRANYekan', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background: linear-gradient(135deg, var(--bg-primary) 0%, var(--bg-secondary) 100%);
    color: var(--text-primary);
    min-height: 100vh;
    line-height: 1.6;
}
/* Ensure form controls use site font */
button, input, textarea, select {
    font-family: inherit;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px;
}

/* Header */
.header {
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border-color);
    padding: 1rem 0;
    position: sticky;
    top: 0;
    z-index: 100;
    backdrop-filter: blur(10px);
}

.header-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.logo {
    display: flex;
    align-items: center;
    gap: 12px;
}

.logo-text {
    font-size: 1.5rem;
    font-weight: 700;
    font-family: 'IBM Plex Sans', 'IRANYekan', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background: linear-gradient(135deg, var(--accent-primary), var(--accent-secondary));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 12px;
}

.btn-support, .btn-credits {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 20px;
    border-radius: 12px;
    font-size: 0.95rem;
    font-weight: 500;
    font-family: 'IRANYekan', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    cursor: pointer;
    transition: all 0.3s ease;
    border: 1px solid var(--border-color);
    background: var(--bg-card);
    color: var(--text-primary);
    text-decoration: none;
}

.btn-support:hover, .btn-credits:hover {
    background: var(--bg-tertiary);
    transform: translateY(-2px);
    box-shadow: var(--shadow);
}

.user-menu {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 16px;
    border-radius: 12px;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
}

.user-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    object-fit: cover;
}

.user-name {
    font-size: 0.95rem;
    font-weight: 500;
}

.btn-logout {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border: none;
    border-radius: 8px;
    background: var(--bg-tertiary);
    color: var(--text-primary);
    cursor: pointer;
    transition: all 0.3s ease;
}

.btn-logout:hover {
    background: var(--error);
    transform: scale(1.05);
}

/* Main Content */
.main-content {
    padding: 3rem 0;
}

.hero {
    text-align: center;
    margin-bottom: 3rem;
}

.hero-title {
    font-size: 2rem;
    font-weight: 800;
    margin-bottom: 1rem;
    background: linear-gradient(135deg, var(--accent-primary), var(--accent-secondary));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

/* Mobile-only site name above hero title */
.mobile-site-name {
    display: none;
    font-family: 'IBM Plex Sans', 'IRANYekan', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
}

.hero-description {
    font-size: 1.125rem;
    color: var(--text-secondary);
    max-width: none; /* allow full container width on desktop */
    margin: 0; /* align with container, not centered fixed width */
    font-weight: 400;
}

/* Tabs */
.tabs {
    display: flex;
    gap: 12px;
    margin-bottom: 2rem;
    background: var(--bg-card);
    padding: 8px;
    border-radius: 16px;
    border: 1px solid var(--border-color);
}

.tab-btn {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 14px 24px;
    border: none;
    border-radius: 12px;
    background: transparent;
    color: var(--text-secondary);
    font-size: 1rem;
    font-weight: 600;
    font-family: 'IRANYekan', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    cursor: pointer;
    transition: all 0.3s ease;
}

.tab-btn:hover {
    color: var(--text-primary);
    background: var(--bg-tertiary);
}

.tab-btn.active {
    background: linear-gradient(135deg, var(--accent-primary), var(--accent-secondary));
    color: white;
    box-shadow: var(--shadow);
}

.tab-btn svg {
    stroke-width: 2.5;
}

/* Tab Content */
.tab-content {
    background: var(--bg-card);
    border-radius: 20px;
    padding: 2rem;
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow);
}

.tab-pane {
    display: none !important;
}

.tab-pane.active {
    display: block !important;
}

/* Upload Section */
.upload-section {
    margin-bottom: 2rem;
}

.input-label {
    display: block;
    font-size: 1rem;
    font-weight: 600;
    margin-bottom: 12px;
    color: var(--text-primary);
}

.upload-box {
    position: relative;
    border: 2px dashed var(--border-color);
    border-radius: 16px;
    padding: 3rem 2rem;
    text-align: center;
    transition: all 0.3s ease;
    background: var(--bg-tertiary);
}

.upload-box:hover {
    border-color: var(--accent-primary);
    background: var(--bg-secondary);
}

/* Drag & Drop state */
.upload-box.dragover {
    border-color: var(--accent-primary);
    background: rgba(139, 92, 246, 0.08);
    box-shadow: 0 0 0 3px rgba(139, 92, 246, 0.15) inset;
}

/* Upload vertical progress overlay */
.upload-progress-overlay {
    position: absolute;
    inset: 0;
    border-radius: 16px;
    overflow: hidden;
    pointer-events: none;
}

.upload-progress-fill {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 0;
    background: linear-gradient(180deg, rgba(139, 92, 246, 0.25), rgba(99, 102, 241, 0.35));
    transition: height 0.2s ease;
}

.upload-progress-text {
    position: absolute;
    bottom: 8px;
    left: 0;
    right: 0;
    text-align: center;
    color: var(--text-primary);
    font-weight: 700;
    text-shadow: 0 1px 2px rgba(0,0,0,0.5);
    font-size: 0.9rem;
}

/* Disabled state while uploading */
.upload-box.uploading {
    pointer-events: none; /* block clicks/drags */
    opacity: 0.85;
}

/* Wave animation overlay (subtle) */
.upload-progress-overlay::before {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 100%;
    background: radial-gradient(200% 50% at 50% 100%, rgba(255,255,255,0.12) 0%, rgba(255,255,255,0) 60%) repeat-x;
    background-size: 200% 100%;
    animation: waveMove 2.2s linear infinite;
    opacity: 0.6;
    pointer-events: none;
    clip-path: inset(calc(100% - var(--upload-fill, 0%)) 0 0 0);
}

@keyframes waveMove {
    0% { background-position: 0% 100%; }
    100% { background-position: 200% 100%; }
}

.file-input {
    display: none;
}

.upload-label {
    cursor: pointer;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    color: var(--text-secondary);
}

.upload-label svg {
    stroke: var(--accent-primary);
    opacity: 0.8;
}

.upload-label span {
    font-size: 1rem;
    font-weight: 500;
}

.preview-images {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
    gap: 12px;
    margin-top: 1rem;
}

.preview-card {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.preview-item {
    position: relative;
    border-radius: 12px;
    overflow: hidden;
    aspect-ratio: 1;
    border: 2px solid var(--border-color);
}

.preview-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.preview-remove {
    position: absolute;
    top: 8px;
    right: 8px;
    background: var(--error);
    border: none;
    color: white;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
    font-weight: bold;
    transition: all 0.3s ease;
}

.preview-remove:hover {
    transform: scale(1.1);
}

.preview-caption {
    font-size: 0.85rem;
    text-align: center;
    color: var(--text-secondary);
}

/* Small guidance hint for multiple uploads */
.multi-upload-hint {
    grid-column: 1 / -1;
    margin-top: 4px;
    padding: 10px 12px;
    border-radius: 10px;
    background: var(--bg-secondary);
    border: 1px dashed var(--border-color);
    color: var(--text-secondary);
    font-size: 0.9rem;
    line-height: 1.6;
}

/* Prompt Section */
.prompt-section {
    margin-bottom: 2rem;
}

.ai-refine-toggle {
    margin-top: 12px;
    padding: 12px 14px;
    border-radius: 12px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
}

.ai-checkbox {
    display: flex;
    align-items: center;
    gap: 10px;
    font-weight: 600;
    color: var(--text-primary);
    cursor: pointer;
}

.ai-checkbox input {
    width: 18px;
    height: 18px;
    accent-color: var(--accent-primary);
}

.ai-checkbox span {
    font-size: 0.95rem;
}

.ai-checkbox-hint {
    margin-top: 6px;
    font-size: 0.85rem;
    color: var(--text-secondary);
    line-height: 1.6;
}

/* Aspect Ratio Section */
.aspect-ratio-section {
    margin-bottom: 2rem;
}

.aspect-ratio-scroll {
    display: flex;
    gap: 12px;
    overflow-x: auto;
    padding: 8px 4px;
    scrollbar-width: thin;
    scrollbar-color: var(--border-color) var(--bg-tertiary);
    scroll-behavior: smooth;
    scroll-padding: 0 20%;
    -webkit-overflow-scrolling: touch;
}

.aspect-ratio-scroll::-webkit-scrollbar {
    height: 6px;
}

.aspect-ratio-scroll::-webkit-scrollbar-track {
    background: var(--bg-tertiary);
    border-radius: 3px;
}

.aspect-ratio-scroll::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 3px;
}

.aspect-ratio-scroll::-webkit-scrollbar-thumb:hover {
    background: var(--accent-primary);
}

.aspect-ratio-item {
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    padding: 12px;
    border-radius: 12px;
    background: var(--bg-tertiary);
    border: 2px solid var(--border-color);
    cursor: pointer;
    transition: all 0.3s ease;
    min-width: 80px;
}

.aspect-ratio-item:hover {
    border-color: var(--accent-primary);
    background: var(--bg-secondary);
    transform: translateY(-2px);
}

.aspect-ratio-item.active {
    border-color: var(--accent-primary);
    background: linear-gradient(135deg, rgba(139, 92, 246, 0.1), rgba(99, 102, 241, 0.1));
    box-shadow: 0 0 0 3px rgba(139, 92, 246, 0.2);
}

.aspect-ratio-item span {
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--text-secondary);
}

.aspect-ratio-item.active span {
    color: var(--accent-primary);
}

.ratio-box {
    width: 50px;
    border: 2px solid var(--text-secondary);
    border-radius: 6px;
    background: var(--bg-primary);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
}

.aspect-ratio-item.active .ratio-box {
    border-color: var(--accent-primary);
    background: var(--bg-card);
}

/* Specific Aspect Ratios */
.ratio-1-1 {
    height: 50px;
}

.ratio-9-16 {
    height: 88px; /* 50 * 16/9 */
}

.ratio-16-9 {
    height: 28px; /* 50 * 9/16 */
}

.ratio-3-4 {
    height: 67px; /* 50 * 4/3 */
}

.ratio-4-3 {
    height: 38px; /* 50 * 3/4 */
}

.ratio-3-2 {
    height: 33px; /* 50 * 2/3 */
}

.ratio-2-3 {
    height: 75px; /* 50 * 3/2 */
}

.ratio-5-4 {
    height: 40px; /* 50 * 4/5 */
}

.ratio-4-5 {
    height: 63px; /* 50 * 5/4 */
}

.ratio-21-9 {
    height: 21px; /* 50 * 9/21 */
}

.ratio-auto {
    height: 50px;
}

.ratio-auto svg {
    stroke: var(--text-secondary);
}

.aspect-ratio-item.active .ratio-auto svg {
    stroke: var(--accent-primary);
}

.prompt-input {
    width: 100%;
    padding: 16px;
    border-radius: 12px;
    border: 1px solid var(--border-color);
    background: var(--bg-tertiary);
    color: var(--text-primary);
    font-size: 1rem;
    font-family: inherit;
    resize: vertical;
    transition: all 0.3s ease;
}

.prompt-input:focus {
    outline: none;
    border-color: var(--accent-primary);
    box-shadow: 0 0 0 3px rgba(139, 92, 246, 0.1);
}

.prompt-input::placeholder {
    color: var(--text-secondary);
    opacity: 0.6;
}

/* Buttons */
.btn-generate {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 16px 32px;
    border: none;
    border-radius: 12px;
    background: linear-gradient(135deg, var(--accent-primary), var(--accent-secondary));
    color: white;
    font-size: 1.125rem;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: var(--shadow);
}

.btn-generate:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}

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

.btn-generate:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}

/* Result Section */
.result-section {
    margin-top: 2rem;
    background: var(--bg-card);
    border-radius: 20px;
    padding: 2rem;
    border: 1px solid var(--border-color);
    text-align: center;
}

.loading {
    text-align: center;
    padding: 3rem 0;
}

.spinner {
    width: 48px;
    height: 48px;
    border: 4px solid var(--bg-tertiary);
    border-top-color: var(--accent-primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto 1rem;
}

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

.loading p {
    font-size: 1.125rem;
    color: var(--text-secondary);
}

.result-image {
    position: relative;
    display: inline-block;
    max-width: 100%;
    border-radius: 20px;
    overflow: hidden;
    cursor: pointer;
    transition: all 0.4s ease;
    box-shadow: var(--shadow-lg);
}

.result-image:hover {
    transform: scale(1.02);
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
}

.result-image img {
    width: 100%;
    height: auto;
    display: block;
    border-radius: 20px;
    transition: all 0.4s ease;
    opacity: 0; /* hidden until loaded */
}

/* Minimal Download Button - Always Visible */
.btn-download {
    position: absolute;
    top: 12px;
    right: 12px;
    width: 44px;
    height: 44px;
    border: none;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(20px);
    color: var(--bg-primary);
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10;
    opacity: 0.9;
}

.result-image:hover .btn-download {
    opacity: 1;
    transform: scale(1.05);
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.25);
}

.btn-download:hover {
    transform: scale(1.1);
    background: rgba(255, 255, 255, 1);
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.3);
}

.btn-download:active {
    transform: scale(0.95);
}

.btn-download svg {
    width: 20px;
    height: 20px;
    stroke: currentColor;
    stroke-width: 2;
    transition: all 0.3s ease;
}

.btn-download:hover svg {
    transform: translateY(-1px);
}

/* Result image loading skeleton */
.image-skeleton {
    position: absolute;
    inset: 0;
    background: linear-gradient(180deg, var(--bg-tertiary), var(--bg-secondary));
    display: none; /* shown during loading */
}

.image-skeleton .skeleton-shimmer {
    position: absolute;
    inset: 0;
    background: linear-gradient(90deg, rgba(255,255,255,0), rgba(255,255,255,0.08), rgba(255,255,255,0));
    transform: translateX(-100%);
    animation: skeletonShimmer 1.2s infinite;
}

@keyframes skeletonShimmer {
    100% { transform: translateX(100%); }
}

/* Utility class to reveal image after load */
.image-visible {
    opacity: 1 !important;
}

/* History Section */
.history-section {
    margin-top: 3rem;
}

.history-title {
    font-size: 1.875rem;
    font-weight: 700;
    margin-bottom: 1.5rem;
    color: var(--text-primary);
}

.history-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 20px;
}

.history-item {
    position: relative;
    border-radius: 20px;
    overflow: hidden;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    cursor: pointer;
    transition: all 0.4s ease;
    box-shadow: var(--shadow);
}

.history-item:hover {
    transform: translateY(-4px) scale(1.02);
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
}

.history-item img {
    width: 100%;
    aspect-ratio: 1;
    object-fit: cover;
    transition: all 0.4s ease;
}

.history-item-actions {
    position: absolute;
    top: 8px;
    right: 8px;
    display: flex;
    gap: 8px;
}

.history-delete {
    background: rgba(239, 68, 68, 0.9);
    border: none;
    color: white;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.3rem;
    font-weight: bold;
    transition: all 0.3s ease;
    backdrop-filter: blur(4px);
    box-shadow: 0 4px 12px rgba(239, 68, 68, 0.3);
}

.history-delete:hover {
    transform: scale(1.15);
    background: var(--error);
    box-shadow: 0 6px 20px rgba(239, 68, 68, 0.4);
}

/* Modal */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    z-index: 1000;
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(4px);
}

.modal.active {
    display: flex;
}

.modal-content {
    background: var(--bg-card);
    border-radius: 24px;
    max-width: 500px;
    width: 90%;
    max-height: 90vh;
    overflow-y: auto;
    position: relative;
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow-lg);
    animation: modalSlideIn 0.3s ease;
}

.modal-large {
    max-width: 900px;
}

.modal-packages {
    max-width: 780px;
}

.modal-header-icon {
    width: 64px;
    height: 64px;
    margin: 0 auto 1rem;
    background: linear-gradient(135deg, rgba(139, 92, 246, 0.1), rgba(99, 102, 241, 0.1));
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-header-icon svg {
    stroke: var(--accent-primary);
    stroke-width: 2;
}

@keyframes modalSlideIn {
    from {
        opacity: 0;
        transform: translateY(-20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.modal-close {
    position: absolute;
    top: 16px;
    right: 16px;
    background: var(--bg-tertiary);
    border: none;
    color: var(--text-primary);
    width: 36px;
    height: 36px;
    border-radius: 50%;
    font-size: 1.5rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
}

.modal-close:hover {
    background: var(--error);
    transform: rotate(90deg);
}

.modal-body {
    padding: 3rem 2rem;
    text-align: center;
}

.modal-body svg {
    margin-bottom: 1.5rem;
}

.modal-title {
    font-size: 1.875rem;
    font-weight: 700;
    margin-bottom: 1rem;
}

.modal-description {
    font-size: 1rem;
    color: var(--text-secondary);
    margin-bottom: 2rem;
    line-height: 1.6;
}

/* Modal body styling for result-image component */
.modal-body .result-image {
    max-width: 80vw;
    max-height: 80vh;
    margin: 0 auto;
}

.modal-body .result-image img {
    width: 100%;
    height: auto;
    max-width: 80vw;
    max-height: 80vh;
    object-fit: contain;
    opacity: 1; /* ensure modal preview image is visible */
}

/* Ensure inline generated image is also limited to 80% of viewport */
.result-section .result-image {
    display: block;
    width: min(100%, 80vw);
    max-width: 640px;
    max-height: 80vh;
    aspect-ratio: var(--result-aspect, 1 / 1);
    min-height: 240px;
    margin: 0 auto;
    background: var(--bg-tertiary);
}

.result-section .result-image img {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    max-width: none;
    max-height: none;
    object-fit: contain;
}

/* Ensure modal download button icon matches in-button centering */
.modal-body .result-image .btn-download svg {
    margin: 0; /* override any inherited modal svg margins */
    display: block;
}

.btn-google {
    display: inline-flex;
    align-items: center;
    gap: 12px;
    padding: 14px 28px;
    border-radius: 12px;
    background: white;
    color: #333;
    font-size: 1rem;
    font-weight: 600;
    text-decoration: none;
    transition: all 0.3s ease;
    box-shadow: var(--shadow);
}

.btn-google:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}

/* Packages Modal */
.packages-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 16px;
    margin-top: 1.5rem;
}

.package-card {
    background: var(--bg-tertiary);
    border: 2px solid var(--border-color);
    border-radius: 16px;
    padding: 1.25rem;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    cursor: pointer;
    position: relative;
    overflow: hidden;
}

.package-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: linear-gradient(90deg, var(--accent-primary), var(--accent-secondary));
    transform: scaleX(0);
    transition: transform 0.3s ease;
}

.package-card:hover {
    border-color: var(--accent-primary);
    transform: translateY(-4px);
    box-shadow: var(--shadow-lg);
}

.package-card:hover::before {
    transform: scaleX(1);
}

/* Package Header */
.package-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1rem;
    padding-bottom: 0.75rem;
    border-bottom: 1px solid var(--border-color);
}

.package-name {
    font-size: 1.125rem;
    font-weight: 700;
    color: var(--text-primary);
}

.package-badge {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--accent-primary), var(--accent-secondary));
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    box-shadow: 0 2px 8px rgba(139, 92, 246, 0.3);
}

.package-badge svg {
    display: block;
    width: 14px;
    height: 14px;
}

/* Package Details */
.package-details {
    display: flex;
    flex-direction: column;
    gap: 0.875rem;
    margin-bottom: 1rem;
}

.package-detail-item {
    display: flex;
    align-items: center;
    gap: 0.625rem;
    padding: 0.625rem;
    background: var(--bg-secondary);
    border-radius: 10px;
    transition: all 0.2s ease;
}

.package-detail-item:hover {
    background: var(--bg-card);
}

.package-detail-item svg {
    flex-shrink: 0;
    stroke: var(--accent-primary);
    stroke-width: 2;
    width: 18px;
    height: 18px;
    margin-top: -1px;
}

.package-credits {
    font-size: 1.375rem;
    font-weight: 800;
    color: var(--accent-primary);
    line-height: 1.2;
}

.package-duration {
    font-size: 1.375rem;
    font-weight: 800;
    color: var(--accent-primary);
    line-height: 1.2;
}

.package-label {
    font-size: 0.875rem;
    color: var(--text-secondary);
    font-weight: 500;
    line-height: 1.2;
}

/* Package Footer */
.package-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    padding-top: 0.75rem;
    border-top: 1px solid var(--border-color);
}

.package-price {
    display: flex;
    align-items: baseline;
    gap: 0.375rem;
}

.price-amount {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--text-primary);
    line-height: 1;
}

.price-currency {
    font-size: 0.8rem;
    color: var(--text-secondary);
    font-weight: 500;
}

.btn-purchase {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.375rem;
    padding: 0.625rem 1rem;
    border: none;
    border-radius: 10px;
    background: linear-gradient(135deg, var(--accent-primary), var(--accent-secondary));
    color: white;
    font-size: 0.9rem;
    font-weight: 600;
    font-family: 'IRANYekan', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    cursor: pointer;
    transition: all 0.3s ease;
    white-space: nowrap;
    box-shadow: 0 2px 8px rgba(139, 92, 246, 0.25);
    line-height: 1;
}

.btn-purchase:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(139, 92, 246, 0.4);
}

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

.btn-purchase svg {
    stroke-width: 2;
    flex-shrink: 0;
    width: 16px;
    height: 16px;
    display: block;
}

/* Loading/disabled state for purchase button */
.btn-purchase.loading,
.btn-purchase:disabled {
    opacity: 0.7;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
    position: relative;
}

.btn-purchase.loading svg {
    opacity: 0;
}

.btn-purchase.loading::after {
    content: '';
    position: absolute;
    width: 18px;
    height: 18px;
    top: 50%;
    left: 50%;
    margin-left: -9px;
    margin-top: -9px;
    border: 3px solid rgba(255, 255, 255, 0.35);
    border-top-color: #fff;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

/* Responsive */
@media (max-width: 768px) {
    .mobile-site-name {
        display: block;
        font-size: 1.1rem;
        font-weight: 800;
        margin-bottom: 0.75rem;
        background: linear-gradient(135deg, var(--accent-primary), var(--accent-secondary));
        -webkit-background-clip: text;
        -webkit-text-fill-color: transparent;
        background-clip: text;
        letter-spacing: 0.3px;
        text-shadow: 0 0 12px rgba(139, 92, 246, 0.25);
    }
    .hero-title {
        font-size: 1.5rem;
    }

    .hero-description {
        font-size: 1rem;
        max-width: 600px; /* keep readable width on mobile */
        margin: 0 auto; /* center on mobile for readability */
    }

    /* Keep tabs side-by-side on mobile */
    .tabs {
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 8px;
        padding: 6px;
    }
    .tab-btn {
        padding: 12px 14px;
        font-size: 0.95rem;
    }

    .tab-content {
        padding: 1.5rem;
    }

    /* Compact single-line header on mobile */
    .header { padding: 0.5rem 0; }
    .header-content { gap: 8px; }
    .logo-text { display: none; }
    .header-actions {
        flex-wrap: nowrap;
        gap: 8px;
    }
    .btn-support .btn-label, .btn-credits .btn-label { display: none; }
    .btn-support, .btn-credits {
        font-size: 0.85rem;
        padding: 8px 10px;
    }
    .user-menu {
        gap: 6px;
        padding: 6px 8px;
    }
    .user-name { display: none; }
    .user-avatar { width: 28px; height: 28px; }
    .btn-logout { width: 28px; height: 28px; }

    .btn-support, .btn-credits {
        font-size: 0.85rem;
        padding: 8px 12px;
    }

    .history-grid {
        grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    }

    .packages-grid {
        grid-template-columns: 1fr;
    }
    
    .package-footer {
        flex-direction: column;
        align-items: stretch;
        gap: 0.75rem;
    }
    
    .package-price {
        justify-content: center;
    }
    
    .btn-purchase {
        width: 100%;
    }
}

/* Animations */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.fade-in {
    animation: fadeIn 0.5s ease;
}

/* Scrollbar */
::-webkit-scrollbar {
    width: 10px;
}

::-webkit-scrollbar-track {
    background: var(--bg-secondary);
}

::-webkit-scrollbar-thumb {
    background: var(--bg-tertiary);
    border-radius: 5px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--border-color);
}

/* Success/Error Messages */
.message {
    padding: 16px 20px;
    border-radius: 12px;
    margin-bottom: 1.5rem;
    display: flex;
    align-items: center;
    gap: 12px;
    font-weight: 500;
}

.message-success {
    background: rgba(16, 185, 129, 0.1);
    border: 1px solid var(--success);
    color: var(--success);
}

.message-error {
    background: rgba(239, 68, 68, 0.1);
    border: 1px solid var(--error);
    color: var(--error);
}

/* Button Loading State */
.btn-generate.loading {
    position: relative;
    color: transparent;
    pointer-events: none;
}

.btn-generate.loading svg {
    opacity: 0;
}

.btn-generate.loading::after {
    content: '';
    position: absolute;
    width: 20px;
    height: 20px;
    top: 50%;
    left: 50%;
    margin-left: -10px;
    margin-top: -10px;
    border: 3px solid rgba(255, 255, 255, 0.3);
    border-top-color: white;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

/* Bottom Status Section (for errors and progress) */
.status-section {
    margin-top: 2rem;
    background: var(--bg-card);
    border-radius: 20px;
    padding: 2rem;
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow);
    scroll-margin-top: 100px;
}

.status-error {
    text-align: center;
    padding: 2rem;
}

.status-error-icon {
    width: 64px;
    height: 64px;
    margin: 0 auto 1rem;
    background: rgba(239, 68, 68, 0.1);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.status-error-icon svg {
    width: 32px;
    height: 32px;
    stroke: var(--error);
    stroke-width: 2.5;
}

.status-error h3 {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--error);
    margin-bottom: 0.5rem;
}

.status-error p {
    font-size: 1rem;
    color: var(--text-secondary);
    line-height: 1.6;
}

/* Progress Bar */
.progress-container {
    padding: 2rem;
}

.progress-header {
    text-align: center;
    margin-bottom: 2rem;
}

.progress-icon {
    width: 64px;
    height: 64px;
    margin: 0 auto 1rem;
    background: linear-gradient(135deg, rgba(139, 92, 246, 0.1), rgba(99, 102, 241, 0.1));
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    animation: pulse 2s ease-in-out infinite;
}

@keyframes pulse {
    0%, 100% {
        transform: scale(1);
        opacity: 1;
    }
    50% {
        transform: scale(1.05);
        opacity: 0.8;
    }
}

.progress-icon svg {
    width: 32px;
    height: 32px;
    stroke: var(--accent-primary);
    stroke-width: 2.5;
    animation: spin 3s linear infinite;
}

.progress-header h3 {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 0.5rem;
}

.progress-header p {
    font-size: 1rem;
    color: var(--text-secondary);
}

.progress-bar-wrapper {
    position: relative;
    width: 100%;
    height: 8px;
    background: var(--bg-tertiary);
    border-radius: 100px;
    overflow: hidden;
    margin-bottom: 1rem;
}

.progress-bar-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--accent-primary), var(--accent-secondary), var(--accent-primary));
    background-size: 200% 100%;
    border-radius: 100px;
    transition: width 0.5s ease;
    animation: shimmer 2s linear infinite;
}

@keyframes shimmer {
    0% {
        background-position: 200% 0;
    }
    100% {
        background-position: -200% 0;
    }
}

.progress-text {
    text-align: center;
    font-size: 0.9rem;
    color: var(--text-secondary);
    font-weight: 500;
}

/* Retry Button */
.btn-retry {
    margin-top: 1.5rem;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 12px 24px;
    border: none;
    border-radius: 12px;
    background: linear-gradient(135deg, var(--accent-primary), var(--accent-secondary));
    color: white;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
}

.btn-retry:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow);
}

/* Smooth scroll behavior */
html {
    scroll-behavior: smooth;
}

