/**
 * Public Styles for TutorLMS Dynamic Custom Fields
 */

/* Profile Fields in Edit/View */
.tdf-profile-fields {
    margin: 30px 0;
    padding: 25px;
    background: #f9f9f9;
    border: 1px solid #ddd;
    border-radius: 8px;
}

.tdf-profile-fields h3 {
    margin: 0 0 20px 0;
    color: #333;
    font-size: 20px;
    border-bottom: 2px solid #ddd;
    padding-bottom: 10px;
}

.tdf-profile-display {
    margin: 30px 0;
    padding: 25px;
    background: #fff;
    border: 1px solid #ddd;
    border-radius: 8px;
}

.tdf-profile-display h3 {
    margin: 0 0 20px 0;
    color: #333;
    font-size: 18px;
    border-bottom: 1px solid #eee;
    padding-bottom: 10px;
}

.tdf-field-item {
    display: flex;
    margin-bottom: 15px;
    padding: 10px 0;
    border-bottom: 1px solid #f0f0f0;
}

.tdf-field-item:last-child {
    border-bottom: none;
    margin-bottom: 0;
}

.tdf-field-item label {
    flex: 0 0 150px;
    font-weight: 600;
    color: #555;
    margin-right: 15px;
}

.tdf-field-item span {
    flex: 1;
    color: #333;
}

/* Field Types */
.tdf-field-radio .tdf-radio-label,
.tdf-field-checkbox .tdf-checkbox-label {
    display: block;
    margin: 8px 0;
    font-weight: normal;
    cursor: pointer;
}

.tdf-field-radio .tdf-radio-label input,
.tdf-field-checkbox .tdf-checkbox-label input {
    margin-right: 8px;
}

.tdf-required {
    color: #d63384;
    font-weight: bold;
}

/* Public Profile */
.tdf-public-profile {
    max-width: 600px;
    margin: 30px auto;
    padding: 30px;
    background: #fff;
    border: 1px solid #ddd;
    border-radius: 12px;
    box-shadow: 0 4px 6px rgba(0,0,0,0.1);
}

.tdf-profile-avatar {
    text-align: center;
    margin-bottom: 25px;
}

.tdf-profile-avatar img {
    border-radius: 50%;
    border: 3px solid #ddd;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.tdf-profile-basic {
    text-align: center;
    margin-bottom: 30px;
}

.tdf-profile-name {
    margin: 0 0 8px 0;
    color: #333;
    font-size: 28px;
    font-weight: 600;
}

.tdf-profile-role {
    color: #666;
    font-style: italic;
    margin: 0 0 20px 0;
    font-size: 16px;
}

.tdf-profile-bio {
    text-align: left;
    color: #555;
    line-height: 1.6;
    background: #f8f9fa;
    padding: 15px;
    border-radius: 6px;
    border-left: 3px solid #0073aa;
}

.tdf-profile-fields {
    border-top: 1px solid #eee;
    padding-top: 25px;
}

.tdf-profile-fields h4 {
    margin: 0 0 20px 0;
    color: #333;
    font-size: 18px;
}

.tdf-fields-grid {
    display: grid;
    gap: 15px;
}

.tdf-fields-grid .tdf-field-item {
    display: flex;
    margin-bottom: 0;
    padding: 12px 0;
    border-bottom: 1px solid #f0f0f0;
}

.tdf-field-label {
    font-weight: 600;
    color: #555;
    flex: 0 0 160px;
    margin-right: 15px;
}

.tdf-field-value {
    flex: 1;
    color: #333;
}

.tdf-field-value a {
    color: #0073aa;
    text-decoration: none;
}

.tdf-field-value a:hover {
    text-decoration: underline;
}

/* Student List */
.tdf-student-list-container {
    margin: 20px 0;
}

.tdf-search-form {
    margin-bottom: 30px;
    padding: 20px;
    background: #f8f9fa;
    border-radius: 8px;
    border: 1px solid #dee2e6;
}

.tdf-search-fields {
    display: flex;
    gap: 15px;
    align-items: flex-end;
}

.tdf-search-input,
.tdf-search-select {
    flex: 1;
    min-width: 200px;
    padding: 10px 15px;
    border: 1px solid #ddd;
    border-radius: 6px;
    font-size: 14px;
    background-color: #fff;
}

.tdf-search-input:focus,
.tdf-search-select:focus {
    border-color: #0073aa;
    outline: none;
    box-shadow: 0 0 0 2px rgba(0,115,170,0.2);
}

.tdf-search-button {
    padding: 10px 20px;
    background: #0073aa;
    color: #fff;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    transition: background-color 0.2s ease;
}

.tdf-search-button:hover {
    background: #005177;
}

.tdf-students-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 25px;
}

.tdf-student-card {
    background: #fff;
    border: 1px solid #ddd;
    border-radius: 12px;
    padding: 20px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    transition: box-shadow 0.2s ease, transform 0.2s ease;
}

.tdf-student-card:hover {
    box-shadow: 0 4px 8px rgba(0,0,0,0.15);
    transform: translateY(-2px);
}

.tdf-student-avatar {
    text-align: center;
    margin-bottom: 15px;
}

.tdf-student-avatar img {
    border-radius: 50%;
    border: 2px solid #ddd;
}

.tdf-student-info h4 {
    margin: 0 0 10px 0;
    color: #333;
    font-size: 18px;
    text-align: center;
}

.tdf-student-email {
    color: #666;
    font-size: 14px;
    text-align: center;
    margin-bottom: 15px;
}

.tdf-student-field {
    margin: 8px 0;
    font-size: 14px;
    color: #555;
}

.tdf-student-field strong {
    color: #333;
}

.tdf-student-joined {
    margin-top: 15px;
    padding-top: 15px;
    border-top: 1px solid #eee;
    font-size: 12px;
    color: #666;
    text-align: center;
}

.tdf-no-students {
    text-align: center;
    padding: 60px 20px;
    color: #666;
}

/* Search Stats */
.tdf-search-stats {
    margin-bottom: 20px;
    padding: 10px 15px;
    background: #e7f3ff;
    border-left: 3px solid #0073aa;
    border-radius: 4px;
}

.tdf-search-stats p {
    margin: 0;
    color: #0073aa;
    font-size: 14px;
    font-weight: 500;
}

/* Search Error */
.tdf-search-error {
    text-align: center;
    padding: 40px 20px;
    background: #fff3f3;
    border: 1px solid #ffdddd;
    border-radius: 8px;
    color: #721c24;
}

/* Field Validation */
.tdf-field-invalid {
    border-color: #dc3545 !important;
    box-shadow: 0 0 0 2px rgba(220, 53, 69, 0.2) !important;
}

.tdf-field-error {
    color: #dc3545;
    font-size: 12px;
    margin-top: 5px;
    display: block;
}

/* Character Counter */
.tdf-char-counter {
    font-size: 11px;
    color: #666;
    margin-top: 5px;
    display: block;
}

.tdf-char-counter.tdf-char-warning {
    color: #ff6600;
    font-weight: 500;
}

/* Loading States */
.tdf-loading {
    position: relative;
    opacity: 0.6;
    pointer-events: none;
}

.tdf-loading::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 20px;
    height: 20px;
    margin: -10px 0 0 -10px;
    border: 2px solid #f3f3f3;
    border-top: 2px solid #0073aa;
    border-radius: 50%;
    animation: tdfSpin 1s linear infinite;
}

@keyframes tdfSpin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Responsive Design */
@media (max-width: 768px) {
    .tdf-public-profile {
        margin: 20px 10px;
        padding: 20px;
    }
    
    .tdf-profile-name {
        font-size: 24px;
    }
    
    .tdf-field-item {
        flex-direction: column;
        gap: 5px;
    }
    
    .tdf-field-item label,
    .tdf-field-label {
        flex: none;
        margin-right: 0;
        margin-bottom: 5px;
    }
    
    .tdf-search-fields {
        flex-direction: column;
        gap: 15px;
    }
    
    .tdf-search-input,
    .tdf-search-select {
        min-width: auto;
    }
    
    .tdf-students-grid {
        grid-template-columns: 1fr;
        gap: 20px;
    }
    
    .tdf-student-card {
        padding: 15px;
    }
}

@media (max-width: 480px) {
    .tdf-public-profile {
        margin: 10px 5px;
        padding: 15px;
    }
    
    .tdf-profile-name {
        font-size: 20px;
    }
    
    .tdf-profile-fields h4 {
        font-size: 16px;
    }
    
    .tdf-student-card {
        padding: 12px;
    }
}

/* Additional Error Handling Styles */
.tdf-ajax-error {
    background: #fff3f3;
    border: 1px solid #ffdddd;
    border-radius: 4px;
    padding: 15px;
    margin: 20px 0;
    color: #721c24;
    text-align: center;
}

.tdf-ajax-loading {
    text-align: center;
    padding: 20px;
    color: #666;
}

.tdf-ajax-loading::before {
    content: '';
    display: inline-block;
    width: 16px;
    height: 16px;
    border: 2px solid #ddd;
    border-top: 2px solid #0073aa;
    border-radius: 50%;
    animation: tdfSpin 1s linear infinite;
    margin-right: 10px;
    vertical-align: middle;
}

/* Field validation states */
.tdf-field-wrapper {
    position: relative;
    margin-bottom: 15px;
}

.tdf-field-wrapper.has-error input,
.tdf-field-wrapper.has-error select,
.tdf-field-wrapper.has-error textarea {
    border-color: #dc3545;
    box-shadow: 0 0 0 1px rgba(220, 53, 69, 0.2);
}

.tdf-field-wrapper .tdf-error-message {
    display: none;
    color: #dc3545;
    font-size: 12px;
    margin-top: 5px;
}

.tdf-field-wrapper.has-error .tdf-error-message {
    display: block;
}

/* Accessibility improvements */
.tdf-screen-reader-text {
    clip: rect(1px, 1px, 1px, 1px);
    position: absolute !important;
    height: 1px;
    width: 1px;
    overflow: hidden;
}

/* Focus improvements */
.tdf-search-input:focus,
.tdf-search-select:focus,
.tdf-search-button:focus {
    outline: 2px solid #0073aa;
    outline-offset: 2px;
}

/* Empty state improvements */
.tdf-empty-state {
    text-align: center;
    padding: 40px 20px;
    background: #f9f9f9;
    border-radius: 8px;
    margin: 20px 0;
}

.tdf-empty-state h3 {
    color: #666;
    margin: 0 0 10px 0;
}

.tdf-empty-state p {
    color: #888;
    margin: 0;
}

/* Enhanced Accessibility */
.tdf-screen-reader-text {
    clip: rect(1px, 1px, 1px, 1px);
    position: absolute !important;
    height: 1px;
    width: 1px;
    overflow: hidden;
}

/* Skip link for keyboard navigation */
.tdf-skip-link {
    position: absolute;
    left: -9999px;
    z-index: 999999;
    padding: 8px 16px;
    background: #000;
    color: #fff;
    text-decoration: none;
    font-size: 14px;
}

.tdf-skip-link:focus {
    left: 6px;
    top: 7px;
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    .tdf-student-card,
    .tdf-public-profile {
        border: 2px solid #000;
    }
    
    .tdf-search-button {
        border: 2px solid #000;
    }
}

/* Reduced motion support */
@media (prefers-reduced-motion: reduce) {
    .tdf-student-card,
    .tdf-modal-content,
    .tdf-search-button,
    * {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* Focus indicators */
.tdf-student-card:focus-within,
.tdf-public-profile:focus-within {
    outline: 2px solid #005fcc;
    outline-offset: 2px;
}

/* Better color contrast */
.tdf-field-label {
    color: #1a1a1a;
    font-weight: 600;
}

.tdf-student-email {
    color: #4a5568;
}

/* ARIA live regions */
.tdf-search-status[aria-live] {
    position: absolute;
    left: -10000px;
    width: 1px;
    height: 1px;
    overflow: hidden;
}

/* Touch target size */
.tdf-search-button,
.tdf-modal-close,
button.tdf-edit-field,
button.tdf-delete-field {
    min-height: 44px;
    min-width: 44px;
}