/* 
 * EWE Registration - Premium Stylesheet
 * Focus on UX, Accessibility, and Responsiveness
 */

:root {
    /* Color Palette - Trustworthy & Modern */
    --primary: #1a56db;
    --primary-light: #3f83f8;
    --primary-dark: #1e429f;
    --secondary: #e1effe;
    --success: #057a55;
    --success-light: #def7ec;
    --danger: #e02424;
    --danger-light: #fde8e8;
    --text-main: #111928;
    --text-muted: #6b7280;
    --bg-main: #f3f4f6;
    --bg-card: #ffffff;
    --border: #e5e7eb;
    --input-focus: rgba(26, 86, 219, 0.2);

    /* Base Font Sizes - Can be scaled for accessibility */
    --font-base: 16px;
    --font-sm: 0.875rem;
    --font-md: 1rem;
    --font-lg: 1.125rem;
    --font-xl: 1.25rem;
    --font-2xl: 1.5rem;
    --font-3xl: 1.875rem;

    /* Border Radius & Shadows */
    --radius-sm: 0.375rem;
    --radius-md: 0.5rem;
    --radius-lg: 0.75rem;
    --radius-full: 9999px;
    --shadow-sm: 0 1px 2px 0 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);
    
    /* Transitions */
    --transition: all 0.3s ease;
}

/* Accessibility Font Scaling */
body.font-size-sm { --font-base: 14px; }
body.font-size-md { --font-base: 16px; }
body.font-size-lg { --font-base: 20px; }

/* Global Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Noto Sans Thai', sans-serif;
}

body {
    background-color: var(--bg-main);
    color: var(--text-main);
    font-size: var(--font-base);
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

.container {
    max-width: 800px;
    margin: 0 auto;
    padding: 0 1rem;
}

.text-primary { color: var(--primary); }
.required { color: var(--danger); font-weight: bold; }

/* Accessibility Bar */
.accessibility-bar {
    background-color: #1f2937;
    color: #fff;
    padding: 0.5rem 0;
    font-size: var(--font-sm);
}

.accessibility-content {
    display: flex;
    justify-content: flex-end;
    align-items: center;
    gap: 1rem;
}

.font-size-controls {
    display: flex;
    gap: 0.5rem;
}

.btn-font {
    background: transparent;
    border: 1px solid #4b5563;
    color: #fff;
    width: 32px;
    height: 32px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: var(--transition);
    font-weight: 500;
}

.btn-font:hover, .btn-font.active {
    background: var(--primary);
    border-color: var(--primary);
}

#btn-font-sm { font-size: 12px; }
#btn-font-md { font-size: 16px; }
#btn-font-lg { font-size: 20px; }

/* Header */
.main-header {
    background: #fff;
    padding: 1.5rem 0;
    box-shadow: var(--shadow-sm);
    margin-bottom: 2rem;
}

.logo-area {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.logo-icon {
    width: 48px;
    height: 48px;
    background: linear-gradient(135deg, var(--primary), var(--primary-light));
    border-radius: var(--radius-lg);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 24px;
    box-shadow: var(--shadow-md);
}

.logo-text h1 {
    font-size: var(--font-xl);
    font-weight: 700;
    color: var(--primary-dark);
}

.logo-text p {
    font-size: var(--font-sm);
    color: var(--text-muted);
}

/* Form Container */
.form-wrapper {
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    padding: 2rem;
    margin-bottom: 3rem;
}

/* Stepper */
.stepper {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 3rem;
    position: relative;
    padding: 0 1rem;
}

.step {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
    position: relative;
    z-index: 2;
}

.step-circle {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: #f3f4f6;
    border: 2px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    color: var(--text-muted);
    transition: var(--transition);
}

.step-text {
    font-size: var(--font-sm);
    color: var(--text-muted);
    font-weight: 500;
    text-align: center;
}

.step.active .step-circle {
    background: var(--primary);
    border-color: var(--primary);
    color: white;
    box-shadow: 0 0 0 4px var(--secondary);
}

.step.active .step-text {
    color: var(--primary);
    font-weight: 600;
}

.step.completed .step-circle {
    background: var(--success);
    border-color: var(--success);
    color: white;
}

.step.completed .step-text {
    color: var(--success);
}

.step-line {
    flex-grow: 1;
    height: 3px;
    background: var(--border);
    margin: 0 1rem;
    position: relative;
    top: -12px;
    z-index: 1;
    transition: var(--transition);
}

.step-line.completed {
    background: var(--success);
}

/* Form Steps */
.form-step {
    display: none;
    animation: fadeIn 0.4s ease-out;
}

.form-step.active {
    display: block;
}

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

.step-header {
    margin-bottom: 2rem;
    text-align: center;
}

.step-header h2 {
    font-size: var(--font-2xl);
    margin-bottom: 0.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
}

.step-header p {
    color: var(--text-muted);
    font-size: var(--font-md);
}

/* Form Grid */
.form-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.5rem;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.form-group.full-width {
    grid-column: 1 / -1;
}

label {
    font-weight: 500;
    color: var(--text-main);
    font-size: var(--font-md);
}

/* Inputs */
input[type="text"],
input[type="email"],
input[type="tel"],
input[type="password"],
input[type="date"],
select {
    width: 100%;
    padding: 0.75rem 1rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    font-size: var(--font-md);
    transition: var(--transition);
    background-color: #f9fafb;
}

input:focus, select:focus {
    outline: none;
    border-color: var(--primary);
    background-color: #fff;
    box-shadow: 0 0 0 3px var(--input-focus);
}

.readonly-input {
    background-color: #f3f4f6 !important;
    color: var(--text-muted);
    cursor: not-allowed;
}

.input-with-icon {
    position: relative;
    display: flex;
    align-items: center;
}

.input-with-icon i:not(.toggle-password) {
    position: absolute;
    left: 1rem;
    color: var(--text-muted);
}

.input-with-icon input {
    padding-left: 2.5rem;
}

.toggle-password {
    position: absolute;
    right: 1rem;
    color: var(--text-muted);
    cursor: pointer;
    padding: 0.5rem;
}

.toggle-password:hover {
    color: var(--primary);
}

/* Errors & Helpers */
.error-message {
    color: var(--danger);
    font-size: var(--font-sm);
    display: none;
    margin-top: 0.25rem;
}

.has-error input {
    border-color: var(--danger);
}

.has-error .error-message {
    display: block;
}

.helper-text {
    color: var(--text-muted);
    font-size: var(--font-sm);
}

/* Cards / Radio Group for Selection */
.radio-group.cards {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1rem;
}

.radio-card input[type="radio"] {
    display: none;
}

.radio-card .card-content {
    border: 2px solid var(--border);
    border-radius: var(--radius-md);
    padding: 1.5rem 1rem;
    text-align: center;
    cursor: pointer;
    transition: var(--transition);
    background: #fff;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.75rem;
}

.radio-card .card-content i {
    font-size: 2rem;
    color: var(--text-muted);
    transition: var(--transition);
}

.radio-card .card-content span {
    font-weight: 500;
    color: var(--text-main);
}

.radio-card input[type="radio"]:checked + .card-content {
    border-color: var(--primary);
    background-color: var(--secondary);
}

.radio-card input[type="radio"]:checked + .card-content i {
    color: var(--primary);
}

/* Autocomplete UX */
.autocomplete-container {
    position: relative;
}

.suggestion-box {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: #fff;
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    z-index: 100;
    max-height: 200px;
    overflow-y: auto;
    display: none;
}

.suggestion-item {
    padding: 0.75rem 1rem;
    cursor: pointer;
    border-bottom: 1px solid var(--border);
    font-size: var(--font-md);
}

.suggestion-item:last-child {
    border-bottom: none;
}

.suggestion-item:hover, .suggestion-item.active {
    background-color: var(--secondary);
    color: var(--primary-dark);
}

.suggestion-highlight {
    font-weight: bold;
    color: var(--primary);
}

/* Password Strength */
.password-strength {
    height: 4px;
    background-color: var(--border);
    border-radius: 2px;
    margin-top: 0.5rem;
    overflow: hidden;
}

.strength-bar {
    height: 100%;
    width: 0%;
    transition: var(--transition);
}

/* Checkbox */
.pdpa-consent {
    background: #f9fafb;
    padding: 1.5rem;
    border-radius: var(--radius-md);
    border: 1px solid var(--border);
    margin-top: 1rem;
}

.checkbox-container {
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
    cursor: pointer;
    position: relative;
}

.checkbox-container input {
    width: 20px;
    height: 20px;
    accent-color: var(--primary);
    margin-top: 0.15rem;
}

.checkbox-text {
    font-size: var(--font-md);
}

.link {
    color: var(--primary);
    text-decoration: none;
}
.link:hover {
    text-decoration: underline;
}

/* Buttons */
.form-actions {
    display: flex;
    justify-content: space-between;
    margin-top: 2.5rem;
    padding-top: 1.5rem;
    border-top: 1px solid var(--border);
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.75rem 1.5rem;
    font-size: var(--font-md);
    font-weight: 600;
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: var(--transition);
    border: none;
}

.btn-primary {
    background-color: var(--primary);
    color: white;
}

.btn-primary:hover {
    background-color: var(--primary-dark);
    box-shadow: var(--shadow-md);
}

.btn-outline {
    background-color: transparent;
    border: 1px solid var(--border);
    color: var(--text-main);
}

.btn-outline:hover {
    background-color: var(--bg-main);
    border-color: var(--text-muted);
}

.btn-success {
    background-color: var(--success);
    color: white;
}

.btn-success:hover {
    background-color: #046c4e;
    box-shadow: var(--shadow-md);
}

/* Success Step */
.success-container {
    text-align: center;
    padding: 3rem 1rem;
}

.success-icon {
    width: 80px;
    height: 80px;
    background-color: var(--success-light);
    color: var(--success);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 40px;
    margin: 0 auto 1.5rem;
    animation: scaleIn 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

@keyframes scaleIn {
    0% { transform: scale(0); }
    100% { transform: scale(1); }
}

.success-container h2 {
    font-size: var(--font-2xl);
    color: var(--success);
    margin-bottom: 1rem;
}

.success-container p {
    color: var(--text-muted);
    margin-bottom: 2rem;
}

/* Responsive (Mobile First is handled above, these are specific breakpoints) */
@media (max-width: 640px) {
    .form-wrapper {
        padding: 1.5rem 1rem;
        border-radius: 0;
        box-shadow: none;
    }
    
    .form-grid {
        grid-template-columns: 1fr;
    }
    
    .radio-group.cards {
        grid-template-columns: 1fr;
    }
    
    .stepper {
        padding: 0;
        margin-bottom: 2rem;
    }
    
    .step-text {
        font-size: 11px;
    }
    
    .step-circle {
        width: 32px;
        height: 32px;
        font-size: 14px;
    }
    
    .step-header h2 {
        font-size: var(--font-xl);
    }
}

/* Custom Modal Popup */
.custom-modal {
    display: none;
    position: fixed;
    z-index: 9999;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(3px);
    opacity: 0;
    transition: opacity 0.3s ease;
}

.custom-modal.show {
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 1;
}

.custom-modal-content {
    background-color: #fff;
    border-radius: var(--radius-lg);
    width: 90%;
    max-width: 400px;
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
    transform: scale(0.9);
    transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    overflow: hidden;
}

.custom-modal.show .custom-modal-content {
    transform: scale(1);
}

.custom-modal-header {
    background-color: var(--danger);
    color: white;
    padding: 1.5rem;
    text-align: center;
}

.custom-modal-header i {
    font-size: 3rem;
    margin-bottom: 0.5rem;
}

.custom-modal-header h2 {
    font-size: var(--font-xl);
    margin: 0;
}

.custom-modal-body {
    padding: 2rem 1.5rem;
    text-align: center;
    font-size: var(--font-md);
    color: var(--text-main);
}

.custom-modal-footer {
    padding: 1rem 1.5rem 1.5rem;
    text-align: center;
}

.custom-modal-footer .btn {
    width: 100%;
}

/* Severe Error Highlight */
@keyframes pulse-danger {
    0% { box-shadow: 0 0 0 0 rgba(224, 36, 36, 0.7); }
    70% { box-shadow: 0 0 0 10px rgba(224, 36, 36, 0); }
    100% { box-shadow: 0 0 0 0 rgba(224, 36, 36, 0); }
}

.severe-error-highlight input {
    border-color: var(--danger) !important;
    border-width: 2px !important;
    background-color: var(--danger-light) !important;
    animation: pulse-danger 1.5s infinite;
}

