/**
 *
 * School Onboarding Survey Stylesheet
 *
 * @version: 1.0.0
 * @package: School Onboarding
 * @author: Survey Development Team
 * @copyright: Copyright (c) 2025
 * @filesource: css/survey.css
 *
 **/

/* Global Variables */
:root {
    /* Dark Theme Colors */
    --dark-bg: #1a1a1a;
    --dark-text: #ffffff;
    --dark-primary: #2ecc71;
    --dark-secondary: #3498db;
    --dark-card-bg: rgba(26, 26, 26, 0.95);
    --dark-card-border: rgba(255, 255, 255, 0.1);
    --dark-input-bg: rgba(255, 255, 255, 0.05);
    --dark-success: #2ed573;
    --dark-error: #ff4757;
    
    /* Light Theme Colors */
    --light-bg: #f5f5f5;
    --light-text: #333333;
    --light-primary: #27ae60;
    --light-secondary: #2980b9;
    --light-card-bg: #ffffff;
    --light-card-border: rgba(0, 0, 0, 0.1);
    --light-input-bg: rgba(0, 0, 0, 0.02);
    --light-success: #2ed573;
    --light-error: #ff4757;
    
    /* Default to Dark Theme */
    --bg-color: var(--dark-bg);
    --text-color: var(--dark-text);
    --primary-color: var(--dark-primary);
    --secondary-color: var(--dark-secondary);
    --card-bg: var(--dark-card-bg);
    --card-border: var(--dark-card-border);
    --input-bg: var(--dark-input-bg);
    --success-color: var(--dark-success);
    --error-color: var(--dark-error);
    
    /* Other Variables */
    --transition-time: 0.3s;
}

/* Theme Classes */
body.theme-light {
    --bg-color: var(--light-bg);
    --text-color: var(--light-text);
    --primary-color: var(--light-primary);
    --secondary-color: var(--light-secondary);
    --card-bg: var(--light-card-bg);
    --card-border: var(--light-card-border);
    --input-bg: var(--light-input-bg);
    --success-color: var(--light-success);
    --error-color: var(--light-error);
}

body.theme-dark {
    --bg-color: var(--dark-bg);
    --text-color: var(--dark-text);
    --primary-color: var(--dark-primary);
    --secondary-color: var(--dark-secondary);
    --card-bg: var(--dark-card-bg);
    --card-border: var(--dark-card-border);
    --input-bg: var(--dark-input-bg);
    --success-color: var(--dark-success);
    --error-color: var(--dark-error);
}

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

/* Base Styles */
body {
    font-family: 'Inter', sans-serif;
    background: var(--bg-color);
    color: var(--text-color);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    padding: 20px;
    transition: background var(--transition-time), color var(--transition-time);
}

/* Logo Styling */
.logo-container {
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 20px 0;
    margin-bottom: 10px;
}

.logo {
    max-width: 200px;
    max-height: 80px;
    height: auto;
}

.container {
    max-width: 800px;
    width: 100%;
    text-align: center;
    padding: 40px 20px;
    background-color: var(--card-bg);
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
    border-radius: 10px;
    border: 1px solid var(--card-border);
    transition: min-height 0.5s ease-in-out;
    min-height: 700px; /* Adjust this value based on your layout */
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
}

h1 {
    font-size: 32px;
    font-weight: 700;
    letter-spacing: 1px;
    margin-bottom: 20px;
    transition: color var(--transition-time);
}

h2 {
    font-size: 24px;
    font-weight: 600;
    margin-bottom: 15px;
    transition: color var(--transition-time);
}

p {
    font-size: 16px;
    line-height: 1.6;
    margin-bottom: 20px;
    color: var(--text-color);
    opacity: 0.9;
    max-width: 700px;
    margin-left: auto;
    margin-right: auto;
    transition: color var(--transition-time);
}

ul {
    text-align: left;
    margin: 0 auto 30px;
    max-width: 500px;
    list-style-position: inside;
}

li {
    margin-bottom: 8px;
    line-height: 1.5;
}

/* Progress Bar */
.progress-container {
    width: 100%;
    margin-bottom: 30px;
}

.progress-bar {
    height: 6px;
    background-color: var(--primary-color);
    width: 0%;
    border-radius: 5px;
    transition: width 0.4s ease-in-out;
}

.progress-text {
    font-size: 14px;
    margin-top: 10px;
    color: var(--text-color);
    opacity: 0.7;
    transition: color var(--transition-time);
}

/* Form Elements */
.form-group {
    margin-bottom: 25px;
    text-align: left;
    min-height: 80px; /* Adjust based on your form fields */
}

label {
    display: block;
    margin-bottom: 8px;
    font-weight: 500;
    font-size: 16px;
    transition: color var(--transition-time);
}

/* Required field indicator */
.required-indicator {
    color: var(--error-color);
    margin-left: 5px;
    font-weight: bold;
}

/* Enhance the existing .invalid-feedback rules with more visual cues */
.invalid-feedback {
    color: var(--error-color);
    font-size: 14px;
    margin-top: 5px;
    display: none;
    padding-left: 5px;
    border-left: 3px solid var(--error-color);
}

/* Add visual feedback for URL input fields with extra styling */
input[type="url"]:focus:invalid,
input[type="text"]:focus.is-invalid {
    border-color: var(--error-color);
    box-shadow: 0 0 0 3px rgba(255, 71, 87, 0.2);
}

/* Enhance the existing is-invalid styling */
.is-invalid {
    border-color: var(--error-color) !important;
    background-color: rgba(255, 71, 87, 0.05) !important;
}

.is-invalid + .invalid-feedback {
    display: block;
    animation: fadeIn 0.3s ease-in-out;
}

.required::after {
    content: '*';
    color: var(--error-color);
    margin-left: 4px;
}

input[type="text"],
input[type="email"],
input[type="url"],
input[type="tel"],
select,
textarea {
    width: 100%;
    padding: 15px;
    border-radius: 5px;
    border: 1px solid var(--card-border);
    background: var(--input-bg);
    color: var(--text-color);
    font-size: 16px;
    outline: none;
    transition: all var(--transition-time) ease;
    font-family: 'Inter', sans-serif;
}

input[type="text"]:focus,
input[type="email"]:focus,
input[type="url"]:focus,
input[type="tel"]:focus,
select:focus,
textarea:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(46, 204, 113, 0.2);
}

.custom-select {
    position: relative;
    width: 100%;
}

.select-selected {
    background-color: var(--input-bg);
    color: var(--text-color);
    padding: 15px;
    border: 1px solid var(--card-border);
    border-radius: 5px;
    cursor: pointer;
    user-select: none;
}

.select-selected:after {
    position: absolute;
    content: "";
    top: 50%;
    right: 10px;
    width: 0;
    height: 0;
    border: 6px solid transparent;
    border-color: var(--text-color) transparent transparent transparent;
    transform: translateY(-25%);
}

.select-selected.select-arrow-active:after {
    transform: translateY(-75%) rotate(180deg);
}

.select-hide {
    display: none;
}

.select-items {
    position: absolute;
    background-color: var(--card-bg);
    top: 100%;
    left: 0;
    right: 0;
    z-index: 99;
    max-height: 300px;
    overflow-y: auto;
    border: 2px solid var(--primary-color);
    border-radius: 5px;
    margin-top: 5px;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.2);
}

.select-items div {
    padding: 10px 15px;
    cursor: pointer;
    transition: background-color 0.2s;
}

.select-items div:hover {
    background-color: var(--primary-color);
    color: var(--bg-color);
}

/* custom select styling for validation */
.custom-select.is-invalid {
    border: 1px solid var(--error-color);
    box-shadow: 0 0 0 2px rgba(255, 71, 87, 0.2);
}

.custom-select.is-invalid .select-selected {
    border-color: var(--error-color);
    background-color: rgba(255, 71, 87, 0.05);
}

/* Additional phone input validation styles */
.phone-input-container {
    position: relative;
}

/* Make sure the invalid-feedback is visible for the phone container */
.phone-input-container + .invalid-feedback {
    display: block;
    margin-top: 5px;
    color: var(--error-color);
}

/* Update the combined container validation effect */
.is-invalid .phone-input-container {
    border-color: var(--error-color);
}

/* Show validation errors more clearly for dropdown */
.country-code-dropdown .custom-select.is-invalid .select-selected {
    border-color: var(--error-color) !important;
    background-color: rgba(255, 71, 87, 0.05);
}

/* Fix for theme-specific styles */
body.theme-light .custom-select.is-invalid .select-selected {
    border-color: var(--light-error) !important;
}

body.theme-dark .custom-select.is-invalid .select-selected {
    border-color: var(--dark-error) !important;
}

.radio-group,
.checkbox-group {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-top: 10px;
}

.radio-option,
.checkbox-option {
    display: flex;
    align-items: center;
    gap: 10px;
}

.radio-option label,
.checkbox-option label {
    margin-bottom: 0;
    cursor: pointer;
}

.radio-option input,
.checkbox-option input {
    cursor: pointer;
}

.other-option {
    margin-top: 10px;
    overflow: hidden;
    max-height: 0;
    opacity: 0;
    transition: max-height 0.4s ease-in-out, opacity 0.4s ease-in-out, margin 0.4s ease-in-out;
    pointer-events: none; /* Prevents interaction when hidden */
}

.other-option.show {
    max-height: 60px; /* Adjust based on your input height */
    opacity: 1;
    margin-top: 10px;
    pointer-events: all; /* Allows interaction when shown */
}

.other-option input {
    transition: opacity 0.3s ease-in-out, transform 0.3s ease-in-out;
    opacity: 0;
    transform: translateY(5px);
}

.other-option.show input {
    opacity: 1;
    transform: translateY(0);
}

/* Phone Input Styling */
.phone-input-container {
    display: flex;
    width: 100%;
}

.country-code-dropdown {
    flex: 0 0 100px;
    margin-right: 10px;
}

.country-code-dropdown select {
    width: 100%;
    padding: 15px;
    border-radius: 5px;
    border: 1px solid var(--card-border);
    background: var(--input-bg);
    color: var(--text-color);
    font-size: 16px;
    outline: none;
    transition: all var(--transition-time) ease;
    font-family: 'Inter', sans-serif;
    appearance: none; /* Remove default browser styling */
    -webkit-appearance: none;
    -moz-appearance: none;
    background-image: url("data:image/svg+xml;utf8,<svg fill='gray' height='24' viewBox='0 0 24 24' width='24' xmlns='http://www.w3.org/2000/svg'><path d='M7 10l5 5 5-5z'/><path d='M0 0h24v24H0z' fill='none'/></svg>");
    background-repeat: no-repeat;
    background-position: right 10px center;
    background-size: 20px;
    cursor: pointer;
}

/* Style for dropdown options */
.country-code-dropdown select option {
    background-color: var(--bg-color);
    color: var(--text-color);
    padding: 10px;
    border: none;
}

/* For dark mode */
body.theme-dark .country-code-dropdown select {
    border-color: #444;
}

body.theme-dark .country-code-dropdown select:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 2px rgba(46, 204, 113, 0.3);
}

body.theme-dark .country-code-dropdown select option {
    background-color: #2a2a2a;
    color: white;
    border: none;
}

/* For light mode */
body.theme-light .country-code-dropdown select {
    border-color: #ddd;
}

body.theme-light .country-code-dropdown select:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 2px rgba(39, 174, 96, 0.2);
}

body.theme-light .country-code-dropdown select option {
    background-color: white;
    color: #333;
    border: none;
}

/* Custom dropdown styling - this will be applied with JavaScript */
.country-code-dropdown .select-items {
    position: absolute;
    background-color: var(--card-bg);
    top: 100%;
    left: 0;
    right: 0;
    z-index: 99;
    max-height: 300px;
    overflow-y: auto;
    border: 2px solid var(--primary-color);
    border-radius: 5px;
    margin-top: 5px;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.2);
}

.country-code-dropdown .select-items div {
    padding: 5px;
    cursor: pointer;
    transition: background-color 0.2s;
}

.country-code-dropdown .select-items div:hover {
    background-color: var(--primary-color);
    color: var(--bg-color);
}

.phone-number-input {
    flex: 1;
}

/* Buttons */
.btn-primary,
.btn-secondary {
    padding: 15px 25px;
    font-weight: 600;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    transition: all var(--transition-time) ease;
    font-size: 16px;
}

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

.btn-primary:hover {
    background: var(--dark-primary);
    transform: translateY(-2px);
}

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

.btn-secondary:hover {
    background: var(--input-bg);
    transform: translateY(-2px);
}

.btn-primary:disabled,
.btn-secondary:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

/* Survey Navigation */
.survey-navigation {
    display: flex;
    justify-content: space-between;
    margin-top: 40px;
}

/* Survey Sections */
.survey-intro,
.question-container,
.survey-complete,
.survey-error {
    width: 100%;
    position: absolute;
    display: none;
    opacity: 0;
    visibility: hidden;
    transform: translateY(20px);
    transition: opacity 0.5s ease, transform 0.5s ease;
    margin-bottom: 20px;
}

.survey-intro.active,
.question-container.active,
.survey-complete.active,
.survey-error.active {
    display: relative;
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

#survey-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    position: relative;
}

/* Question transition effects */
.question-container {
    transition: transform 0.5s ease-in-out, opacity 0.5s ease-in-out;
    position: absolute;
    opacity: 0;
    visibility: hidden;
    transform: translateX(50px);  /* Start from right */
    width: 100%;
    left: 0;
    right: 0;
    top: 0;
}

.question-container.active {
    position: relative;
    opacity: 1;
    visibility: visible;
    transform: translateX(0);     /* Move to normal position */
}

.question-container.exiting {
    opacity: 0;
    transform: translateX(-50px); /* Exit to left */
    position: absolute;
    width: 100%;
    top: 0;
    left: 0;
}

/* Ensure the container has proper positioning for absolute elements */
#survey-questions {
    position: relative;
    min-height: 200px; 
    width: 100%;
}

/* Success and Error Styles */
.success-icon {
    font-size: 80px;
    color: var(--success-color);
    margin: 20px 0;
}

#error-message {
    color: var(--error-color);
    margin: 15px 0;
    padding: 10px;
    background: rgba(255, 71, 87, 0.1);
    border-radius: 5px;
}

/* Theme Switcher */
.theme-switch-wrapper {
    position: absolute;
    top: 20px;
    right: 20px;
    display: flex;
    align-items: center;
}

.theme-switch {
    display: inline-block;
    height: 34px;
    position: relative;
    width: 60px;
}

.theme-switch input {
    display: none;
}

.slider {
    background-color: var(--bg-color);
    border: 1px solid var(--card-border);
    bottom: 0;
    cursor: pointer;
    left: 0;
    position: absolute;
    right: 0;
    top: 0;
    transition: .4s;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 4px;
}

.slider:before {
    background-color: var(--primary-color);
    bottom: 4px;
    content: "";
    height: 26px;
    left: 4px;
    position: absolute;
    transition: .4s;
    width: 26px;
    z-index: 1;
}

.slider .icon {
    z-index: 0;
    font-size: 14px;
}

input:checked + .slider:before {
    transform: translateX(26px);
}

.slider.round {
    border-radius: 34px;
}

.slider.round:before {
    border-radius: 50%;
}

/* Footer */
footer {
    margin-top: 40px;
    font-size: 14px;
    color: var(--text-color);
    opacity: 0.7;
    text-align: center;
    transition: color var(--transition-time);
}

/* Field validation */
.invalid-feedback {
    color: var(--error-color);
    font-size: 14px;
    margin-top: 5px;
    display: none;
}

.is-invalid {
    border-color: var(--error-color) !important;
}

.is-invalid + .invalid-feedback {
    display: block;
}

/* Animations */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes fadeOut {
    from {
        opacity: 1;
        transform: translateY(0);
    }
    to {
        opacity: 0;
        transform: translateY(-20px);
    }
}

.fade-in {
    animation: fadeIn 0.5s ease forwards;
}

.fade-out {
    animation: fadeOut 0.5s ease forwards;
}

/* Responsive Styles */
@media (max-width: 768px) {
    h1 {
        font-size: 28px;
    }
    
    h2 {
        font-size: 22px;
    }
    
    .container {
        padding: 30px 15px;
    }
    
    .btn-primary,
    .btn-secondary {
        padding: 12px 20px;
        font-size: 15px;
    }
    
    .theme-switch-wrapper {
        top: 10px;
        right: 10px;
    }
}

@media (max-width: 480px) {
    h1 {
        font-size: 24px;
    }
    
    h2 {
        font-size: 20px;
    }
    
    p {
        font-size: 15px;
    }
    
    .survey-navigation {
        flex-direction: column;
        gap: 15px;
    }
    
    .btn-primary,
    .btn-secondary {
        width: 100%;
    }
    
    .radio-option label,
    .checkbox-option label {
        font-size: 15px;
    }
}