/* ================================================================
   StoryNest — Coloring Page Generator Styles
   Companion to coloring.js · No interference with frontend.css
================================================================ */

/* ── Mode Switcher Tabs ───────────────────────────────────────── */
.scai-mode-switcher {
    display: flex;
    justify-content: center;
    gap: 0;
    margin: 0 0 -2px;
    position: relative;
    z-index: 2;
    flex-wrap: nowrap;
}

.scai-mode-btn {
    padding: 14px 0;
    font-size: 14px;
    font-weight: 600;
    border: 2px solid #e2e8f0;
    border-bottom: none;
    background: #f8fafc;
    color: #64748b;
    cursor: pointer;
    border-radius: 12px 12px 0 0;
    transition: all .2s;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
    flex: 1;
    text-align: center;
    margin-right: -2px;
    min-width: 0;
    white-space: nowrap;
    padding-left: 12px;
    padding-right: 12px;
}

.scai-mode-btn:last-child { margin-right: 0; }

.scai-mode-btn.active {
    background: #fff;
    color: var(--scai-primary, #6c3fc5);
    border-color: var(--scai-primary, #6c3fc5);
    border-bottom: 2px solid #fff;
    z-index: 3;
}

.scai-mode-btn.active[data-mode="color"]       { color: #ea580c; border-color: #ea580c; }
.scai-mode-btn.active[data-mode="handwriting"] { color: #059669; border-color: #059669; }

.scai-mode-btn:hover:not(.active) {
    background: #fff;
    color: #334155;
}

.scai-mode-content {
    border: 2px solid #e2e8f0;
    border-radius: 0 16px 16px 16px;
    background: #fff;
    overflow: hidden;
}

/* ── Coloring App Wrapper ─────────────────────────────────────── */
.scai-coloring-app {
    padding: 0;
}

/* ── Coloring Hero ───────────────────────────────────────────── */
.scai-color-hero {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    padding: 40px 32px 32px;
    text-align: center;
    color: #fff;
}

.scai-color-hero-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: rgba(255,255,255,.2);
    backdrop-filter: blur(8px);
    border: 1px solid rgba(255,255,255,.3);
    border-radius: 20px;
    padding: 6px 16px;
    font-size: 13px;
    font-weight: 600;
    margin-bottom: 16px;
}

.scai-color-hero h2 {
    font-size: clamp(22px, 4vw, 34px);
    font-weight: 800;
    margin: 0 0 10px;
    line-height: 1.2;
}

.scai-color-hero p {
    font-size: 15px;
    opacity: .85;
    max-width: 480px;
    margin: 0 auto 20px;
    line-height: 1.6;
}

.scai-color-features {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 10px;
}

.scai-color-features span {
    background: rgba(255,255,255,.18);
    border: 1px solid rgba(255,255,255,.3);
    border-radius: 20px;
    padding: 5px 14px;
    font-size: 12px;
    font-weight: 600;
}

/* ── Generator Panel ─────────────────────────────────────────── */
.scai-color-generator {
    padding: 32px 32px 28px;
    max-width: 820px;
    margin: 0 auto;
}

/* ── Age Group Tabs ──────────────────────────────────────────── */
.scai-age-tabs {
    display: flex;
    gap: 0;
    border: 2px solid #e2e8f0;
    border-radius: 12px;
    overflow: hidden;
    margin-bottom: 24px;
}

.scai-age-tab {
    flex: 1;
    padding: 14px 10px;
    text-align: center;
    cursor: pointer;
    transition: all .18s;
    border-right: 2px solid #e2e8f0;
    background: #f8fafc;
}

.scai-age-tab:last-child { border-right: none; }

.scai-age-tab .age-icon {
    font-size: 24px;
    display: block;
    margin-bottom: 4px;
}

.scai-age-tab .age-label {
    font-size: 13px;
    font-weight: 700;
    color: #475569;
    display: block;
}

.scai-age-tab .age-range {
    font-size: 11px;
    color: #94a3b8;
    display: block;
    margin-top: 2px;
}

.scai-age-tab .age-tip {
    font-size: 10.5px;
    color: #64748b;
    display: block;
    margin-top: 6px;
    line-height: 1.4;
    padding: 0 4px;
}

.scai-age-tab.active {
    background: var(--scai-primary, #6c3fc5);
    color: #fff;
}

.scai-age-tab.active .age-label,
.scai-age-tab.active .age-range,
.scai-age-tab.active .age-tip {
    color: rgba(255,255,255,.9);
}

.scai-age-tab:hover:not(.active) {
    background: #f1f5f9;
}

/* ── Prompt Input ────────────────────────────────────────────── */
.scai-color-prompt-wrap {
    margin-bottom: 20px;
}

.scai-color-prompt-wrap label {
    display: block;
    font-weight: 700;
    font-size: 14px;
    color: #334155;
    margin-bottom: 8px;
}

.scai-color-prompt-wrap textarea {
    width: 100%;
    border: 2px solid #e2e8f0;
    border-radius: 12px;
    padding: 14px 16px;
    font-size: 14px;
    color: #334155;
    resize: vertical;
    min-height: 80px;
    transition: border-color .2s;
    font-family: inherit;
    box-sizing: border-box;
}

.scai-color-prompt-wrap textarea:focus {
    border-color: var(--scai-primary, #6c3fc5);
    outline: none;
}

.scai-prompt-examples {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 8px;
}

.scai-prompt-example {
    font-size: 12px;
    padding: 4px 10px;
    border: 1px solid #cbd5e1;
    border-radius: 20px;
    cursor: pointer;
    color: #64748b;
    transition: all .15s;
    background: #f8fafc;
}

.scai-prompt-example:hover {
    border-color: var(--scai-primary, #6c3fc5);
    color: var(--scai-primary, #6c3fc5);
    background: #f3eeff;
}

/* ── Pages Counter ───────────────────────────────────────────── */
.scai-color-pages-row {
    display: flex;
    align-items: center;
    gap: 16px;
    margin-bottom: 24px;
    padding: 14px 18px;
    background: #f8fafc;
    border: 2px solid #e2e8f0;
    border-radius: 12px;
}

.scai-color-pages-row label {
    font-weight: 600;
    font-size: 14px;
    color: #475569;
    flex: 1;
}

.scai-color-pages-row label span {
    color: var(--scai-primary, #6c3fc5);
    font-weight: 700;
}

.scai-page-counter {
    display: flex;
    align-items: center;
    gap: 8px;
}

.scai-page-counter button {
    width: 32px;
    height: 32px;
    border-radius: 8px;
    border: 2px solid #e2e8f0;
    background: #fff;
    font-size: 16px;
    font-weight: 700;
    cursor: pointer;
    line-height: 1;
    color: #475569;
    transition: all .15s;
}

.scai-page-counter button:hover {
    border-color: var(--scai-primary, #6c3fc5);
    color: var(--scai-primary, #6c3fc5);
}

.scai-page-counter input {
    width: 48px;
    text-align: center;
    border: 2px solid #e2e8f0;
    border-radius: 8px;
    padding: 6px;
    font-size: 16px;
    font-weight: 700;
    color: #1e293b;
}

/* ── Generate Button ─────────────────────────────────────────── */
.scai-color-generate-btn {
    width: 100%;
    padding: 16px;
    background: linear-gradient(135deg, var(--scai-primary, #6c3fc5), #9b59b6);
    color: #fff;
    border: none;
    border-radius: 12px;
    font-size: 16px;
    font-weight: 700;
    cursor: pointer;
    transition: all .2s;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    margin-bottom: 8px;
}

.scai-color-generate-btn:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 8px 24px rgba(108,63,197,.35);
}

.scai-color-generate-btn:disabled {
    opacity: .65;
    cursor: not-allowed;
    transform: none;
}

.scai-generate-note {
    text-align: center;
    font-size: 12px;
    color: #94a3b8;
    margin-bottom: 28px;
}

/* ── Preview Grid ────────────────────────────────────────────── */
.scai-color-preview-section {
    margin-top: 8px;
    display: none;
}

.scai-color-preview-section.visible {
    display: block;
}

.scai-preview-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 16px;
    flex-wrap: wrap;
    gap: 8px;
}

.scai-preview-header h3 {
    font-size: 18px;
    font-weight: 700;
    color: #1e293b;
    margin: 0;
}

.scai-preview-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 18px;
    margin-bottom: 28px;
}

/* ── Preview Card + Watermark ────────────────────────────────── */
.scai-preview-card {
    position: relative;
    border-radius: 12px;
    overflow: hidden;
    border: 2px solid #e2e8f0;
    background: #f8fafc;
    transition: transform .2s, box-shadow .2s;
    cursor: default;
}

.scai-preview-card:hover {
    transform: translateY(-3px);
    box-shadow: 0 12px 32px rgba(0,0,0,.1);
}

.scai-preview-card img {
    width: 100%;
    display: block;
    aspect-ratio: 1/1;
    object-fit: cover;
}

/* Skeleton loader */
.scai-preview-card.loading {
    aspect-ratio: 1/1;
    background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
    background-size: 200% 100%;
    animation: scai-shimmer 1.4s infinite;
}

@keyframes scai-shimmer {
    0%   { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

/* Watermark overlay */
.scai-watermark-overlay {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    pointer-events: none;
}

.scai-watermark-overlay::before {
    content: attr(data-text);
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: clamp(14px, 3vw, 20px);
    font-weight: 800;
    color: rgba(108, 63, 197, 0.35);
    letter-spacing: 1px;
    text-transform: uppercase;
    transform: rotate(-30deg);
    text-align: center;
    padding: 12px;
    line-height: 1.3;
}

/* Page badge */
.scai-page-badge {
    position: absolute;
    top: 8px;
    left: 8px;
    background: rgba(0,0,0,.55);
    color: #fff;
    font-size: 11px;
    font-weight: 700;
    padding: 3px 9px;
    border-radius: 20px;
    backdrop-filter: blur(4px);
}

/* Regenerate button on card */
.scai-regen-btn {
    position: absolute;
    bottom: 8px;
    right: 8px;
    background: rgba(255,255,255,.9);
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    padding: 5px 10px;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    color: #475569;
    transition: all .15s;
    backdrop-filter: blur(4px);
}

.scai-regen-btn:hover {
    background: var(--scai-primary, #6c3fc5);
    color: #fff;
    border-color: transparent;
}

/* ── Email + Download Section ────────────────────────────────── */
.scai-color-download-section {
    background: linear-gradient(135deg, #f8f4ff, #fef9ff);
    border: 2px solid #e9d5ff;
    border-radius: 16px;
    padding: 24px;
    text-align: center;
}

.scai-color-download-section h4 {
    font-size: 18px;
    font-weight: 700;
    color: #1e293b;
    margin: 0 0 6px;
}

.scai-color-download-section p {
    font-size: 13px;
    color: #64748b;
    margin: 0 0 18px;
}

.scai-color-email-row {
    display: flex;
    gap: 10px;
    max-width: 440px;
    margin: 0 auto 16px;
}

.scai-color-email-row input {
    flex: 1;
    padding: 12px 16px;
    border: 2px solid #e2e8f0;
    border-radius: 10px;
    font-size: 14px;
    transition: border-color .2s;
}

.scai-color-email-row input:focus {
    border-color: var(--scai-primary, #6c3fc5);
    outline: none;
}

.scai-color-download-btn {
    padding: 13px 28px;
    background: linear-gradient(135deg, #10b981, #059669);
    color: #fff;
    border: none;
    border-radius: 10px;
    font-size: 14px;
    font-weight: 700;
    cursor: pointer;
    white-space: nowrap;
    transition: all .2s;
}

.scai-color-download-btn:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(16,185,129,.35);
}

.scai-color-download-btn:disabled {
    opacity: .6;
    cursor: not-allowed;
    transform: none;
}

.scai-price-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: #fff;
    border: 2px solid #e9d5ff;
    border-radius: 20px;
    padding: 6px 18px;
    font-size: 14px;
    font-weight: 700;
    color: var(--scai-primary, #6c3fc5);
    margin-bottom: 16px;
}

/* ── Success / Download Ready State ─────────────────────────── */
.scai-color-success-box {
    display: none;
    background: linear-gradient(135deg, #f0fdf4, #dcfce7);
    border: 2px solid #86efac;
    border-radius: 16px;
    padding: 28px 24px;
    text-align: center;
    margin-top: 24px;
}

.scai-color-success-box.visible { display: block; }

.scai-color-success-box h4 {
    font-size: 20px;
    font-weight: 800;
    color: #14532d;
    margin: 0 0 8px;
}

.scai-color-success-box p {
    color: #166534;
    margin: 0 0 20px;
    font-size: 14px;
}

.scai-final-download-btn {
    padding: 14px 36px;
    background: linear-gradient(135deg, var(--scai-primary, #6c3fc5), #9b59b6);
    color: #fff;
    border: none;
    border-radius: 12px;
    font-size: 16px;
    font-weight: 700;
    cursor: pointer;
    transition: all .2s;
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.scai-final-download-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 24px rgba(108,63,197,.35);
}

/* ── Status / Progress Messages ──────────────────────────────── */
.scai-color-status {
    text-align: center;
    padding: 12px 18px;
    border-radius: 10px;
    font-size: 14px;
    font-weight: 600;
    margin: 12px 0;
    display: none;
}

.scai-color-status.visible  { display: block; }
.scai-color-status.info     { background: #eff6ff; color: #1d4ed8; border: 1.5px solid #bfdbfe; }
.scai-color-status.success  { background: #f0fdf4; color: #15803d; border: 1.5px solid #bbf7d0; }
.scai-color-status.error    { background: #fef2f2; color: #b91c1c; border: 1.5px solid #fecaca; }
.scai-color-status.loading  { background: #fdf4ff; color: #7c3aed; border: 1.5px solid #e9d5ff; }

.scai-color-status.loading::before {
    content: '';
    display: inline-block;
    width: 14px;
    height: 14px;
    border: 2.5px solid currentColor;
    border-top-color: transparent;
    border-radius: 50%;
    animation: spin .7s linear infinite;
    margin-right: 8px;
    vertical-align: middle;
}

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

/* ── PDF Progress Overlay ────────────────────────────────────── */
.scai-pdf-progress {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.55);
    z-index: 99999;
    align-items: center;
    justify-content: center;
}

.scai-pdf-progress.visible { display: flex; }

.scai-pdf-progress-inner {
    background: #fff;
    border-radius: 20px;
    padding: 40px 48px;
    text-align: center;
    max-width: 380px;
    width: 90%;
    box-shadow: 0 20px 60px rgba(0,0,0,.25);
}

.scai-pdf-spinner {
    width: 60px;
    height: 60px;
    border: 5px solid #e9d5ff;
    border-top-color: var(--scai-primary, #6c3fc5);
    border-radius: 50%;
    animation: spin .8s linear infinite;
    margin: 0 auto 20px;
}

.scai-pdf-progress-inner h4 {
    font-size: 18px;
    font-weight: 700;
    color: #1e293b;
    margin: 0 0 8px;
}

.scai-pdf-progress-inner p {
    font-size: 13px;
    color: #64748b;
    margin: 0;
}

.scai-pdf-progress-bar {
    width: 100%;
    height: 8px;
    background: #e9d5ff;
    border-radius: 4px;
    overflow: hidden;
    margin-top: 20px;
}

.scai-pdf-progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--scai-primary, #6c3fc5), #9b59b6);
    border-radius: 4px;
    transition: width .4s ease;
    width: 0%;
}

/* ── Responsive ──────────────────────────────────────────────── */
@media (max-width: 600px) {
    .scai-mode-btn { padding: 10px 6px; font-size: 11px; gap: 4px; }
    .scai-mode-btn .tab-emoji { font-size: 16px; }
    .scai-color-generator { padding: 20px 16px; }
    .scai-color-hero { padding: 28px 16px 24px; }
    .scai-age-tabs { flex-direction: column; }
    .scai-age-tab { border-right: none; border-bottom: 2px solid #e2e8f0; }
    .scai-age-tab:last-child { border-bottom: none; }
    .scai-color-email-row { flex-direction: column; }
    .scai-preview-grid { grid-template-columns: 1fr 1fr; }
    .scai-color-pages-row { flex-direction: column; align-items: flex-start; }
}

/* ══════════════════════════════════════════════
   Language Selector Row
══════════════════════════════════════════════ */
.scai-lang-row {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 20px;
    padding: 12px 16px;
    background: linear-gradient(135deg, #fff8f0, #fff3e0);
    border: 1.5px solid #e8c87a;
    border-radius: 12px;
}

.scai-lang-label {
    font-size: 14px;
    font-weight: 600;
    color: #7a5530;
    white-space: nowrap;
    margin: 0;
}

.scai-lang-select-wrap {
    position: relative;
    flex: 0 0 auto;
}

.scai-lang-select {
    appearance: none;
    -webkit-appearance: none;
    padding: 8px 36px 8px 14px;
    font-size: 14px;
    font-weight: 600;
    color: #3d2800;
    background: #fff url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%237a5530' stroke-width='1.8' fill='none' stroke-linecap='round'/%3E%3C/svg%3E") no-repeat right 12px center;
    border: 2px solid #c9922a;
    border-radius: 8px;
    cursor: pointer;
    transition: border-color .2s, box-shadow .2s;
    min-width: 160px;
}

.scai-lang-select:focus {
    outline: none;
    border-color: var(--scai-primary, #6c3fc5);
    box-shadow: 0 0 0 3px rgba(108,63,197,.15);
}

.scai-lang-select:hover {
    border-color: #a06620;
}

/* ══════════════════════════════════════════════
   Preview Cards — A4 Portrait Ratio
══════════════════════════════════════════════ */
.scai-preview-card {
    aspect-ratio: 210 / 297 !important;   /* A4 portrait */
    overflow: hidden;
    position: relative;
    display: flex;
    flex-direction: column;
    background: #f8f8f6;
    border-radius: 6px;
    border: 1px solid #e0d5c5;
    box-shadow: 0 2px 10px rgba(0,0,0,.08);
}

.scai-card-img-wrap {
    position: relative;
    flex: 1 1 auto;
    overflow: hidden;
    background: #fff;
}

.scai-card-img-wrap img {
    width: 100%;
    height: 100%;
    object-fit: contain;   /* never crop/distort — black & white needs full view */
    display: block;
}

/* Caption strip below the image in preview */
.scai-card-caption {
    padding: 8px 10px 6px;
    font-size: 13px;
    font-weight: 700;
    text-align: center;
    color: #2a1a00;
    background: linear-gradient(135deg, #fff8f0, #fff3e0);
    border-top: 1.5px solid #e8c87a;
    line-height: 1.3;
    flex: 0 0 auto;
}

/* Redo button */
.scai-regen-btn {
    position: absolute;
    bottom: 8px;
    right: 8px;
    background: rgba(255,255,255,.92);
    border: 1.5px solid #c9922a;
    color: #7a5530;
    font-size: 11px;
    font-weight: 700;
    padding: 5px 10px;
    border-radius: 20px;
    cursor: pointer;
    backdrop-filter: blur(4px);
    transition: background .18s;
    z-index: 5;
}
.scai-regen-btn:hover { background: #fff; }

