/* Custom CSS for Bacari Learn */

/* HTMX Loading States */
.htmx-indicator {
    display: none;
}

.htmx-request .htmx-indicator {
    display: inline-block;
}

.htmx-request.htmx-indicator {
    display: inline-block;
}

/* Loading spinner */
.loading-spinner {
    border: 2px solid #f3f3f;
    border-top: 2px solid #3498db;
    border-radius: 50%;
    width: 20px;
    height: 20px;
    animation: spin 1s linear infinite;
    display: inline-block;
    margin-left: 8px;
}

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

/* Progress bars */
.progress-bar {
    background-color: #e5e7eb;
    border-radius: 9999px;
    overflow: hidden;
}

.progress-bar-fill {
    background-color: #3b82f6;
    height: 100%;
    transition: width 0.3s ease-in-out;
}

/* Card styles */
.card {
    background: white;
    border-radius: 8px;
    box-shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.1), 0 1px 2px 0 rgba(0, 0, 0, 0.06);
    padding: 1.5rem;
}

.card-hover {
    transition: all 0.2s ease-in-out;
}

.card-hover:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
}

/* Button styles */
.btn {
    padding: 0.5rem 1rem;
    border-radius: 6px;
    font-weight: 500;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease-in-out;
    cursor: pointer;
    border: none;
}

.btn-primary {
    background-color: #3b82f6;
    color: white;
}

.btn-primary:hover {
    background-color: #2563eb;
}

.btn-secondary {
    background-color: #6b7280;
    color: white;
}

.btn-secondary:hover {
    background-color: #4b5563;
}

.btn-success {
    background-color: #10b981;
    color: white;
}

.btn-success:hover {
    background-color: #059669;
}

.btn-danger {
    background-color: #ef4444;
    color: white;
}

.btn-danger:hover {
    background-color: #dc2626;
}

/* Form styles */
.form-group {
    margin-bottom: 1rem;
}

.form-label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 500;
    color: #374151;
}

.form-input {
    width: 100%;
    padding: 0.5rem 0.75rem;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    font-size: 1rem;
    transition: border-color 0.2s ease-in-out;
}

.form-input:focus {
    outline: none;
    border-color: #3b82f6;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

.form-error {
    color: #ef4444;
    font-size: 0.875rem;
    margin-top: 0.25rem;
}

/* Alert styles */
.alert {
    padding: 0.75rem 1rem;
    border-radius: 6px;
    margin-bottom: 1rem;
}

.alert-success {
    background-color: #d1fae5;
    color: #065f46;
    border: 1px solid #a7f3d0;
}

.alert-error {
    background-color: #fee2e2;
    color: #991b1b;
    border: 1px solid #fecaca;
}

.alert-warning {
    background-color: #fef3c7;
    color: #92400e;
    border: 1px solid #fde68a;
}

.alert-info {
    background-color: #dbeafe;
    color: #1e40af;
    border: 1px solid #bfdbfe;
}

/* Navigation styles */
.nav-link {
    color: #4b5563;
    text-decoration: none;
    padding: 0.5rem 0.75rem;
    border-radius: 6px;
    transition: color 0.2s ease-in-out;
}

.nav-link:hover {
    color: #3b82f6;
}

.nav-link.active {
    color: #3b82f6;
    background-color: #eff6ff;
}

/* Badge styles */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 0.25rem 0.5rem;
    border-radius: 9999px;
    font-size: 0.75rem;
    font-weight: 500;
}

.badge-primary {
    background-color: #dbeafe;
    color: #1e40af;
}

.badge-success {
    background-color: #d1fae5;
    color: #065f46;
}

.badge-warning {
    background-color: #fef3c7;
    color: #92400e;
}

.badge-danger {
    background-color: #fee2e2;
    color: #991b1b;
}

/* Streak flame animation */
.streak-flame {
    display: inline-block;
    color: #f59e0b;
    animation: flicker 1.5s ease-in-out infinite alternate;
}

@keyframes flicker {
    0% { opacity: 1; transform: scale(1); }
    100% { opacity: 0.8; transform: scale(0.95); }
}

/* Quiz styles */
.quiz-option {
    padding: 1rem;
    border: 2px solid #e5e7eb;
    border-radius: 8px;
    margin-bottom: 0.75rem;
    cursor: pointer;
    transition: all 0.2s ease-in-out;
}

.quiz-option:hover {
    border-color: #3b82f6;
    background-color: #f8fafc;
}

.quiz-option.selected {
    border-color: #3b82f6;
    background-color: #eff6ff;
}

.quiz-option.correct {
    border-color: #10b981;
    background-color: #d1fae5;
}

.quiz-option.incorrect {
    border-color: #ef4444;
    background-color: #fee2e2;
}

/* Answer option styles - Consistent styling for all quiz/evaluation answers */
.answer-option {
    position: relative;
    display: block;
    cursor: pointer !important;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    border: 3px solid #e5e7eb !important;
    border-radius: 12px !important;
    background-color: #ffffff !important;
    font-weight: 500;
    user-select: none;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1) !important;
}

.answer-option:hover {
    border-color: #3b82f6 !important;
    background-color: #dbeafe !important;
    transform: translateX(4px);
    box-shadow: 0 4px 12px rgba(59, 130, 246, 0.25) !important;
    cursor: pointer !important;
}

.answer-option:active {
    transform: translateX(2px) scale(0.99);
    box-shadow: 0 1px 4px rgba(59, 130, 246, 0.2) !important;
}

/* Disabled state */
.answer-option:disabled,
.answer-option.disabled {
    cursor: not-allowed !important;
    opacity: 0.6;
    transform: none !important;
}

.answer-option:disabled:hover,
.answer-option.disabled:hover {
    border-color: #d1d5db !important;
    background-color: #f9fafb !important;
    box-shadow: none !important;
}

/* Focus state for accessibility */
.answer-option:focus {
    outline: none;
    border-color: #3b82f6 !important;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.2) !important;
}

/* Selected state */
.answer-option.selected {
    border-color: #3b82f6;
    background-color: #eff6ff;
    box-shadow: 0 2px 8px rgba(59, 130, 246, 0.15);
}

/* Correct answer state */
.answer-option.correct {
    border-color: #10b981;
    background-color: #d1fae5;
}

/* Incorrect answer state */
.answer-option.incorrect {
    border-color: #ef4444;
    background-color: #fee2e2;
}

/* Radio/checkbox inside answer option */
.answer-option input[type="radio"],
.answer-option input[type="checkbox"] {
    cursor: pointer;
    accent-color: #3b82f6;
}

/* Add a subtle gradient on hover for extra visual feedback */
.answer-option::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 4px;
    height: 100%;
    background: linear-gradient(to bottom, #3b82f6, #1d4ed8);
    border-radius: 8px 0 0 8px;
    opacity: 0;
    transition: opacity 0.2s ease;
}

.answer-option:hover::before {
    opacity: 1;
}

/* Question card styling */
.question-card {
    transition: all 0.2s ease;
}

.question-card:hover {
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
}

/* Lesson content styles */
.lesson-content {
    line-height: 1.6;
    color: #374151;
}

.lesson-content h1,
.lesson-content h2,
.lesson-content h3 {
    margin-top: 2rem;
    margin-bottom: 1rem;
    font-weight: 600;
}

.lesson-content h1 { font-size: 2rem; }
.lesson-content h2 { font-size: 1.5rem; }
.lesson-content h3 { font-size: 1.25rem; }

.lesson-content p {
    margin-bottom: 1rem;
}

.lesson-content ul,
.lesson-content ol {
    margin-bottom: 1rem;
    padding-left: 1.5rem;
}

.lesson-content li {
    margin-bottom: 0.5rem;
}

/* Stats grid improvements */
.stats-grid {
    display: grid;
    gap: 1.5rem;
}

@media (min-width: 768px) {
    .stats-grid {
        grid-template-columns: repeat(4, 1fr);
    }
}

/* Activity feed improvements */
.activity-item {
    padding: 1rem;
    border-bottom: 1px solid #f3f4f;
    transition: background-color 0.2s ease-in-out;
}

.activity-item:hover {
    background-color: #f9fafb;
}

.activity-item:last-child {
    border-bottom: none;
}

/* Goal cards */
.goal-card {
    position: relative;
    overflow: hidden;
}

.goal-card .progress-ring {
    width: 48px;
    height: 48px;
    margin-bottom: 0.75rem;
}

/* Enhanced progress bars */
.progress-enhanced {
    position: relative;
    width: 100%;
    height: 8px;
    background-color: #e5e7eb;
    border-radius: 9999px;
    overflow: hidden;
}

.progress-enhanced .progress-fill {
    height: 100%;
    background: linear-gradient(to right, #3b82f6, #1d4ed8);
    border-radius: 9999px;
    transition: width 0.5s ease-out;
}

/* Domain progress bars */
.domain-progress {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.5rem;
}

.domain-progress .progress-bar {
    width: 100px;
    height: 8px;
    background-color: #e5e7eb;
    border-radius: 9999px;
    overflow: hidden;
}

/* Achievement animations */
.achievement-card {
    transition: transform 0.3s ease;
}

.achievement-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 16px rgba(0, 0, 0, 0.1);
}

/* Modal improvements */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 50;
}

.modal-content {
    background: white;
    border-radius: 12px;
    box-shadow: 0 20px 25px rgba(0, 0, 0, 0.15);
    max-width: 90vw;
    max-height: 90vh;
    overflow-y: auto;
    animation: modalSlideIn 0.3s ease-out;
}

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

/* Chart containers */
.chart-container {
    position: relative;
    height: 250px;
    width: 100%;
}

.chart-container canvas {
    width: 100% !important;
    height: 100% !important;
}

/* Responsive improvements */
@media (max-width: 768px) {
    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 1rem;
    }
    
    .card {
        padding: 1rem;
        margin-bottom: 1rem;
    }
    
    .btn {
        padding: 0.75rem 1.25rem;
        font-size: 0.875rem;
        width: 100%;
        margin-bottom: 0.5rem;
    }
    
    .goals-container {
        gap: 1rem;
    }
    
    .achievement-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 1rem;
    }
    
    .modal-content {
        margin: 1rem;
        max-width: 95vw;
    }
}

@media (max-width: 480px) {
    .stats-grid {
        grid-template-columns: 1fr;
        gap: 0.75rem;
    }
    
    .card {
        padding: 0.75rem;
        margin-bottom: 0.75rem;
    }
    
    .btn {
        padding: 0.75rem 1rem;
        font-size: 0.875rem;
    }
    
    .modal-content {
        margin: 0.5rem;
        max-width: 98vw;
    }
    
    .goals-container {
        gap: 0.75rem;
    }
    
    .achievement-grid {
        grid-template-columns: 1fr;
        gap: 0.75rem;
    }
}

/* Focus states */
.form-input:focus,
.btn:focus,
.nav-link:focus {
    outline: 2px solid transparent;
    outline-offset: 2px;
}

/* Smooth scrolling */
.smooth-scroll {
    scroll-behavior: smooth;
}

/* Loading states for dynamic content */
.loading-skeleton {
    background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
    background-size: 200% 100%;
    border-radius: 4px;
    animation: skeleton-loading 1.5s infinite ease-in-out;
}

@keyframes skeleton-loading {
    0% {
        background-position: 200% 0%;
    }
    100% {
        background-position: -200% 0%;
    }
}

/* Enhanced hover states */
.hover-lift {
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.hover-lift:hover {
    transform: translateY(-4px);
    box-shadow: 0 10px 20px rgba(0, 0, 0, 0.1);
}

/* Success/Error states */
.state-success {
    border-color: #10b981;
    background-color: #f0fdf4;
}

.state-error {
    border-color: #ef4444;
    background-color: #fef2f2;
}

/* Improved readability */
.text-contrast {
    color: #111827;
}

.text-muted {
    color: #6b7280;
}

/* Interactive elements */
.interactive-element {
    transition: all 0.2s ease;
}

.interactive-element:active {
    transform: scale(0.98);
}

/* Accessibility improvements */
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
}

/* Enhanced focus ring */
.focus-ring {
    position: relative;
}

.focus-ring::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    border-radius: inherit;
    border: 2px solid transparent;
    transition: border-color 0.2s ease;
}

.focus-ring:focus::after {
    border-color: #3b82f6;
}
