/* ─────────────────────────────────────────────────────────────────
   ACD Modern Submission Form v2.0
   Font: Sarabun (Thai-optimized), Noto Serif Thai (headers)
   Theme: Warm-professional / Clean blueprint
   ───────────────────────────────────────────────────────────────── */

@import url('https://fonts.googleapis.com/css2?family=Sarabun:wght@300;400;500;600;700&family=Noto+Serif+Thai:wght@600;700&display=swap');

/* ── Variables ──────────────────────────────────────────────────── */
:root {
    --acd-primary:      #1a6fc4;
    --acd-primary-dk:   #135ba3;
    --acd-primary-lt:   #e8f1fb;
    --acd-accent:       #f5a623;
    --acd-success:      #1a9e5e;
    --acd-error:        #d9354a;
    --acd-warn:         #e07b00;
    --acd-surface:      #ffffff;
    --acd-bg:           #f4f6f9;
    --acd-border:       #dde2ea;
    --acd-border-focus: #1a6fc4;
    --acd-text:         #1c2535;
    --acd-text-muted:   #6b7a92;
    --acd-text-light:   #9aa3b3;
    --acd-radius:       12px;
    --acd-radius-sm:    8px;
    --acd-shadow:       0 4px 24px rgba(26,111,196,.10);
    --acd-shadow-lg:    0 12px 48px rgba(26,111,196,.18);
    --acd-transition:   .2s cubic-bezier(.4,0,.2,1);
    --acd-font:         'Sarabun', 'Helvetica Neue', Arial, sans-serif;
}

/* ── Base Reset ─────────────────────────────────────────────────── */
.acd-form-wrapper *,
.acd-form-wrapper *::before,
.acd-form-wrapper *::after {
    box-sizing: border-box;
}

/* ── Login Notice ───────────────────────────────────────────────── */
.acd-login-notice {
    font-family: var(--acd-font);
    background: var(--acd-primary-lt);
    border: 1px solid var(--acd-primary);
    border-radius: var(--acd-radius);
    padding: 20px 24px;
    color: var(--acd-primary-dk);
    font-size: 1rem;
    text-align: center;
}
.acd-login-notice a {
    color: var(--acd-primary);
    font-weight: 600;
}

/* ── Wrapper ────────────────────────────────────────────────────── */
.acd-form-wrapper {
    font-family: var(--acd-font);
    max-width: 820px;
    margin: 32px auto;
    background: var(--acd-surface);
    border-radius: 20px;
    box-shadow: var(--acd-shadow-lg);
    overflow: hidden;
    color: var(--acd-text);
    line-height: 1.6;
    animation: acdFadeUp .45s ease both;
}

@keyframes acdFadeUp {
    from { opacity: 0; transform: translateY(18px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* ── Form Header ────────────────────────────────────────────────── */
.acd-form-header {
    background: linear-gradient(135deg, var(--acd-primary) 0%, #0d4f9e 100%);
    color: #fff;
    padding: 40px 48px 36px;
    text-align: center;
    position: relative;
    overflow: hidden;
}
.acd-form-header::before {
    content: '';
    position: absolute;
    inset: 0;
    background: url("data:image/svg+xml,%3Csvg width='60' height='60' viewBox='0 0 60 60' xmlns='http://www.w3.org/2000/svg'%3E%3Cg fill='none' fill-rule='evenodd'%3E%3Cg fill='%23ffffff' fill-opacity='0.04'%3E%3Cpath d='M36 34v-4h-2v4h-4v2h4v4h2v-4h4v-2h-4zm0-30V0h-2v4h-4v2h4v4h2V6h4V4h-4zM6 34v-4H4v4H0v2h4v4h2v-4h4v-2H6zM6 4V0H4v4H0v2h4v4h2V6h4V4H6z'/%3E%3C/g%3E%3C/g%3E%3C/svg%3E");
}
.acd-form-header-icon {
    font-size: 3rem;
    margin-bottom: 12px;
    display: block;
    filter: drop-shadow(0 2px 8px rgba(0,0,0,.2));
}
.acd-form-header h2 {
    font-family: 'Noto Serif Thai', 'Sarabun', serif;
    font-size: 1.75rem;
    font-weight: 700;
    margin: 0 0 8px;
    color: #fff;
}
.acd-form-header p {
    margin: 0;
    opacity: .82;
    font-size: .95rem;
    font-weight: 300;
}

/* ── Form body ──────────────────────────────────────────────────── */
#acd-main-form {
    padding: 0 48px 48px;
}

/* ── Section ────────────────────────────────────────────────────── */
.acd-section {
    padding: 36px 0 28px;
    border-bottom: 1px solid var(--acd-border);
}
.acd-section:last-of-type {
    border-bottom: none;
}

.acd-section-title {
    font-family: 'Noto Serif Thai', serif;
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 1.05rem;
    font-weight: 700;
    color: var(--acd-text);
    margin: 0 0 24px;
}
.acd-sec-num {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 30px;
    height: 30px;
    background: var(--acd-primary);
    color: #fff;
    border-radius: 50%;
    font-size: .85rem;
    font-weight: 700;
    flex-shrink: 0;
    font-family: var(--acd-font);
}

/* ── Fields Grid ────────────────────────────────────────────────── */
.acd-fields-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px 24px;
}
.acd-field { display: flex; flex-direction: column; gap: 6px; }
.acd-field.col-full  { grid-column: 1 / -1; }
.acd-field.col-half  { grid-column: span 1; }

/* ── Labels ─────────────────────────────────────────────────────── */
.acd-field label,
.acd-field > label {
    font-size: .88rem;
    font-weight: 600;
    color: var(--acd-text);
    letter-spacing: .01em;
}
.req { color: var(--acd-error); margin-left: 2px; }

/* ── Inputs / Textarea / Select ─────────────────────────────────── */
.acd-form-wrapper input[type="text"],
.acd-form-wrapper input[type="email"],
.acd-form-wrapper input[type="number"],
.acd-form-wrapper input[type="url"],
.acd-form-wrapper input[type="tel"],
.acd-form-wrapper input[type="date"],
.acd-form-wrapper input[type="password"],
.acd-form-wrapper textarea,
.acd-form-wrapper select {
    font-family: var(--acd-font);
    width: 100%;
    padding: 11px 14px;
    background: var(--acd-bg);
    border: 1.5px solid var(--acd-border);
    border-radius: var(--acd-radius-sm);
    font-size: .95rem;
    color: var(--acd-text);
    transition: border-color var(--acd-transition), box-shadow var(--acd-transition), background var(--acd-transition);
    outline: none;
    line-height: 1.5;
}
.acd-form-wrapper input:focus,
.acd-form-wrapper textarea:focus,
.acd-form-wrapper select:focus {
    border-color: var(--acd-border-focus);
    background: #fff;
    box-shadow: 0 0 0 3px rgba(26,111,196,.12);
}
.acd-form-wrapper input.field-invalid,
.acd-form-wrapper textarea.field-invalid,
.acd-form-wrapper select.field-invalid {
    border-color: var(--acd-error);
    box-shadow: 0 0 0 3px rgba(217,53,74,.1);
}
.acd-form-wrapper textarea { resize: vertical; min-height: 100px; }

/* ── Input with icon ────────────────────────────────────────────── */
.input-icon-wrap {
    position: relative;
    display: flex;
    align-items: center;
}
.input-icon {
    position: absolute;
    left: 12px;
    font-size: 1rem;
    pointer-events: none;
    line-height: 1;
    z-index: 1;
}
.input-icon-wrap input {
    padding-left: 38px;
}

/* ── Select wrapper (custom arrow) ─────────────────────────────── */
.select-wrap {
    position: relative;
}
.select-wrap::after {
    content: '▾';
    position: absolute;
    right: 14px;
    top: 50%;
    transform: translateY(-50%);
    pointer-events: none;
    color: var(--acd-text-muted);
    font-size: .9rem;
}
.select-wrap select {
    appearance: none;
    -webkit-appearance: none;
    cursor: pointer;
    padding-right: 36px;
}

/* ── Checkbox / Radio ───────────────────────────────────────────── */
.check-radio-group {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    padding: 6px 0;
}
.check-radio-item {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-size: .9rem;
    cursor: pointer;
    padding: 8px 14px;
    border: 1.5px solid var(--acd-border);
    border-radius: 50px;
    transition: all var(--acd-transition);
    user-select: none;
    background: var(--acd-bg);
}
.check-radio-item:hover {
    border-color: var(--acd-primary);
    background: var(--acd-primary-lt);
    color: var(--acd-primary-dk);
}
.check-radio-item input[type="checkbox"],
.check-radio-item input[type="radio"] {
    position: absolute;
    opacity: 0;
    width: 0;
    height: 0;
}
.checkmark-box,
.radiomark-circle {
    width: 18px;
    height: 18px;
    border: 2px solid var(--acd-border);
    background: #fff;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--acd-transition);
}
.checkmark-box { border-radius: 4px; }
.radiomark-circle { border-radius: 50%; }

.check-radio-item input:checked ~ .checkmark-box {
    background: var(--acd-primary);
    border-color: var(--acd-primary);
}
.check-radio-item input:checked ~ .checkmark-box::after {
    content: '✓';
    color: #fff;
    font-size: .75rem;
    font-weight: 700;
}
.check-radio-item input:checked ~ .radiomark-circle {
    border-color: var(--acd-primary);
}
.check-radio-item input:checked ~ .radiomark-circle::after {
    content: '';
    width: 8px; height: 8px;
    border-radius: 50%;
    background: var(--acd-primary);
}
.check-radio-item:has(input:checked) {
    border-color: var(--acd-primary);
    background: var(--acd-primary-lt);
    color: var(--acd-primary-dk);
}

/* ── Char count & Hints ─────────────────────────────────────────── */
.char-count {
    font-size: .78rem;
    color: var(--acd-text-muted);
    text-align: right;
    margin-top: 2px;
    transition: color var(--acd-transition);
}
.char-count.near-limit { color: var(--acd-warn); }
.char-count.at-limit   { color: var(--acd-error); font-weight: 600; }
.field-hint {
    font-size: .8rem;
    color: var(--acd-text-muted);
}

/* ── Field Error ────────────────────────────────────────────────── */
.field-error {
    font-size: .8rem;
    color: var(--acd-error);
    font-weight: 500;
    min-height: 1em;
    transition: opacity var(--acd-transition);
}
.field-error:empty { opacity: 0; }

/* ── Dropzone ───────────────────────────────────────────────────── */
.acd-dropzone {
    position: relative;
    border: 2px dashed var(--acd-border);
    border-radius: var(--acd-radius);
    background: var(--acd-bg);
    padding: 40px 24px;
    text-align: center;
    cursor: pointer;
    transition: all var(--acd-transition);
    overflow: hidden;
}
.acd-dropzone input[type="file"] {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    opacity: 0;
    cursor: pointer;
    z-index: 2;
}
.acd-dropzone .dropzone-content {
    pointer-events: none;
    position: relative;
    z-index: 1;
}
.dropzone-icon {
    font-size: 3rem;
    display: block;
    margin-bottom: 12px;
    transition: transform var(--acd-transition);
}
.dropzone-title {
    font-weight: 600;
    color: var(--acd-text);
    margin: 0 0 6px;
    font-size: .95rem;
}
.dropzone-sub {
    font-size: .82rem;
    color: var(--acd-text-muted);
    margin: 0;
}
.acd-dropzone:hover,
.acd-dropzone.drag-over {
    border-color: var(--acd-primary);
    background: var(--acd-primary-lt);
}
.acd-dropzone.drag-over .dropzone-icon { transform: scale(1.15); }

/* ── Image Preview Grid ─────────────────────────────────────────── */
#acd-img-preview {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
    gap: 12px;
    margin-top: 16px;
}

/* instruction bar */
.acd-prev-instruction {
    grid-column: 1 / -1;
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: .82rem;
    color: var(--acd-text-muted);
    background: var(--acd-bg);
    border: 1px solid var(--acd-border);
    border-radius: var(--acd-radius-sm);
    padding: 6px 12px;
    user-select: none;
}
.acd-prev-instruction .hint {
    font-style: italic;
    opacity: .75;
}

/* card */
.acd-preview-item {
    position: relative;
    border-radius: var(--acd-radius-sm);
    overflow: hidden;
    aspect-ratio: 1;
    background: var(--acd-bg);
    box-shadow: 0 2px 8px rgba(0,0,0,.1);
    border: 2px solid transparent;
    cursor: grab;
    transition: box-shadow .2s, border-color .2s, opacity .2s, transform .18s;
    animation: acdPreviewIn .28s ease both;
}
@keyframes acdPreviewIn {
    from { opacity: 0; transform: scale(.82); }
    to   { opacity: 1; transform: scale(1);   }
}

/* primary ring */
.acd-preview-item.is-primary {
    border-color: var(--acd-primary);
    box-shadow: 0 0 0 3px rgba(37,99,235,.22), 0 2px 8px rgba(0,0,0,.1);
}

/* dragging state */
.acd-preview-item.dragging {
    opacity: .38;
    cursor: grabbing;
    transform: scale(.95);
}

/* drop target highlight */
.acd-preview-item.drag-target {
    border-color: var(--acd-primary);
    box-shadow: 0 0 0 3px rgba(37,99,235,.4);
    transform: scale(1.04);
}

/* removing animation */
.acd-preview-item.removing {
    opacity: 0;
    transform: scale(.75);
    pointer-events: none;
}

.acd-preview-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    pointer-events: none;
    user-select: none;
    -webkit-user-drag: none;
}

/* drag handle */
.acd-prev-drag-handle {
    position: absolute;
    top: 5px; left: 5px;
    width: 22px; height: 22px;
    background: rgba(0,0,0,.52);
    color: #fff;
    border-radius: 4px;
    font-size: 15px;
    line-height: 22px;
    text-align: center;
    letter-spacing: 1px;
    z-index: 3;
    opacity: 0;
    transition: opacity .18s;
    cursor: grab;
    user-select: none;
    pointer-events: none;   /* handle เพื่อ visual เท่านั้น drag อยู่ที่ card */
}
.acd-preview-item:hover .acd-prev-drag-handle { opacity: 1; }

/* overlay button group */
.acd-prev-overlay {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: flex-end;
    justify-content: center;
    gap: 8px;
    padding: 0 6px 8px;
    background: linear-gradient(to top, rgba(0,0,0,.62) 0%, transparent 55%);
    opacity: 0;
    transition: opacity .18s;
    z-index: 2;
}
.acd-preview-item:hover .acd-prev-overlay { opacity: 1; }

.acd-prev-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px; height: 32px;
    border: none;
    border-radius: 50%;
    background: rgba(255,255,255,.18);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    color: #fff;
    font-size: 15px;
    cursor: pointer;
    transition: background .15s, transform .12s;
    flex-shrink: 0;
}
.acd-prev-btn:hover { transform: scale(1.15); }

.acd-prev-set-primary:hover { background: rgba(250,204,21,.75); }  /* amber */
.acd-prev-remove:hover      { background: rgba(239,68,68,.85);  }  /* red   */

/* badge */
.acd-prev-badge-wrap {
    position: absolute;
    top: 5px; right: 5px;
    z-index: 3;
    pointer-events: none;
}
.acd-preview-badge {
    display: inline-block;
    font-size: .62rem;
    font-weight: 700;
    padding: 2px 7px;
    border-radius: 10px;
    letter-spacing: .04em;
    line-height: 1.5;
    white-space: nowrap;
    text-transform: uppercase;
}
.acd-preview-badge.primary {
    background: var(--acd-primary);
    color: #fff;
    box-shadow: 0 1px 4px rgba(0,0,0,.25);
}
.acd-preview-badge.order {
    background: rgba(0,0,0,.52);
    color: #fff;
}

/* dropzone เต็มแล้ว — dim */
.acd-dropzone.is-full {
    opacity: .55;
    pointer-events: none;
}
.acd-dropzone.is-full::after {
    content: '✅ ครบ ' attr(data-max) ' รูปแล้ว';
    position: absolute;
    inset: 0;
    background: rgba(255,255,255,.75);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    color: var(--acd-primary);
    font-size: .9rem;
    pointer-events: none;
}

/* ── CAPTCHA ────────────────────────────────────────────────────── */
.acd-captcha-wrap {
    padding: 24px 0 0;
    display: flex;
    justify-content: center;
}

/* ── Submit Area ────────────────────────────────────────────────── */
.acd-submit-area {
    padding: 32px 0 0;
    text-align: center;
}
.acd-btn-submit {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    width: 100%;
    max-width: 420px;
    padding: 16px 32px;
    background: linear-gradient(135deg, var(--acd-primary) 0%, var(--acd-primary-dk) 100%);
    color: #fff;
    border: none;
    border-radius: 50px;
    font-family: var(--acd-font);
    font-size: 1.05rem;
    font-weight: 700;
    letter-spacing: .02em;
    cursor: pointer;
    transition: all var(--acd-transition);
    box-shadow: 0 4px 16px rgba(26,111,196,.35);
    position: relative;
    overflow: hidden;
}
.acd-btn-submit::after {
    content: '';
    position: absolute;
    inset: 0;
    background: rgba(255,255,255,0);
    transition: background var(--acd-transition);
}
.acd-btn-submit:hover:not(:disabled)::after { background: rgba(255,255,255,.08); }
.acd-btn-submit:active:not(:disabled)       { transform: scale(.98); }
.acd-btn-submit:disabled {
    opacity: .55;
    cursor: not-allowed;
    box-shadow: none;
}
.acd-btn-submit .btn-icon { font-size: 1.1em; }
.submit-note {
    font-size: .8rem;
    color: var(--acd-text-muted);
    margin-top: 12px;
}

/* ── Loading Overlay ────────────────────────────────────────────── */
#acd-loading-overlay {
    position: fixed;
    inset: 0;
    background: rgba(240,244,250,.88);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    z-index: 99999;
    display: flex;
    align-items: center;
    justify-content: center;
}
.acd-loader-card {
    background: var(--acd-surface);
    border-radius: 20px;
    padding: 48px 56px;
    text-align: center;
    box-shadow: var(--acd-shadow-lg);
    min-width: 280px;
    animation: acdFadeUp .25s ease;
}
.acd-spinner-ring {
    width: 56px;
    height: 56px;
    border: 4px solid var(--acd-border);
    border-top-color: var(--acd-primary);
    border-radius: 50%;
    animation: acdSpin .9s linear infinite;
    margin: 0 auto 20px;
}
@keyframes acdSpin {
    to { transform: rotate(360deg); }
}
.acd-progress-label {
    font-size: .9rem;
    color: var(--acd-text-muted);
    margin: 0 0 16px;
    font-weight: 500;
}
.acd-progress-bar-wrap {
    width: 100%;
    height: 6px;
    background: var(--acd-border);
    border-radius: 99px;
    overflow: hidden;
    margin-bottom: 10px;
}
.acd-progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--acd-primary), #5badff);
    border-radius: 99px;
    transition: width .2s ease;
}
.acd-progress-pct {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--acd-primary);
    display: block;
}

/* ── Toast Notifications ─────────────────────────────────────────── */
#acd-toast-container {
    position: fixed;
    top: 24px;
    right: 24px;
    z-index: 100000;
    display: flex;
    flex-direction: column;
    gap: 10px;
    pointer-events: none;
}
.acd-toast {
    font-family: var(--acd-font);
    background: var(--acd-text);
    color: #fff;
    padding: 14px 20px;
    border-radius: var(--acd-radius-sm);
    font-size: .9rem;
    font-weight: 500;
    max-width: 360px;
    box-shadow: 0 8px 32px rgba(0,0,0,.2);
    pointer-events: all;
    display: flex;
    align-items: center;
    gap: 10px;
    animation: acdToastIn .3s ease both;
    position: relative;
    overflow: hidden;
}
.acd-toast.success { background: var(--acd-success); }
.acd-toast.error   { background: var(--acd-error); }
.acd-toast.warn    { background: var(--acd-warn); }
.acd-toast::after {
    content: '';
    position: absolute;
    bottom: 0; left: 0;
    height: 3px;
    background: rgba(255,255,255,.35);
    animation: acdToastTimer 4s linear forwards;
}
@keyframes acdToastIn {
    from { opacity: 0; transform: translateX(24px); }
    to   { opacity: 1; transform: translateX(0); }
}
@keyframes acdToastTimer {
    from { width: 100%; }
    to   { width: 0%; }
}
.acd-toast.hiding {
    animation: acdToastOut .25s ease forwards;
}
@keyframes acdToastOut {
    to { opacity: 0; transform: translateX(24px); }
}
.toast-icon { font-size: 1.1em; }
.toast-close {
    margin-left: auto;
    background: none;
    border: none;
    color: rgba(255,255,255,.7);
    cursor: pointer;
    font-size: 1rem;
    padding: 0;
    line-height: 1;
}

/* ── Responsive ─────────────────────────────────────────────────── */
@media (max-width: 680px) {
    .acd-form-header  { padding: 28px 24px 24px; }
    #acd-main-form    { padding: 0 20px 32px; }
    .acd-fields-grid  { grid-template-columns: 1fr; }
    .acd-field.col-half { grid-column: 1 / -1; }
    #acd-img-preview  { grid-template-columns: repeat(auto-fill, minmax(80px, 1fr)); }
    #acd-toast-container { top: 12px; right: 12px; left: 12px; }
    .acd-toast        { max-width: 100%; }
}

/* ── Map Section ─────────────────────────────────────────────────── */
.acd-map-section { padding-bottom: 8px; }

.acd-map-header {
    display: flex;
    align-items: center;
    min-height: 28px;
    margin-bottom: 10px;
}
.acd-map-status {
    font-size: .8rem;
    padding: 4px 12px;
    border-radius: 20px;
    display: inline-flex;
    align-items: center;
    gap: 5px;
    transition: all .2s;
}
.acd-map-status:empty { display: none; }
.acd-map-status.searching { background:#eff6ff; color:#2563eb; }
.acd-map-status.found     { background:#f0fdf4; color:#16a34a; }
.acd-map-status.notfound  { background:#fef2f2; color:#dc2626; }

.acd-map-container {
    border-radius: 14px;
    overflow: hidden;
    border: 2px solid var(--acd-border, #e2e8f0);
    position: relative;
}
.acd-map-canvas {
    width: 100%;
    height: 340px;
    display: block;
}
@media (max-width: 680px) {
    .acd-map-canvas { height: 240px; }
}
