/* ============================================
   VALENTINE GENERATOR - LIGHT PINKISH THEME
   Super smooth & clean design
   ============================================ */

/* CSS Variables - Light Pinkish Theme */
:root {
    --primary: #ff6b9d;
    --primary-light: #ff8fb3;
    --primary-dark: #e84a7f;
    --accent: #ffd1dc;
    --accent-light: #ffe8ed;

    --bg-primary: #fff5f7;
    --bg-secondary: #ffffff;
    --bg-card: #ffffff;

    --text-primary: #2d2d3a;
    --text-secondary: #6b6b7a;
    --text-muted: #9b9bab;

    --border: rgba(255, 107, 157, 0.15);
    --shadow-sm: 0 2px 8px rgba(255, 107, 157, 0.08);
    --shadow-md: 0 4px 20px rgba(255, 107, 157, 0.12);
    --shadow-lg: 0 8px 40px rgba(255, 107, 157, 0.15);

    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 20px;
    --radius-xl: 28px;

    --font-display: 'Playfair Display', serif;
    --font-body: 'Poppins', sans-serif;
    --font-script: 'Playfair Display', serif;

    --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    --transition-slow: all 0.5s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Reset */
*,
*::before,
*::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
}

body {
    font-family: var(--font-body);
    background: var(--bg-primary);
    min-height: 100vh;
    color: var(--text-primary);
    overflow-x: hidden;
    position: relative;
    line-height: 1.6;
    -webkit-tap-highlight-color: transparent;
    /* Mobile native feel */
}

/* Background Shapes */
.bg-shapes {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 0;
    overflow: hidden;
}

.shape {
    position: absolute;
    border-radius: 50%;
    filter: blur(60px);
    opacity: 0.5;
}

.shape-1 {
    width: 400px;
    height: 400px;
    background: linear-gradient(135deg, var(--accent) 0%, var(--primary-light) 100%);
    top: -150px;
    right: -100px;
    animation: floatShape 20s ease-in-out infinite;
}

.shape-2 {
    width: 300px;
    height: 300px;
    background: linear-gradient(135deg, var(--accent-light) 0%, var(--accent) 100%);
    bottom: -100px;
    left: -50px;
    animation: floatShape 15s ease-in-out infinite reverse;
}

.shape-3 {
    width: 200px;
    height: 200px;
    background: var(--accent);
    top: 50%;
    left: 30%;
    animation: floatShape 25s ease-in-out infinite;
}

@keyframes floatShape {

    0%,
    100% {
        transform: translateY(0) rotate(0deg);
    }

    33% {
        transform: translateY(-30px) rotate(5deg);
    }

    66% {
        transform: translateY(20px) rotate(-5deg);
    }
}

/* Floating Hearts */
.hearts-bg {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 0;
    overflow: hidden;
}

.floating-heart {
    position: absolute;
    animation: floatHeart 20s linear infinite;
    opacity: 0.15;
    color: var(--primary);
}

@keyframes floatHeart {
    0% {
        transform: translateY(100vh) rotate(0deg) scale(0.5);
        opacity: 0;
    }

    10% {
        opacity: 0.15;
    }

    90% {
        opacity: 0.15;
    }

    100% {
        transform: translateY(-100vh) rotate(360deg) scale(1);
        opacity: 0;
    }
}

/* Container */
.container {
    position: relative;
    z-index: 1;
    max-width: 1200px;
    margin: 0 auto;
    padding: 2rem;
    min-height: 100vh;
}

/* Header */
.header {
    text-align: center;
    padding: 1.5rem 0 2.5rem;
}

.logo {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
    margin-bottom: 0.5rem;
}

.heart-icon {
    font-size: 2.5rem;
    animation: heartbeat 2s ease-in-out infinite;
}

@keyframes heartbeat {

    0%,
    100% {
        transform: scale(1);
    }

    15% {
        transform: scale(1.15);
    }

    30% {
        transform: scale(1);
    }

    45% {
        transform: scale(1.1);
    }
}

.logo h1 {
    font-family: var(--font-display);
    font-size: 2.2rem;
    font-weight: 600;
    color: var(--primary);
}

.tagline {
    font-size: 1rem;
    color: var(--text-secondary);
    font-weight: 400;
}

/* Main Content */
.main-content {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 2rem;
    align-items: stretch;
}

@media (max-width: 900px) {
    .main-content {
        grid-template-columns: 1fr;
        gap: 1.5rem;
    }

    .container {
        padding: 1.5rem;
    }
}

@media (max-width: 600px) {
    .container {
        padding: 1rem;
    }

    .header {
        padding: 1rem 0 1.5rem;
    }

    .logo h1 {
        font-size: 1.8rem;
    }
}

/* Generator Card */
.generator-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-xl);
    padding: 1.5rem;
    /* Consistent padding */
    box-shadow: var(--shadow-md);
    transition: var(--transition);
}

.generator-card:hover {
    box-shadow: var(--shadow-lg);
}

/* Form Styles */
.valentine-form {
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
}

@media (max-width: 500px) {
    .form-row {
        grid-template-columns: 1fr;
    }
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
}

.form-group label {
    font-weight: 500;
    font-size: 0.9rem;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.required-star {
    color: var(--primary);
    font-weight: 700;
}

.optional-tag {
    font-size: 0.7rem;
    padding: 0.1rem 0.4rem;
    background: var(--accent-light);
    color: var(--primary-dark);
    border-radius: 10px;
    font-weight: 500;
}

/* Input Styles */
input[type="text"],
textarea {
    width: 100%;
    padding: 0.85rem 1rem;
    background: var(--bg-primary);
    border: 1.5px solid var(--border);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    font-family: var(--font-body);
    font-size: 1rem;
    /* Prevents iOS auto-zoom */
    transition: var(--transition);
}

input[type="text"]:focus,
textarea:focus {
    outline: none;
    border-color: var(--primary);
    background: white;
    box-shadow: 0 0 0 3px rgba(255, 107, 157, 0.1);
}

input::placeholder,
textarea::placeholder {
    color: var(--text-muted);
}

textarea {
    resize: vertical;
    min-height: 80px;
}

.error-message {
    display: none;
    color: var(--primary-dark);
    font-size: 0.8rem;
}

.form-group.error .error-message {
    display: block;
}

.form-group.error input {
    border-color: var(--primary-dark);
}

/* File Input - Simple & Clean */
.file-input-wrapper {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.6rem 1rem;
    background: var(--bg-primary);
    border: 1.5px solid var(--border);
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: var(--transition);
}

.file-input-wrapper:hover {
    border-color: var(--primary-light);
}

.file-input {
    position: absolute;
    opacity: 0;
    width: 0;
    height: 0;
}

.file-label {
    flex: 1;
    font-size: 0.9rem;
    color: var(--text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.file-label.has-file {
    color: var(--text-primary);
}

.file-btn {
    padding: 0.5rem 1rem;
    background: var(--accent-light);
    border: none;
    border-radius: var(--radius-sm);
    color: var(--primary-dark);
    font-size: 0.85rem;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition);
}

.file-btn:hover {
    background: var(--accent);
}

/* Theme Selector */
.theme-selector {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 0.75rem;
}

.theme-option {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    aspect-ratio: 1 / 1;
    /* Perfect square */
    background: var(--bg-primary);
    border: 2px solid transparent;
    border-radius: var(--radius-md);
    text-align: center;
    cursor: pointer;
    transition: var(--transition);
    padding: 0.25rem;
}

.theme-option:hover {
    transform: translateY(-2px);
}

.theme-option.selected {
    border-color: var(--primary);
    background: white;
    box-shadow: var(--shadow-sm);
}

.theme-preview {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    margin: 0 auto 0.4rem;
    box-shadow: inset 0 -2px 4px rgba(0, 0, 0, 0.1);
}

.theme-preview.rose {
    background: linear-gradient(135deg, #ff6b9d 0%, #ff4757 100%);
}

.theme-preview.purple {
    background: linear-gradient(135deg, #a55eea 0%, #5f27cd 100%);
}

.theme-preview.red {
    background: linear-gradient(135deg, #e53935 0%, #c62828 100%);
}

.theme-preview.dark {
    background: linear-gradient(135deg, #2d1f3d 0%, #1a1a2e 100%);
}

.theme-preview.light {
    background: linear-gradient(135deg, #ffffff 0%, #fff0f3 100%);
    border: 1px solid #ffd1dc;
}

.theme-option span {
    font-size: 0.75rem;
    font-weight: 500;
    color: var(--text-secondary);
}

.theme-option.selected span {
    color: var(--primary-dark);
}

/* Template Selector */
.template-selector {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 0.75rem;
}

@media (max-width: 400px) {
    .template-selector {
        grid-template-columns: 1fr;
    }
}

.template-option {
    padding: 1rem 0.5rem;
    background: var(--bg-primary);
    border: 2px solid transparent;
    border-radius: var(--radius-md);
    text-align: center;
    cursor: pointer;
    transition: var(--transition);
}

.template-option:hover {
    transform: translateY(-2px);
}

.template-option.selected {
    border-color: var(--primary);
    background: white;
    box-shadow: var(--shadow-sm);
}

.template-icon {
    font-size: 1.8rem;
    margin-bottom: 0.3rem;
    animation: none;
}

.template-option.selected .template-icon {
    animation: pulse 2s ease-in-out infinite;
}

@keyframes pulse {

    0%,
    100% {
        transform: scale(1);
    }

    50% {
        transform: scale(1.15);
    }
}

.template-option span {
    font-size: 0.8rem;
    font-weight: 500;
    color: var(--text-secondary);
}

.template-option.selected span {
    color: var(--primary-dark);
}

/* Generate Button */
.generate-btn {
    width: 100%;
    padding: 1rem 2rem;
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
    border: none;
    border-radius: var(--radius-lg);
    color: white;
    font-family: var(--font-body);
    font-size: 1.1rem;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    margin-top: 0.5rem;
    position: relative;
    overflow: hidden;
}

.generate-btn::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.2), transparent);
    transition: 0.5s;
}

.generate-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(255, 107, 157, 0.35);
}

.generate-btn:hover::before {
    left: 100%;
}

.generate-btn:active {
    transform: scale(0.97);
    /* Mobile native tap feedback */
}

.generate-btn.loading .btn-text {
    opacity: 0;
}

.generate-btn.loading::after {
    content: "";
    position: absolute;
    width: 22px;
    height: 22px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-top-color: white;
    border-radius: 50%;
    animation: spin 0.7s linear infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

/* Preview Panel */
.preview-panel {
    position: sticky;
    top: 2rem;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-xl);
    padding: 1.5rem;
    /* Match generator-card padding */
    box-shadow: var(--shadow-md);
    display: flex;
    flex-direction: column;
}

.preview-frame {
    background: var(--bg-primary);
    border-radius: var(--radius-lg);
    flex: 1;
    /* Match the height of the generator card */
    min-height: 450px;
    overflow: hidden;
    position: relative;
    display: flex;
    flex-direction: column;
}

.preview-frame iframe {
    width: 100%;
    flex: 1;
    height: 100%;
    border: none;
    border-radius: var(--radius-lg);
}

.preview-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
    padding-bottom: 0.75rem;
    border-bottom: 1px solid var(--border);
}

.preview-header h3 {
    font-family: var(--font-display);
    font-size: 1.2rem;
    color: var(--primary-dark);
}

.preview-actions {
    display: flex;
    gap: 0.5rem;
}

.action-btn {
    padding: 0.5rem 0.9rem;
    background: var(--bg-primary);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    font-family: var(--font-body);
    font-size: 0.8rem;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition);
    user-select: none;
    /* App feel */
}

.action-btn:active {
    transform: scale(0.95);
}

.action-btn:hover:not(:disabled) {
    background: var(--accent-light);
    color: var(--primary-dark);
}

.action-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.action-btn.primary {
    background: var(--primary);
    border: none;
    color: white;
}

.action-btn.primary:hover:not(:disabled) {
    background: var(--primary-dark);
    color: white;
}

.preview-frame {
    background: var(--bg-primary);
    border-radius: var(--radius-lg);
    min-height: 450px;
    overflow: hidden;
    position: relative;
}

.preview-frame iframe {
    width: 100%;
    height: 450px;
    border: none;
    border-radius: var(--radius-lg);
}

@media (max-width: 600px) {

    .preview-frame,
    .preview-frame iframe,
    .preview-placeholder {
        min-height: 500px;
        height: 500px;
    }
}

.preview-placeholder {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    flex: 1;
    min-height: 450px;
    color: var(--text-muted);
    gap: 0.75rem;
}

.placeholder-heart {
    font-size: 3rem;
    animation: heartbeat 2s ease-in-out infinite;
    opacity: 0.4;
}

.preview-placeholder p {
    font-size: 0.9rem;
}

/* Footer */
.footer {
    text-align: center;
    padding: 2.5rem 0 1.5rem;
}

.tip-section {
    position: relative;
    display: inline-block;
    margin-bottom: 1.25rem;
}

.tip-btn {
    padding: 0.85rem 1.75rem;
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
    border: none;
    border-radius: 50px;
    color: white;
    font-family: var(--font-body);
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    box-shadow: 0 4px 15px rgba(255, 107, 157, 0.3);
    text-decoration: none;
    display: inline-block;
}

.tip-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 25px rgba(255, 107, 157, 0.4);
}

.tip-dropdown {
    position: absolute;
    bottom: calc(100% + 10px);
    left: 50%;
    transform: translateX(-50%) scale(0.95);
    background: white;
    border-radius: var(--radius-lg);
    padding: 0.75rem;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.15);
    display: flex;
    gap: 0.5rem;
    opacity: 0;
    visibility: hidden;
    transition: var(--transition);
}

.tip-dropdown::after {
    content: '';
    position: absolute;
    bottom: -8px;
    left: 50%;
    transform: translateX(-50%);
    border: 8px solid transparent;
    border-top-color: white;
}

.tip-section:hover .tip-dropdown,
.tip-dropdown.show {
    opacity: 1;
    visibility: visible;
    transform: translateX(-50%) scale(1);
}

.tip-option {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.25rem;
    padding: 0.75rem 1.25rem;
    background: var(--bg-primary);
    border-radius: var(--radius-md);
    text-decoration: none;
    transition: var(--transition);
    border: 2px solid transparent;
}

.tip-option:hover {
    background: var(--accent-light);
    transform: translateY(-2px);
}

.tip-option.featured {
    background: linear-gradient(135deg, var(--accent-light) 0%, var(--accent) 100%);
    border-color: var(--primary-light);
}

.tip-option.featured:hover {
    transform: translateY(-3px);
    box-shadow: 0 4px 15px rgba(255, 107, 157, 0.25);
}

.tip-amount {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--primary-dark);
}

.tip-emoji {
    font-size: 1.25rem;
}

.footer-text {
    color: var(--text-muted);
    font-size: 0.9rem;
}

.footer-text a {
    color: var(--primary);
    text-decoration: none;
    font-weight: 500;
    transition: var(--transition);
}

.footer-text a:hover {
    text-decoration: underline;
}

/* Responsive refinements */
@media (max-width: 768px) {
    .logo h1 {
        font-size: 1.8rem;
    }

    .heart-icon {
        font-size: 2rem;
    }

    .generator-card {
        padding: 1.5rem;
    }

    .preview-panel {
        position: relative;
        top: 0;
    }
}

@media (max-width: 480px) {
    .preview-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.75rem;
    }

    .preview-actions {
        width: 100%;
    }

    .action-btn {
        flex: 1;
        text-align: center;
    }
}

/* Share Button */
.share-btn {
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%) !important;
    color: white !important;
    border: none !important;
}

.share-btn:hover:not(:disabled) {
    transform: translateY(-1px);
    box-shadow: 0 4px 15px rgba(255, 107, 157, 0.3);
}

/* Share Modal */
.share-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(5px);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: 1rem;
}

.share-modal.active {
    display: flex;
}

.share-modal-content {
    background: white;
    border-radius: var(--radius-xl);
    padding: 2rem;
    max-width: 420px;
    width: 100%;
    text-align: center;
    position: relative;
    animation: modalPop 0.3s ease;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.2);
}

@keyframes modalPop {
    0% {
        transform: scale(0.9);
        opacity: 0;
    }

    100% {
        transform: scale(1);
        opacity: 1;
    }
}

.share-close {
    position: absolute;
    top: 1rem;
    right: 1rem;
    background: none;
    border: none;
    font-size: 1.5rem;
    color: var(--text-muted);
    cursor: pointer;
    transition: var(--transition);
}

.share-close:hover {
    color: var(--text-primary);
}

.share-icon {
    font-size: 3rem;
    margin-bottom: 0.75rem;
}

.share-title {
    font-family: var(--font-display);
    font-size: 1.5rem;
    color: var(--text-primary);
    margin-bottom: 0.5rem;
}

.share-subtitle {
    color: var(--text-secondary);
    font-size: 0.95rem;
    margin-bottom: 1rem;
}

.share-link-box {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1rem;
}

.share-link-box input {
    flex: 1;
    padding: 0.75rem 1rem;
    border: 2px solid var(--accent);
    border-radius: var(--radius-md);
    font-size: 0.9rem;
    color: var(--text-primary);
    background: var(--accent-light);
}

.copy-btn {
    padding: 0.75rem 1.25rem;
    background: var(--primary);
    border: none;
    border-radius: var(--radius-md);
    color: white;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    white-space: nowrap;
}

.copy-btn:hover {
    background: var(--primary-dark);
}

.copy-btn.copied {
    background: #22c55e;
}

.share-note {
    font-size: 0.8rem;
    color: var(--text-muted);
}

/* History Section */
.history-section {
    margin-top: 4rem;
    padding-top: 2rem;
    border-top: 1.5px solid var(--border);
}

.history-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2rem;
}

.history-header h2 {
    font-family: var(--font-display);
    color: var(--primary-dark);
    font-size: 1.8rem;
}

.clear-history {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 0.9rem;
    cursor: pointer;
    text-decoration: underline;
    transition: var(--transition);
}

/* Stats Section */
.stats-section {
    display: none;
    /* Hidden by default */
    margin: 3rem auto 2rem;
    text-align: center;
    padding: 2rem;
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.9), rgba(255, 192, 203, 0.2));
    border: 2px solid var(--primary-light);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-md);
    max-width: 400px;
    animation: fadeIn 1s ease-out;
}

@media (max-width: 600px) {
    .stats-section {
        margin: 2rem 1rem;
        padding: 1.5rem;
    }
}

.stats-section p {
    font-size: 1.2rem;
    color: var(--text-primary);
    font-weight: 500;
    margin: 0;
}

#totalGenerations {
    font-size: 2rem;
    font-weight: 800;
    color: var(--primary);
    display: block;
    margin-top: 0.5rem;
    font-family: var(--font-display);
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}