/* CSS Reset & Base */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

:root {
    --primary-color: #6366f1;
    --primary-dark: #4f46e5;
    --text-color: #1f2937;
    --text-light: #6b7280;
    --bg-color: rgb(254, 243, 199);
    --card-bg: #ffffff;
    --border-color: #e5e7eb;
    --shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -2px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -4px rgba(0, 0, 0, 0.1);
    --radius: 12px;
    --radius-sm: 8px;

    /* Card panel colors */
    --panel-1: #1e3a5f;
    --panel-2: #2d5a3d;
    --panel-3: #8b2942;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
    background: var(--bg-color);
    color: var(--text-color);
    line-height: 1.6;
    min-height: 100vh;
}

.container {
    max-width: 600px;
    margin: 0 auto;
    padding: 16px;
}

/* Header */
header {
    text-align: center;
    padding: 24px 0;
}

.header-logo {
    max-width: 200px;
    height: auto;
    margin-bottom: 16px;
}

header h1 {
    font-size: 1.75rem;
    font-weight: 700;
    color: var(--primary-color);
    margin-bottom: 8px;
}

.tagline {
    color: var(--text-light);
    font-size: 0.95rem;
}

/* Hero Example Section */
.hero-example {
    background: var(--card-bg);
    border-radius: var(--radius);
    padding: 20px;
    margin-bottom: 16px;
    box-shadow: var(--shadow);
    text-align: center;
}

.hero-text {
    font-size: 0.95rem;
    color: var(--text-color);
    margin-bottom: 16px;
}

.hero-cards {
    display: flex;
    gap: 16px;
    justify-content: center;
    flex-wrap: wrap;
}

.hero-card-wrapper {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
}

.hero-label {
    font-size: 0.75rem;
    color: var(--text-light);
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* Example Card Front - MOO ratio */
.example-front {
    display: flex;
    width: 175px;
    height: 100px;
    border-radius: var(--radius-sm);
    overflow: hidden;
    box-shadow: var(--shadow);
}

.example-panel {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
}

.example-starburst {
    width: 36px;
    height: 36px;
    background: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 0 0 4px rgba(255,255,255,0.3);
}

.example-starburst span {
    font-weight: 700;
    font-size: 6px;
    color: #1f2937;
    text-align: center;
    line-height: 1.1;
}

/* Example Card Back - MOO ratio */
.example-back {
    width: 175px;
    height: 100px;
    background: white;
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow);
    padding: 8px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
}

.example-text {
    font-size: 5px;
    line-height: 1.4;
    color: var(--text-color);
}

.example-text p {
    margin-bottom: 3px;
}

.example-branding {
    display: flex;
    justify-content: flex-end;
    align-items: center;
}

.example-branding img {
    height: 12px;
    width: auto;
}

@media (min-width: 480px) {
    .example-front,
    .example-back {
        width: 224px;
        height: 128px;
    }

    .example-starburst {
        width: 42px;
        height: 42px;
        box-shadow: 0 0 0 5px rgba(255,255,255,0.3);
    }

    .example-starburst span {
        font-size: 7px;
    }

    .example-back {
        padding: 12px;
    }

    .example-text {
        font-size: 6.5px;
    }

    .example-branding img {
        height: 16px;
    }
}

/* Sections */
.section {
    background: var(--card-bg);
    border-radius: var(--radius);
    padding: 20px;
    margin-bottom: 16px;
    box-shadow: var(--shadow);
}

.section h2 {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-color);
    margin-bottom: 16px;
}

/* Template Grid */
.template-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 12px;
}

.template-card {
    border: 2px solid var(--border-color);
    border-radius: var(--radius-sm);
    padding: 16px;
    cursor: pointer;
    transition: all 0.2s ease;
    background: var(--card-bg);
}

.template-card:hover {
    border-color: var(--primary-color);
    transform: translateY(-2px);
}

.template-card.selected {
    border-color: var(--primary-color);
    background: rgba(99, 102, 241, 0.05);
}

.template-card h4 {
    font-size: 0.9rem;
    font-weight: 600;
    margin-bottom: 4px;
    color: var(--text-color);
}

.template-card p {
    font-size: 0.8rem;
    color: var(--text-light);
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* Editor Section Titles */
.editor-section-title {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text-light);
    margin-bottom: 12px;
    margin-top: 8px;
    padding-bottom: 8px;
    border-bottom: 1px solid var(--border-color);
}

.editor-section-title:first-child {
    margin-top: 0;
}

/* Form Elements */
.form-group {
    margin-bottom: 16px;
}

.form-group:last-child {
    margin-bottom: 0;
}

.form-group label {
    display: block;
    font-size: 0.875rem;
    font-weight: 500;
    margin-bottom: 6px;
    color: var(--text-color);
}

.form-row {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
}

.form-group-third {
    flex: 1;
    min-width: 80px;
}

input[type="text"],
textarea {
    width: 100%;
    padding: 12px;
    border: 2px solid var(--border-color);
    border-radius: var(--radius-sm);
    font-size: 1rem;
    font-family: inherit;
    transition: border-color 0.2s ease;
    background: var(--card-bg);
}

input[type="text"]:focus,
textarea:focus {
    outline: none;
    border-color: var(--primary-color);
}

textarea {
    resize: vertical;
    min-height: 60px;
}

/* Checkbox */
.checkbox-label {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    font-size: 0.9rem;
}

.checkbox-label input[type="checkbox"] {
    width: 18px;
    height: 18px;
    cursor: pointer;
}

/* Card Preview */
.preview-container {
    display: flex;
    justify-content: center;
    gap: 16px;
    padding: 16px 0;
    flex-wrap: wrap;
}

.preview-card-wrapper {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
}

.preview-label {
    font-size: 0.75rem;
    color: var(--text-light);
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* Card Front - MOO business card ratio 3.5:2 */
.card-front {
    display: flex;
    width: 210px;
    height: 120px;
    border-radius: var(--radius-sm);
    overflow: hidden;
    box-shadow: var(--shadow);
}

.card-panel {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
}

.panel-1 { background: var(--panel-1); }
.panel-2 { background: var(--panel-2); }
.panel-3 { background: var(--panel-3); }

/* Badge */
.starburst {
    width: 45px;
    height: 45px;
    background: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 0 0 5px rgba(255,255,255,0.3);
}

.starburst span {
    font-weight: 700;
    font-size: 7px;
    color: #1f2937;
    text-align: center;
    line-height: 1.1;
}

/* Card Back - MOO business card ratio 3.5:2 */
.card-back {
    width: 210px;
    height: 120px;
    background: white;
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow);
    padding: 10px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    box-sizing: border-box;
}

.card-back-content {
    font-size: 6px;
    line-height: 1.4;
    color: var(--text-color);
}

.card-back-content p {
    margin-bottom: 4px;
}

.card-back-content p:last-child {
    margin-bottom: 0;
}

.card-back-content strong {
    color: var(--text-color);
}

.card-back-branding {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 6px;
    margin-top: 6px;
    padding-top: 6px;
    border-top: 1px solid var(--border-color);
}

.card-back-branding .qr-code {
    width: 28px;
    height: 28px;
}

.branding-text {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 2px;
}

.branding-text img {
    height: 14px;
    width: auto;
}

.branding-text span {
    font-size: 5px;
    color: var(--text-light);
    font-style: italic;
}

/* Checkbox group */
.checkbox-group {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

/* Export Options */
.export-options {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 14px 24px;
    border-radius: var(--radius-sm);
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    border: none;
    font-family: inherit;
}

.btn-primary {
    background: var(--primary-color);
    color: white;
}

.btn-primary:hover {
    background: var(--primary-dark);
    transform: translateY(-1px);
}

.btn-secondary {
    background: white;
    color: var(--text-color);
    border: 2px solid var(--border-color);
}

.btn-secondary:hover {
    border-color: var(--primary-color);
    color: var(--primary-color);
}

.btn-icon {
    font-size: 1.2rem;
}

.export-hint {
    font-size: 0.8rem;
    color: var(--text-light);
    text-align: center;
    margin-top: 12px;
}

/* Format Selection */
.format-selection {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-bottom: 16px;
}

.format-option {
    cursor: pointer;
}

.format-option input {
    display: none;
}

.format-card {
    display: flex;
    flex-direction: column;
    gap: 4px;
    padding: 14px 16px;
    border: 2px solid var(--border-color);
    border-radius: var(--radius-sm);
    transition: all 0.2s ease;
}

.format-card strong {
    font-size: 0.95rem;
    color: var(--text-color);
}

.format-card span {
    font-size: 0.8rem;
    color: var(--text-light);
}

.format-option input:checked + .format-card {
    border-color: var(--primary-color);
    background: rgba(99, 102, 241, 0.05);
}

.avery-link {
    font-size: 0.85rem;
    text-align: center;
    margin-top: 12px;
    padding: 10px;
    background: #fef3c7;
    border-radius: var(--radius-sm);
}

.avery-link a {
    color: var(--primary-color);
    font-weight: 500;
}

@media (min-width: 480px) {
    .format-selection {
        flex-direction: row;
    }

    .format-option {
        flex: 1;
    }
}

/* Donation Section */
.donation-section {
    background: linear-gradient(135deg, #fef3c7 0%, #fde68a 100%);
    border: 2px solid #f59e0b;
}

.donation-content {
    text-align: center;
}

.donation-content h3 {
    font-size: 1.1rem;
    font-weight: 600;
    color: #92400e;
    margin-bottom: 8px;
}

.donation-content p {
    font-size: 0.9rem;
    color: #78350f;
    margin-bottom: 16px;
    line-height: 1.5;
}

.btn-donate {
    display: inline-flex;
    background: #f59e0b;
    color: white;
    text-decoration: none;
    padding: 12px 24px;
    border-radius: var(--radius-sm);
    font-weight: 600;
    transition: all 0.2s ease;
}

.btn-donate:hover {
    background: #d97706;
    transform: translateY(-1px);
}

/* App Footer */
.app-footer {
    text-align: center;
    padding: 24px 0;
    color: var(--text-light);
    font-size: 0.875rem;
}

.footer-logo {
    max-width: 150px;
    height: auto;
    margin-bottom: 12px;
}

.app-footer a {
    color: var(--primary-color);
    text-decoration: none;
    font-weight: 500;
}

.app-footer a:hover {
    text-decoration: underline;
}

.footer-sub {
    font-size: 0.8rem;
    margin-top: 4px;
    color: var(--text-light);
}

/* Tablet and up */
@media (min-width: 480px) {
    .container {
        padding: 24px;
    }

    header h1 {
        font-size: 2rem;
    }

    .section {
        padding: 24px;
    }

    .template-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .export-options {
        flex-direction: row;
    }

    .btn {
        flex: 1;
    }

    /* Larger preview cards - MOO ratio */
    .card-front,
    .card-back {
        width: 280px;
        height: 160px;
    }

    .starburst {
        width: 55px;
        height: 55px;
        box-shadow: 0 0 0 6px rgba(255,255,255,0.3);
    }

    .starburst span {
        font-size: 8px;
    }

    .card-back {
        padding: 12px;
    }

    .card-back-content {
        font-size: 7px;
    }

    .card-back-content p {
        margin-bottom: 5px;
    }

    .card-back-branding .qr-code {
        width: 32px;
        height: 32px;
    }

    .branding-text img {
        height: 16px;
    }

    .branding-text span {
        font-size: 6px;
    }
}

/* Desktop */
@media (min-width: 768px) {
    .container {
        padding: 32px;
    }

    header {
        padding: 40px 0;
    }

    .section {
        padding: 32px;
        margin-bottom: 24px;
    }
}

/* Toast notification */
.toast {
    position: fixed;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%) translateY(100px);
    background: var(--text-color);
    color: white;
    padding: 12px 24px;
    border-radius: var(--radius-sm);
    font-size: 0.9rem;
    opacity: 0;
    transition: all 0.3s ease;
    z-index: 1000;
}

.toast.show {
    transform: translateX(-50%) translateY(0);
    opacity: 1;
}

/* Loading state */
.btn.loading {
    opacity: 0.7;
    pointer-events: none;
}

.btn.loading::after {
    content: '';
    width: 16px;
    height: 16px;
    border: 2px solid transparent;
    border-top-color: currentColor;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin-left: 8px;
}

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