/* Reset and base styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Noto Sans Thai', sans-serif;
    line-height: 1.6;
    color: #333;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
}

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

/* Header styles */
.breadcrumb {
    margin-bottom: 1rem;
}

.back-link {
    display: inline-flex;
    align-items: center;
    color: #667eea;
    text-decoration: none;
    font-weight: 500;
    padding: 0.5rem 1rem;
    border-radius: 8px;
    transition: all 0.3s ease;
    background-color: rgba(102, 126, 234, 0.1);
}

.back-link:hover {
    background-color: rgba(102, 126, 234, 0.2);
    transform: translateX(-2px);
}

.back-link:focus {
    outline: 3px solid #667eea;
    outline-offset: 2px;
}

header {
    text-align: center;
    margin-bottom: 2rem;
    background: white;
    padding: 2rem;
    border-radius: 15px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.1);
}

header h1 {
    color: #4a5568;
    font-size: 2rem;
    margin-bottom: 0.5rem;
    font-weight: 600;
}

.subtitle {
    color: #718096;
    font-size: 1.1rem;
}

/* Form styles */
form {
    background: white;
    padding: 2rem;
    border-radius: 15px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.1);
    margin-bottom: 2rem;
}

.form-section {
    margin-bottom: 2.5rem;
    padding-bottom: 2rem;
    border-bottom: 2px solid #e2e8f0;
}

.form-section:last-of-type {
    border-bottom: none;
}

.form-section h2 {
    color: #2d3748;
    font-size: 1.5rem;
    margin-bottom: 1.5rem;
    padding-bottom: 0.5rem;
    border-bottom: 3px solid #667eea;
    display: inline-block;
    font-weight: 600;
}

.form-group {
    margin-bottom: 1.5rem;
}

/* Label styles */
label {
    display: block;
    font-weight: 500;
    margin-bottom: 0.5rem;
    color: #4a5568;
    font-size: 1rem;
}

legend {
    font-weight: 500;
    color: #4a5568;
    font-size: 1rem;
    margin-bottom: 1rem;
    padding: 0;
}

.required {
    color: #e53e3e;
    font-weight: bold;
}

/* Input styles */
input[type="text"],
input[type="email"],
input[type="tel"],
textarea,
select {
    width: 100%;
    padding: 0.75rem;
    border: 2px solid #e2e8f0;
    border-radius: 8px;
    font-size: 1rem;
    font-family: inherit;
    transition: all 0.3s ease;
    background-color: #fff;
}

input[type="text"]:focus,
input[type="email"]:focus,
input[type="tel"]:focus,
textarea:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
    transform: translateY(-1px);
}

input[type="text"]:invalid,
input[type="email"]:invalid,
input[type="tel"]:invalid {
    border-color: #e53e3e;
}

textarea {
    resize: vertical;
    min-height: 100px;
}

/* Radio and checkbox styles */
.radio-group,
.checkbox-group {
    display: grid;
    gap: 0.75rem;
    margin-top: 0.5rem;
}

.radio-item,
.checkbox-item {
    display: flex;
    align-items: center;
    padding: 0.75rem;
    border: 2px solid #e2e8f0;
    border-radius: 8px;
    transition: all 0.3s ease;
    cursor: pointer;
    background-color: #fff;
}

.radio-item:hover,
.checkbox-item:hover {
    border-color: #667eea;
    background-color: #f7fafc;
    transform: translateX(2px);
}

.radio-item input[type="radio"],
.checkbox-item input[type="checkbox"] {
    width: auto;
    margin-right: 0.75rem;
    transform: scale(1.2);
    cursor: pointer;
}

.radio-item label,
.checkbox-item label {
    margin: 0;
    cursor: pointer;
    flex: 1;
    font-weight: 400;
}

.radio-item input[type="radio"]:checked + label,
.checkbox-item input[type="checkbox"]:checked + label {
    color: #667eea;
    font-weight: 500;
}

.radio-item:has(input:checked),
.checkbox-item:has(input:checked) {
    border-color: #667eea;
    background-color: #eef2ff;
}

/* Fieldset styles */
fieldset {
    border: none;
    padding: 0;
    margin: 0;
}

/* Conditional fields */
.conditional-field,
.conditional-section {
    margin-top: 1rem;
    padding: 1rem;
    background-color: #f7fafc;
    border-radius: 8px;
    border-left: 4px solid #667eea;
}

/* Error and help text */
.error-message {
    color: #e53e3e;
    font-size: 0.875rem;
    margin-top: 0.5rem;
    display: none;
    font-weight: 500;
}

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

.help-text {
    font-size: 0.875rem;
    color: #718096;
    margin-top: 0.5rem;
    font-style: italic;
}

/* Button styles */
.form-actions {
    display: flex;
    gap: 1rem;
    justify-content: center;
    margin-top: 2rem;
    padding-top: 2rem;
    border-top: 2px solid #e2e8f0;
}

.submit-btn,
.reset-btn,
.btn-primary {
    padding: 1rem 2rem;
    border: none;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    font-family: inherit;
    min-width: 150px;
}

.submit-btn {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
}

.submit-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(102, 126, 234, 0.3);
}

.submit-btn:active {
    transform: translateY(0);
}

.reset-btn {
    background-color: #e2e8f0;
    color: #4a5568;
}

.reset-btn:hover {
    background-color: #cbd5e0;
    transform: translateY(-2px);
}

.btn-primary {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(102, 126, 234, 0.3);
}

/* Loading overlay */
.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(0, 0, 0, 0.7);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
}

.loading-content {
    background: white;
    padding: 2rem;
    border-radius: 15px;
    text-align: center;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
}

.spinner {
    width: 50px;
    height: 50px;
    border: 4px solid #e2e8f0;
    border-top: 4px solid #667eea;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto 1rem;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Success message */
.success-message {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(0, 0, 0, 0.7);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
}

.success-content {
    background: white;
    padding: 2rem;
    border-radius: 15px;
    text-align: center;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
    max-width: 400px;
    margin: 20px;
}

.success-content h3 {
    color: #38a169;
    margin-bottom: 1rem;
    font-size: 1.5rem;
}

.success-content p {
    color: #4a5568;
    margin-bottom: 1.5rem;
    line-height: 1.6;
}

/* Responsive design */
@media (max-width: 768px) {
    .container {
        padding: 10px;
    }
    
    header {
        padding: 1.5rem;
    }
    
    header h1 {
        font-size: 1.5rem;
    }
    
    form {
        padding: 1.5rem;
    }
    
    .form-section h2 {
        font-size: 1.25rem;
    }
    
    .form-actions {
        flex-direction: column;
        align-items: stretch;
    }
    
    .submit-btn,
    .reset-btn {
        width: 100%;
        margin-bottom: 0.5rem;
    }
}

@media (max-width: 480px) {
    .container {
        padding: 5px;
    }
    
    header {
        padding: 1rem;
    }
    
    header h1 {
        font-size: 1.25rem;
    }
    
    .subtitle {
        font-size: 1rem;
    }
    
    form {
        padding: 1rem;
    }
    
    .radio-item,
    .checkbox-item {
        padding: 0.5rem;
    }
    
    .radio-item label,
    .checkbox-item label {
        font-size: 0.9rem;
    }
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    body {
        background: #000;
        color: #fff;
    }
    
    .container,
    form,
    header {
        background: #fff;
        color: #000;
        border: 2px solid #000;
    }
    
    input,
    textarea {
        border: 2px solid #000;
        background: #fff;
        color: #000;
    }
    
    .radio-item,
    .checkbox-item {
        border: 2px solid #000;
        background: #fff;
    }
}

/* Reduced motion support */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
    
    .spinner {
        animation: none;
        border: 4px solid #667eea;
    }
}

/* Focus visible styles for better keyboard navigation */
.radio-item:focus-within,
.checkbox-item:focus-within {
    outline: 3px solid #667eea;
    outline-offset: 2px;
}

input:focus-visible,
textarea:focus-visible,
button:focus-visible {
    outline: 3px solid #667eea;
    outline-offset: 2px;
}

/* Skip link for screen readers */
.skip-link {
    position: absolute;
    top: -40px;
    left: 6px;
    background: #667eea;
    color: white;
    padding: 8px;
    text-decoration: none;
    border-radius: 4px;
    z-index: 1001;
}

.skip-link:focus {
    top: 6px;
}
