/* ============================
   Design Tokens
   ============================ */
:root {
    --primary: #0F6E56;
    --primary-hover: #0A4A3A;
    --primary-light: #6FBA8A;
    --primary-bg: #F0FDF4;
    --secondary: #10B981;
    --warning: #F59E0B;
    --danger: #DC2626;
    --text-primary: #111827;
    --text-secondary: #6B7280;
    --border: #E5E7EB;
    --bg-page: #F9FAFB;
    --bg-card: #FFFFFF;
    
    --shadow-sm: 0 1px 3px rgba(0,0,0,0.04);
    --shadow-md: 0 4px 12px rgba(0,0,0,0.06);
    --shadow-lg: 0 10px 25px rgba(0,0,0,0.08);
    
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 24px;
    --radius-xl: 28px;
    
    --transition-fast: 0.15s ease;
    --transition-normal: 0.3s ease;
}

/* ============================
   Page wrap + background
   ============================ */
body {
    background: var(--bg-page);
    margin: 0;
    padding: 0;
    font-family: 'Noto Sans Thai', -apple-system, BlinkMacSystemFont, sans-serif;
    -webkit-font-smoothing: antialiased;
    color: var(--text-primary);
}

.hidden {
    display: none !important;
}

.page-wrap {
    min-height: 100vh;
    padding: 24px 16px;
    display: flex;
    justify-content: center;
    align-items: flex-start;
}

/* ============================
   Card หลัก
   ============================ */
.qr-card {
    background: var(--bg-card);
    border-radius: var(--radius-xl);
    padding: 28px 24px;
    max-width: 380px;
    width: 100%;
    box-shadow: var(--shadow-md);
    border: 1px solid var(--border);
    box-sizing: border-box;
    transition: var(--transition-normal);
}

/* ============================
   Header (Logo + Title)
   ============================ */
.card-header {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    margin-bottom: 28px;
}

.company-logo {
    width: 64px;
    height: auto;
    flex-shrink: 0;
    object-fit: contain;
}

.header-text {
    flex: 1;
    min-width: 0;
}

.header-text h1 {
    font-size: 13px;
    font-weight: 500;
    color: var(--text-primary);
    margin: 0 0 4px;
    line-height: 1.4;
    word-break: break-word;
}

.header-text .company-name {
    font-size: 11px;
    color: var(--text-secondary);
    margin: 0;
    line-height: 1.4;
    word-break: break-word;
}

/* ============================
   Form
   ============================ */
.qr-form {
    width: 100%;
}

.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    font-size: 14px;
    font-weight: 500;
    color: var(--text-primary);
    margin-bottom: 8px;
}

.required {
    color: var(--danger);
    margin-left: 2px;
}

.form-input {
    width: 100%;
    padding: 14px 16px;
    font-size: 15px;
    font-family: inherit;
    color: var(--text-primary);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    background: var(--bg-card);
    box-sizing: border-box;
    transition: border-color 0.15s, box-shadow 0.15s, background 0.4s;
    min-height: 50px;
}

.form-input::placeholder {
    color: var(--text-secondary);
}

.form-input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(15, 110, 86, 0.08);
}

/* Auto-fill flash animation */
.form-input.autofilled {
    background: var(--primary-bg);
    border-color: #86EFAC;
    animation: autofillFlash 0.6s ease;
}

@keyframes autofillFlash {
    0% { background: #FFFFFF; }
    50% { background: #DCFCE7; }
    100% { background: var(--primary-bg); }
}

input.form-input[readonly] {
    background-color: #F3F4F6;
    color: #6B7280;
    cursor: not-allowed;
    border-color: #E5E7EB;
}

/* Select dropdown chevron */
.form-select {
    appearance: none;
    -webkit-appearance: none;
    background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%239CA3AF' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'><polyline points='6 9 12 15 18 9'></polyline></svg>");
    background-repeat: no-repeat;
    background-position: right 16px center;
    padding-right: 42px;
    cursor: pointer;
}



/* ============================
   Customer info display (read-only)
   ============================ */
.customer-info {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 14px;
    background: var(--primary-bg);
    border: 1px solid #BBF7D0;
    border-radius: var(--radius-sm);
    margin-bottom: 20px;
    font-size: 13px;
    color: #166534;
    animation: fadeInUp 0.25s ease;
}

.customer-info svg {
    flex-shrink: 0;
    color: #16A34A;
}

.customer-info strong {
    color: #14532D;
    font-weight: 600;
}

@keyframes fadeInUp {
    from { opacity: 0; transform: translateY(4px); }
    to { opacity: 1; transform: translateY(0); }
}

/* ============================
   ปุ่มสร้าง QR (เขียวอ่อนตามภาพ)
   ============================ */
.btn-create-qr {
    width: 100%;
    padding: 15px;
    background: var(--primary-light);
    color: white;
    border: none;
    border-radius: var(--radius-md);
    font-size: 16px;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    transition: var(--transition-normal);
    margin-top: 8px;
    box-shadow: 0 4px 12px rgba(111, 186, 138, 0.3);
}

.btn-create-qr:hover {
    background: #5FA77A; /* slightly darker green for hover */
    box-shadow: 0 6px 16px rgba(111, 186, 138, 0.4);
    transform: translateY(-1px);
}

.btn-create-qr:active {
    transform: scale(0.98);
    box-shadow: 0 2px 8px rgba(111, 186, 138, 0.2);
}

.btn-create-qr:disabled {
    background: #D1D5DB;
    cursor: not-allowed;
    box-shadow: none;
    transform: none;
}

/* ============================
   Mobile small (< 360px)
   ============================ */
@media (max-width: 360px) {
    .qr-card {
        padding: 24px 18px;
        border-radius: 22px;
    }
    
    .company-logo {
        width: 56px;
    }
    
    .header-text h1 {
        font-size: 12px;
    }
}

/* ==========================================
   QR Display Card
   ========================================== */
.qr-display-card {
    background: #FFFFFF;
    border-radius: 28px;
    padding: 20px;
    max-width: 380px;
    width: 100%;
    margin: 16px auto 0;
    box-shadow: 0 1px 3px rgba(0,0,0,0.04);
    border: 1px solid #F3F4F6;
    box-sizing: border-box;
    animation: fadeIn 0.35s ease;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
}

/* ==========================================
   กรอบเส้นประ — ครอบ Header + QR + Info
   ========================================== */
.qr-dashed-frame {
    border: 1.5px dashed #D1D5DB;
    border-radius: 20px;
    padding: 16px 14px 18px;
    background: #FFFFFF;
}

/* Header เล็กใน frame */
.qr-frame-header {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 0 4px 12px;
}

.qr-frame-logo {
    width: 32px;
    height: auto;
    flex-shrink: 0;
    object-fit: contain;
}

.qr-frame-title {
    font-size: 11px;
    color: #374151;
    font-weight: 500;
    line-height: 1.4;
    flex: 1;
    min-width: 0;
    word-break: break-word;
}

/* เส้นคั่น */
.qr-frame-divider {
    border: none;
    border-top: 1px solid #E5E7EB;
    margin: 0;
}

.qr-frame-divider.top {
    margin-bottom: 16px;
}

.qr-frame-divider.bottom {
    margin-top: 16px;
    margin-bottom: 16px;
}

/* QR Canvas Area */
.qr-canvas-container {
    text-align: center;
    padding: 4px 0;
    position: relative;
}

#qr-canvas {
    display: block;
    margin: 0 auto;
    max-width: 100%;
    height: auto;
}

/* Info section */
.qr-info {
    padding: 0 4px;
}

.qr-info-row {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    padding: 6px 0;
    gap: 12px;
    font-size: 12px;
}

.qr-info-row .info-label {
    color: #6B7280;
    font-weight: 400;
    width: 135px;
    flex-shrink: 0;
}

.qr-info-row .info-value {
    color: #111827;
    font-weight: 500;
    text-align: left;
    word-break: break-word;
    flex: 1;
}

/* ==========================================
   ปุ่ม Actions (Outline style)
   ========================================== */
.qr-actions {
    margin-top: 16px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.btn-row-2 {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
}

.btn-outline {
    background: #FFFFFF;
    color: #1F2937;
    border: 1px solid #E5E7EB;
    border-radius: 12px;
    padding: 14px 16px;
    font-size: 14px;
    font-weight: 500;
    font-family: inherit;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: all 0.15s;
    min-height: 50px;
}

.btn-outline svg {
    flex-shrink: 0;
    stroke: #1F2937;
}

.btn-outline:hover {
    border-color: #0F6E56;
    color: #0F6E56;
    background: #F0FDF4;
}

.btn-outline:hover svg {
    stroke: #0F6E56;
}

.btn-outline:active {
    transform: scale(0.98);
}

.btn-outline.btn-full {
    width: 100%;
}

/* ==========================================
   ปุ่ม Reset text เล็กข้างล่าง
   ========================================== */
.btn-reset-text {
    background: transparent;
    border: none;
    color: #6B7280;
    font-size: 13px;
    font-weight: 400;
    font-family: inherit;
    cursor: pointer;
    width: 100%;
    text-align: center;
    padding: 14px 8px;
    margin-top: 4px;
    transition: color 0.15s;
}

.btn-reset-text:hover {
    color: #0F6E56;
    text-decoration: underline;
}

/* ==========================================
   Mobile small (< 360px)
   ========================================== */
@media (max-width: 360px) {
    .qr-display-card {
        padding: 16px;
        border-radius: 22px;
    }
    
    .qr-dashed-frame {
        padding: 14px 12px 16px;
        border-radius: 16px;
    }
    
    .qr-frame-title {
        font-size: 10px;
    }
    
    #qr-canvas {
        width: 200px !important;
        height: 200px !important;
    }
    
    .btn-outline {
        font-size: 13px;
        padding: 12px 10px;
    }
}

/* ==========================================
   Survey Form Card Styles
   ========================================== */
.survey-body {
    background: #F9FAFB;
}

.survey-container {
    padding: 24px 16px 40px;
    display: flex;
    justify-content: center;
}

.survey-card {
    background: #FFFFFF;
    border-radius: 20px;
    padding: 28px 24px;
    max-width: 420px;
    width: 100%;
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.05), 0 4px 6px -2px rgba(0, 0, 0, 0.025);
    border: 1px solid #F3F4F6;
    box-sizing: border-box;
    margin-bottom: 32px;
}

.error-content {
    text-align: center;
    padding: 16px 0;
    display: flex;
    flex-direction: column;
    gap: 12px;
    align-items: center;
}

/* Info Badge */
.info-badge {
    border: 1px solid #E5E7EB;
    border-radius: 12px;
    padding: 16px;
    margin-bottom: 28px;
    background: #F9FAFB;
}

.info-row {
    display: flex;
    font-size: 14px;
    line-height: 1.6;
    margin-bottom: 8px;
}

.info-row:last-child {
    margin-bottom: 0;
}

.info-label {
    color: #6B7280;
    width: 130px;
    flex-shrink: 0;
}

.info-value {
    color: #111827;
    font-weight: 600;
}

/* Titles */
.survey-title {
    font-size: 18px;
    font-weight: 700;
    color: #0F6E56;
    margin-bottom: 24px;
    text-align: center;
    line-height: 1.4;
}

/* Questions */
.question-block {
    margin-bottom: 28px;
}

.question-title {
    font-size: 15px;
    font-weight: 500;
    color: #1F2937;
    margin-bottom: 12px;
    line-height: 1.4;
}

/* Stars */
.stars-container {
    display: flex;
    gap: 14px;
    font-size: 56px;
    line-height: 1;
    justify-content: center;
    margin-bottom: 8px;
}

.star-btn {
    background: none;
    border: none;
    padding: 0;
    margin: 0;
    cursor: pointer;
    color: #D1D5DB;
    transition: color 0.2s, transform 0.1s;
    -webkit-tap-highlight-color: transparent;
    font-size: inherit;
    line-height: inherit;
    touch-action: manipulation;
}

.star-btn.active, .star-btn.hover-active {
    color: var(--warning); /* Golden Yellow stars */
}

.star-btn:active {
    transform: scale(0.85);
}

.rating-text {
    text-align: center;
    font-size: 14px;
    font-weight: 600;
    min-height: 20px;
    margin-top: -4px;
    margin-bottom: 12px;
    color: #6B7280;
    transition: color 0.2s;
}

.rating-text.level-5 { color: #10B981; } /* ดีมาก - Green */
.rating-text.level-4 { color: #3B82F6; } /* ดี - Blue */
.rating-text.level-3 { color: #F59E0B; } /* ปานกลาง - Yellow */
.rating-text.level-2 { color: #F97316; } /* พอใช้ - Orange */
.rating-text.level-1 { color: #EF4444; } /* ต้องปรับปรุง - Red */

/* Checkboxes */
.checkbox-group {
    display: flex;
    flex-direction: column;
    gap: 14px;
    margin-left: 4px;
}

.checkbox-label {
    display: flex;
    align-items: center;
    cursor: pointer;
    font-size: 14.5px;
    color: #374151;
}

.checkbox-label input[type="checkbox"] {
    position: absolute;
    opacity: 0;
    width: 0;
    height: 0;
    pointer-events: none;
}

.custom-checkbox {
    width: 20px;
    height: 20px;
    background: #F3F4F6;
    border: 1px solid #D1D5DB;
    border-radius: 6px;
    margin-right: 12px;
    position: relative;
    transition: all 0.2s;
    flex-shrink: 0;
}

.checkbox-label input[type="checkbox"]:checked + .custom-checkbox {
    background: #0F6E56;
    border-color: #0F6E56;
}

.checkbox-label input[type="checkbox"]:checked + .custom-checkbox::after {
    content: '';
    position: absolute;
    left: 6px;
    top: 2px;
    width: 5px;
    height: 10px;
    border: solid white;
    border-width: 0 2px 2px 0;
    transform: rotate(45deg);
}

.inline-input-wrapper {
    align-items: center;
    flex-wrap: wrap;
}

.inline-text-input {
    border: none;
    border-bottom: 1px solid #D1D5DB;
    background: transparent;
    font-family: inherit;
    font-size: 14.5px;
    padding: 4px 6px;
    margin-left: 8px;
    width: 180px;
    outline: none;
    color: #111827;
    transition: border-color 0.2s;
}

.inline-text-input:disabled {
    background: transparent;
    border-bottom-color: #E5E7EB;
    color: #9CA3AF;
}

.inline-text-input:focus {
    border-bottom-color: #0F6E56;
}

/* Divider */
.survey-divider {
    border: none;
    border-top: 1px solid #E5E7EB;
    margin: 36px 0;
}

/* Contact Section */
.section-subtitle {
    font-size: 16px;
    font-weight: 600;
    color: #0F6E56;
    margin-bottom: 24px;
    line-height: 1.5;
}

.section-subtitle.bold {
    font-weight: 700;
    margin-bottom: 12px;
}

.form-group-contact {
    margin-bottom: 20px;
}

.form-group-contact label {
    display: block;
    font-size: 13.5px;
    font-weight: 500;
    color: #374151;
    margin-bottom: 8px;
}

.form-input-contact {
    width: 100%;
    padding: 14px;
    font-size: 15px;
    font-family: inherit;
    color: #111827;
    background: #F9FAFB;
    border: 1px solid #E5E7EB;
    border-radius: 10px;
    box-sizing: border-box;
    transition: all 0.2s;
}

.form-input-contact:focus {
    outline: none;
    border-color: #0F6E56;
    background: #FFFFFF;
    box-shadow: 0 0 0 3px rgba(15, 110, 86, 0.1);
}

/* PDPA */
.pdpa-section {
    margin-top: 40px;
    padding-top: 32px;
    border-top: 1px solid #E5E7EB;
}

.pdpa-intro {
    font-size: 14px;
    color: #4B5563;
    margin-bottom: 20px;
}

.pdpa-toggle {
    color: #DC2626;
    font-weight: 500;
    text-decoration: none;
    touch-action: manipulation;
}

button.pdpa-toggle {
    background: none;
    border: none;
    padding: 0;
    font: inherit;
    cursor: pointer;
    display: inline;
    -webkit-tap-highlight-color: transparent;
}

.pdpa-toggle:hover {
    text-decoration: underline;
}

.pdpa-full-text {
    background: #FEF2F2;
    padding: 16px 20px;
    border-radius: 12px;
    margin-bottom: 20px;
    border: 1px solid #FEE2E2;
}

.pdpa-red-text {
    font-size: 13px;
    color: #DC2626;
    line-height: 1.6;
    margin: 0 0 12px 0;
}

.pdpa-red-text:last-child {
    margin-bottom: 0;
}

.pdpa-red-text a {
    color: #DC2626;
    text-decoration: underline;
    word-break: break-all;
    overflow-wrap: break-word;
    font-weight: 500;
}

.pdpa-question {
    font-size: 14.5px;
    font-weight: 500;
    color: #1F2937;
    margin-bottom: 16px;
}

/* Radio Buttons */
.radio-group {
    display: flex;
    flex-direction: column;
    gap: 14px;
    margin-left: 4px;
}

.radio-label {
    display: flex;
    align-items: center;
    cursor: pointer;
    font-size: 14.5px;
    color: #374151;
}

.radio-label input[type="radio"] {
    display: none;
}

.custom-radio {
    width: 22px;
    height: 22px;
    border: 2px solid #D1D5DB;
    background: #F9FAFB;
    border-radius: 50%;
    margin-right: 12px;
    position: relative;
    box-sizing: border-box;
    transition: all 0.2s;
}

.radio-label input[type="radio"]:checked + .custom-radio {
    border-color: #0F6E56;
}

.radio-label input[type="radio"]:checked + .custom-radio::after {
    content: '';
    position: absolute;
    width: 12px;
    height: 12px;
    background: #0F6E56;
    border-radius: 50%;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
}

/* Step Indicator */
.step-progress {
    text-align: center;
    margin-bottom: 24px;
}

.step-dots {
    display: flex;
    justify-content: center;
    gap: 8px;
    margin-bottom: 8px;
}

.step-dot {
    width: 40px;
    height: 6px;
    background: #E5E7EB;
    border-radius: 3px;
    transition: background 0.3s;
}

.step-dot.active {
    background: #0F6E56;
}

.step-text {
    font-size: 13px;
    color: var(--text-secondary);
    font-weight: 500;
}

/* Action Buttons */
.action-buttons {
    margin-top: 32px;
}

.dual-btn {
    display: flex;
    gap: 12px;
}

.dual-btn button {
    flex: 1;
}

.btn-outline-survey {
    background: var(--bg-card);
    color: var(--text-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 16px;
    font-size: 16px;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    transition: var(--transition-normal);
    width: 100%;
    margin-top: 12px;
    touch-action: manipulation;
}

.btn-outline-survey:hover {
    background: var(--bg-page);
    border-color: #9CA3AF;
    color: var(--text-primary);
}

.btn-outline-survey:active {
    transform: translateY(0);
}

/* ===============================
   WebView Warning Banner
=============================== */
.webview-banner {
    background-color: #FEF3C7;
    border-bottom: 1px solid #FDE68A;
    color: #92400E;
    padding: 12px 16px;
    display: none;
}

.webview-banner:not([hidden]) {
    display: block;
    animation: slideDown 0.3s ease-out;
}

@keyframes slideDown {
    from { transform: translateY(-100%); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}

.webview-banner-content {
    display: flex;
    align-items: center;
    gap: 12px;
    max-width: 600px;
    margin: 0 auto;
}

.webview-icon {
    flex-shrink: 0;
    color: #D97706;
    display: flex;
    align-items: center;
    justify-content: center;
}

.webview-text {
    flex-grow: 1;
}

.webview-title {
    font-size: 14px;
    font-weight: 600;
    margin: 0 0 4px;
}

.webview-detail {
    font-size: 12px;
    margin: 0;
    opacity: 0.9;
}

.webview-btn {
    flex-shrink: 0;
    background-color: #D97706;
    color: #FFFFFF;
    border: none;
    border-radius: 20px;
    padding: 6px 14px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: background-color 0.2s;
    font-family: inherit;
    box-shadow: 0 2px 4px rgba(217, 119, 6, 0.2);
}

.webview-btn:active {
    background-color: #B45309;
    transform: scale(0.95);
}

/* ===============================
   Custom Prompt Modal
=============================== */
.modal-overlay {
    position: fixed;
    top: 0; left: 0; width: 100%; height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(4px);
    opacity: 0;
    transition: opacity 0.2s ease;
    visibility: hidden;
}

.modal-overlay:not([hidden]) {
    opacity: 1;
    visibility: visible;
}

.modal-card {
    background: #FFFFFF;
    border-radius: 16px;
    width: 90%;
    max-width: 320px;
    padding: 24px;
    box-shadow: 0 10px 25px rgba(0,0,0,0.15);
    transform: scale(0.95);
    transition: transform 0.2s ease;
}

.modal-overlay:not([hidden]) .modal-card {
    transform: scale(1);
}

.modal-title {
    margin: 0 0 8px;
    font-size: 18px;
    font-weight: 600;
    color: #111827;
}

.modal-desc {
    margin: 0 0 16px;
    font-size: 14px;
    color: #4B5563;
    line-height: 1.4;
}

.modal-input {
    width: 100%;
    box-sizing: border-box;
    padding: 12px;
    border: 1px solid #D1D5DB;
    border-radius: 8px;
    font-size: 14px;
    margin-bottom: 24px;
    outline: none;
    font-family: inherit;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.modal-input:focus {
    border-color: #10B981;
    box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.1);
}

.modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 12px;
}

.btn-cancel {
    background: #F3F4F6;
    color: #4B5563;
    border: none;
    padding: 8px 16px;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    font-family: inherit;
}

.btn-cancel:active { background: #E5E7EB; }

.btn-ok {
    background: var(--primary-color, #0F6E56);
    color: #FFFFFF;
    border: none;
    padding: 8px 16px;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    font-family: inherit;
}

.btn-ok:active { opacity: 0.8; }


.form-step {
    animation: fadeInStep 0.3s ease;
}

@keyframes fadeInStep {
    from { opacity: 0; transform: translateX(10px); }
    to { opacity: 1; transform: translateX(0); }
}

/* Submit Button */
.btn-submit-survey {
    background: var(--primary);
    color: #FFFFFF;
    border: none;
    border-radius: var(--radius-md);
    padding: 16px;
    font-size: 16px;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    transition: var(--transition-normal);
    width: 100%;
    margin-top: 12px;
    box-shadow: 0 4px 12px rgba(15, 110, 86, 0.25);
    touch-action: manipulation;
}

.btn-submit-survey:hover {
    background: var(--primary-hover);
    transform: translateY(-1px);
    box-shadow: 0 6px 16px rgba(15, 110, 86, 0.35);
}

.btn-submit-survey:active {
    transform: translateY(0);
    box-shadow: 0 2px 8px rgba(15, 110, 86, 0.2);
}

.btn-submit-survey:disabled {
    background: #9CA3AF;
    box-shadow: none;
    cursor: not-allowed;
    transform: none;
}

/* ==========================================
   Dashboard Styles
   ========================================== */
.container-dashboard {
    max-width: 1200px;
    margin: 0 auto;
    padding: 24px;
}

.dashboard-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 24px;
    flex-wrap: wrap;
    gap: 16px;
}

.logo-box {
    width: 48px;
    height: 48px;
    border-radius: var(--radius-md);
    color: white;
    font-size: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.filter-bar {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    align-items: center;
}

.filter-btn {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 8px 16px;
    font-size: 14px;
    color: var(--text-secondary);
    cursor: pointer;
    transition: var(--transition-fast);
}

.filter-btn:hover {
    background: var(--bg-page);
    color: var(--text-primary);
}

.filter-btn.active {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
    box-shadow: 0 2px 6px rgba(15, 110, 86, 0.2);
}

.date-range-container {
    display: flex;
    align-items: center;
    gap: 8px;
    background: var(--bg-card);
    padding: 4px 8px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
}

.date-input {
    border: none;
    background: transparent;
    font-family: inherit;
    color: var(--text-primary);
    font-size: 13px;
    outline: none;
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}

.stat-card {
    background: var(--bg-card);
    border-radius: var(--radius-md);
    padding: 20px;
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    transition: var(--transition-normal);
}

.stat-card:hover {
    box-shadow: var(--shadow-md);
    transform: translateY(-2px);
}

.stat-title {
    font-size: 14px;
    color: var(--text-secondary);
    font-weight: 500;
    margin-bottom: 8px;
}

.stat-value {
    font-size: 32px;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 4px;
    line-height: 1.2;
}

.stat-desc {
    font-size: 12px;
    color: var(--text-secondary);
}

/* Base Card Style for Dashboard Sections */
.card {
    background: var(--bg-card);
    border-radius: var(--radius-md);
    padding: 24px;
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border);
    margin-bottom: 24px;
}

.card-title {
    margin-bottom: 16px;
}

.card-title h2 {
    font-size: 18px;
    font-weight: 600;
    color: var(--text-primary);
    margin: 0;
}

/* Question Stats Grid */
.question-stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
}

.question-stat {
    background: var(--bg-page);
    padding: 16px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
}

.qs-title {
    font-size: 13px;
    color: var(--text-secondary);
    margin-bottom: 8px;
    min-height: 38px;
}

.qs-value {
    font-size: 24px;
    font-weight: 700;
    color: var(--primary);
}

.qs-stars {
    color: var(--warning);
    font-size: 16px;
}

/* Table Styles */
.table-responsive {
    overflow-x: auto;
}

table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    font-size: 14px;
}

th {
    background: var(--bg-page);
    color: var(--text-secondary);
    font-weight: 600;
    text-align: left;
    padding: 12px 16px;
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
}

td {
    padding: 14px 16px;
    border-bottom: 1px solid var(--border);
    color: var(--text-primary);
    vertical-align: middle;
}

tbody tr {
    transition: background-color 0.15s;
}

tbody tr:hover {
    background-color: var(--primary-bg);
}

th.sortable {
    cursor: pointer;
    user-select: none;
}

th.sortable:hover {
    color: var(--primary);
    background: #E5E7EB;
}

/* Toast Notification */
.toast-container {
    visibility: hidden;
    min-width: 280px;
    max-width: 90%;
    background-color: #374151; /* Dark Gray */
    color: #fff;
    text-align: center;
    border-radius: 8px;
    padding: 14px 16px;
    position: fixed;
    z-index: 1000;
    left: 50%;
    bottom: 20px;
    transform: translateX(-50%);
    font-size: 14px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    opacity: 0;
    transition: opacity 0.3s ease, bottom 0.3s ease, visibility 0.3s ease;
}

.toast-container.show {
    visibility: visible;
    opacity: 1;
    bottom: 40px;
}

.toast-container.error {
    background-color: #DC2626; /* Red */
}

.toast-container.success {
    background-color: #10B981; /* Green */
}

/* Utilities */
.text-center { text-align: center; }

/* Loading Card */
.loading-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 60px 20px;
}

.loading-spinner-ring {
    width: 64px;
    height: 64px;
    border-radius: 50%;
    background: conic-gradient(from 0deg, #10B981 0%, rgba(16, 185, 129, 0.1) 80%);
    mask: radial-gradient(farthest-side, transparent calc(100% - 6px), black calc(100% - 5px));
    -webkit-mask: radial-gradient(farthest-side, transparent calc(100% - 6px), black calc(100% - 5px));
    animation: spin 1s linear infinite;
    margin-bottom: 24px;
}

.loading-title {
    font-size: 16px;
    color: var(--text-primary);
    font-weight: 500;
    margin-bottom: 8px;
}

.loading-subtitle {
    font-size: 13px;
    color: var(--text-secondary);
}

/* Success Card */
.success-card {
    text-align: center;
    padding: 40px 24px;
}

.success-icon-wrapper {
    background: #E8F5E9;
    width: 64px;
    height: 64px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 24px;
    animation: successPop 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

@keyframes successPop {
    0% { transform: scale(0.5); opacity: 0; }
    100% { transform: scale(1); opacity: 1; }
}

.success-title {
    font-size: 20px;
    color: var(--primary);
    font-weight: 600;
    margin-bottom: 12px;
}

.success-subtitle {
    font-size: 15px;
    color: var(--text-primary);
    font-weight: 600;
    margin-bottom: 16px;
}

.success-desc {
    font-size: 13px;
    color: var(--text-secondary);
    line-height: 1.6;
    margin-bottom: 40px;
}

.success-divider {
    border: none;
    border-top: 1px solid #E5E7EB;
    margin-bottom: 16px;
}

.success-footer {
    font-size: 12px;
    color: #9CA3AF;
}

/* Autocomplete Dropdown */
.autocomplete-items {
    position: absolute;
    border: 1px solid #E5E7EB;
    border-bottom: none;
    border-top: none;
    z-index: 99;
    top: 100%;
    left: 0;
    right: 0;
    border-radius: 0 0 12px 12px;
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
    background-color: #fff;
    max-height: 200px;
    overflow-y: auto;
}

.autocomplete-item {
    padding: 12px 16px;
    cursor: pointer;
    background-color: #fff;
    border-bottom: 1px solid #E5E7EB;
    font-size: 14px;
    color: #1F2937;
    transition: background-color 0.2s;
    touch-action: manipulation;
}

button.autocomplete-item {
    width: 100%;
    border: none;
    border-bottom: 1px solid #E5E7EB;
    text-align: left;
    font-family: inherit;
    display: block;
    background-color: #ffffff;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
    box-sizing: border-box;
}

button.autocomplete-item:last-child {
    border-radius: 0 0 12px 12px;
    border-bottom: none;
}

.autocomplete-item:hover, button.autocomplete-item:hover, button.autocomplete-item:active {
    background-color: #F3F4F6;
}

.autocomplete-active {
    background-color: #F3F4F6;
}

@keyframes spin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

/* Job Filters Styling (Redesigned Grid for 100% Mobile Visibility) */
.dept-chips-scroll-wrapper {
    width: 100%;
    margin-top: 8px;
    margin-bottom: 12px;
    display: flex;
}

.dept-chips-container {
    width: 100%;
}

.dept-chips {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 4px; /* clean micro-gap */
    background: #F3F4F6; /* light track background */
    padding: 4px; /* inner spacing for segments */
    border-radius: var(--radius-md, 10px);
    border: 1px solid #E5E7EB;
    width: 100%;
    box-sizing: border-box;
}

.dept-chip {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: transparent; /* transparent inside the track */
    border: none;
    padding: 10px 4px;
    border-radius: 6px; /* slightly smaller border-radius for segments */
    font-size: 11.5px;
    font-weight: 700; /* bold corporate font */
    color: #4B5563; /* neutral dark text */
    cursor: pointer;
    transition: all 0.15s ease;
    text-align: center;
    white-space: normal;
    word-break: break-word;
    user-select: none;
    outline: none;
    box-sizing: border-box;
    touch-action: manipulation;
}

.dept-chip:hover {
    background: rgba(0, 0, 0, 0.04);
    color: #1F2937;
}

.dept-chip:active {
    transform: scale(0.97); /* tactile scaling on press */
}

.dept-chip.active {
    background: #FFFFFF; /* active segment is solid white card */
    color: #0F6E56; /* active text is corporate teal */
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.08); /* crisp drop shadow */
}

.customer-filter-inline {
    margin-bottom: 12px;
    margin-top: 4px;
}

.filter-select-inline {
    width: 100%;
    min-height: 44px !important;
    padding: 10px 14px !important;
    font-size: 14px !important;
    border-radius: 10px !important;
    border: 1px solid #D1D5DB !important;
    background-color: #FFFFFF !important;
    cursor: pointer;
    font-weight: 500;
    color: #1F2937;
    transition: border-color 0.15s ease;
}

.filter-select-inline:focus {
    border-color: #0F6E56 !important;
    outline: none;
}

/* ==========================================================================
   🔍 Job Search Modal & Custom Select Trigger (Mobile Bottom Drawer UI)
   ========================================================================== */

/* Dropdown Trigger Button */
.form-select-trigger {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
    min-height: 48px;
    padding: 12px 16px;
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    font-size: 14px;
    font-weight: 500;
    color: var(--text-primary);
    background: var(--bg-card);
    cursor: pointer;
    user-select: none;
    transition: all 0.2s ease;
    box-sizing: border-box;
    touch-action: manipulation;
}

button.form-select-trigger {
    font-family: inherit;
    text-align: left;
    outline: none;
    -webkit-tap-highlight-color: transparent;
}

.form-select-trigger:active {
    transform: scale(0.99);
    background-color: #F9FAFB;
}

.form-select-trigger #jobSelectTriggerText {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    padding-right: 8px;
    flex: 1;
    text-align: left;
}

.dropdown-chevron {
    color: var(--text-secondary);
    flex-shrink: 0;
    transition: transform 0.2s ease;
}

/* Search Modal Backdrop */
.search-modal-backdrop {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0; /* Use absolute edges for perfect mobile keyboard resizing stability */
    background: rgba(15, 23, 42, 0.65);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    display: none; /* Hidden by default to prevent overriding hidden attribute */
    align-items: flex-end; /* Align bottom on mobile (Bottom Sheet) */
    justify-content: center;
    z-index: 2000;
    cursor: pointer; /* Critical iOS Safari click delegation bubble fix */
}

.search-modal-backdrop.show {
    display: flex; /* Shown as flex only when opened */
}

/* Modal Content Box */
.search-modal-content {
    background: var(--bg-card, #FFFFFF);
    border-top-left-radius: 20px;
    border-top-right-radius: 20px;
    width: 100%;
    max-width: 480px;
    max-height: 82vh;
    display: flex;
    flex-direction: column;
    box-shadow: 0 -10px 25px -5px rgba(0, 0, 0, 0.15);
    border: 1px solid var(--border);
    animation: slideUp 0.28s cubic-bezier(0.16, 1, 0.3, 1);
    box-sizing: border-box;
    overflow: hidden;
}

/* Header */
.search-modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 20px; /* adjusted padding to save vertical space on mobile */
    border-bottom: 1px solid var(--border);
    background: #FFFFFF;
    position: relative;
    z-index: 10;
    flex-shrink: 0;
}

.search-modal-title {
    font-size: 16px;
    font-weight: 700;
    color: var(--text-primary);
    margin: 0;
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    text-align: left;
}

.btn-close-modal {
    background: #F3F4F6;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    width: 44px; /* 44px minimum touch target size for accessibility */
    height: 44px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    flex-shrink: 0;
    margin-left: 12px;
    outline: none;
    -webkit-tap-highlight-color: transparent; /* remove blue highlight on touch */
    touch-action: manipulation;
}

.btn-close-modal:hover {
    background: #E5E7EB;
    color: var(--text-primary);
}

.btn-close-modal:active {
    transform: scale(0.92); /* tactile scaling feedback when tapped */
}

/* Body */
.search-modal-body {
    padding: 16px 20px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    overflow: hidden;
    height: 100%;
    background: #F9FAFB;
}

/* Search Box Wrapper */
.search-input-wrapper {
    position: relative;
    display: flex;
    align-items: center;
    width: 100%;
}

.search-input-wrapper .search-icon {
    position: absolute;
    left: 14px;
    color: #9CA3AF;
    pointer-events: none;
}

.modal-search-input {
    width: 100%;
    padding: 12px 16px 12px 38px;
    border: 1px solid #D1D5DB;
    border-radius: 12px;
    font-size: 14px;
    font-weight: 500;
    outline: none;
    transition: all 0.2s;
    background: #FFFFFF;
    color: var(--text-primary);
    box-shadow: inset 0 1px 2px rgba(0,0,0,0.02);
}

.modal-search-input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(15, 110, 86, 0.08);
}

/* Scrollable Job List */
.modal-job-list {
    overflow-y: auto;
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding-bottom: 24px;
    -webkit-overflow-scrolling: touch;
}

/* Job List Item */
.modal-job-item {
    padding: 14px 16px;
    border: 1px solid #E5E7EB;
    background: #FFFFFF;
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.18s ease;
    display: flex;
    flex-direction: column;
    gap: 4px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.02);
    box-sizing: border-box;
    touch-action: manipulation;
}

button.modal-job-item {
    width: 100%;
    font-family: inherit;
    text-align: left;
    outline: none;
    -webkit-tap-highlight-color: transparent;
}

.modal-job-item:hover {
    border-color: var(--primary);
    background: #F0FDF4; /* Light emerald tint */
}

.modal-job-item:active {
    transform: scale(0.985);
}

.modal-job-item.completed {
    background: #F9FAFB;
    border-color: #E5E7EB;
    opacity: 0.85;
}

.modal-job-item.completed:hover {
    background: #F0FDF4;
    border-color: var(--primary);
}

.job-item-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.job-item-number {
    font-size: 13.5px;
    font-weight: 700;
    color: var(--text-primary);
}

.job-item-customer {
    font-size: 12px;
    color: var(--text-secondary);
    line-height: 1.45;
}

/* Completed tag badge */
.completed-tag {
    font-size: 10px;
    font-weight: 700;
    color: #047857;
    background: #D1FAE5;
    padding: 2px 8px;
    border-radius: 8px;
}

/* Custom text field fallback button */
.custom-option {
    border-style: dashed !important;
    border-color: var(--primary) !important;
    background: #F0FDF4 !important;
}

.custom-option:hover {
    background: #DCFCE7 !important;
}

/* Animations */
@keyframes slideUp {
    from {
        transform: translateY(100%);
    }
    to {
        transform: translateY(0);
    }
}

/* Center modal on larger screens (Tablet/Desktop) */
@media (min-width: 500px) {
    .search-modal-backdrop {
        align-items: center;
    }
    .search-modal-content {
        border-radius: 20px;
        max-height: 70vh;
        animation: scaleIn 0.25s cubic-bezier(0.16, 1, 0.3, 1);
    }
}

@keyframes scaleIn {
    from {
        transform: scale(0.92);
        opacity: 0;
    }
    to {
        transform: scale(1);
        opacity: 1;
    }
}

/* Drag handle at the top of the Bottom Sheet */
.modal-drag-handle {
    width: 38px;
    height: 4px;
    background: #E5E7EB;
    border-radius: 2px;
    margin: 8px auto 0 auto;
    flex-shrink: 0;
}

/* Clear search query button inside search box */
.btn-clear-search {
    position: absolute;
    right: 12px;
    background: #E5E7EB;
    border: none;
    color: #4B5563;
    cursor: pointer;
    padding: 3px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s, transform 0.1s;
    outline: none;
    z-index: 5;
    touch-action: manipulation;
}

.btn-clear-search:hover {
    background: #D1D5DB;
    color: #1F2937;
}

.btn-clear-search:active {
    transform: scale(0.9);
}

/* Update modal search input padding to prevent text overlap with the clear button */
.modal-search-input {
    padding-right: 36px !important;
}

