/**
 * Activities System Stylesheet
 * 
 * Comprehensive styling for activity components including:
 * - Activity containers and forms
 * - Textarea styling
 * - Counter badges and indicators
 * - Button states and interactions
 * - Feedback displays
 * - Accessibility features
 * - Responsive design
 * - Animation and transitions
 * 
 * @package Evolve AI Institute
 * @author Tim Mousel, M.S.
 * @copyright 2025 Tim Mousel. All rights reserved.
 * @version 1.0
 * @wcag WCAG 2.2 AAA compliant
 */

/* ==========================================
   Activity Container
   ========================================== */

.activity-container {
    transition: all 0.3s ease;
}

.activity-container:hover {
    transform: translateY(-2px);
    box-shadow: 0 0.5rem 1.5rem rgba(0, 0, 0, 0.15) !important;
}

.activity-container .card-header {
    background: linear-gradient(135deg, var(--bs-primary) 0%, #0056b3 100%);
}

/* ==========================================
   Activity Textarea
   ========================================== */

.activity-textarea {
    font-size: 1rem;
    line-height: 1.6;
    padding: 1rem;
    border: 2px solid #dee2e6;
    border-radius: 0.5rem;
    transition: all 0.3s ease;
    resize: vertical;
    min-height: 300px;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
}

.activity-textarea:focus {
    border-color: var(--bs-primary);
    box-shadow: 0 0 0 0.25rem rgba(13, 110, 253, 0.15);
    outline: none;
}

.activity-textarea:read-only {
    background-color: #f8f9fa;
    cursor: not-allowed;
    opacity: 0.7;
}

.activity-textarea.is-invalid {
    border-color: var(--bs-danger);
    padding-right: calc(1.5em + 0.75rem);
    background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 12' width='12' height='12' fill='none' stroke='%23dc3545'%3e%3ccircle cx='6' cy='6' r='4.5'/%3e%3cpath stroke-linejoin='round' d='M5.8 3.6h.4L6 6.5z'/%3e%3ccircle cx='6' cy='8.2' r='.6' fill='%23dc3545' stroke='none'/%3e%3c/svg%3e");
    background-repeat: no-repeat;
    background-position: right calc(0.375em + 0.1875rem) top calc(0.375em + 0.1875rem);
    background-size: calc(0.75em + 0.375rem) calc(0.75em + 0.375rem);
}

/* ==========================================
   Character and Word Counters
   ========================================== */

.badge.bg-secondary {
    font-size: 0.875rem;
    font-weight: 500;
    padding: 0.5rem 0.75rem;
    border-radius: 0.375rem;
}

#char-counter-\* .char-current,
#word-counter-\* .word-current,
[id^="char-counter-"] .char-current,
[id^="word-counter-"] .word-current {
    font-weight: 700;
}

/* Counter color states */
[id^="char-counter-"].text-warning,
[id^="char-counter-"].bg-warning {
    background-color: #ffc107 !important;
    color: #000 !important;
}

[id^="char-counter-"].text-danger,
[id^="char-counter-"].bg-danger {
    background-color: #dc3545 !important;
    color: #fff !important;
}

/* ==========================================
   Form Actions and Buttons
   ========================================== */

.activity-form .btn-group {
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    border-radius: 0.375rem;
}

.save-draft-btn {
    position: relative;
    overflow: hidden;
}

.save-draft-btn::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 0;
    height: 0;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.3);
    transform: translate(-50%, -50%);
    transition: width 0.6s, height 0.6s;
}

.save-draft-btn:hover::before {
    width: 300px;
    height: 300px;
}

.submit-activity-btn {
    font-weight: 600;
    position: relative;
    overflow: hidden;
}

.submit-activity-btn::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 0;
    height: 0;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.4);
    transform: translate(-50%, -50%);
    transition: width 0.6s, height 0.6s;
}

.submit-activity-btn:hover::after {
    width: 300px;
    height: 300px;
}

/* Button disabled states */
.btn:disabled,
.btn.disabled {
    cursor: not-allowed;
    opacity: 0.6;
}

/* ==========================================
   Auto-save Status
   ========================================== */

.autosave-status {
    font-size: 0.875rem;
    color: #6c757d;
    transition: color 0.3s ease;
}

.autosave-status.saving {
    color: var(--bs-warning);
}

.autosave-status.saved {
    color: var(--bs-success);
}

.autosave-status.error {
    color: var(--bs-danger);
}

/* Keyboard shortcut badge */
kbd {
    padding: 0.2rem 0.4rem;
    font-size: 0.75rem;
    color: #fff;
    background-color: #212529;
    border-radius: 0.25rem;
    box-shadow: inset 0 -0.1rem 0 rgba(0, 0, 0, 0.25);
    font-family: SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
}

/* ==========================================
   Feedback and Status Alerts
   ========================================== */

.alert {
    border-left: 4px solid;
    animation: slideInLeft 0.4s ease-out;
}

.alert-info {
    border-left-color: var(--bs-info);
    background-color: #cff4fc;
}

.alert-success {
    border-left-color: var(--bs-success);
    background-color: #d1e7dd;
}

.alert-warning {
    border-left-color: var(--bs-warning);
    background-color: #fff3cd;
}

.alert-danger {
    border-left-color: var(--bs-danger);
    background-color: #f8d7da;
}

/* ==========================================
   Status Badges - WCAG 2.2 AAA Compliant
   ========================================== */

.badge {
    font-weight: 500;
    letter-spacing: 0.025em;
}

/* WCAG 2.2 AAA: Maximum contrast for badges with light backgrounds */
/* Using maximum specificity to override Bootstrap defaults */
span.badge.bg-light,
span.badge.bg-light.text-dark,
.badge.bg-light,
.badge.bg-light.text-dark {
    background-color: #ffffff !important;
    color: #000000 !important;
    border: 2px solid #000000 !important;
    font-weight: 700 !important;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.12) !important;
}

/* Ensure icons within light badges have proper contrast */
span.badge.bg-light i,
span.badge.bg-light.text-dark i,
.badge.bg-light i,
.badge.bg-light.text-dark i,
span.badge.bg-light .bi,
span.badge.bg-light.text-dark .bi,
.badge.bg-light .bi,
.badge.bg-light.text-dark .bi {
    color: #000000 !important;
}

/* Alternative high-contrast badge style for points display */
.badge.badge-stat,
span.badge.badge-stat {
    background-color: #ffffff !important;
    color: #000000 !important;
    border: 2px solid #000000 !important;
    font-weight: 700 !important;
    padding: 0.5rem 0.75rem !important;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.12) !important;
}

.badge.badge-stat i,
span.badge.badge-stat i,
.badge.badge-stat .bi,
span.badge.badge-stat .bi {
    color: #000000 !important;
}

/* Warning badges - black text on yellow for AAA contrast */
span.badge.bg-warning,
.badge.bg-warning {
    background-color: #ffc107 !important;
    color: #000000 !important;
    border: 2px solid #000000 !important;
    font-weight: 700 !important;
}

span.badge.bg-warning i,
.badge.bg-warning i,
span.badge.bg-warning .bi,
.badge.bg-warning .bi {
    color: #000000 !important;
}

/* Dark badges - white text on black for AAA contrast */
span.badge.bg-dark,
.badge.bg-dark {
    background-color: #000000 !important;
    color: #ffffff !important;
    border: 2px solid #ffffff !important;
    font-weight: 700 !important;
}

span.badge.bg-dark i,
.badge.bg-dark i,
span.badge.bg-dark .bi,
.badge.bg-dark .bi {
    color: #ffffff !important;
}

/* ==========================================
   Example Submission
   ========================================== */

.example-content {
    font-size: 0.9375rem;
    line-height: 1.7;
    color: #495057;
    max-height: 500px;
    overflow-y: auto;
    padding: 1rem;
    background-color: #fff;
    border: 1px solid #dee2e6;
    border-radius: 0.375rem;
}

.example-content::-webkit-scrollbar {
    width: 8px;
}

.example-content::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 4px;
}

.example-content::-webkit-scrollbar-thumb {
    background: #888;
    border-radius: 4px;
}

.example-content::-webkit-scrollbar-thumb:hover {
    background: #555;
}

/* ==========================================
   Animations
   ========================================== */

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

@keyframes fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

@keyframes pulse {
    0% {
        transform: scale(1);
    }
    50% {
        transform: scale(1.05);
    }
    100% {
        transform: scale(1);
    }
}

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

/* ==========================================
   Loading Spinner
   ========================================== */

.spinner-border-sm {
    width: 1rem;
    height: 1rem;
    border-width: 0.15rem;
}

/* ==========================================
   Accessibility Enhancements
   ========================================== */

/* Skip links */
.skip-link {
    position: absolute;
    top: -40px;
    left: 0;
    background: var(--bs-primary);
    color: white;
    padding: 8px;
    text-decoration: none;
    z-index: 100;
}

.skip-link:focus {
    top: 0;
}

/* Focus visible */
*:focus-visible {
    outline: 3px solid var(--bs-primary);
    outline-offset: 2px;
}

/* Required field indicator */
.form-label.required::after {
    content: ' *';
    color: var(--bs-danger);
}

/* Screen reader only text */
.visually-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border-width: 0;
}

/* ==========================================
   High Contrast Mode Support
   ========================================== */

@media (prefers-contrast: high) {
    .activity-textarea {
        border-width: 3px;
    }
    
    .badge {
        border: 2px solid currentColor;
    }
    
    .btn {
        border-width: 2px;
    }
}

/* ==========================================
   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;
        scroll-behavior: auto !important;
    }
}

/* ==========================================
   Dark Mode Support (Future Enhancement)
   ========================================== */

@media (prefers-color-scheme: dark) {
    /* Dark mode styles can be added here when implemented */
}

/* ==========================================
   Print Styles
   ========================================== */

@media print {
    .activity-container {
        box-shadow: none !important;
        border: 1px solid #000;
    }
    
    .save-draft-btn,
    .submit-activity-btn,
    .autosave-status,
    [data-bs-toggle="collapse"] {
        display: none !important;
    }
    
    .activity-textarea {
        border: 1px solid #000;
        background-color: #fff !important;
    }
    
    .example-content {
        max-height: none;
        overflow: visible;
    }
}

/* ==========================================
   Responsive Design
   ========================================== */

@media (max-width: 768px) {
    .activity-container .card-body {
        padding: 1.5rem 1rem;
    }
    
    .activity-textarea {
        font-size: 16px; /* Prevent zoom on iOS */
        min-height: 250px;
    }
    
    .btn-group {
        width: 100%;
    }
    
    .btn-group .btn {
        width: 50%;
    }
    
    .badge {
        font-size: 0.75rem;
        padding: 0.35rem 0.55rem;
    }
    
    .form-text {
        font-size: 0.8125rem;
    }
}

@media (max-width: 576px) {
    .activity-container .card-header h3 {
        font-size: 1.25rem;
    }
    
    .activity-textarea {
        min-height: 200px;
    }
    
    .example-content {
        font-size: 0.875rem;
        max-height: 400px;
    }
}

/* ==========================================
   Touch Device Optimizations
   ========================================== */

@media (hover: none) and (pointer: coarse) {
    .btn {
        min-height: 44px; /* Minimum touch target size */
        min-width: 44px;
    }
    
    .activity-textarea {
        font-size: 16px; /* Prevent zoom */
    }
}
