/* ตัวแปรสี - ธีมสีน้ำเงินและส้ม (DGA Theme) */
:root {
    --primary-blue: #1e40af;       /* น้ำเงินเข้ม */
    --primary-blue-light: #3b82f6; /* น้ำเงินอ่อน */
    --primary-blue-hover: #1e3a8a; /* น้ำเงินเข้มสำหรับ hover */
    --primary-orange: #f97316;     /* ส้ม DGA */
    --primary-orange-light: #fb923c; /* ส้มอ่อน */
    --primary-orange-hover: #ea580c; /* ส้มเข้มสำหรับ hover */
    
    --bg-white: #ffffff;
    --bg-light: #f8fafc;
    --bg-light-blue: #eff6ff;
    
    --text-dark: #0f172a;
    --text-gray: #475569;
    --text-light: #94a3b8;
    
    --error-color: #ef4444;
    --success-color: #10b981;
    
    --border-color: #cbd5e1;
    --border-focus: #3b82f6;
    
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
    
    --radius-sm: 4px;
    --radius-md: 6px;
    --radius-lg: 8px;
    
    --transition: all 0.3s ease;
}

/* ===== ฟอร์มหลัก ===== */
.registration-form {
    max-width: 600px;
    margin: 40px auto;
    padding: 32px;
    background: var(--bg-white);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    color: var(--text-dark);
    border-top: 5px solid var(--primary-blue);
    position: relative;
    overflow: hidden;
}

.registration-form::before {
    content: '';
    position: absolute;
    top: 0;
    right: 0;
    width: 120px;
    height: 120px;
    background: radial-gradient(circle at top right, rgba(59, 130, 246, 0.1), transparent 70%);
    z-index: 0;
}

.registration-form h2 {
    color: var(--primary-blue);
    margin-bottom: 28px;
    font-size: 28px;
    font-weight: 700;
    text-align: center;
    position: relative;
}

.registration-form h2::after {
    content: '';
    display: block;
    width: 80px;
    height: 4px;
    background: var(--primary-orange);
    margin: 10px auto 0;
    border-radius: 2px;
}

/* ===== ฟิลด์และป้ายกำกับ ===== */
.form-group {
    margin-bottom: 24px;
    position: relative;
}

.form-group label {
    display: block;
    margin-bottom: 8px;
    font-weight: 500;
    color: var(--text-dark);
    font-size: 15px;
    transition: var(--transition);
}

.form-group input[type="email"],
.form-group input[type="text"],
.form-group input[type="password"] {
    width: 100%;
    padding: 12px 16px;
    padding-left: 40px; /* ช่องว่างสำหรับไอคอน */
    font-size: 16px;
    line-height: 1.5;
    color: var(--text-dark);
    background-color: var(--bg-white);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    transition: var(--transition);
    box-shadow: var(--shadow-sm);
}

.form-group input:focus {
    border-color: var(--border-focus);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.2);
    outline: none;
}

/* ===== แก้ไข Icon ให้อยู่ตำแหน่งที่ถูกต้อง ===== */
.form-group::before {
    font-family: 'dashicons';
    position: absolute;
    left: 14px;
    top: 42px; /* ปรับตำแหน่งให้อยู่กึ่งกลางของ input field */
    color: var(--text-light);
    font-size: 18px;
    z-index: 1;
    line-height: 1;
    display: flex;
    align-items: center;
}

/* Icon สำหรับแต่ละ field */
.form-group:has(#email)::before {
    content: '\f466'; /* ไอคอนอีเมล */
}

.form-group:has(#firstname)::before {
    content: '\f110'; /* ไอคอนผู้ใช้ */
}

.form-group:has(#lastname)::before {
    content: '\f110'; /* ไอคอนผู้ใช้ */
}

.form-group:has(#password)::before {
    content: '\f112'; /* ไอคอนกุญแจ */
}

.form-group:has(#confirm_password)::before {
    content: '\f112'; /* ไอคอนกุญแจ */
}

/* Fallback สำหรับ browser ที่ไม่รองรับ :has() */
@supports not selector(:has(*)) {
    .form-group:nth-of-type(1)::before { content: '\f466'; }
    .form-group:nth-of-type(2)::before { content: '\f110'; }
    .form-group:nth-of-type(3)::before { content: '\f110'; }
    .form-group:nth-of-type(4)::before { content: '\f112'; }
    .form-group:nth-of-type(5)::before { content: '\f112'; }
}

/* เมื่อฟิลด์มีโฟกัส ให้ไอคอนเปลี่ยนสี */
.form-group:focus-within::before {
    color: var(--primary-blue);
}

/* สัญลักษณ์ดอกจัน (จำเป็น) */
.required {
    color: var(--error-color);
    margin-left: 4px;
    font-weight: bold;
}

/* ===== รหัสผ่าน ===== */
.password-input-wrapper {
    position: relative;
}

/* ===== แก้ไข Icon ดวงตาสำหรับดูรหัสผ่าน ===== */
.password-toggle-icon,
.password-confirm-toggle-icon {
    position: absolute;
    right: 10px; /* ขยับให้ชิดขวามากขึ้น */
    top: 50%;
    transform: translateY(-50%);
    cursor: pointer;
    padding: 6px;
    color: var(--text-gray);
    transition: var(--transition);
    z-index: 2;
    background: var(--bg-white); /* เพิ่มพื้นหลังสีขาว */
    border-radius: 4px;
}

.password-toggle-icon:hover,
.password-confirm-toggle-icon:hover {
    color: var(--primary-blue);
    background: rgba(59, 130, 246, 0.05);
}

/* Icon ดวงตา */
.eye-icon {
    position: relative;
    display: inline-block;
    width: 20px;
    height: 20px;
}

.eye-icon::before {
    content: '\f177'; /* Dashicons eye closed */
    font-family: 'dashicons';
    position: absolute;
    font-size: 20px;
    line-height: 1;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
}

.eye-icon.eye-open::before {
    content: '\f530'; /* Dashicons eye open */
}

/* Icon สถานะการยืนยันรหัสผ่าน */
.password-status-icon {
    position: absolute;
    right: 50px; /* ขยับออกจาก eye icon ให้มากขึ้น */
    top: 50%;
    transform: translateY(-50%);
    font-size: 18px;
    z-index: 1;
}

.password-status-icon.match-icon::before {
    content: '\f147'; /* Check mark */
    font-family: 'dashicons';
    color: var(--success-color);
}

.password-status-icon.mismatch-icon::before {
    content: '\f158'; /* X mark */
    font-family: 'dashicons';
    color: var(--error-color);
}

/* ปรับ padding ของ input fields */
#password {
    padding-right: 45px; /* เพิ่มพื้นที่สำหรับ eye icon */
}

#confirm_password {
    padding-right: 85px; /* เพิ่มพื้นที่สำหรับ status icon + eye icon */
}

/* ===== ปุ่มสร้างรหัสผ่าน ===== */
.generate-password-btn {
    display: inline-flex;
    align-items: center;
    margin-top: 10px;
    padding: 8px 14px;
    background-color: var(--primary-orange);
    color: white;
    border: none;
    border-radius: var(--radius-md);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition);
    box-shadow: var(--shadow-sm);
}

.generate-password-btn:hover {
    background-color: var(--primary-orange-hover);
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
}

.generate-password-btn:active {
    transform: translateY(0);
}

.generate-password-btn .key-icon::before {
    content: '\f112';
    font-family: 'dashicons';
    margin-left: 6px;
    font-size: 16px;
}

/* แถบวัดความปลอดภัยของรหัสผ่าน */
.password-strength-meter {
    height: 6px;
    background-color: #e2e8f0;
    margin-top: 12px;
    border-radius: 3px;
    overflow: hidden;
}

.strength-bar {
    height: 100%;
    width: 0;
    border-radius: 3px;
    transition: width 0.5s ease, background-color 0.5s ease;
}

.strength-very-weak { 
    background-color: var(--error-color);
}

.strength-weak { 
    background-color: #f97316;
}

.strength-medium { 
    background-color: #f59e0b;
}

.strength-strong { 
    background-color: #84cc16;
}

.strength-very-strong { 
    background-color: var(--success-color);
}

.password-strength-text {
    margin-top: 8px;
    font-size: 13px;
    font-weight: 500;
}

.password-hint {
    display: block;
    margin-top: 8px;
    font-size: 13px;
    color: var(--text-gray);
}

/* ===== แก้ไข Checkbox ให้เป็น Inline ===== */
.checkbox-group {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    padding: 16px;
    background-color: var(--bg-light-blue);
    border-radius: var(--radius-md);
    margin-bottom: 24px;
    border: 1px solid #dbeafe;
}

.checkbox-group input[type="checkbox"] {
    appearance: none;
    -webkit-appearance: none;
    -moz-appearance: none;
    width: 20px;
    height: 20px;
    min-width: 20px; /* ป้องกันการหดตัว */
    border: 2px solid var(--primary-blue-light);
    border-radius: var(--radius-sm);
    margin-top: 2px;
    position: relative;
    cursor: pointer;
    transition: var(--transition);
    flex-shrink: 0; /* ป้องกันการหดตัว */
}

.checkbox-group input[type="checkbox"]:checked {
    background-color: var(--primary-blue);
    border-color: var(--primary-blue);
}

.checkbox-group input[type="checkbox"]:checked::before {
    content: '\f147'; /* Dashicons checkmark */
    font-family: 'dashicons';
    color: white;
    position: absolute;
    font-size: 14px;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    line-height: 1;
}

.checkbox-group label[for="terms"] {
    font-size: 14px;
    color: var(--text-dark);
    cursor: pointer;
    line-height: 1.5;
    font-weight: normal;
    margin: 0;
    flex: 1; /* ใช้พื้นที่ที่เหลือทั้งหมด */
    display: inline; /* บังคับให้เป็น inline */
}

/* ===== ปุ่ม ===== */
.button-group {
    display: flex;
    gap: 12px;
    margin-top: 30px;
}

button[type="submit"] {
    flex: 2;
    padding: 14px 24px;
    background-color: var(--primary-blue);
    color: white;
    border: none;
    border-radius: var(--radius-md);
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
}

button[type="submit"]:not(:disabled):hover {
    background-color: var(--primary-blue-hover);
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

button[type="submit"]:disabled {
    background-color: var(--text-light);
    cursor: not-allowed;
    opacity: 0.7;
}

.clear-button {
    flex: 1;
    padding: 14px 24px;
    background-color: transparent;
    color: var(--text-gray);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    font-size: 16px;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition);
}

.clear-button:hover {
    background-color: var(--bg-light);
    color: var(--text-dark);
    border-color: var(--text-light);
}

/* ===== ข้อความแจ้งเตือน ===== */
.error-message {
    color: var(--error-color);
    font-size: 12px;
    margin-top: 6px;
    font-weight: 500;
}

#registration-messages {
    margin-bottom: 20px;
}

.success-message {
    background-color: rgba(16, 185, 129, 0.1);
    color: #065f46;
    padding: 12px 16px;
    border-radius: var(--radius-md);
    border-left: 4px solid var(--success-color);
    margin-bottom: 20px;
    animation: fadeIn 0.3s ease-out;
}

.error-message-box {
    background-color: rgba(239, 68, 68, 0.1);
    color: #b91c1c;
    padding: 12px 16px;
    border-radius: var(--radius-md);
    border-left: 4px solid var(--error-color);
    margin-bottom: 20px;
    animation: fadeIn 0.3s ease-out;
}

/* เอฟเฟกต์แอนิเมชั่น */
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(-10px); }
    to { opacity: 1; transform: translateY(0); }
}

/* ===== รองรับหน้าจอขนาดเล็ก ===== */
@media (max-width: 768px) {
    .registration-form {
        padding: 24px 20px;
        margin: 20px;
    }
    
    .registration-form h2 {
        font-size: 24px;
    }
    
    .button-group {
        flex-direction: column;
    }
    
    button[type="submit"], .clear-button {
        width: 100%;
    }
    
    /* ปรับ checkbox สำหรับมือถือ */
    .checkbox-group {
        padding: 12px;
    }
    
    .checkbox-group label[for="terms"] {
        font-size: 13px;
    }
}

/* ===== ปรับแต่งเพิ่มเติมเพื่อให้ดูทันสมัย ===== */
/* เพิ่มเอฟเฟกต์ตกแต่งพื้นหลัง */
.registration-form::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100px;
    height: 100px;
    background: radial-gradient(circle at bottom left, rgba(249, 115, 22, 0.1), transparent 70%);
    z-index: 0;
}

/* เพิ่มเอฟเฟกต์เมื่อโฟกัสที่ฟอร์ม */
.form-group:focus-within label {
    color: var(--primary-blue);
}

/* เพิ่ม transition สวยๆ ให้กับปุ่ม */
.generate-password-btn {
    position: relative;
    overflow: hidden;
}

.generate-password-btn::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(255, 255, 255, 0.2);
    transform: translateX(-100%);
    transition: transform 0.3s ease;
}

.generate-password-btn:hover::after {
    transform: translateX(0);
}

/* ช่องกรอกที่มีข้อผิดพลาด */
.form-group.error input {
    border-color: var(--error-color);
    box-shadow: 0 0 0 1px var(--error-color);
}

/* เอฟเฟกต์เมื่อกดปุ่มสร้างรหัสผ่าน */
.btn-flash {
    animation: flash 0.3s;
}

@keyframes flash {
    0%, 100% { background-color: var(--primary-orange); }
    50% { background-color: var(--primary-orange-light); }
}

/* ปรับแต่งตัวอักษร */
.registration-form {
    font-family: 'Sarabun', 'Prompt', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

/* เพิ่มความสวยงามให้กับทั้งฟอร์ม */
.registration-form * {
    position: relative;
    z-index: 1;
}

/* ===== CAPTCHA Group ===== */
.captcha-group {
    margin-bottom: 24px;
    padding: 20px;
    background: linear-gradient(135deg, #eff6ff 0%, #fef3c7 100%);
    border-radius: var(--radius-lg);
    border: 1px solid #dbeafe;
    text-align: center;
}

.captcha-label {
    display: block;
    margin-bottom: 12px;
    font-weight: 600;
    color: var(--primary-blue);
    font-size: 15px;
}

#cf-turnstile-registration {
    margin: 0 auto;
    min-height: 65px;
    width: 300px;
    display: inline-block;
}

/* ===== ปุ่ม ===== */
.button-group {
    display: flex;
    gap: 12px;
    margin-top: 30px;
}