/* ========= Modern UI – Flyer Generator ========= */
:root {
    --fg-bg: #F8F9FB;
    --fg-surface: #FFFFFF;
    --fg-border: #E6E8EF;
    --fg-muted: #6B7280;
    --fg-text: #0F172A;
    --fg-accent: #014f66;
    /* Sky 500 */
    --fg-accent-600: #07576f;
    /* Sky 600 */
    --fg-ring: rgba(14, 165, 233, .35);
    --fg-radius: 6px;
    --fg-shadow: 0 10px 24px rgba(16, 24, 40, .06), 0 2px 6px rgba(16, 24, 40, .06);
    --fg-gap: 22px;
}

@media (prefers-color-scheme: dark) {
    :root {
        --fg-bg: #0B1220;
        --fg-surface: #0E1726;
        --fg-border: #e9e9e9;
        --fg-muted: #A3A9B6;
        --fg-text: #E5E7EB;
        --fg-accent: #014f66;
        --fg-accent-600: #07576f;
        --fg-ring: rgba(56, 189, 248, .35);
    }
}

/* Page wrapper */
.flyer-creation-form-wrapper {
    margin: 0 auto;
    /* padding: 28px; */
    /* background: var(--fg-bg); */
    border-radius: var(--fg-radius);
    position: relative;
}

/* Two-column content as cards */
.form-content {
    display: grid;
    grid-template-columns: 1.25fr 1.05fr;
    gap: var(--fg-gap);
    align-items: stretch;
}

.left-column,
.right-column {
    padding-bottom: 40px;
}

/* Sticky preview (optional class) */
.sticky-preview {
    position: sticky;
    top: 10px;
    /* give some spacing instead of 0 */
    align-self: flex-start;
    /* if inside a flex container */
    transition: transform 0.2s ease-in-out;
    z-index: 100;
}

/* Headings & text */
.flyer-creation-form-wrapper h2 {
    margin: 0 0 18px;
    font-size: 20px;
    /* color: var(--fg-text); */
}

.flyer-preview-wrapper {
    /* padding: 28px 0; */
}

/* Labels */
.flyer-creation-form-wrapper label {
    display: block;
    font-weight: 600;
    margin-bottom: 8px;
    font-size: 12px;
    /* color: var(--fg-text); */
}

/* Color picker row */
.flyer-colors-container {
    padding: 8px 0 16px 0;
}

.flyer-colors.grid-item-4 {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 10px;

}

.flyer-colors label {
    font-weight: 600 !important;
    color: var(--fg-muted) !important;
    font-size: 9px !important;
    text-align: center;
    margin-top: 6px;
    letter-spacing: 0.3px !important;
}

.flyer-colors input[type="color"] {
    -webkit-appearance: none;
    border: none;
    width: 32px;
    height: 30px;
    border-radius: 12px;
    cursor: pointer;
    background: transparent;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.12);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.flyer-colors input[type="color"]:hover {
    transform: scale(1.1);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.18);
}

.flyer-colors input[type="color"]::-webkit-color-swatch {
    border-radius: 12px;
    border: none;
    padding: 0;
}

.flyer-colors input[type="color"]::-webkit-color-swatch-wrapper {
    padding: 0;
    border-radius: 12px;
}

/* ==== Flyer Images – Elegant Upload Grid (No Dropzone) ==== */
.fg-image-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 4px;
    margin: 8px 0 16px 0;
}

@media (max-width:900px) {
    .fg-image-grid {
        grid-template-columns: 1fr;
    }
}

.fg-upload-card {
    border: 2px solid var(--fg-border);
    border-radius: var(--fg-radius);
    padding: 8px;
    /* box-shadow: var(--fg-shadow); */
    transition: border-color .2s, box-shadow .2s, transform .08s ease;
}

.fg-upload-card:hover {
    border-color: var(--fg-accent);
    /* box-shadow: 0 10px 24px rgba(14, 165, 233, .15); */
    transform: translateY(-1px);
}

.fg-card-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.flyer-creation-form-wrapper label.fg-label {
    font-weight: 700;
    font-size: 10px;
    margin: 0;
}

.fg-file {
    position: absolute !important;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
    border: 0;
}

/* Upload button */
.flyer-creation-form-wrapper label.fg-upload-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    background: var(--fg-accent);
    color: #fff;
    font-weight: 600;
    font-size: 9px;
    padding: 2px 6px;
    border-radius: 10px;
    cursor: pointer;
    user-select: none;
    box-shadow: 0 2px 6px rgba(14, 165, 233, .25);
    transition: transform .06s ease, box-shadow .2s ease, background .2s ease;
}

.fg-upload-btn:hover {
    background: var(--fg-accent-600);
    box-shadow: 0 6px 18px rgba(14, 165, 233, .25)
}

.fg-upload-btn:active {
    transform: translateY(1px)
}

.fg-upload-btn:focus-visible {
    outline: 2px solid var(--fg-ring);
    outline-offset: 2px
}

.fg-upload-btn .fg-icon {
    width: 18px;
    height: 18px;
    fill: currentColor
}

/* Preview */
.fg-thumb-wrap {
    border-radius: 6px;
    overflow: hidden;
    background: #F2F4F7;
    height: 120px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.fg-thumb {
    display: block;
    width: 100%;
    height: auto;
    object-fit: cover;
}

/* Remove switch */
.fg-remove {
    margin-top: 10px
}

.fg-switch {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    user-select: none
}

.fg-switch input {
    position: absolute;
    opacity: 0;
    pointer-events: none
}

.fg-switch-ui {
    width: 40px;
    height: 22px;
    border-radius: 999px;
    background: #c7ced9;
    position: relative;
    transition: background .2s, box-shadow .2s;
}

.fg-switch-ui::after {
    content: "";
    position: absolute;
    top: 3px;
    left: 3px;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: #fff;
    box-shadow: 0 1px 2px rgba(0, 0, 0, .15);
    transition: transform .2s;
}

.fg-switch input:checked+.fg-switch-ui {
    background: var(--fg-accent)
}

.fg-switch input:checked+.fg-switch-ui::after {
    transform: translateX(18px)
}

.fg-switch-label {
    font-size: 13px;
    color: var(--fg-muted)
}

/* template selector Styles */
#template-selector {
    display: flex;
    gap: 4px;
    margin: 10px 0;
    flex-wrap: wrap;
}

#template-selector label {
    height: 128px;
    cursor: pointer;
    border: 2px solid transparent;
    border-radius: 6px;
    overflow: hidden;
    transition: border-color 0.3s;
    background: #e9e9e9;
    width: 24%;
}

#template-selector label:hover,
#template-selector label.selected {
    border-color: #fecc16;
}

#template-selector img {
    width: 100%;
    height: auto;
    display: block;
}

/* Card */
.template-card {
    display: grid;
    grid-template-rows: auto auto;
    gap: 10px;
    align-items: start;
    background: var(--fg-surface);
    border: 1px solid var(--fg-border);
    border-radius: 14px;
    padding: 12px;
    cursor: pointer;
    transition: border-color .2s, box-shadow .2s, transform .08s ease;
    position: relative;
    user-select: none;
}

.template-card:hover {
    border-color: var(--fg-accent);
    box-shadow: 0 10px 24px rgba(14, 165, 233, .15);
    transform: translateY(-1px);
}

.template-card .thumb {
    display: block;
    background: #F2F4F7;
    border-radius: 10px;
    overflow: hidden;
}

.template-card img {
    display: block;
    width: 100%;
    height: auto;
    aspect-ratio: 4/5;
    object-fit: cover;
}

.template-card .meta {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}

.template-card .title {
    font-weight: 600;
    /* color: var(--fg-text); */
    font-size: 14px;
}

.template-card .badge {
    font-size: 12px;
    color: var(--fg-muted);
    background: rgba(2, 132, 199, .08);
    padding: 4px 8px;
    border-radius: 999px;
}


.template-card .checkmark {
    position: absolute;
    top: 10px;
    right: 10px;
    width: 28px;
    height: 28px;
    line-height: 28px;
    text-align: center;
    font-weight: 700;
    border-radius: 999px;
    background: var(--fg-accent);
    color: #fff;
    opacity: 0;
    transform: scale(.9);
    transition: opacity .18s ease, transform .18s ease;
    pointer-events: none;
}

/* Preview frame */
#flyer-preview {
    display: block;
    background: #fff;
    border: 1px solid var(--fg-border) !important;
    border-radius: 6px;
    width: 105mm !important;
    max-width: 105mm !important;
    height: 148mm !important;
    padding: 0;
    box-shadow: var(--fg-shadow);
}

/* My flyers table – subtle refresh */
.my-flyers-wrapper {
    margin: 20px auto;
}

.my-flyers-table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    background: transparent;
    box-shadow: none;
}

.my-flyers-table th {
    background: linear-gradient(180deg, rgba(14, 165, 233, .08), transparent);
    /* color: var(--fg-text); */
    border-bottom: 1px solid var(--fg-border);
}

.my-flyers-table th,
.my-flyers-table td {
    padding: 14px 12px;
    font-size: 14px;
}

.my-flyers-table tr:hover {
    background: rgba(2, 132, 199, .04);
}

/* Responsive */
@media (max-width: 1024px) {
    .form-content {
        grid-template-columns: 1fr;
    }

}

@media (max-width: 600px) {
    .flyer-colors {
        grid-template-columns: 1fr;
    }
}

/* Overlay background */
.loader-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(255, 255, 255, 0.7);
    /* light overlay, adapt for dark mode */
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--fg-radius);
    z-index: 999;
}

/* Spinner */
.loader {
    width: 40px;
    height: 40px;
    border: 4px solid #ccc;
    border-top: 4px solid var(--fg-accent);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

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