/* Font face declarations */
@font-face {
    font-family: 'CormorantGaramond-MediumItalic';
    font-style: italic;
    font-weight: 500;
    src: url('fonts/CormorantGaramond-MediumItalic.ttf') format('truetype');
}
@font-face {
    font-family: 'CormorantGaramond-BoldItalic';
    font-style: italic;
    font-weight: 700;
    src: url('fonts/CormorantGaramond-BoldItalic.ttf') format('truetype');
}

:root {
    /* Sage Green + Gold + Cream palette */
    --sage: #5B7B5D;
    --sage-dark: #2D5A3D;
    --sage-light: #7A9E7C;
    --gold: #B8934A;
    --gold-light: #D4AD5E;
    --gold-dark: #9A7B3A;
    --cream: #FEFCF6;
    --cream-dark: #F5F0E4;
    --charcoal: #333333;
    --charcoal-light: #555555;
    --white: #FFFFFF;

    /* Fonts */
    --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    --font-serif: 'Cormorant Garamond', Georgia, serif;
    --font-display: 'Playfair Display', Georgia, serif;

    /* UI Colors */
    --panel-bg: #1a2e22;
    --panel-border: rgba(91, 123, 93, 0.2);
    --input-bg: rgba(255,255,255,0.06);
    --input-border: rgba(255,255,255,0.1);
    --input-focus: rgba(91, 123, 93, 0.5);
    --text-light: rgba(255,255,255,0.7);
    --text-dim: rgba(255,255,255,0.45);
}

html { font-size: 16px; scroll-behavior: smooth; }

body {
    font-family: var(--font-sans);
    background: linear-gradient(135deg, #0f1f15 0%, #1a2e22 40%, #1f3328 100%);
    color: var(--charcoal);
    min-height: 100vh;
    display: flex;
    overflow: hidden;
}

/* ================================================
   INPUT PANEL
   ================================================ */

.input-panel {
    width: 400px;
    min-width: 360px;
    height: 100vh;
    overflow-y: auto;
    background: rgba(255,255,255,0.03);
    backdrop-filter: blur(20px);
    border-right: 1px solid var(--panel-border);
    padding: 2rem 1.5rem;
    display: flex;
    flex-direction: column;
}

.input-panel::-webkit-scrollbar { width: 5px; }
.input-panel::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.12); border-radius: 3px; }

.input-panel-inner { flex: 1; }

.brand-header {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 1.5rem;
}

.brand-icon {
    font-size: 2rem;
    width: 48px;
    height: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(91, 123, 93, 0.15);
    border: 1px solid rgba(91, 123, 93, 0.3);
    border-radius: 12px;
}

#app-title {
    font-family: var(--font-display);
    font-size: 1.3rem;
    font-weight: 700;
    color: var(--cream);
    line-height: 1.3;
}

.brand-subtitle {
    font-size: 0.7rem;
    color: var(--sage-light);
    font-weight: 500;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    margin-top: 2px;
}

.input-description {
    font-size: 0.82rem;
    color: var(--text-dim);
    line-height: 1.6;
    margin-bottom: 1.5rem;
    padding: 0.75rem 1rem;
    background: rgba(91, 123, 93, 0.06);
    border-left: 3px solid var(--sage);
    border-radius: 0 8px 8px 0;
}

/* Form */
.invitation-form { display: flex; flex-direction: column; gap: 1.25rem; }
.form-group { display: flex; flex-direction: column; gap: 0.4rem; }

.form-label {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-light);
    letter-spacing: 0.04em;
    text-transform: uppercase;
    display: flex;
    align-items: center;
    gap: 0.4rem;
}
.label-icon { font-size: 0.95rem; }

.form-input {
    width: 100%;
    padding: 12px 16px;
    font-family: var(--font-sans);
    font-size: 0.9rem;
    color: var(--cream);
    background: var(--input-bg);
    border: 1px solid var(--input-border);
    border-radius: 10px;
    outline: none;
    transition: all 0.3s ease;
}
.form-input::placeholder { color: rgba(255,255,255,0.2); }
.form-input:focus {
    border-color: var(--sage);
    background: rgba(255,255,255,0.09);
    box-shadow: 0 0 0 3px rgba(91, 123, 93, 0.15);
}

/* Buttons */
.form-actions { display: flex; gap: 0.75rem; margin-top: 0.25rem; }

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
    padding: 11px 18px;
    font-family: var(--font-sans);
    font-size: 0.82rem;
    font-weight: 600;
    border: none;
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.3s ease;
    white-space: nowrap;
}
.btn-icon { font-size: 1rem; }

.btn-primary {
    flex: 1;
    background: linear-gradient(135deg, var(--sage) 0%, var(--sage-dark) 100%);
    color: white;
    box-shadow: 0 4px 15px rgba(91, 123, 93, 0.3);
}
.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 25px rgba(91, 123, 93, 0.4);
    background: linear-gradient(135deg, var(--sage-light) 0%, var(--sage) 100%);
}
.btn-primary:active { transform: translateY(0); }

.btn-secondary {
    flex: 0.7;
    background: rgba(255,255,255,0.08);
    color: var(--cream);
    border: 1px solid rgba(255,255,255,0.12);
}
.btn-secondary:hover:not(:disabled) { background: rgba(255,255,255,0.12); border-color: rgba(255,255,255,0.2); }
.btn-secondary:disabled { opacity: 0.4; cursor: not-allowed; }

.btn-outline {
    width: 100%;
    background: transparent;
    color: var(--text-dim);
    border: 1px dashed rgba(255,255,255,0.12);
    padding: 9px 14px;
}
.btn-outline:hover { border-color: var(--sage); color: var(--sage-light); background: rgba(91, 123, 93, 0.06); }

/* Bulk */
.bulk-section { margin-top: 1.5rem; padding-top: 1.5rem; border-top: 1px solid rgba(255,255,255,0.06); }
.bulk-panel { margin-top: 1rem; animation: slideDown 0.3s ease; }
.bulk-hint { font-size: 0.75rem; color: var(--text-dim); margin-bottom: 0.75rem; }
.bulk-hint code { background: rgba(255,255,255,0.08); padding: 2px 6px; border-radius: 4px; font-size: 0.72rem; color: var(--sage-light); }

.form-textarea {
    width: 100%;
    padding: 12px 16px;
    font-family: var(--font-sans);
    font-size: 0.82rem;
    color: var(--cream);
    background: var(--input-bg);
    border: 1px solid var(--input-border);
    border-radius: 10px;
    outline: none;
    resize: vertical;
    min-height: 100px;
    transition: all 0.3s ease;
    margin-bottom: 0.75rem;
}
.form-textarea::placeholder { color: rgba(255,255,255,0.2); }
.form-textarea:focus { border-color: var(--sage); background: rgba(255,255,255,0.09); box-shadow: 0 0 0 3px rgba(91, 123, 93, 0.15); }

.bulk-progress { margin-top: 0.75rem; }
.progress-bar { width: 100%; height: 5px; background: rgba(255,255,255,0.08); border-radius: 3px; overflow: hidden; }
.progress-fill { height: 100%; background: linear-gradient(90deg, var(--sage), var(--sage-light)); border-radius: 3px; width: 0%; transition: width 0.4s ease; }
.progress-text { font-size: 0.72rem; color: var(--text-dim); margin-top: 0.4rem; text-align: center; }

.hidden { display: none !important; }

/* ================================================
   PREVIEW PANEL
   ================================================ */

.preview-panel {
    flex: 1;
    height: 100vh;
    overflow-y: auto;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2rem;
    background: radial-gradient(ellipse at 40% 50%, rgba(91, 123, 93, 0.06) 0%, transparent 60%);
}
.preview-panel::-webkit-scrollbar { width: 5px; }
.preview-panel::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.08); border-radius: 3px; }

.preview-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 100%;
    max-width: 600px;
}

.preview-title {
    font-family: var(--font-sans);
    font-size: 0.7rem;
    font-weight: 600;
    color: rgba(255,255,255,0.3);
    letter-spacing: 0.2em;
    margin-bottom: 1rem;
}

.preview-hint {
    font-size: 0.8rem;
    color: rgba(255,255,255,0.3);
    margin-top: 1rem;
    text-align: center;
}

/* ================================================
   INVITATION CARD (IMAGE OVERLAY)
   ================================================ */

.invitation-card {
    position: relative;
    width: 100%;
    /* Keep A4 aspect ratio */
    aspect-ratio: 1024 / 1024; /* The generated image is actually square 1024x1024! */
    max-width: 600px;
    background: #FEFCF6;
    overflow: hidden;
    box-shadow: 0 20px 60px rgba(0,0,0,0.3), 0 0 0 1px rgba(184, 147, 74, 0.1);
    transition: transform 0.4s ease;
}

.invitation-card:hover {
    transform: scale(1.005);
}

.template-bg {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: contain;
    z-index: 1;
}

/* Dynamic Text Overlay */
.dynamic-overlay {
    position: absolute;
    top: 27.0%;
    left: 8%;
    width: 84%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    z-index: 2;
    pointer-events: none;
}

/* Salutation Typography matching the image */
.salutation {
    font-family: var(--font-serif);
    font-size: clamp(0.85rem, 2.7vw, 1.8rem);
    font-weight: 500;
    font-style: italic;
    color: #2D5A3D;
    line-height: 1.2;
    margin: 0;
    padding: 0;
}

.display-name {
    font-weight: 700;
}

.nickname {
    font-family: var(--font-serif);
    font-size: clamp(0.7rem, 2.2vw, 1.4rem);
    font-weight: 500;
    font-style: italic;
    color: #2D5A3D;
    line-height: 1.2;
    margin-top: 0.2rem;
    opacity: 0.9;
}

/* ================================================
   ANIMATIONS
   ================================================ */

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

@keyframes fadeIn {
    from { opacity: 0; transform: scale(0.98); }
    to { opacity: 1; transform: scale(1); }
}

.invitation-card.generated {
    animation: fadeIn 0.5s ease;
}

/* ================================================
   RESPONSIVE
   ================================================ */

@media (max-width: 900px) {
    body { flex-direction: column; overflow: auto; }
    .input-panel {
        width: 100%;
        min-width: unset;
        height: auto;
        border-right: none;
        border-bottom: 1px solid var(--panel-border);
    }
    .preview-panel { height: auto; min-height: 60vh; padding: 1.5rem 1rem; }
    .preview-container { max-width: 480px; }
    .form-actions { flex-direction: column; }
}

@media (max-width: 480px) {
    .input-panel { padding: 1rem; }
    #app-title { font-size: 1.1rem; }
    .preview-panel { padding: 1rem 0.75rem; }
}

/* Print */
@media print {
    body { background: white; }
    .input-panel { display: none; }
    .preview-panel { width: 100%; padding: 0; }
    .invitation-card { box-shadow: none; max-height: none; }
    .preview-title, .preview-hint { display: none; }
}
