:root {
    --bucci-blue: #94bfe2;
    --bucci-dark: #0e2a47;
    --bucci-accent: #195286;
    --bucci-light: #f1f7fc;
    --bucci-grey: #424242;
    --bg-panel: #ffffff;
    --text-main: #1e293b;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    font-family: 'Montserrat', system-ui, -apple-system, sans-serif;
}

.windsong-regular {
    font-family: "WindSong", cursive;
    font-weight: 400;
    font-style: normal;
}

.windsong-medium {
    font-family: "WindSong", cursive;
    font-weight: 500;
    font-style: normal;
}

.waterfall-regular {
    font-family: "Waterfall", cursive;
    font-weight: 400;
    font-style: normal;
}



body {
    background: #e9f2f8;
    color: var(--text-main);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* Top Navigation Bar */
header {
    background: var(--bucci-dark);
    color: #ffffff;
    padding: 12px 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 4px solid var(--bucci-blue);
    box-shadow: 0 4px 12px rgba(14, 42, 71, 0.15);
}

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

header .brand-title {
    font-size: 1.15rem;
    font-weight: 800;
    letter-spacing: 0.5px;
    color: #ffffff;
}

header .brand-sub {
    font-size: 0.75rem;
    color: var(--bucci-blue);
    text-transform: uppercase;
    letter-spacing: 1.5px;
    font-weight: 600;
}

/* Main App Layout */
.app-container {
    display: grid;
    grid-template-columns: 420px 1fr;
    gap: 24px;
    padding: 24px;
    max-width: 1400px;
    margin: 0 auto;
    width: 100%;
    flex: 1;
}

@media (max-width: 992px) {
    .app-container {
        grid-template-columns: 1fr;
    }
}

/* Controls Panel */
.panel {
    background: var(--bg-panel);
    border-radius: 16px;
    padding: 24px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.05);
    border: 1px solid #d8e5f0;
    display: flex;
    flex-direction: column;
    gap: 22px;
    max-height: calc(100vh - 110px);
    overflow-y: auto;
}

.section-title {
    font-size: 0.8rem;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--bucci-accent);
    margin-bottom: 8px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

label {
    font-size: 0.8rem;
    font-weight: 700;
    color: #334155;
}

input[type="text"],
textarea,
select {
    width: 100%;
    padding: 10px 12px;
    border: 1.5px solid #cbd5e1;
    border-radius: 10px;
    font-size: 0.875rem;
    background: #f8fafc;
    transition: all 0.2s;
}

input[type="text"]:focus,
textarea:focus,
select:focus {
    outline: none;
    border-color: var(--bucci-accent);
    background: #ffffff;
    box-shadow: 0 0 0 3px rgba(148, 191, 226, 0.4);
}

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

.template-card {
    padding: 10px;
    border: 2px solid #e2e8f0;
    border-radius: 10px;
    cursor: pointer;
    background: #ffffff;
    transition: all 0.2s;
    text-align: left;
}

.template-card:hover {
    border-color: var(--bucci-blue);
    transform: translateY(-1px);
}

.template-card.active {
    border-color: var(--bucci-accent);
    background: #f0f7fd;
    box-shadow: 0 0 0 2px var(--bucci-blue);
}

.template-card .tpl-name {
    font-weight: 800;
    font-size: 0.85rem;
    color: var(--bucci-dark);
    display: flex;
    align-items: center;
    gap: 6px;
}

.template-card .tpl-desc {
    font-size: 0.72rem;
    color: #64748b;
    margin-top: 2px;
}

/* Button Toolbar for Styles */
.button-group {
    display: flex;
    gap: 6px;
    background: #f1f5f9;
    padding: 4px;
    border-radius: 10px;
}

.btn-toggle {
    flex: 1;
    border: none;
    background: transparent;
    padding: 8px;
    font-size: 0.85rem;
    border-radius: 6px;
    cursor: pointer;
    color: #475569;
    font-weight: 600;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    transition: all 0.15s;
}

.btn-toggle:hover {
    background: #e2e8f0;
}

.btn-toggle.active {
    background: #ffffff;
    color: var(--bucci-dark);
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.08);
    font-weight: 800;
}

/* Range Sliders */
.range-wrap {
    display: flex;
    align-items: center;
    gap: 12px;
}

.range-wrap input[type="range"] {
    flex: 1;
    accent-color: var(--bucci-accent);
    cursor: pointer;
}

.range-val {
    font-size: 0.8rem;
    font-weight: 700;
    color: var(--bucci-accent);
    min-width: 44px;
}

/* Upload & Reset Buttons */
.file-btn-wrap {
    display: flex;
    gap: 8px;
    align-items: center;
}

.btn-secondary {
    background: #ffffff;
    border: 1.5px solid #cbd5e1;
    padding: 8px 14px;
    border-radius: 8px;
    font-size: 0.8rem;
    font-weight: 700;
    color: var(--bucci-dark);
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    transition: all 0.2s;
}

.btn-secondary:hover {
    background: #f1f5f9;
    border-color: #94a3b8;
}

/* Download Action Buttons */
.actions-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    margin-top: 6px;
}

.btn-download {
    padding: 12px 16px;
    border: none;
    border-radius: 10px;
    font-size: 0.88rem;
    font-weight: 800;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: all 0.2s;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.1);
}

.btn-jpg {
    background: var(--bucci-accent);
    color: #ffffff;
}

.btn-jpg:hover {
    background: #0f3d67;
    transform: translateY(-1px);
}

.btn-pdf {
    background: var(--bucci-dark);
    color: #ffffff;
}

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

/* Live Preview Column */
.preview-col {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 10px;
}

.preview-header {
    width: 100%;
    max-width: 720px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
}

.preview-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: #dbeefd;
    color: var(--bucci-dark);
    padding: 5px 12px;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* CARD ROOT CANVAS (Standard 4:3 Ratio for Greeting Card) */
.card-wrap {
    width: 100%;
    max-width: 720px;
    aspect-ratio: 4 / 3;
    position: relative;
    border-radius: 20px;
    overflow: hidden;
    box-shadow: 0 14px 40px rgba(14, 42, 71, 0.22);
    transition: all 0.3s ease;
    display: flex;
    flex-direction: column;
}

/* ============================================================
       CARD TEMPLATES (All anchored on dominant #94bfe2)
       ============================================================ */

/* Layout 01: Classic Buccinasco (Soft Blue Gradient + Triple Frame) */
.tpl-layout1 {
    background: linear-gradient(135deg, #ffffff 0%, #e8f4fc 40%, #94bfe2 100%);
    color: #0e2a47;
    border: 8px solid #94bfe2;
}

.tpl-layout1 .card-inner-frame {
    border: 2px solid #4a86b9;
    border-radius: 12px;
}

/* Layout 02: Rugby Field & Posts (Rich #94bfe2 with subtle diagonal grid) */
.tpl-layout2 {
    background: radial-gradient(circle at 90% 10%, #d8ecf8 0%, #94bfe2 60%, #6da9d8 100%);
    color: #081d33;
    border: 8px solid #0e2a47;
}

.tpl-layout2 .card-inner-frame {
    border: 2px dashed rgba(255, 255, 255, 0.9);
    border-radius: 14px;
    background: repeating-linear-gradient(45deg, transparent, transparent 15px, rgba(255, 255, 255, 0.08) 15px, rgba(255, 255, 255, 0.08) 30px);
}

/* Layout 03: Contrast Hoops (Navy Header & Foot with #94bfe2 core) */
.tpl-layout3 {
    background: #ffffff;
    color: #0e2a47;
    border: 8px solid #94bfe2;
}

.tpl-layout3 .card-inner-frame {
    border: 3px solid #0e2a47;
    border-radius: 12px;
    background: linear-gradient(180deg, rgba(148, 191, 226, 0.25) 0%, #ffffff 40%, #ffffff 75%, rgba(148, 191, 226, 0.4) 100%);
}

/* Layout 04: Solid Club Blue (#94bfe2 full body with crisp white inner pill) */
.tpl-layout4 {
    background: #94bfe2;
    color: #091c30;
    border: 8px solid #ffffff;
}

.tpl-layout4 .card-inner-frame {
    border: 2px dashed #0e2a47;
    border-radius: 20px;
    background: rgba(255, 255, 255, 0.35);
}

/* Card Internal Geometry */
.card-inner-frame {
    margin: 10px;
    padding: 16px 20px 12px 20px;
    display: flex;
    flex-direction: column;
    flex: 1;
    position: relative;
    z-index: 1;
}

/* Card Top Header / Top Emblem */
.card-top-icon {
    text-align: center;
    font-size: 1.5rem;
    color: var(--bucci-dark);
    opacity: 0.85;
    margin-bottom: 6px;
}

/* Card Middle Content: 2-column flex */
.card-body-content {
    display: flex;
    align-items: center;
    gap: 18px;
    flex: 1;
    min-height: 0;
    /* Prevents overflow */
}

.card-left-img-wrap {
    width: 40%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.card-left-img-wrap img {
    max-width: 100%;
    max-height: 250px;
    object-fit: contain;
    filter: drop-shadow(0 6px 12px rgba(0, 0, 0, 0.15));
    transition: transform 0.2s;
}

.card-right-text-wrap {
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
    overflow: hidden;
    padding: 4px 6px;
}

.card-title-display {
    font-size: 1.35rem;
    font-weight: 800;
    margin-bottom: 8px;
    line-height: 1.25;
    letter-spacing: -0.3px;
}

.card-message-display {
    line-height: 1.45;
    white-space: pre-line;
    margin-bottom: 8px;
    word-break: break-word;
}

/* Card Footer: Always Buccinasco Rugby Handshake Logo + Signature */
.card-footer-bar {
    margin-top: auto;
    padding-top: 10px;
    border-top: 1.5px solid rgba(14, 42, 71, 0.18);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
}

.card-footer-logo-group {
    display: flex;
    align-items: center;
    gap: 10px;
}

.card-footer-logo-img {
    height: 48px;
    width: auto;
    object-fit: contain;
    filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.1));
}

.card-footer-club-name {
    font-size: 0.75rem;
    font-weight: 900;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--bucci-dark);
    line-height: 1.1;
}

.card-footer-club-sub {
    font-size: 0.62rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 1px;
    opacity: 0.7;
}

.card-signature-display {
    font-size: 1.05rem;
    font-weight: 700;
    text-align: right;
}

.card-newsignature-display {
    font-size: 1.5rem;
    font-weight: 900;
    text-align: right;
    padding-top: 20px;
    color: var(--bucci-grey)
}

/* Toast Notification */
#toast {
    position: fixed;
    bottom: 24px;
    right: 24px;
    background: var(--bucci-dark);
    color: #ffffff;
    padding: 12px 20px;
    border-radius: 10px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.25);
    border-left: 4px solid var(--bucci-blue);
    font-size: 0.85rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 10px;
    transform: translateY(100px);
    opacity: 0;
    transition: all 0.3s ease;
    z-index: 9999;
}

#toast.show {
    transform: translateY(0);
    opacity: 1;
}

/* Print styles */
@media print {
    body * {
        visibility: hidden;
    }

    .card-wrap,
    .card-wrap * {
        visibility: visible;
    }

    .card-wrap {
        position: fixed;
        left: 50%;
        top: 50%;
        transform: translate(-50%, -50%);
        box-shadow: none;
        width: 90vw;
        max-width: none;
    }
}