/* ================================================================
   Monday Form – Front-end Styles
   Clean, modern, fully mobile-responsive
================================================================ */

:root {
    --mf-primary:     #3e2683;
    --mf-primary-dk:  #341d75;
    --mf-accent:      #e42315;
    --mf-surface:     #ffffff;
    --mf-bg:          #f4f6fa;
    --mf-border:      #dde1ec;
    --mf-text:        #1d1d1b;
    --mf-muted:       #6b7280;
    --mf-radius:      12px;
    --mf-shadow:      0 4px 24px rgba(0,0,0,.08);
    --mf-progress-h:  6px;
    --mf-transition:  .25s cubic-bezier(.4,0,.2,1);
}

/* ── Wrapper ── */
.mf-wrapper {
    max-width: 720px;
    margin: 0 auto;
    padding: 0 16px 48px;
    font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
    color: var(--mf-text);
    box-sizing: border-box;
}

/* ── Progress bar ── */
.mf-progress-bar-wrap {
    position: relative;
    height: var(--mf-progress-h);
    background: var(--mf-border);
    border-radius: 99px;
    margin-bottom: 32px;
    overflow: visible;
}
.mf-progress-bar {
    height: 100%;
    background: linear-gradient(90deg, var(--mf-primary), var(--mf-accent));
    border-radius: 99px;
    transition: width .5s cubic-bezier(.4,0,.2,1);
    position: relative;
}
.mf-progress-label {
    position: absolute;
    right: 0;
    top: -22px;
    font-size: 11px;
    font-weight: 700;
    color: var(--mf-accent);
    letter-spacing: .04em;
    white-space: nowrap;
}

/* ── Steps ── */
.mf-step { display: none; animation: mf-fadein .35s ease; }
.mf-step.active { display: block; }

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

/* ── Step title ── */
.mf-step-title {
    font-size: clamp(1.2rem, 4vw, 1.6rem);
    font-weight: 700;
    margin: 0 0 24px;
    color: var(--mf-text);
    line-height: 1.2;
}

/* ── Image grid ── */
.mf-image-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: 16px;
    margin-bottom: 28px;
    align-items: stretch;
}

.mf-image-option { cursor: pointer; display: flex; height: 100%; }
.mf-image-option input { position: absolute; opacity: 0; width: 0; height: 0; }

.mf-image-card {
    border: 2.5px solid var(--mf-border);
    border-radius: var(--mf-radius);
    overflow: hidden;
    background: var(--mf-surface);
    box-shadow: var(--mf-shadow);
    transition: border-color var(--mf-transition), transform var(--mf-transition), box-shadow var(--mf-transition);
    position: relative;
    display: flex;
    flex-direction: column;
    width: 100%;
}
.mf-image-card:hover {
    border-color: var(--mf-primary);
    transform: translateY(-3px);
    box-shadow: 0 8px 32px rgba(0,115,230,.15);
}
.mf-image-option input:checked + .mf-image-card {
    border-color: var(--mf-primary);
    box-shadow: 0 0 0 3px rgba(0,115,230,.18), var(--mf-shadow);
}
.mf-image-option input:checked + .mf-image-card::after {
    content: '✓';
    position: absolute;
    top: 10px; right: 10px;
    width: 26px; height: 26px;
    background: var(--mf-primary);
    color: #fff;
    border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    font-size: 14px; font-weight: 700;
    line-height: 26px;
    text-align: center;
}

.mf-image-card img {
    width: 100%;
    aspect-ratio: 4/3;
    object-fit: cover;
    display: block;
}
.mf-image-placeholder {
    width: 100%; aspect-ratio: 4/3;
    background: linear-gradient(135deg, var(--mf-primary) 0%, var(--mf-accent) 100%);
    display: flex; align-items: center; justify-content: center;
}
.mf-image-placeholder span {
    font-size: 2.5rem; font-weight: 800; color: #fff; text-transform: uppercase;
}
.mf-image-label {
    display: flex;
    align-items: center;
    justify-content: center;
    flex: 1;
    padding: 12px;
    font-weight: 600;
    font-size: .93rem;
    text-align: center;
    color: var(--mf-text);
    background: var(--mf-surface);
}

/* ── Fields ── */
.mf-fields { display: flex; flex-direction: column; gap: 18px; margin-bottom: 28px; }
.mf-field-hidden { display: none; }

.mf-label {
    display: block;
    font-size: .88rem;
    font-weight: 600;
    margin-bottom: 6px;
    color: var(--mf-text);
}
.mf-required { color: #e53935; margin-left: 2px; }

.mf-input,
.mf-textarea,
.mf-select {
    width: 100%;
    padding: 12px 14px;
    border: 2px solid var(--mf-border);
    border-radius: 8px;
    font-size: 1rem;
    font-family: inherit;
    color: var(--mf-text);
    background: var(--mf-surface);
    box-sizing: border-box;
    transition: border-color var(--mf-transition), box-shadow var(--mf-transition);
    -webkit-appearance: none;
    appearance: none;
}
.mf-input:focus,
.mf-textarea:focus,
.mf-select:focus {
    outline: none;
    border-color: var(--mf-primary);
    box-shadow: 0 0 0 3px rgba(0,115,230,.12);
}
.mf-textarea { min-height: 120px; resize: vertical; }
.mf-select { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24'%3E%3Cpath fill='%236b7280' d='M7 10l5 5 5-5z'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 12px center; padding-right: 36px; }

/* ── Number stepper ── */
.mf-number-wrap {
    display: flex;
    align-items: center;
    gap: 0;
    border: 2px solid var(--mf-border);
    border-radius: 8px;
    overflow: hidden;
    width: fit-content;
    min-width: 160px;
}
.mf-num-btn {
    width: 44px; height: 48px;
    border: none; background: var(--mf-bg);
    cursor: pointer; font-size: 1.4rem; font-weight: 300;
    color: var(--mf-primary); line-height: 1;
    transition: background var(--mf-transition);
    flex-shrink: 0;
}
.mf-num-btn:hover { background: var(--mf-border); }
.mf-number-input {
    flex: 1; border: none; border-radius: 0;
    text-align: center; font-size: 1.1rem; font-weight: 600;
    padding: 12px 8px;
    min-width: 60px;
}
.mf-number-input:focus { box-shadow: none; }
.mf-number-input::-webkit-inner-spin-button,
.mf-number-input::-webkit-outer-spin-button { -webkit-appearance: none; }

/* ── File upload ── */
.mf-file-wrap { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.mf-file-input { display: none; }
.mf-file-label {
    display: inline-flex; align-items: center; gap: 8px;
    padding: 10px 18px;
    background: var(--mf-bg); border: 2px dashed var(--mf-border);
    border-radius: 8px; cursor: pointer; font-weight: 600; font-size: .9rem;
    color: var(--mf-primary); transition: border-color var(--mf-transition), background var(--mf-transition);
}
.mf-file-label:hover { border-color: var(--mf-primary); background: rgba(0,115,230,.04); }
.mf-file-label svg { width: 18px; height: 18px; stroke: currentColor; fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.mf-file-name { font-size: .85rem; color: var(--mf-muted); }

/* ── Navigation ── */
.mf-nav {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    margin-top: 8px;
    flex-wrap: wrap;
}

.mf-btn {
    display: inline-flex; align-items: center; gap: 8px;
    padding: 13px 26px;
    border-radius: 8px;
    font-size: .95rem; font-weight: 700;
    border: none; cursor: pointer;
    transition: all var(--mf-transition);
    font-family: inherit;
    line-height: 1;
}
.mf-btn svg {
    width: 18px; height: 18px;
    stroke: currentColor; fill: none;
    stroke-width: 2.5; stroke-linecap: round; stroke-linejoin: round;
    flex-shrink: 0;
}

.mf-btn-next,
.mf-btn-submit {
    background: var(--mf-primary);
    color: #fff;
    margin-left: auto;
    box-shadow: 0 4px 12px rgba(0,115,230,.3);
}
.mf-btn-next:hover,
.mf-btn-submit:hover {
    background: var(--mf-primary-dk);
    transform: translateY(-2px);
    box-shadow: 0 6px 18px rgba(0,115,230,.4);
}
.mf-btn-submit { background: var(--mf-accent); box-shadow: 0 4px 12px rgba(200,0,27,.3); }
.mf-btn-submit:hover { background: #e42315; box-shadow: 0 6px 18px rgba(200,0,27,.4); }

.mf-btn-prev {
    background: transparent; color: var(--mf-muted);
    border: 2px solid var(--mf-border);
}
.mf-btn-prev:hover { border-color: var(--mf-primary); color: var(--mf-primary); }

/* ── Field validation error ── */
.mf-input.mf-error,
.mf-select.mf-error,
.mf-textarea.mf-error {
    border-color: #e53935;
    box-shadow: 0 0 0 3px rgba(229,57,53,.12);
}
.mf-field-error-msg {
    font-size: .8rem; color: #e53935; margin-top: 4px;
}

/* ── Error banner ── */
.mf-error-msg {
    margin-top: 16px;
    padding: 14px 18px;
    background: #fff3f3;
    border: 1.5px solid #e53935;
    border-radius: 8px;
    color: #c62828;
    font-size: .93rem;
}

/* ── Success ── */
.mf-success {
    text-align: center;
    padding: 56px 24px;
}
.mf-success-icon {
    width: 72px; height: 72px;
    margin: 0 auto 24px;
    background: var(--mf-accent);
    border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    animation: mf-pop .5s cubic-bezier(.175,.885,.32,1.275);
}
.mf-success-icon svg {
    width: 36px; height: 36px;
    stroke: #fff; fill: none;
    stroke-width: 3; stroke-linecap: round; stroke-linejoin: round;
}
.mf-success p {
    font-size: 1.2rem; font-weight: 600; color: var(--mf-text);
}
@keyframes mf-pop {
    from { transform: scale(0); opacity: 0; }
    to   { transform: scale(1); opacity: 1; }
}

/* ── Loading spinner ── */
.mf-btn.mf-loading { pointer-events: none; opacity: .7; }
.mf-spinner {
    width: 18px; height: 18px;
    border: 2.5px solid rgba(255,255,255,.4);
    border-top-color: #fff;
    border-radius: 50%;
    animation: mf-spin .7s linear infinite;
    display: inline-block;
}
@keyframes mf-spin { to { transform: rotate(360deg); } }

/* ================================================================
   MOBILE
================================================================ */
@media (max-width: 600px) {
    .mf-wrapper { padding: 0 12px 32px; }
    .mf-image-grid { grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 10px; }
    .mf-image-label { font-size: .82rem; padding: 8px; }
    .mf-btn { padding: 12px 18px; font-size: .88rem; }
    .mf-step-title { margin-bottom: 16px; }
    .mf-fields { gap: 14px; }
    .mf-input, .mf-textarea, .mf-select { padding: 10px 12px; font-size: .95rem; }
    .mf-nav { gap: 8px; }
    .mf-btn-next, .mf-btn-submit { flex: 1; justify-content: center; }
}

@media (max-width: 400px) {
    .mf-image-grid { grid-template-columns: 1fr 1fr; }
    .mf-number-wrap { min-width: 100%; }
}

/* ── v2: Loading state while steps fetch ── */
.mf-loading-steps {
    text-align: center;
    padding: 40px 0;
    color: var(--mf-muted);
    font-size: .95rem;
}
.mf-dots {
    display: inline-block;
    animation: mf-dots 1.2s steps(4, end) infinite;
    letter-spacing: 2px;
}
@keyframes mf-dots {
    0%  { content: '';   }
    25% { content: '.';  }
    50% { content: '..'; }
    75% { content: '...'; }
}

/* ── Sub-fields (revealed when image option selected) ── */
.mf-sub-fields {
    display: none;
    padding: 20px;
    margin-top: 12px;
    background: var(--mf-bg);
    border: 2px solid var(--mf-border);
    border-radius: var(--mf-radius);
}
.mf-sub-fields .mf-fields { margin-bottom: 0; }
.mf-sub-fields .mf-label { font-size: .88rem; }
.mf-sub-fields .mf-input,
.mf-sub-fields .mf-select,
.mf-sub-fields .mf-textarea { font-size: .95rem; }