/* ========================================
   FORMS COMPONENT STYLES
   Comprehensive form styling system for ESL Go
   Consolidates all form styles across the application
   ======================================== */

/* ========================================
   FORM LAYOUT & STRUCTURE
   ======================================== */

.form-group {
    margin-bottom: 1.5rem;
}

.form-row {
    display: flex;
    flex-wrap: wrap;
    margin-right: -0.5rem;
    margin-left: -0.5rem;
}

.form-col {
    flex: 1;
    padding-right: 0.5rem;
    padding-left: 0.5rem;
}

.form-section {
    margin-bottom: 2rem;
    padding: 1.5rem;
    background: var(--bg-card, #ffffff);
    border: 1px solid var(--border-color, #e5e7eb);
    border-radius: var(--border-radius-lg, 0.5rem);
}

.form-section-title {
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--text-primary, #111827);
    margin-bottom: 1rem;
    padding-bottom: 0.5rem;
    border-bottom: 2px solid var(--primary-color, #10b981);
}

/* ========================================
   FORM LABELS
   ======================================== */

.form-label {
    display: block;
    font-weight: 500;
    color: var(--text-primary, #111827);
    margin-bottom: 0.5rem;
    font-size: 0.875rem;
    line-height: 1.25rem;
}

.form-label.required::after {
    content: " *";
    color: var(--error-color, #ef4444);
}

.form-label.optional::after {
    content: " (optional)";
    color: var(--text-muted, #6b7280);
    font-weight: 400;
    font-size: 0.75rem;
}

/* ========================================
   FORM CONTROLS - INPUTS
   ======================================== */

.form-control {
    display: block;
    width: 100%;
    padding: 0.75rem 1rem;
    font-family: var(--font-family-primary, inherit);
    font-size: 0.875rem;
    line-height: 1.25rem;
    color: var(--text-primary, #111827);
    background-color: var(--bg-card, #ffffff);
    border: 1px solid var(--border-color, #d1d5db);
    border-radius: 0.5rem;
    transition: border-color 0.15s ease-in-out, box-shadow 0.15s ease-in-out;
    min-height: 44px; /* Touch-friendly height */
}

.form-control:focus {
    outline: none;
    border-color: var(--primary-color, #10b981);

}

.form-control:disabled {
    background-color: var(--bg-disabled, #f9fafb);
    color: var(--text-disabled, #9ca3af);
    cursor: not-allowed;
}

.form-control::placeholder {
    color: var(--text-muted, #9ca3af);
}

/* Input sizes */
.form-control-sm {
    padding: 0.5rem 0.75rem;
    font-size: 0.75rem;
    min-height: 36px;
}

.form-control-lg {
    padding: 1rem 1.25rem;
    font-size: 1rem;
    min-height: 52px;
}

/* ========================================
   FORM CONTROLS - SELECTS
   ======================================== */

.form-select, select.form-control, .modal .form-select {
    padding-right: 2.5rem !important; /* Ensure room for chevron */
    text-overflow: ellipsis;
    white-space: nowrap;
    overflow: hidden;
    background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 20 20'%3e%3cpath stroke='%236b7280' stroke-linecap='round' stroke-linejoin='round' stroke-width='1.5' d='m6 8 4 4 4-4'/%3e%3c/svg%3e");
    background-position: right 0.75rem center;
    background-repeat: no-repeat;
    background-size: 1.5em 1.5em;
    appearance: none;
}

.form-select:focus {
    border-color: var(--primary-color, #10b981);

}

/* ========================================
   FORM CONTROLS - TEXTAREAS
   ======================================== */

.form-textarea {
    width: 100%;
    padding: 0.75rem 1rem;
    border: 1px solid var(--border-color, #d1d5db);
    border-radius: 0.5rem;
    font-size: 0.875rem;
    color: var(--text-primary, #111827);
    background: var(--bg-card, #ffffff);
    min-height: 120px;
    resize: vertical;
    font-family: var(--font-family-primary, inherit);
    transition: border-color 0.15s ease-in-out, box-shadow 0.15s ease-in-out;
}

.form-textarea:focus {
    outline: none;
    border-color: var(--primary-color, #10b981);

}

/* ========================================
   FORM CONTROLS - CHECKBOXES & RADIOS
   ======================================== */

.form-check {
    display: flex;
    align-items: center;
    margin-bottom: 0.5rem;
}

.form-check-input {
    margin-right: 0.5rem;
    width: 1rem;
    height: 1rem;
    border: 1px solid var(--border-color, #d1d5db);
    border-radius: 0.25rem;
    cursor: pointer;
}

.form-check-input:checked {
    background-color: var(--primary-color, #10b981);
    border-color: var(--primary-color, #10b981);
}

.form-check-label {
    font-size: 0.875rem;
    color: var(--text-primary, #111827);
    cursor: pointer;
    user-select: none;
}

/* ========================================
   FORM CONTROLS - FILE INPUTS
   ======================================== */

.form-file {
    position: relative;
    display: inline-block;
    width: 100%;
}

.form-file-input {
    position: absolute;
    left: -9999px;
    opacity: 0;
}

.form-file-label {
    display: inline-block;
    padding: 0.75rem 1rem;
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text-primary, #111827);
    background-color: var(--bg-card, #ffffff);
    border: 1px solid var(--border-color, #d1d5db);
    border-radius: 0.5rem;
    cursor: pointer;
    transition: all 0.15s ease-in-out;
    text-align: center;
    width: 100%;
}

.form-file-label:hover {
    background-color: var(--bg-hover, #f9fafb);
    border-color: var(--primary-color, #10b981);
}

.form-file-label:active {
    background-color: var(--bg-active, #f3f4f6);
}

/* ========================================
   FORM VALIDATION STATES
   ======================================== */

.form-control.is-valid {
    border-color: var(--success-color, #10b981);
}

.form-control.is-valid:focus {
    border-color: var(--success-color, #10b981);

}

.form-control.is-invalid {
    border-color: var(--error-color, #ef4444);
}

.form-control.is-invalid:focus {
    border-color: var(--error-color, #ef4444);

}

/* Validation feedback */
.valid-feedback {
    display: block;
    width: 100%;
    margin-top: 0.25rem;
    font-size: 0.75rem;
    color: var(--success-color, #10b981);
}

.invalid-feedback {
    display: block;
    width: 100%;
    margin-top: 0.25rem;
    font-size: 0.75rem;
    color: var(--error-color, #ef4444);
}

/* ========================================
   FORM HELP TEXT
   ======================================== */

.form-text {
    margin-top: 0.25rem;
    font-size: 0.75rem;
    color: var(--text-muted, #6b7280);
}

.form-text.help-text {
    color: var(--info-color, #3b82f6);
}

.form-text.warning-text {
    color: var(--warning-color, #f59e0b);
}

/* ========================================
   FORM BUTTONS
   ======================================== */

.form-actions {
    display: flex;
    gap: 0.75rem;
    margin-top: 1.5rem;
    padding-top: 1rem;
    border-top: 1px solid var(--border-color, #e5e7eb);
}

.form-actions .btn {
    min-width: 100px;
}

.form-actions .btn:first-child {
    margin-left: auto;
}

/* ========================================
   FORM MODALS & OVERLAYS
   ======================================== */

.form-modal .modal-body {
    max-height: 70vh;
    overflow-y: auto;
}

.form-modal .form-section {
    margin-bottom: 1rem;
    padding: 1rem;
}

/* ========================================
   RESPONSIVE FORM DESIGN
   ======================================== */

@media (max-width: 768px) {
    .form-row {
        flex-direction: column;
    }
    
    .form-col {
        margin-bottom: 1rem;
    }
    
    .form-actions {
        flex-direction: column;
    }
    
    .form-actions .btn {
        width: 100%;
    }
    
    .form-control {
        font-size: 16px; /* Prevent zoom on iOS */
    }
}

/* ========================================
   LEGACY COMPATIBILITY
   ======================================== */

/* Maintain compatibility with existing TPD classes */
.tpd-input {
    @extend .form-control;
}

.tpd-textarea {
    @extend .form-textarea;
}

.tpd-form-group {
    @extend .form-group;
}

/* ========================================
   EXISTING STYLES (KEPT FOR COMPATIBILITY)
   ======================================== */

/* Profile Picture Upload */
.profile-picture-upload {
    cursor: pointer;
    display: block;
}

.profile-picture-input {
    display: none;
}

.profile-quiz-avatar {
    width: 90px;
    height: 90px;
    object-fit: cover;
}

/* Cropper Image */
#cropperImage {
    max-width: 100%;
    display: block;
}

/* Error Message */
#errorMessage {
    display: none;
}

/* Location Input */
#location-input {
    display: none;
    width: 120px;
    margin-left: 8px;
}

#location-emoji {
    cursor: pointer;
}

/* Save Button */
#save-button {
    display: none;
}

/* Whiteboard Save Button */
.whiteboard-save-btn {
    display: none;
}

/* Debug Panel */
#debugPanel {
    position: fixed;
    top: 10px;
    right: 10px;
    background: #000;
    color: #0f0;
    padding: 10px;
    border-radius: 5px;
    font-family: monospace;
    font-size: 12px;
    z-index: 9999;
    max-width: 300px;
}

.debug-panel-title {
    margin-bottom: 10px;
    font-weight: bold;
}

.debug-button {
    background: #333;
    color: #0f0;
    border: 1px solid #0f0;
    padding: 5px;
    margin: 5px 0;
    cursor: pointer;
}

.debug-button-danger {
    background: #f00;
    color: #fff;
    border: 1px solid #f00;
}

/* Container Styles */
.container-narrow {
    max-width: 600px;
}

/* Progress Bar */
.progress {
    width: 75%; /* Default value, can be overridden */
}

/* Exam Options */
.exam-options {
    display: none;
} 