/* ==========================================================================
   Instructor Profile Form Stylesheet
   Modern UI/UX design with responsive Grid CSS layout
   ========================================================================== */

/* ==========================================================================
   1. CSS Variables & Base Styles
   ========================================================================== */

/* Base variables for consistent styling */
:root {
    /* Colors */
    --primary-color: #324791;
    --secondary-color: #576aab;
    --text-color: #283c5a;
    --light-text: #5d7194;
    --placeholder-color: #A1A1AA;
    --header-bg: #e8f0fe;
    --body-bg: #f2f5fa;
    --form-bg: #ffffff;
    --error-color: #e74c3c;
    --success-color: #324791;
    --success-bg: #e8f0fe;
    --info-color: #3498db;
    --border-color: #e1e5ee;
    --input-border: #c4cce0;
    --footer-bg: #1A2B4A;
    --footer-text: #e1e7f5;
    --footer-link: #a0d2ff;
    
    /* Effects */
    --box-shadow: 2px 4px 12px #00000014;
    --input-focus-shadow: 0 0 0 3px rgba(74, 111, 220, 0.2);
    --transition: all 0.3s ease;
    --focus-outline: 1px solid #324791;
    
    /* Responsive breakpoints */
    --bp-small: 576px;   /* Mobile */
    --bp-medium: 768px;  /* Tablet */
    --bp-large: 992px;   /* Small desktop */
    --bp-xlarge: 1200px; /* Large desktop */
}

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

html {
    font-size: 62.5%; /* 10px for easier rem calculations */
    scroll-behavior: smooth;
}

body {
    font-family: 'DM Sans', sans-serif;
    color: var(--text-color);
    background-color: var(--body-bg);
    padding: 0;
    font-size: 1.8rem;
    line-height: 1.6;
}

/* Improved focus styles for accessibility */
:focus {
    outline: var(--focus-outline);
    outline-offset: 1px;
}

/* ==========================================================================
   2. Layout Containers
   ========================================================================== */

/* Main container styles */
.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 clamp(1rem, 5vw, 2rem); /* Responsive padding */
    width: 100%;
}

/* ==========================================================================
   3. Header Styles
   ========================================================================== */

header {
    color: var(--text-color);
    padding-top: clamp(2rem, 0.893vw + 1.714rem, 3rem);
    padding-bottom: clamp(2rem, 1.786vw + 1.429rem, 4rem);
    position: relative;
    overflow: hidden;
    text-align: center;
}

.logo {
    max-width: 18rem;
    display: block;
    margin: 0 auto 2rem;
}

header h1 {
    font-size: clamp(3.2rem, 0.357vw + 3.086rem, 3.6rem);
    line-height: 1;
    font-weight: 700;
    letter-spacing: -0.025em;
    margin-bottom: 1rem;
}

header p {
    color: var(--light-text);
    font-size: 1.8rem;
    line-height: 1.4;
    margin: 0;
}

/* ==========================================================================
   4. Form Container & Sections
   ========================================================================== */

.form-container {
    background-color: var(--form-bg);
    border-radius: clamp(1.6rem, 0.357vw + 1.486rem, 2rem);
    box-shadow: var(--box-shadow);
    margin: 0 auto 4rem;
    overflow: hidden;
    transition: padding 0.3s ease;
    min-height: 200px;
}

/* Form sections styling */
.form-section {
    margin: 0;
    padding: clamp(1.6rem, 0.714vw + 1.371rem, 2.4rem);
    border-bottom: 1px solid var(--border-color);
    transition: all 0.3s ease;
}

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

.form-section h2 {
    font-size: clamp(2.2rem, 0.179vw + 2.143rem, 2.4rem);
    margin-bottom: clamp(2.2rem, 0.179vw + 2.143rem, 2.4rem);
    color: var(--text-color);
    font-weight: 600;
    padding-bottom: 1.2rem;
    border-bottom: 2px solid var(--header-bg);
}

/* Form actions */
.form-actions {
    text-align: center;
    padding: 3rem 4rem;
    position: relative;
}

/* ==========================================================================
   5. Form Controls
   ========================================================================== */

/* Base form group styles */
.form-group {
    margin-bottom: clamp(1.2rem, 1.071vw + 0.857rem, 2.4rem);
    width: 100%;
    transition: opacity 0.2s ease;
}

.form-group:hover {
    opacity: 1;
}

/* Labels */
label {
    display: block;
    margin-bottom: clamp(0.6rem, 0.179vw + 0.543rem, 0.8rem);
    font-weight: 600;
    color: var(--text-color);
    font-size: clamp(1.6rem, 0.179vw + 1.543rem, 1.8rem);
    transition: color 0.3s ease;
}

/* Required field indicator */
label.required:after {
    content: " *";
    color: var(--error-color);
}

/* Input fields */
input[type="text"],
input[type="email"],
input[type="tel"],
input[type="url"],
textarea,
select {
    width: 100%;
    padding: 1.2rem 1.5rem;
    border: 1px solid var(--input-border);
    border-radius: 8px;
    font-size: clamp(1.5rem, 0.1vw + 1.4rem, 1.6rem);
    background-color: var(--form-bg);
    transition: all 0.3s ease;
    color: var(--text-color);
}

/* Improved placeholder styling */
::placeholder {
    font-size: clamp(1.4rem, 0.179vw + 1.343rem, 1.6rem);
    color: var(--placeholder-color);
    opacity: 1;
}

/* Focus states */
input[type="text"]:focus,
input[type="email"]:focus,
input[type="tel"]:focus,
input[type="url"]:focus,
textarea:focus,
select:focus {
    border-color: var(--primary-color);
    outline: var(--focus-outline);
    box-shadow: var(--input-focus-shadow);
}

/* Specific textarea height for About You field */
textarea {
    min-height: 250px;
    resize: vertical;
}

/* Hint text */
.hint {
    font-size: clamp(1.2rem, 0.179vw + 1.143rem, 1.4rem);
    line-height: 1.2;
    color: var(--light-text);
    margin-top: .8rem;
    margin-bottom: .8rem;
}

/* ==========================================================================
   6. Grid Layout System
   ========================================================================== */

/* Grid layout for form rows - Responsive approach with auto-fit */
.form-row {
    display: grid;
    gap: 1.6rem;
    
    /* Auto-fit responsive layout with minimum width */
    grid-template-columns: repeat(auto-fit, minmax(min(320px, 100%), 1fr));
    transition: grid-template-columns 0.3s ease, gap 0.3s ease;
}

/* Grid span modifiers */
.col-span-full {
    grid-column: 1 / -1;
}

/* Single column sections */
.form-row.single-column {
    grid-template-columns: 1fr;
}

/* Personal information section - single column for fields */
.personal-details .form-row:not(.profile-image-row) {
    grid-template-columns: 1fr;
}

/* Social media - 3 columns */
.social-media-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(min(280px, 100%), 1fr));
    gap: 1.6rem;
    transition: grid-template-columns 0.3s ease, gap 0.3s ease;
}

/* Location section */
.location-form-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(min(280px, 100%), 1fr));
    gap: 1.6rem;
    transition: grid-template-columns 0.3s ease, gap 0.3s ease;
}

/* When a region field is visible, adjust minimum width to ensure better fit */
.region-visible .location-form-row {
    grid-template-columns: repeat(auto-fit, minmax(min(280px, 100%), 1fr));
}

/* ==========================================================================
   7. Checkbox Groups
   ========================================================================== */

/* Checkbox groups with Grid CSS */
.checkbox-group {
    padding: 8px;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    background-color: var(--body-bg);
    transition: grid-template-columns 0.3s ease, gap 0.3s ease;
}

/* Conditions - 3 columns with medium minimum width */
.conditions-group {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(min(280px, 100%), 1fr));
    gap: 1rem;
}

/* Work with clients - 2 columns with larger minimum width */
.work-client-group {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(min(240px, 100%), 1fr));
    gap: 1rem;
}

/* Languages - 4 columns with smaller minimum width */
.languages-group {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(min(240px, 100%), 1fr));
    gap: 1rem;
}

/* Checkbox items styling */
.checkbox-item {
    display: flex;
    align-items: center;
    padding: 1rem;
    margin: 2px;
    background-color: white;
    border-radius: 6px;
    border: 1px solid var(--border-color);
    transition: all 0.2s ease-out;
    will-change: transform, box-shadow, border-color, background-color;
    cursor: pointer;
    position: relative;
    box-shadow: 0 1px 3px rgba(0,0,0,0.05);
}

.checkbox-item.checked {
    background-color: var(--header-bg);
    border-color: var(--primary-color);
    box-shadow: 0 1px 4px rgba(0,0,0,0.1);
}

.checkbox-item:hover {
    box-shadow: 0 4px 8px rgba(0,0,0,0.08);
    border-color: var(--primary-color);
    background-color: #f2f6ff;
}

/* Additional focus style for keyboard navigation */
.checkbox-item:focus-within {
    outline: var(--focus-outline);
    outline-offset: 2px;
    box-shadow: 0 0 0 3px rgba(74, 111, 220, 0.2);
}

/* Enhance checkbox indicators for better UX */
.checkbox-item input[type="checkbox"] {
    margin-right: 10px;
    cursor: pointer;
    min-width: 18px;
    height: 18px;
    position: relative;
    z-index: 2;
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
    border: 2px solid var(--input-border);
    border-radius: 3px;
    background-color: white;
    transition: all 0.2s ease;
}

.checkbox-item input[type="checkbox"]:checked {
    background-color: var(--primary-color);
    border-color: var(--primary-color);
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='white'%3E%3Cpath d='M9 16.17L4.83 12l-1.42 1.41L9 19 21 7l-1.41-1.41L9 16.17z'/%3E%3C/svg%3E");
    background-position: center;
    background-repeat: no-repeat;
    background-size: 14px;
}

/* Checkbox label styling */
.checkbox-item label {
    margin: 0;
    font-weight: 500;
    font-size: clamp(1.4rem, 0.179vw + 1.343rem, 1.6rem);
    line-height: 1.35;
    cursor: pointer;
    flex: 1; /* Allow label to take remaining space */
    z-index: 1;
    position: relative;
    user-select: none; /* Prevent text selection when clicking rapidly */
    -webkit-user-select: none;
}

/* ==========================================================================
   8. File Upload & Image Preview
   ========================================================================== */

/* File input styling */
.file-input-container {
    position: relative;
    overflow: hidden;
    display: inline-block;
    cursor: pointer;
    width: 100%;
}

.file-input-container input[type="file"] {
    position: absolute;
    font-size: 100px;
    opacity: 0;
    right: 0;
    top: 0;
    cursor: pointer;
}

.file-input-button {
    display: inline-block;
    padding: 1rem 2rem;
    border-radius: 8px;
    background-color: var(--header-bg);
    color: var(--text-color);
    font-weight: 500;
    cursor: pointer;
    margin-bottom: 1rem;
    transition: var(--transition);
    border: 1px solid var(--border-color);
}

.file-input-container:hover .file-input-button {
    background-color: var(--primary-color);
    color: white;
}

.file-input-name {
    font-size: 1.4rem;
    color: var(--light-text);
    margin-left: 1rem;
}

/* Image preview styling */
.image-preview {
    margin-top: 1.5rem;
    max-height: 280px;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 5px;
    min-height: 100px;
    display: flex;
    align-items: center;
    justify-content: center;
    background-color: #f8f9fc;
}

.image-preview:empty::before {
    content: 'Image preview will appear here';
    color: var(--light-text);
    font-size: 1.4rem;
    text-align: center;
}

.image-preview img {
    max-width: 100%;
    max-height: 280px;
    display: block;
    border-radius: 5px;
}

/* Profile image grid layout */
.profile-image-container {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.6rem;
    align-items: start;
}

.profile-image-container .file-upload-area {
    display: flex;
    flex-direction: column;
}

.profile-image-container .image-preview-area {
    display: flex;
    flex-direction: column;
    align-items: center;
}

.profile-image-container .hint {
    margin-bottom: 1.5rem;
}

.profile-image-container .file-input-container {
    width: 100%;
    margin-bottom: 1rem;
}

.profile-image-container .image-preview {
    margin-top: 0;
    width: 100%;
    height: auto;
    aspect-ratio: 1/1;
    display: flex;
    align-items: center;
    justify-content: center;
    background-color: #f8f9fc;
}

/* Make image preview responsive */
.profile-image-container .image-preview img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
}

/* ==========================================================================
   9. Buttons & Interactions
   ========================================================================== */

button {
    background-color: var(--primary-color);
    color: white;
    border: none;
    padding: 1.4rem 3.2rem;
    font-size: 1.6rem;
    border-radius: 8px;
    cursor: pointer;
    transition: var(--transition);
    font-weight: 500;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
}

button:hover {
    background-color: var(--secondary-color);
    transform: translateY(-2px);
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.15);
}

button:focus {
    outline: var(--focus-outline);
    outline-offset: 2px;
}

button:disabled {
    background-color: #a0a8bd;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
    position: relative;
}

/* Loading indicator animation */
.loading {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 3px solid rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    border-top-color: white;
    animation: spin 1s linear infinite;
    margin-left: 10px;
}

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

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

/* Hide elements with the hidden class */
.hidden {
    display: none !important;
}

/* ==========================================================================
   10. Form Messages & Validation
   ========================================================================== */

/* Form messages styling */
#form-messages {
    margin: 0 auto;
    padding: 1.6rem;
    border-radius: 8px;
    text-align: center;
    display: none;
    margin-top: 2rem;
}

#form-messages.error {
    background-color: rgba(231, 76, 60, 0.08);
    color: var(--error-color);
    border-left: 4px solid var(--error-color);
    display: block;
}

#form-messages.success {
    background-color: rgba(46, 204, 113, 0.08);
    color: var(--success-color);
    border-left: 4px solid var(--success-color);
    display: block;
}

#form-messages.info {
    background-color: #fff;
    color: var(--info-color);
    border-left: 4px solid var(--info-color);
    display: block;
}

/* Validation styles */
.error {
    border-color: var(--error-color) !important;
}

/* Highlight the input field with error */
input.error,
textarea.error,
select.error {
    background-color: rgba(231, 76, 60, 0.05);
}

.checkbox-group.error {
    background-color: rgba(231, 76, 60, 0.05);
}

/* Success message styling */
.success-message {
    padding: 2.5rem;
    border-radius: 8px;
    background-color: white;
    border-left: 4px solid var(--success-color);
    margin: 0 auto 4rem;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.05);
}

.success-message h3 {
    color: var(--success-color);
    margin-bottom: 1.5rem;
    font-size: 2rem;
}

.success-message p {
    margin-bottom: 1.5rem;
    line-height: 1.6;
    font-size: 1.6rem;
}

.success-message a {
    color: var(--primary-color);
    text-decoration: none;
    font-weight: 500;
}

.success-message a:hover {
    text-decoration: underline;
}

.success-message p:last-child {
    margin-bottom: 0;
}

/* Submission success styling */
#submission-success {
    margin: 0 auto 4rem;
    margin-top: 2rem;
    animation: fadeIn 0.5s ease-in-out;
}

/* ==========================================================================
   11. Footer Styling
   ========================================================================== */

footer {
    background-color: var(--footer-bg);
}

footer .footer-copyright {
    color: var(--footer-text);
    padding: 3rem 0;
    font-size: 1.6rem;
    margin-top: 4rem;
}

.footer-content {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 2rem;
    text-align: center;
}

/* ==========================================================================
   12. Browser Compatibility
   ========================================================================== */

/* Fix for Firefox */
@-moz-document url-prefix() {
    .checkbox-item input[type="checkbox"] {
        appearance: none;
    }
}

/* Fix for Safari */
_::-webkit-full-page-media, _:future, :root .checkbox-item input[type="checkbox"] {
    opacity: 0.0001;
}

_::-webkit-full-page-media, _:future, :root .checkbox-item {
    position: relative;
}

_::-webkit-full-page-media, _:future, :root .checkbox-item::before {
    content: '';
    display: block;
    width: 18px;
    height: 18px;
    border: 2px solid var(--input-border);
    border-radius: 3px;
    position: absolute;
    left: 10px;
    top: 50%;
    transform: translateY(-50%);
    background-color: white;
    z-index: 1;
}

_::-webkit-full-page-media, _:future, :root .checkbox-item.checked::before {
    background-color: var(--primary-color);
    border-color: var(--primary-color);
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='white'%3E%3Cpath d='M9 16.17L4.83 12l-1.42 1.41L9 19 21 7l-1.41-1.41L9 16.17z'/%3E%3C/svg%3E");
    background-position: center;
    background-repeat: no-repeat;
    background-size: 14px;
}

/* Container query fallback for older browsers */
@supports not (min: 0) {
    .form-row, 
    .personal-details .form-row,
    .social-media-row,
    .location-form-row {
        grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    }
    
    .region-visible .location-form-row {
        grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    }
    
    .conditions-group {
        grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    }
    
    .work-client-group {
        grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    }
    
    .languages-group {
        grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    }
}

/* ==========================================================================
   13. Performance Optimizations
   ========================================================================== */

/* Performance optimizations */
.form-container,
.form-row,
.checkbox-group,
.location-form-row {
    contain: layout style;
}

/* ==========================================================================
   14. Responsive Styles
   ========================================================================== */

/* Medium screens (tablets landscape) */
@media (max-width: 768px) {
    /* Larger touch targets on mobile */
    .checkbox-item {
        padding: 1.2rem;
        margin: 4px 2px;
    }
    
    .checkbox-item input[type="checkbox"] {
        min-width: 22px;
        height: 22px;
    }
    
    /* Improved button experience on mobile */
    button {
        padding: 1.6rem 3.2rem;
        font-size: 1.8rem;
    }
    
    /* Mobile layout for profile image container */
    .profile-image-container {
        grid-template-columns: 1fr;
        gap: 1rem;
    }
    
    .profile-image-container .image-preview-area {
        margin-top: 1rem;
    }
}

/* Mobile phones - single column */
@media (max-width: 576px) {
    /* Override auto-fit for very small screens to ensure single column */
    .form-row,
    .social-media-row,
    .location-form-row,
    .region-visible .location-form-row,
    .conditions-group,
    .work-client-group,
    .languages-group {
        grid-template-columns: 1fr;
    }

    button {
        width: 100%;
    }
}

/* Improved mobile experience for landscape mode */
@media (max-height: 500px) and (orientation: landscape) {
    .form-section {
        padding: 1.5rem;
    }
}

/* Enhance support for ultra-wide screens */
@media (min-width: 1800px) {
    .container {
        max-width: 1400px;
    }
}