/* ============================================================
   style.css — CMI Service Quick Poll
   Responsive, mobile-first, blue/white theme
   ============================================================ */

/* Google Font import is done via <link> in HTML */

/* ── Reset & base ─────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
    --primary:        #c0392b;
    --primary-dark:   #922b21;
    --primary-light:  #fadbd8;
    --primary-xlight: #fdedec;
    --accent:         #e74c3c;
    --star-gold:      #f59e0b;
    --star-hover:     #fbbf24;
    --star-empty:     #d1d5db;
    --text-dark:      #1e293b;
    --text-muted:     #64748b;
    --bg:             #fdf5f5;
    --white:          #ffffff;
    --border:         #f5c6c2;
    --success:        #10b981;
    --success-dark:   #059669;
    --danger:         #ef4444;
    --warning:        #f59e0b;
    --radius:         14px;
    --radius-sm:      8px;
    --shadow:         0 4px 24px rgba(146, 43, 33, .10);
    --shadow-lg:      0 8px 40px rgba(146, 43, 33, .18);
    --transition:     .25s ease;
}

html { scroll-behavior: smooth; }

body {
    font-family: 'Noto Sans Lao', 'Phetsarath OT', 'Sarabun', sans-serif;
    background: var(--bg);
    color: var(--text-dark);
    line-height: 1.6;
    min-height: 100vh;
    /* Prevent horizontal overflow on mobile */
    overflow-x: hidden;
}

/* ── Layout wrapper ───────────────────────────────────────── */
.page-wrapper {
    max-width: 720px;
    width: 100%;
    margin: 0 auto;
    padding: 0 16px 60px;
}

/* ── Header / Hero ────────────────────────────────────────── */
.site-header {
    background: linear-gradient(135deg, #7b241c 0%, #c0392b 55%, #e74c3c 100%);
    color: var(--white);
    text-align: center;
    padding: 44px 24px 36px;
    border-radius: 0 0 var(--radius) var(--radius);
    margin-bottom: 28px;
    position: relative;
    overflow: hidden;
}

.site-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");
    pointer-events: none;
}

.header-logo {
    width: 100px;
    height: 100px;
    background: #ffffff;
    border-radius: 50%;
    border: 3px solid rgba(255,255,255,.6);
    box-shadow: 0 4px 18px rgba(0,0,0,.25);
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 16px;
    padding: 8px;
    transition: transform .3s ease, box-shadow .3s ease;
}

.header-logo:hover {
    transform: scale(1.07) rotate(4deg);
    box-shadow: 0 8px 28px rgba(0,0,0,.35);
}

.header-logo img {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.header-title {
    font-size: clamp(1.4rem, 5vw, 2rem);
    font-weight: 700;
    margin-bottom: 4px;
    letter-spacing: -.3px;
    text-shadow: 0 2px 8px rgba(0,0,0,.18);
}

.header-subtitle {
    font-size: .95rem;
    opacity: .9;
    margin-bottom: 16px;
}

.header-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: rgba(255,255,255,.2);
    border: 1px solid rgba(255,255,255,.35);
    backdrop-filter: blur(8px);
    border-radius: 30px;
    padding: 6px 16px;
    font-size: .82rem;
    font-weight: 600;
    letter-spacing: .3px;
}

/* ── Instruction banner ──────────────────────────────────── */
.instruction-banner {
    background: var(--primary-xlight);
    border-left: 4px solid var(--primary);
    border-radius: var(--radius-sm);
    padding: 12px 18px;
    margin-bottom: 24px;
    font-size: .9rem;
    color: var(--primary-dark);
    display: flex;
    align-items: flex-start;
    gap: 10px;
}

.instruction-banner .icon { font-size: 1.1rem; flex-shrink: 0; margin-top: 1px; }

/* ── Card ────────────────────────────────────────────────── */
.card {
    background: var(--white);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 28px 24px;
    margin-bottom: 18px;
    border: 1px solid var(--border);
    transition: box-shadow var(--transition);
}

.card:hover { box-shadow: var(--shadow-lg); }

/* ── Question header inside card ─────────────────────────── */
.question-num {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    background: var(--primary);
    color: var(--white);
    border-radius: 50%;
    font-size: .78rem;
    font-weight: 700;
    flex-shrink: 0;
}

.question-title {
    font-size: 1.05rem;
    font-weight: 700;
    color: var(--text-dark);
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 6px;
}

.question-title .q-icon { font-size: 1.2rem; }

.question-desc {
    font-size: .86rem;
    color: var(--text-muted);
    margin-bottom: 20px;
    line-height: 1.65;
    padding-left: 38px;
}

/* ── Star Rating ─────────────────────────────────────────── */
.star-rating {
    display: flex;
    gap: 10px;
    justify-content: center;
    padding: 8px 0 4px;
    flex-wrap: wrap;
    border: none;       /* remove default fieldset border */
    margin: 0;
    padding-inline: 0;
    min-inline-size: 0;
}

.star-rating input[type="radio"] { display: none; }

.star-rating label {
    cursor: pointer;
    font-size: 2.4rem;
    color: var(--star-empty);
    transition: color .18s ease, transform .18s ease;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
}

.star-rating label .star-icon { line-height: 1; }

.star-rating label .star-label {
    font-size: .68rem;
    font-weight: 600;
    color: var(--text-muted);
    letter-spacing: .2px;
    transition: color .18s;
    white-space: nowrap;
}

/* Hover state — light gold up to hovered star */
.star-rating label:hover,
.star-rating label:hover ~ label { color: var(--star-empty); }    /* reset siblings after */

/* Reverse sibling trick: stars are ordered RTL in DOM but displayed LTR via flex-direction:row-reverse */
.star-rating {
    flex-direction: row-reverse;
    justify-content: center;
}

.star-rating label:hover,
.star-rating label:hover ~ label {
    color: var(--star-hover);
    transform: scale(1.15);
}

/* Selected state */
.star-rating input[type="radio"]:checked ~ label {
    color: var(--star-gold);
}

/* Animate the checked star itself */
.star-rating input[type="radio"]:checked + label {
    color: var(--star-gold);
    animation: starPop .3s ease forwards;
}

@keyframes starPop {
    0%   { transform: scale(1); }
    50%  { transform: scale(1.35); }
    100% { transform: scale(1.1); }
}

/* Rating legend labels — show score label on hover */
.star-rating label:hover .star-label { color: var(--star-gold); }
.star-rating input[type="radio"]:checked ~ label .star-label { color: var(--star-gold); }

/* Selected label highlight */
.star-rating input[type="radio"]:checked + label .star-label { color: var(--primary-dark); font-weight: 700; }

/* ── Rating scale legend ─────────────────────────────────── */
.rating-scale {
    display: flex;
    justify-content: space-between;
    font-size: .72rem;
    color: var(--text-muted);
    margin-top: 8px;
    padding: 0 4px;
}

/* ── Validation error state on card ─────────────────────── */
.card.has-error {
    border-color: var(--danger);
    box-shadow: 0 0 0 3px rgba(239,68,68,.12), var(--shadow);
}

.error-msg {
    color: var(--danger);
    font-size: .8rem;
    font-weight: 600;
    text-align: center;
    margin-top: 8px;
    display: none;
    animation: fadeIn .2s ease;
}

.card.has-error .error-msg { display: block; }

@keyframes fadeIn { from { opacity: 0; transform: translateY(-4px); } to { opacity: 1; transform: none; } }

/* ── Feedback textarea ───────────────────────────────────── */
.form-label {
    display: block;
    font-size: .9rem;
    font-weight: 700;
    margin-bottom: 8px;
    color: var(--text-dark);
}

.form-textarea {
    width: 100%;
    border: 1.5px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 12px 14px;
    font-family: inherit;
    font-size: 1rem;   /* 16px prevents iOS auto-zoom */
    color: var(--text-dark);
    resize: vertical;
    min-height: 100px;
    transition: border-color var(--transition), box-shadow var(--transition);
    background: var(--bg);
}

.form-textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(192,57,43,.12);
    background: var(--white);
}

.form-textarea::placeholder { color: #94a3b8; }

/* ── Branch select ───────────────────────────────────────── */
.form-select {
    width: 100%;
    border: 1.5px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 10px 14px;
    font-family: inherit;
    font-size: 1rem;   /* 16px prevents iOS auto-zoom */
    color: var(--text-dark);
    background: var(--bg);
    cursor: pointer;
    transition: border-color var(--transition), box-shadow var(--transition);
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='%2364748b' viewBox='0 0 16 16'%3E%3Cpath d='M7.247 11.14L2.451 5.658C1.885 5.013 2.345 4 3.204 4h9.592a1 1 0 0 1 .753 1.659l-4.796 5.48a1 1 0 0 1-1.506 0z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 14px center;
    padding-right: 40px;
}

.form-select:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(192,57,43,.12);
    background-color: var(--white);
}

/* ── Submit button ───────────────────────────────────────── */
.btn-submit {
    display: block;
    width: 100%;
    padding: 16px 24px;
    background: linear-gradient(135deg, #c0392b 0%, #922b21 100%);
    color: var(--white);
    border: none;
    border-radius: var(--radius);
    font-family: inherit;
    font-size: 1.05rem;
    font-weight: 700;
    cursor: pointer;
    box-shadow: 0 4px 16px rgba(192,57,43,.40);
    transition: transform .18s ease, box-shadow .18s ease, opacity .18s;
    letter-spacing: .3px;
    margin-top: 8px;
}

.btn-submit:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 8px 24px rgba(192,57,43,.50);
}

.btn-submit:active:not(:disabled) { transform: translateY(0); }

.btn-submit:disabled {
    opacity: .55;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

/* ── Progress dots ───────────────────────────────────────── */
.progress-bar {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    margin: 0 0 24px;
}

.progress-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: var(--border);
    transition: background var(--transition), transform .2s;
}

.progress-dot.done   { background: var(--success); transform: scale(1.2); }
.progress-dot.active { background: var(--primary);  transform: scale(1.3); }

/* ── Footer note ─────────────────────────────────────────── */
.form-footer {
    text-align: center;
    font-size: .78rem;
    color: var(--text-muted);
    margin-top: 20px;
    line-height: 1.7;
}

/* ── Responsive — Mobile-first ───────────────────────────── */

/* ── Small phones (≤ 480px) ─────────────────────────── */
@media (max-width: 480px) {
    /* Header */
    .site-header        { padding: 28px 16px 24px; margin-bottom: 18px; }
    .header-logo        { width: 76px; height: 76px; margin-bottom: 12px; }
    .header-title       { font-size: 1.25rem; }
    .header-subtitle    { font-size: .8rem; margin-bottom: 12px; }
    .header-badge       { font-size: .75rem; padding: 5px 12px; }

    /* Layout */
    .page-wrapper       { padding: 0 10px 64px; }
    .card               { padding: 18px 14px; margin-bottom: 14px; }

    /* Instruction banner */
    .instruction-banner { font-size: .82rem; padding: 10px 14px; }

    /* Question */
    .question-title     { font-size: .95rem; gap: 8px; }
    .question-num       { width: 24px; height: 24px; font-size: .72rem; }
    .question-desc      { font-size: .82rem; padding-left: 0; margin-bottom: 16px; }

    /* Stars — bigger touch targets, fewer per row still fits */
    .star-rating        { gap: 4px; }
    .star-rating label  { font-size: 2.5rem; gap: 2px; }
    .star-rating label .star-label { font-size: .65rem; }

    /* Service type vertical items */
    .stype-label        { padding: 12px 14px; font-size: .88rem; }

    /* Submit button */
    .btn-submit         { font-size: 1rem; padding: 15px 20px; }

    /* Footer */
    .form-footer        { font-size: .72rem; }
}

/* ── Tablet / large phone (481px – 720px) ───────────── */
@media (min-width: 481px) and (max-width: 720px) {
    .site-header        { padding: 36px 20px 30px; }
    .header-logo        { width: 88px; height: 88px; }
    .page-wrapper       { padding: 0 14px 64px; }
    .card               { padding: 22px 20px; }
    .star-rating label  { font-size: 2.6rem; }
    .star-rating        { gap: 8px; }
}

/* ── Touch device: bigger tap targets for stars ─────── */
@media (hover: none) and (pointer: coarse) {
    .star-rating label  { min-width: 44px; min-height: 44px; justify-content: center; }
    .stype-label        { min-height: 52px; }
    .btn-submit         { min-height: 54px; }
    .form-select,
    .form-textarea      { font-size: 16px; } /* prevent iOS auto-zoom */
}

/* ── Thank-you page ──────────────────────────────────────── */
.thankyou-card {
    text-align: center;
    padding: 48px 24px;
}

.thankyou-icon {
    display: block;
    margin-bottom: 16px;
    animation: bounceIn .5s ease;
}

.mascot-img {
    width: 180px;
    height: 180px;
    object-fit: contain;
    filter: drop-shadow(0 4px 16px rgba(192,57,43,.20));
}

@keyframes bounceIn {
    0%  { transform: scale(.5); opacity: 0; }
    60% { transform: scale(1.15); opacity: 1; }
    80% { transform: scale(.95); }
    100%{ transform: scale(1); }
}

.thankyou-title {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--primary-dark);
    margin-bottom: 8px;
}

.thankyou-msg {
    font-size: .95rem;
    color: var(--text-muted);
    margin-bottom: 24px;
    line-height: 1.7;
}

.btn-back {
    display: inline-block;
    padding: 12px 32px;
    background: var(--primary);
    color: var(--white);
    text-decoration: none;
    border-radius: var(--radius);
    font-weight: 700;
    font-size: .95rem;
    transition: background var(--transition), transform .18s;
}

.btn-back:hover { background: var(--primary-dark); transform: translateY(-2px); }

/* ── Dashboard ───────────────────────────────────────────── */
.dash-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}

.stat-card {
    background: var(--white);
    border-radius: var(--radius);
    padding: 20px;
    text-align: center;
    box-shadow: var(--shadow);
    border: 1px solid var(--border);
}

.stat-card .stat-value {
    font-size: 2rem;
    font-weight: 800;
    color: var(--primary);
    line-height: 1;
    margin-bottom: 4px;
}

.stat-card .stat-label {
    font-size: .78rem;
    color: var(--text-muted);
    font-weight: 600;
}

.pct-ring {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 1.6rem;
    font-weight: 800;
}

.pct-ring.pass  { color: var(--success); }
.pct-ring.warn  { color: var(--warning); }
.pct-ring.fail  { color: var(--danger);  }

.section-title {
    font-size: 1.05rem;
    font-weight: 700;
    color: var(--text-dark);
    margin-bottom: 14px;
    display: flex;
    align-items: center;
    gap: 8px;
}

/* Table */
.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: .85rem;
}

.data-table th {
    background: var(--primary-xlight);
    color: var(--primary-dark);
    font-weight: 700;
    padding: 10px 12px;
    text-align: left;
    border-bottom: 2px solid var(--primary-light);
}

.data-table td {
    padding: 9px 12px;
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
}

.data-table tbody tr:hover { background: var(--primary-xlight); }

/* Alert badges */
.badge {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 30px;
    font-size: .72rem;
    font-weight: 700;
    white-space: nowrap;
}

.badge-success { background: #d1fae5; color: #065f46; }
.badge-warning { background: #fef3c7; color: #92400e; }
.badge-danger  { background: #fee2e2; color: #991b1b; }
.badge-info    { background: var(--primary-light); color: var(--primary-dark); }

/* Progress bar for satisfaction % */
.pct-bar-wrap { background: var(--bg); border-radius: 8px; height: 8px; overflow: hidden; min-width: 80px; }
.pct-bar      { height: 100%; border-radius: 8px; transition: width .6s ease; }
.pct-bar.pass { background: var(--success); }
.pct-bar.warn { background: var(--warning); }
.pct-bar.fail { background: var(--danger);  }

/* Trend indicator */
.trend-up   { color: var(--success); font-weight: 700; }
.trend-down { color: var(--danger);  font-weight: 700; }

/* Dashboard nav */
.dash-nav {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 24px;
    flex-wrap: wrap;
}

.dash-nav a {
    display: inline-block;
    padding: 8px 18px;
    border-radius: 30px;
    font-size: .85rem;
    font-weight: 600;
    text-decoration: none;
    background: var(--white);
    color: var(--primary);
    border: 1.5px solid var(--primary-light);
    transition: background var(--transition), color var(--transition);
}

.dash-nav a:hover,
.dash-nav a.active {
    background: var(--primary);
    color: var(--white);
    border-color: var(--primary);
}
