:root {
    --primary: #9c27b0;
    --primary-light: #d05ce3;
    --primary-dark: #6a0080;
    --secondary: #ffd54f;
    --secondary-light: #ffff81;
    --secondary-dark: #c8a415;
    --text-light: #ffffff;
    --text-dark: #212121;
    --background: #f5f5f5;
    --card-bg: #ffffff;
    --font-main: 'Montserrat', sans-serif;
    --font-decorative: 'Pacifico', cursive;
    --spacing-unit: 1rem;
    --border-radius: 12px;
    --shadow-sm: 0 2px 4px rgba(0, 0, 0, 0.1);
    --shadow-md: 0 4px 8px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 8px 16px rgba(0, 0, 0, 0.1);
    --text-format-color: #000000; /* Default color for text formatting */
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    overflow-y: scroll; /* Force scrollbar to always show */
    scrollbar-gutter: stable; /* Prevent layout shift */
    font-size: 16px;
    scroll-behavior: smooth;
}

body {
    font-family: var(--font-main);
    background-color: var(--background);
    color: var(--text-dark);
    line-height: 1.6;
    min-height: 100vh;
    position: relative;
    width: 100%;
    overflow-x: hidden; /* Prevent horizontal scroll */
    display: flex;
    flex-direction: column;
}

header {
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    color: var(--text-light);
    padding: calc(var(--spacing-unit) * 2);
    text-align: center;
    box-shadow: var(--shadow-md);
    position: relative;
    overflow: hidden;
}

header::before {
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-image: url("data:image/svg+xml,%3Csvg width='100' height='100' viewBox='0 0 100 100' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M11 18c3.866 0 7-3.134 7-7s-3.134-7-7-7-7 3.134-7 7 3.134 7 7 7zm48 25c3.866 0 7-3.134 7-7s-3.134-7-7-7-7 3.134-7 7 3.134 7 7 7zm-43-7c1.657 0 3-1.343 3-3s-1.343-3-3-3-3 1.343-3 3 1.343 3 3 3zm63 31c1.657 0 3-1.343 3-3s-1.343-3-3-3-3 1.343-3 3 1.343 3 3 3zM34 90c1.657 0 3-1.343 3-3s-1.343-3-3-3-3 1.343-3 3 1.343 3 3 3zm56-76c1.657 0 3-1.343 3-3s-1.343-3-3-3-3 1.343-3 3 1.343 3 3 3zM12 86c2.21 0 4-1.79 4-4s-1.79-4-4-4-4 1.79-4 4 1.79 4 4 4zm28-65c2.21 0 4-1.79 4-4s-1.79-4-4-4-4 1.79-4 4 1.79 4 4 4zm23-11c2.76 0 5-2.24 5-5s-2.24-5-5-5-5 2.24-5 5 2.24 5 5 5zm-6 60c2.21 0 4-1.79 4-4s-1.79-4-4-4-4 1.79-4 4 1.79 4 4 4zm29 22c2.76 0 5-2.24 5-5s-2.24-5-5-5-5 2.24-5 5 2.24 5 5 5zM32 63c2.76 0 5-2.24 5-5s-2.24-5-5-5-5 2.24-5 5 2.24 5 5 5zm57-13c2.76 0 5-2.24 5-5s-2.24-5-5-5-5 2.24-5 5 2.24 5 5 5zm-9-21c1.105 0 2-.895 2-2s-.895-2-2-2-2 .895-2 2 .895 2 2 2zM60 91c1.105 0 2-.895 2-2s-.895-2-2-2-2 .895-2 2 .895 2 2 2zM35 41c1.105 0 2-.895 2-2s-.895-2-2-2-2 .895-2 2 .895 2 2 2zM12 60c1.105 0 2-.895 2-2s-.895-2-2-2-2 .895-2 2 .895 2 2 2z' fill='%23ffffff' fill-opacity='0.1' fill-rule='evenodd'/%3E%3C/svg%3E");
    opacity: 0.3;
}

.header-content {
    position: relative;
    z-index: 1;
    max-width: 800px;
    margin: 0 auto;
}

h1 {
    font-family: var(--font-decorative);
    font-size: clamp(2rem, 5vw, 3rem);
    margin-bottom: var(--spacing-unit);
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.2);
    color: var(--text-light);
}

h2 {
    font-size: clamp(1rem, 3vw, 1.5rem);
    font-weight: 400;
    color: var(--text-light);
    opacity: 0.9;
    margin-bottom: 1rem;
}

.container {
    width: min(90%, 1200px);
    margin: 0 auto;
    padding: calc(var(--spacing-unit) * 2) 0;
    flex: 1;
    overflow: hidden; /* Contain floating elements */
}

.main-content {
    display: grid;
    gap: calc(var(--spacing-unit) * 2);
    grid-template-columns: 1fr;
    min-height: 100vh; /* Minimum height to prevent jumps */
}

@media (min-width: 1024px) {
    .main-content {
        grid-template-columns: repeat(2, 1fr);
    }
}

.section {
    background: var(--card-bg);
    border-radius: var(--border-radius);
    padding: calc(var(--spacing-unit) * 1.5);
    box-shadow: var(--shadow-md);
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.section:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-lg);
}

.section-title {
    display: flex;
    align-items: center;
    gap: var(--spacing-unit);
    margin-bottom: calc(var(--spacing-unit) * 1.5);
    padding-bottom: var(--spacing-unit);
    border-bottom: 2px solid var(--primary-light);
    color: var(--primary);
    font-size: 1.25rem;
}

.section-title i {
    margin-right: 10px;
    font-size: 1.5rem;
}

.template-list {
    max-height: 300px;
    overflow-y: auto;
    margin-bottom: 1rem;
    border: 1px solid rgba(0, 0, 0, 0.1);
    border-radius: 8px;
    padding: 0.5rem;
}

.template-item {
    padding: 0.8rem;
    border-radius: 6px;
    margin-bottom: 0.5rem;
    cursor: pointer;
    transition: all 0.2s ease;
    background-color: rgba(156, 39, 176, 0.1);
    min-height: 60px; /* Minimum height to prevent text jumping */
    overflow: hidden;
}

.template-item:hover {
    background-color: rgba(156, 39, 176, 0.2);
}

.template-item:last-child {
    margin-bottom: 0;
}

.template-item.selected {
    background-color: var(--secondary-light);
    border-left: 4px solid var(--primary);
}

.editor-area {
    width: 100%;
    min-height: 150px;
    padding: 1rem;
    border-radius: 8px;
    border: 2px solid rgba(0, 0, 0, 0.1);
    resize: vertical;
    font-family: var(--font-main);
    font-size: 1rem;
    margin-bottom: 1rem;
    transition: border-color 0.3s ease;
}

.editor-area:focus {
    outline: none;
    border-color: var(--primary-light);
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: calc(var(--spacing-unit) * 0.5);
    padding: calc(var(--spacing-unit) * 0.75) calc(var(--spacing-unit) * 1.5);
    border-radius: 50px;
    font-weight: 600;
    transition: all 0.3s ease;
    cursor: pointer;
    border: none;
    box-shadow: var(--shadow-sm);
}

.btn:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.btn-primary {
    background: var(--primary);
    color: var(--text-light);
}

.btn-secondary {
    background: var(--secondary);
    color: var(--text-dark);
}

.btn-outline {
    background: transparent;
    border: 2px solid var(--primary);
    color: var(--primary);
}

.btn-outline:hover {
    background: var(--primary);
    color: var(--text-light);
}

.btn-sm {
    padding: 0.5rem 1rem;
    font-size: 0.9rem;
}

.btn-icon {
    display: flex;
    align-items: center;
    justify-content: center;
}

.btn-icon i {
    margin-right: 8px;
}

.saved-list {
    max-height: 300px;
    overflow-y: auto;
    margin-top: 1rem;
}

.saved-item {
    background-color: #fff;
    border-radius: 8px;
    padding: 1rem;
    margin-bottom: 1rem;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
    position: relative;
    min-height: 60px; /* Minimum height to prevent text jumping */
    overflow: hidden;
}

.saved-item h3 {
    font-size: 1.1rem;
    margin-bottom: 0.5rem;
    color: var(--primary);
}

.saved-item p {
    margin-bottom: 0.5rem;
}

.saved-actions {
    display: flex;
    justify-content: flex-end;
    margin-top: 0.5rem;
}

.empty-state {
    text-align: center;
    padding: 2rem;
    color: #777;
}

.empty-state i {
    font-size: 3rem;
    margin-bottom: 1rem;
    color: #ddd;
}

.emoji-list {
    display: flex;
    flex-wrap: wrap;
    margin-bottom: 1rem;
    gap: 0.5rem;
}

.emoji {
    font-size: 1.2rem;
    background-color: rgba(0, 0, 0, 0.05);
    border-radius: 4px;
    padding: 0.3rem;
    cursor: pointer;
    transition: all 0.2s ease;
}

.emoji:hover {
    background-color: var(--secondary-light);
    transform: scale(1.2);
}

.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    justify-content: center;
    align-items: center;
    z-index: 100;
}

.modal-content {
    background-color: white;
    padding: 2rem;
    border-radius: 12px;
    width: 90%;
    max-width: 500px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
    position: relative;
}

.close-modal {
    position: absolute;
    top: 1rem;
    right: 1rem;
    font-size: 1.5rem;
    cursor: pointer;
    color: #777;
}

.input-group {
    margin-bottom: 1rem;
}

.input-group label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 600;
}

.input-field {
    width: 100%;
    padding: calc(var(--spacing-unit) * 0.75);
    border-radius: calc(var(--border-radius) / 2);
    border: 2px solid rgba(0, 0, 0, 0.1);
    font-family: var(--font-main);
    transition: border-color 0.3s ease;
}

.input-field:focus {
    outline: none;
    border-color: var(--primary-light);
}

footer {
    background: var(--card-bg);
    padding: calc(var(--spacing-unit) * 2);
    margin-top: auto;
    box-shadow: var(--shadow-sm);
}

.footer-content {
    max-width: 1200px;
    margin: 0 auto;
    text-align: center;
}

.footer-content p {
    margin-bottom: 1rem;
    color: #666;
    font-size: 0.9rem;
}

.footer-content a {
    color: var(--primary);
    text-decoration: none;
    font-weight: 600;
    transition: color 0.3s ease;
}

.footer-content a:hover {
    color: var(--primary-dark);
    text-decoration: underline;
}

.share-buttons {
    display: flex;
    justify-content: center;
    gap: 1rem;
    margin-top: 1rem;
}

.share-btn {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    background-color: rgba(255, 255, 255, 0.2);
    color: var(--text-light);
    transition: all 0.3s ease;
}

.share-btn:hover {
    background-color: var(--secondary);
    color: var(--text-dark);
    transform: translateY(-3px);
}

.toast {
    position: fixed;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    background: #9c27b0;
    color: white;
    padding: 12px 24px;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    z-index: 1000;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.toast.show {
    opacity: 1;
}

/* Animation Effects */
@keyframes floating {
    0% { transform: translateY(0); }
    50% { transform: translateY(-10px); }
    100% { transform: translateY(0); }
}

.floating {
    animation: floating 3s ease-in-out infinite;
}

.copied-message {
    display: none;
    position: absolute;
    background-color: var(--secondary);
    color: var(--text-dark);
    padding: 0.5rem 1rem;
    border-radius: 4px;
    font-size: 0.8rem;
    top: -40px;
    left: 50%;
    transform: translateX(-50%);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.search-container {
    position: relative;
    margin-bottom: 1rem;
}

.search-input {
    width: 100%;
    padding: 0.8rem 2.5rem 0.8rem 1rem;
    border-radius: 50px;
    border: 2px solid rgba(0, 0, 0, 0.1);
    font-family: var(--font-main);
    font-size: 1rem;
    transition: all 0.3s ease;
}

.search-input:focus {
    outline: none;
    border-color: var(--primary-light);
    box-shadow: 0 0 0 3px rgba(156, 39, 176, 0.1);
}

.search-icon {
    position: absolute;
    right: 1rem;
    top: 50%;
    transform: translateY(-50%);
    color: #777;
}

/* Decorative Elements */
.decoration {
    position: absolute;
    width: 150px;
    height: 150px;
    background-color: var(--secondary);
    opacity: 0.1;
    border-radius: 50%;
    z-index: 0;
}

.decoration-1 {
    top: -50px;
    left: -50px;
}

.decoration-2 {
    bottom: -50px;
    right: -50px;
}

/* Loading animation */
.loading {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 3px solid rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    border-top-color: white;
    animation: spin 1s ease-in-out infinite;
    margin-right: 10px;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* Responsiveness */
@media (max-width: 768px) {
    h1 {
        font-size: 2rem;
    }

    h2 {
        font-size: 1rem;
    }

    .container {
        width: 95%;
        padding: 1rem 0;
    }

    .section {
        padding: 1rem;
    }

    .btn {
        padding: 0.7rem 1.2rem;
        font-size: 0.9rem;
    }
}

/* Card Preview */
.card-preview {
    background: #f8f9fa;
    border-radius: 8px;
    padding: 20px;
    margin: 20px 0;
    min-height: 400px;
    display: flex;
    justify-content: center;
    align-items: center;
    overflow: hidden; /* Prevent content overflow */
}

.card-preview.show {
    display: flex;
}

.card-container {
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    width: 100%;
    max-width: 800px;
    aspect-ratio: 16/9;
    border-radius: 15px;
    padding: 3rem;
    color: var(--text-light);
    position: relative;
    overflow: hidden;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
}

.card-container::before {
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-image: url("data:image/svg+xml,%3Csvg width='100' height='100' viewBox='0 0 100 100' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M11 18c3.866 0 7-3.134 7-7s-3.134-7-7-7-7 3.134-7 7 3.134 7 7 7zm48 25c3.866 0 7-3.134 7-7s-3.134-7-7-7-7 3.134-7 7 3.134 7 7 7zm-43-7c1.657 0 3-1.343 3-3s-1.343-3-3-3-3 1.343-3 3 1.343 3 3 3zm63 31c1.657 0 3-1.343 3-3s-1.343-3-3-3-3 1.343-3 3 1.343 3 3 3zM34 90c1.657 0 3-1.343 3-3s-1.343-3-3-3-3 1.343-3 3 1.343 3 3 3zm56-76c1.657 0 3-1.343 3-3s-1.343-3-3-3-3 1.343-3 3 1.343 3 3 3zM12 86c2.21 0 4-1.79 4-4s-1.79-4-4-4-4 1.79-4 4 1.79 4 4 4zm28-65c2.21 0 4-1.79 4-4s-1.79-4-4-4-4 1.79-4 4 1.79 4 4 4zm23-11c2.76 0 5-2.24 5-5s-2.24-5-5-5-5 2.24-5 5 2.24 5 5 5zm-6 60c2.21 0 4-1.79 4-4s-1.79-4-4-4-4 1.79-4 4 1.79 4 4 4zm29 22c2.76 0 5-2.24 5-5s-2.24-5-5-5-5 2.24-5 5 2.24 5 5 5zM32 63c2.76 0 5-2.24 5-5s-2.24-5-5-5-5 2.24-5 5 2.24 5 5 5zm57-13c2.76 0 5-2.24 5-5s-2.24-5-5-5-5 2.24-5 5 2.24 5 5 5zm-9-21c1.105 0 2-.895 2-2s-.895-2-2-2-2 .895-2 2 .895 2 2 2zM60 91c1.105 0 2-.895 2-2s-.895-2-2-2-2 .895-2 2 .895 2 2 2zM35 41c1.105 0 2-.895 2-2s-.895-2-2-2-2 .895-2 2 .895 2 2 2zM12 60c1.105 0 2-.895 2-2s-.895-2-2-2-2 .895-2 2 .895 2 2 2z' fill='%23ffffff' fill-opacity='0.1' fill-rule='evenodd'/%3E%3C/svg%3E");
    opacity: 0.1;
}

.card-content {
    position: relative;
    z-index: 1;
    height: 100%;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    text-align: center;
}

.card-text {
    position: relative;
    z-index: 1;
    text-align: center;
    padding: 40px;
    font-family: 'Montserrat', sans-serif;
    font-size: 16px;
    line-height: 1.6;
    color: #333;
    background: rgba(255, 255, 255, 0.9);
    border-radius: 8px;
    margin: 20px;
    max-width: 80%;
}

.card-decoration {
    position: absolute;
    width: 200px;
    height: 200px;
    background-color: var(--secondary);
    opacity: 0.1;
    border-radius: 50%;
}

.card-decoration-1 {
    top: -100px;
    left: -100px;
}

.card-decoration-2 {
    bottom: -100px;
    right: -100px;
}

.mt-3 {
    margin-top: calc(var(--spacing-unit) * 3);
}

/* Loading Spinner */
.loading-spinner {
    display: inline-block;
    width: 50px;
    height: 50px;
    border: 5px solid rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    border-top-color: white;
    animation: spin 1s ease-in-out infinite;
}

@media (max-width: 768px) {
    .card-container {
        padding: 1.5rem;
    }

    .card-text {
        font-size: 1.2rem;
    }
}

/* Preview & Export Styles */
.preview-container {
    background: #fff;
    border-radius: 12px;
    padding: 20px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
    margin-bottom: 20px;
    overflow: hidden; /* Contain all content */
}

.preview-options {
    display: flex;
    gap: 15px;
    margin-bottom: 20px;
    flex-wrap: wrap; /* Allow wrapping on small screens */
}

.select-field {
    flex: 1;
    min-width: 200px; /* Prevent too narrow fields */
    padding: 10px;
    border: 1px solid #ddd;
    border-radius: 6px;
    font-size: 14px;
    background: #fff;
}

.preview-frame {
    background: white;
    box-shadow: 0 4px 15px rgba(0,0,0,0.1);
    padding: 20px;
    width: 100%;
    max-width: 600px;
    min-height: 350px;
    position: relative;
    transition: all 0.3s ease;
    transform: translateZ(0); /* Force GPU acceleration */
    will-change: transform; /* Optimize animations */
    overflow: auto; /* Allow scrolling if content is too large */
}

.preview-content {
    width: 100%;
    min-height: 400px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-top: 1rem;
    margin-bottom: 1rem;
    position: relative;
    border: 1px solid rgba(0, 0, 0, 0.1);
    border-radius: 8px;
    padding: 1rem;
    overflow: hidden;
}

.qr-options {
    display: flex;
    gap: 20px;
    align-items: center;
    margin-top: 20px;
    padding-top: 20px;
    border-top: 1px solid #eee;
    flex-wrap: wrap; /* Allow wrapping on small screens */
}

.qr-preview {
    width: 150px;
    height: 150px;
    min-width: 150px; /* Prevent QR code from shrinking */
    min-height: 150px;
    background: #f8f9fa;
    border: 1px dashed #ddd;
    border-radius: 8px;
    display: flex;
    justify-content: center;
    align-items: center;
}

/* Template Styles */
.template-classic {
    font-family: 'Times New Roman', serif;
    text-align: center;
}

.template-modern {
    font-family: 'Montserrat', sans-serif;
    background: linear-gradient(135deg, #f6f8f9 0%, #fff 100%);
}

.template-floral {
    background-color: #fff;
    background-image: url('data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSI0MCIgaGVpZ2h0PSI0MCIgdmlld0JveD0iMCAwIDQwIDQwIj48cGF0aCBkPSJNMjAgMGMxMSAwIDIwIDkgMjAgMjBzLTkgMjAtMjAgMjBTMCAzMSAwIDIwIDkgMCAyMCAwem0wIDJjLTkuOSAwLTE4IDguMS0xOCAxOHM4LjEgMTggMTggMTggMTgtOC4xIDE4LTE4UzI5LjkgMiAyMCAyeiIgZmlsbD0iI2YwZjBmMCIvPjwvc3ZnPg==');
}

.template-islamic {
    background-color: #fff;
    border: 8px double #2c3e50;
}

/* Responsive adjustments */
@media (max-width: 768px) {
    .preview-frame {
        padding: 15px;
        min-height: 300px; /* Smaller height on mobile */
    }
    
    .preview-options {
        flex-direction: column;
    }
    
    .select-field {
        width: 100%;
    }
    
    .qr-options {
        flex-direction: column;
        align-items: stretch;
    }
    
    .qr-preview {
        margin: 0 auto;
    }
    
    .button-group {
        justify-content: center;
    }
}

/* Smooth transitions */
.preview-frame, .card-preview, .qr-preview {
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Prevent text jumping */
.saved-item {
    min-height: 60px; /* Minimum height to prevent text jumping */
    overflow: hidden;
}

/* Button group fixes */
.button-group {
    display: flex;
    gap: 10px;
    flex-wrap: wrap; /* Allow buttons to wrap */
    margin: 15px 0;
}

/* Background Upload Styles */
.background-options {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.5rem;
}

.bg-label {
    position: relative;
    cursor: pointer;
    flex: 1;
}

.bg-upload {
    display: none;
}

.bg-settings {
    background-color: rgba(156, 39, 176, 0.05);
    padding: 0.75rem;
    border-radius: 8px;
    margin-top: 0.5rem;
}

.opacity-control {
    margin-top: 10px;
}

.opacity-label {
    display: block;
    margin-bottom: 5px;
    font-size: 0.9rem;
    color: #666;
}

.opacity-slider {
    width: 100%;
    height: 6px;
    -webkit-appearance: none;
    background: var(--primary-light);
    border-radius: 3px;
    outline: none;
}

.opacity-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 18px;
    height: 18px;
    background: var(--primary);
    border-radius: 50%;
    cursor: pointer;
    transition: all 0.2s ease;
}

.opacity-slider::-webkit-slider-thumb:hover {
    transform: scale(1.2);
}

/* Preview Frame with Background */
.preview-frame {
    background-color: white;
    background-position: center;
    background-size: cover;
    background-repeat: no-repeat;
}

.preview-frame.has-bg::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: inherit;
    opacity: 1;
    z-index: 0;
}

.preview-content {
    position: relative;
    z-index: 1;
    background: rgba(255, 255, 255, 0.8);
    padding: 20px;
    border-radius: 8px;
}

/* Responsive adjustments */
@media (max-width: 768px) {
    .background-options {
        flex-direction: column;
    }
    
    .bg-settings {
        flex-direction: column;
    }
    
    .opacity-control {
        width: 100%;
    }
}

/* Personalization Styles */
.personalization-section {
    background: #fff;
    border-radius: 12px;
    padding: 20px;
    margin-top: 20px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

.section-subtitle {
    font-size: 1.1rem;
    color: var(--primary);
    margin-bottom: 15px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.option-group {
    margin-bottom: 20px;
    padding-bottom: 15px;
    border-bottom: 1px solid #eee;
}

.option-group:last-child {
    border-bottom: none;
    margin-bottom: 0;
    padding-bottom: 0;
}

.option-group label {
    display: block;
    margin-bottom: 8px;
    font-weight: 500;
    color: #555;
}

/* Color Picker */
.color-picker {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 10px;
}

.color-picker input[type="color"] {
    -webkit-appearance: none;
    width: 40px;
    height: 40px;
    border: none;
    border-radius: 8px;
    cursor: pointer;
}

.color-picker input[type="color"]::-webkit-color-swatch-wrapper {
    padding: 0;
}

.color-picker input[type="color"]::-webkit-color-swatch {
    border: none;
    border-radius: 8px;
}

.color-preview {
    width: 100px;
    height: 24px;
    border-radius: 4px;
    border: 1px solid #ddd;
}

/* Frame Selector */
.frame-selector {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(80px, 1fr));
    gap: 10px;
}

.frame-option {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 10px;
    border: 2px solid #eee;
    border-radius: 8px;
    background: none;
    cursor: pointer;
    transition: all 0.2s ease;
}

.frame-option:hover {
    border-color: var(--primary-light);
}

.frame-option.active {
    border-color: var(--primary);
    background: var(--primary-light);
    color: white;
}

.frame-option i {
    font-size: 1.5rem;
    margin-bottom: 5px;
}

/* Text Layout */
.text-layout-options {
    display: flex;
    gap: 10px;
    margin-bottom: 15px;
}

.layout-btn {
    padding: 8px 15px;
    border: 1px solid #ddd;
    border-radius: 6px;
    background: white;
    cursor: pointer;
    transition: all 0.2s ease;
}

.layout-btn:hover {
    background: var(--primary-light);
    color: white;
}

.layout-btn.active {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
}

/* Spacing Control */
.spacing-control {
    margin-top: 15px;
}

.spacing-control input[type="range"] {
    width: 100%;
    margin-top: 8px;
}

/* Stickers */
.sticker-container {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(40px, 1fr));
    gap: 10px;
    padding: 10px;
    background: #f8f9fa;
    border-radius: 8px;
    max-height: 120px;
    overflow-y: auto;
}

.sticker {
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    background: white;
    border-radius: 8px;
    cursor: pointer;
    transition: transform 0.2s ease;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.sticker:hover {
    transform: scale(1.1);
}

/* Font Import */
@import url('https://fonts.googleapis.com/css2?family=Amiri:wght@400;700&family=Dancing+Script:wght@400;700&family=Quicksand:wght@400;700&family=Noto+Sans:wght@400;700&display=swap');

/* Preview Content with Personalization */
.preview-content.personalized {
    position: relative;
    transition: all 0.3s ease;
}

/* Frame Styles */
.frame-classic {
    border: double 6px #333;
    padding: 20px;
}

.frame-floral {
    border: 15px solid transparent;
    border-image: url('data:image/svg+xml,...') 30 stretch;
    padding: 20px;
}

.frame-islamic {
    border: 20px solid transparent;
    border-image: url('data:image/svg+xml,...') 40 stretch;
    padding: 20px;
}

/* Responsive Design */
@media (max-width: 768px) {
    .personalization-section {
        padding: 15px;
    }

    .frame-selector {
        grid-template-columns: repeat(2, 1fr);
    }

    .sticker-container {
        grid-template-columns: repeat(5, 1fr);
    }
}

/* Mobile Friendly Styles */
@media (max-width: 768px) {
    /* Container adjustments */
    .container {
        width: 100%;
        padding: 1rem;
        margin: 0;
    }

    /* Header adjustments */
    header {
        padding: 1rem;
    }

    h1 {
        font-size: 1.8rem;
    }

    h2 {
        font-size: 1rem;
    }

    /* Preview section */
    .preview-container {
        padding: 10px;
        margin: 10px 0;
    }

    .preview-options {
        flex-direction: column;
        gap: 10px;
    }

    .select-field {
        width: 100%;
        min-width: unset;
    }

    /* Personalization section */
    .personalization-section {
        padding: 15px;
        margin-top: 10px;
    }

    .option-group {
        margin-bottom: 15px;
        padding-bottom: 10px;
    }

    /* Color picker adjustments */
    .color-picker {
        flex-wrap: wrap;
    }

    .color-preview {
        width: 100%;
    }

    /* Frame selector */
    .frame-selector {
        grid-template-columns: repeat(2, 1fr);
        gap: 8px;
    }

    .frame-option {
        padding: 8px;
    }

    /* Text layout */
    .text-layout-options {
        justify-content: space-between;
    }

    .layout-btn {
        flex: 1;
        padding: 8px;
        font-size: 0.9rem;
    }

    /* Stickers */
    .sticker-container {
        grid-template-columns: repeat(5, 1fr);
        gap: 8px;
        padding: 8px;
    }

    .sticker {
        width: 35px;
        height: 35px;
        font-size: 1.2rem;
    }

    /* Preview frame */
    .card-preview {
        min-height: 300px;
        padding: 10px;
        margin: 10px 0;
    }

    .preview-frame {
        transform: scale(0.8);
        transform-origin: top center;
        margin-bottom: -20%;
    }

    /* Button groups */
    .button-group {
        flex-direction: column;
        width: 100%;
    }

    .button-group .btn {
        width: 100%;
        margin: 5px 0;
    }

    /* Bottom actions */
    .qr-options {
        flex-direction: column;
        align-items: stretch;
    }

    .qr-preview {
        width: 100%;
        max-width: 200px;
        margin: 10px auto;
    }

    /* Floating action button for personalization */
    .personalize-fab {
        position: fixed;
        bottom: 20px;
        right: 20px;
        width: 56px;
        height: 56px;
        border-radius: 50%;
        background: var(--primary);
        color: white;
        display: flex;
        align-items: center;
        justify-content: center;
        box-shadow: 0 4px 12px rgba(0,0,0,0.2);
        z-index: 1000;
        cursor: pointer;
        transition: all 0.3s ease;
    }

    .personalize-fab:hover {
        transform: scale(1.1);
    }

    .personalize-fab i {
        font-size: 24px;
    }

    /* Mobile menu */
    .mobile-menu {
        display: flex;
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        background: rgba(255, 255, 255, 0.95);
        backdrop-filter: blur(10px);
        padding: 10px;
        box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.1);
        z-index: 999;
        justify-content: space-around;
        border-top: 1px solid rgba(0, 0, 0, 0.1);
    }

    .mobile-menu-item {
        display: flex;
        flex-direction: column;
        align-items: center;
        padding: 8px;
        color: var(--text-dark);
        text-decoration: none;
        font-size: 0.75rem;
        opacity: 0.7;
        transition: all 0.3s ease;
    }

    .mobile-menu-item i {
        font-size: 1.2rem;
        margin-bottom: 4px;
    }

    .mobile-menu-item.active {
        color: var(--primary);
        opacity: 1;
    }

    .mobile-menu-item:hover {
        opacity: 1;
        transform: translateY(-2px);
    }

    /* Adjust main content padding for mobile menu */
    .container {
        padding-bottom: 80px;
    }

    /* Move toast notifications above mobile menu */
    .toast {
        bottom: 80px;
    }
}

/* Hide mobile menu on desktop */
@media (min-width: 769px) {
    .mobile-menu {
        display: none !important;
    }
}

/* Preview Styles */
.preview-wrapper {
    width: 100%;
    max-width: 800px;
    margin: 0 auto;
    padding: 20px;
    background: #f8f9fa;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.card {
    width: 100%;
    height: 100%;
    min-height: 300px;
    padding: 2rem;
    background-color: white;
    border-radius: 8px;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
    position: relative;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    margin: 0 auto;
    max-width: 100%;
    background-position: center;
    background-size: cover;
    background-repeat: no-repeat;
}

.card[style*="background-image"] {
    background-color: transparent;
}

.card-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 1;
}

.card-text {
    position: relative;
    z-index: 2;
    text-align: center;
    padding: 1.5rem;
    max-width: 90%;
    width: 90%;
    background-color: rgba(255, 255, 255, 0.8);
    border-radius: 6px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    margin: 0 auto;
    word-wrap: break-word;
    overflow-wrap: break-word;
}

/* Card Sizes */
.card.size-4x6 {
    width: 400px;
    height: 600px;
    max-width: 100%;
}

.card.size-5x7 {
    width: 500px;
    height: 700px;
    max-width: 100%;
}

.card.size-a5 {
    width: 420px;
    height: 595px;
    max-width: 100%;
}

.card.size-a4 {
    width: 595px;
    height: 842px;
    max-width: 100%;
}

/* Card Templates */
.card.template-classic {
    background-color: #fff;
    border: 2px solid #ddd;
}

.card.template-modern {
    background: linear-gradient(135deg, #f6f8f9 0%, #fff 100%);
}

.card.template-floral {
    background-color: #fff;
    background-image: url('data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSI0MCIgaGVpZ2h0PSI0MCIgdmlld0JveD0iMCAwIDQwIDQwIj48cGF0aCBkPSJNMjAgMGMxMSAwIDIwIDkgMjAgMjBzLTkgMjAtMjAgMjBTMCAzMSAwIDIwIDkgMCAyMCAwem0wIDJjLTkuOSAwLTE4IDguMS0xOCAxOHM4LjEgMTggMTggMTggMTgtOC4xIDE4LTE4UzI5LjkgMiAyMCAyeiIgZmlsbD0iI2YwZjBmMCIvPjwvc3ZnPg==');
}

.card.template-islamic {
    background-color: #fff;
    border: 8px double #2c3e50;
}

/* Responsive adjustments */
@media (max-width: 768px) {
    .preview-content {
        padding: 0.5rem;
        width: 100%;
        display: flex;
        justify-content: center;
        align-items: center;
    }
    
    .card {
        transform: scale(0.95);
        transform-origin: center;
        max-width: 100%;
        width: 100%;
        margin: 0 auto;
    }
    
    .card.size-4x6,
    .card.size-5x7,
    .card.size-a5,
    .card.size-a4 {
        width: 90%;
        height: auto;
        aspect-ratio: 2/3;
        max-height: 70vh;
    }
}

/* Extra small devices */
@media (max-width: 480px) {
    .card {
        transform: scale(0.9);
        padding: 1rem;
    }
    
    .card-text {
        padding: 1rem;
        width: 95%;
        max-width: 95%;
        font-size: 0.9rem;
    }
    
    .main-content {
        padding: 0;
    }
    
    .section {
        padding: 0.8rem;
    }
}

.bg-upload-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    background-color: var(--primary);
    color: white;
    border-radius: 50px;
    cursor: pointer;
    font-weight: 600;
    transition: all 0.3s ease;
}

.bg-upload-btn:hover {
    background-color: var(--primary-dark);
}

.bg-upload {
    display: none;
}

.background-options {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.5rem;
}

.bg-settings {
    background-color: rgba(156, 39, 176, 0.05);
    padding: 0.75rem;
    border-radius: 8px;
    margin-top: 0.5rem;
}

/* Card wrapper for better mobile centering */
.card-wrapper {
    width: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
    margin: 0 auto;
}

@media (max-width: 768px) {
    .card-wrapper {
        padding: 0;
    }

    .preview-container {
        padding: 10px 5px;
    }
    
    .option-group {
        margin-bottom: 10px;
    }

    .button-group {
        flex-direction: column;
    }
    
    .button-group .btn {
        width: 100%;
        margin-bottom: 8px;
    }
}

/* Text Formatting Tools */
.text-formatting-tools {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 1rem;
    padding: 8px;
    background-color: rgba(156, 39, 176, 0.05);
    border-radius: 8px;
    align-items: center;
}

.format-btn {
    width: 40px;
    height: 40px;
    border-radius: 6px;
    background-color: white;
    border: 1px solid #ddd;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s ease;
    color: var(--text-dark);
    position: relative;
}

.format-btn:hover {
    background-color: var(--secondary-light);
    color: var(--text-dark);
    border-color: var(--primary-light);
    transform: translateY(-2px);
}

.format-btn.active {
    background-color: var(--primary);
    color: white;
    border-color: var(--primary-dark);
}

.format-color-picker {
    position: absolute;
    width: 30px;
    height: 30px;
    opacity: 0;
    cursor: pointer;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 1;
}

/* Show a small color indicator */
.format-btn[data-format="color"]::after {
    content: '';
    position: absolute;
    bottom: 5px;
    right: 5px;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background-color: var(--text-format-color, #000000); /* Use variable with fallback */
    border: 1px solid #ddd;
}

/* Mobile responsiveness for format buttons */
@media (max-width: 480px) {
    .text-formatting-tools {
        gap: 4px;
        padding: 6px;
    }
    
    .format-btn {
        width: 36px;
        height: 36px;
        border-radius: 4px;
    }
} 