/* * Ivy LMS Learning Suite - Enterprise AI Edition
 * Version: 10.7 (Full Featured: V9.6 + V10 Features + iOS Support + Tutor Dashboard)
 * Author: Ko Yan Naing (Ed-Tech Lead)
 */

/* =========================================
   0. CROSS-BROWSER & IOS RESETS (CRITICAL)
   ========================================= */

/* Forces iOS/Safari to respect custom styling */
.ivy-interactive-entry input, 
.ivy-interactive-entry textarea, 
.ivy-interactive-entry select, 
.ivy-interactive-entry button,
#ivy-admin-root input,
#ivy-admin-root select,
#ivy-admin-root button {
    -webkit-appearance: none !important;
    -moz-appearance: none !important;
    appearance: none !important;
    border-radius: 0; /* Resets iOS rounded corners default */
}

/* Prevents text from auto-zooming on iPhone when focusing inputs */
html {
    -webkit-text-size-adjust: 100%;
}

/* Fix for flexbox gap in older Safari */
.flex {
    display: -webkit-box;
    display: -ms-flexbox;
    display: flex;
}

/* Touch target size for mobile accessibility */
.touch-target {
    min-height: 44px;
    min-width: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
}

/* =========================================
   1. FRONTEND QUIZ CONTAINER (ISOLATION)
   ========================================= */

/* Scoped container to prevent Theme (Kadence) conflicts */
.ivy-interactive-entry {
    font-family: 'Lexend', ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif !important;
    line-height: 1.6;
    color: #334155; /* Slate 700 */
    background: transparent;
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
    -webkit-font-smoothing: antialiased;
    margin-bottom: 3rem;
    position: relative;
    display: block !important; /* Ensure visibility */
    z-index: 10; /* Prevent overlap issues */
    opacity: 1; /* Fallback for animation */
}

.ivy-interactive-entry * {
    box-sizing: border-box;
}

/* Main Card Style */
.ivy-interactive-entry .ivy-quiz {
    background-color: #ffffff;
    border: 1px solid #e2e8f0;
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
    border-radius: 1.5rem; /* 24px */
    overflow: hidden;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    width: 100%;
    transform: translateZ(0); /* Hardware acceleration for iOS */
}

/* Typography Overrides */
.ivy-interactive-entry h2 {
    color: #ffffff !important;
    margin-top: 0 !important;
    margin-bottom: 0.5rem !important;
    line-height: 1.3 !important;
    font-weight: 800 !important;
    font-size: 1.5rem !important;
}

.ivy-interactive-entry h3 {
    color: #1e293b !important;
    font-size: 1.25rem !important;
    font-weight: 700 !important;
    margin-bottom: 0.5rem !important;
}

.ivy-interactive-entry p {
    margin-bottom: 1rem;
    font-size: 1rem;
}

/* =========================================
   2. FORM ELEMENTS & INTERACTION
   ========================================= */

/* Buttons */
.ivy-interactive-entry button {
    cursor: pointer;
    font-family: inherit;
    font-weight: 600;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    outline: none;
}

.ivy-interactive-entry button:active {
    transform: scale(0.98);
}

.ivy-interactive-entry button:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

.ivy-interactive-entry button:focus-visible {
    ring: 2px solid #3b82f6;
    ring-offset: 2px;
}

/* Text Inputs */
.ivy-interactive-entry input[type="text"] {
    background-color: #fff;
    border: 2px solid #e2e8f0;
    padding: 0.75rem 1rem;
    font-size: 1rem;
    line-height: 1.5;
    border-radius: 0.5rem !important;
    width: 100%;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.ivy-interactive-entry input[type="text"]:focus {
    border-color: #3b82f6;
    outline: none;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

/* Select Dropdowns (Custom Chevron) */
.ivy-interactive-entry select {
    background-color: #fff;
    background-image: url("data:image/svg+xml;charset=US-ASCII,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20width%3D%22292.4%22%20height%3D%22292.4%22%3E%3Cpath%20fill%3D%22%23334155%22%20d%3D%22M287%2069.4a17.6%2017.6%200%200%200-13-5.4H18.4c-5%200-9.3%201.8-12.9%205.4A17.6%2017.6%200%200%200%200%2082.2c0%205%201.8%209.3%205.4%2012.9l128%20127.9c3.6%203.6%207.8%205.4%2012.8%205.4s9.2-1.8%2012.8-5.4L287%2095c3.5-3.5%205.4-7.8%205.4-12.8%200-5-1.9-9.2-5.5-12.8z%22%2F%3E%3C%2Fsvg%3E");
    background-repeat: no-repeat;
    background-position: right 1rem center;
    background-size: 0.65rem auto;
    border: 1px solid #cbd5e1;
    border-radius: 0.5rem !important;
    padding: 0.75rem 2.5rem 0.75rem 1rem !important;
    font-size: 0.95rem;
    cursor: pointer;
    width: 100%;
    transition: all 0.2s ease;
}

.ivy-interactive-entry select:focus {
    border-color: #3b82f6;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

/* =========================================
   3. QUESTION TYPE SPECIFIC STYLES
   ========================================= */

/* --- CLOZE (Fill in the blanks) --- */
.ivy-interactive-entry .cloze-select {
    display: inline-block;
    width: auto;
    min-width: 80px;
    max-width: 200px;
    padding: 0.25rem 1.5rem 0.25rem 0.5rem !important;
    margin: 0 0.25rem;
    border: none;
    border-bottom: 2px solid #3b82f6;
    border-radius: 0.25rem 0.25rem 0 0 !important;
    background-color: rgba(59, 130, 246, 0.05);
    color: #1e3a8a;
    font-weight: 600;
    font-size: 0.95em;
    height: auto;
    line-height: 1.4;
    vertical-align: baseline;
    cursor: pointer;
}

.ivy-interactive-entry .cloze-select:hover {
    background-color: rgba(59, 130, 246, 0.1);
}

.ivy-interactive-entry .word-bank-chip {
    display: inline-block;
    background: #fff;
    border: 1px solid #bfdbfe;
    color: #1e40af;
    padding: 0.25rem 0.75rem;
    border-radius: 9999px !important;
    font-size: 0.85rem;
    font-weight: 600;
    box-shadow: 0 1px 2px rgba(0,0,0,0.05);
    margin: 0.25rem;
    user-select: none;
}

/* --- REORDER (Sorting) --- */
.ivy-interactive-entry .reorder-item {
    transition: background-color 0.2s ease, transform 0.2s ease;
    cursor: grab;
}
.ivy-interactive-entry .reorder-item:active {
    cursor: grabbing;
}

/* --- MATCHING (Pairs) --- */
.ivy-interactive-entry .matching-row {
    display: flex;
    align-items: center;
    gap: 1rem;
    background-color: #f8fafc;
    padding: 1rem;
    border-radius: 0.75rem;
    border: 1px solid #e2e8f0;
}

.ivy-interactive-entry .matching-left {
    flex: 1;
    font-weight: 600;
    color: #334155;
}

.ivy-interactive-entry .matching-right {
    flex: 1;
}

/* Mobile Matching */
@media (max-width: 640px) {
    .ivy-interactive-entry .matching-row {
        flex-direction: column;
        align-items: stretch;
        text-align: center;
    }
    .ivy-interactive-entry .matching-arrow {
        transform: rotate(90deg);
        margin: 0.5rem auto;
    }
}

/* --- TRUE/FALSE & MCQ --- */
.ivy-interactive-entry .option-btn {
    width: 100%;
    text-align: left;
    padding: 1rem;
    border-radius: 0.5rem;
    border: 2px solid #f1f5f9;
    background-color: #fff;
    color: #475569;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.ivy-interactive-entry .option-btn:hover {
    border-color: #cbd5e1;
    background-color: #f8fafc;
}

.ivy-interactive-entry .option-btn.selected {
    border-color: #3b82f6;
    background-color: #eff6ff;
    color: #1e40af;
    font-weight: 600;
}

/* =========================================
   4. V10 MEDIA & LAYOUTS
   ========================================= */

/* Responsive Video Container (16:9) */
.aspect-w-16 {
    position: relative;
    padding-bottom: 56.25%;
    background-color: #000;
    border-radius: 0.75rem;
    overflow: hidden;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
}

.aspect-w-16 iframe,
.aspect-w-16 video {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    border: none;
}

/* Audio Player styling */
.ivy-interactive-entry audio {
    width: 100%;
    height: 40px;
    border-radius: 20px;
}

/* =========================================
   5. ADMIN DASHBOARD (TUTOR LMS INTEGRATION)
   ========================================= */

/* Scoped Admin Root to prevent global styles bleeding in */
#ivy-admin-root {
    font-size: 16px !important;
    line-height: 1.5 !important;
    color: #334155;
    background-color: transparent;
    width: 100%;
    max-width: 100%;
    overflow-x: hidden; /* Prevent horizontal scrollbars */
    padding: 0;
    margin: 0;
}

/* Dashboard Headers */
#ivy-admin-root h1 { 
    font-size: 1.5rem !important; 
    line-height: 1.2 !important; 
    margin-bottom: 0.5rem !important; 
    font-weight: 700 !important;
}
#ivy-admin-root h2 { 
    font-size: 1.25rem !important; 
    line-height: 1.3 !important; 
    margin-bottom: 0.75rem !important; 
    font-weight: 600 !important;
}
#ivy-admin-root h3 { 
    font-size: 1.125rem !important; 
    font-weight: 600 !important; 
    color: #1e293b !important;
}

/* Dashboard Inputs */
#ivy-admin-root input[type="text"], 
#ivy-admin-root input[type="number"], 
#ivy-admin-root input[type="date"],
#ivy-admin-root textarea, 
#ivy-admin-root select {
    font-size: 14px !important;
    line-height: 1.5 !important;
    padding: 0.6rem 0.75rem !important;
    height: auto !important;
    min-height: 40px !important;
    border: 1px solid #cbd5e1 !important;
    border-radius: 0.375rem !important;
    background-color: #fff !important;
    box-shadow: 0 1px 2px rgba(0,0,0,0.05) !important;
    max-width: 100%;
    box-sizing: border-box !important;
}

#ivy-admin-root input:focus,
#ivy-admin-root textarea:focus,
#ivy-admin-root select:focus {
    border-color: #6366f1 !important;
    outline: 2px solid rgba(99, 102, 241, 0.2) !important;
}

/* Admin Scrollbars */
.ivy-admin-dashboard textarea::-webkit-scrollbar,
.ivy-admin-dashboard .overflow-auto::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}
.ivy-admin-dashboard textarea::-webkit-scrollbar-track,
.ivy-admin-dashboard .overflow-auto::-webkit-scrollbar-track {
    background: #f1f5f9;
}
.ivy-admin-dashboard textarea::-webkit-scrollbar-thumb,
.ivy-admin-dashboard .overflow-auto::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 4px;
}
.ivy-admin-dashboard textarea::-webkit-scrollbar-thumb:hover {
    background: #94a3b8;
}

/* Fix table scrolling on mobile */
#ivy-admin-root .overflow-x-auto {
    -webkit-overflow-scrolling: touch;
    overflow-x: auto;
    width: 100%;
    border-radius: 0.5rem;
    border: 1px solid #e2e8f0;
}

/* =========================================
   6. AI REPORT TYPOGRAPHY (The "Prose" Class)
   ========================================= */

/* Ensures AI generated HTML reports look professional */
.prose {
    color: #374151;
    line-height: 1.75;
    font-size: 0.95rem;
}

.prose h1, .prose h2, .prose h3, .prose h4 {
    color: #1e3a8a; /* Ivy Navy */
    font-weight: 700;
    margin-top: 1.5em;
    margin-bottom: 0.5em;
    line-height: 1.2;
}

.prose h3 {
    font-size: 1.15rem;
    border-bottom: 2px solid #e0e7ff;
    padding-bottom: 0.5rem;
    margin-top: 2rem;
    display: flex;
    align-items: center;
}

.prose h3::before {
    content: '';
    display: inline-block;
    width: 6px;
    height: 24px;
    background-color: #4f46e5;
    border-radius: 4px;
    margin-right: 10px;
}

.prose p {
    margin-bottom: 1rem;
}

.prose ul {
    list-style-type: none;
    padding-left: 0;
    margin-bottom: 1.5rem;
}

.prose ul li {
    padding-left: 1.5rem;
    position: relative;
    margin-bottom: 0.5rem;
}

.prose ul li::before {
    content: '•';
    color: #4f46e5;
    font-weight: bold;
    position: absolute;
    left: 0;
    font-size: 1.2em;
}

.prose ol {
    list-style-type: decimal;
    padding-left: 1.5rem;
    margin-bottom: 1.5rem;
}

.prose table {
    width: 100%;
    border-collapse: collapse;
    margin: 1.5rem 0;
    font-size: 0.9em;
    border: 1px solid #e5e7eb;
}

.prose th {
    background-color: #f3f4f6;
    text-align: left;
    padding: 0.75rem;
    border-bottom: 2px solid #e5e7eb;
    font-weight: 700;
    color: #1f2937;
}

.prose td {
    padding: 0.75rem;
    border-bottom: 1px solid #e5e7eb;
}

.prose tr:nth-child(even) {
    background-color: #f9fafb;
}

/* =========================================
   7. ANIMATIONS
   ========================================= */

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes bounceIn {
    0% { opacity: 0; transform: scale(0.9); }
    50% { opacity: 1; transform: scale(1.02); }
    100% { transform: scale(1); }
}

@keyframes spin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

.animate-in {
    animation: fadeIn 0.5s ease-out forwards;
}

.animate-bounce-in {
    animation: bounceIn 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards;
}

.animate-spin {
    animation: spin 1s linear infinite;
    display: inline-block;
}

/* =========================================
   8. UTILITIES & HELPERS
   ========================================= */

.text-center { text-align: center !important; }
.font-bold { font-weight: 700 !important; }
.cursor-pointer { cursor: pointer !important; }

/* Status Colors */
.text-green-600 { color: #16a34a !important; }
.text-red-500 { color: #ef4444 !important; }
.bg-green-50 { background-color: #f0fdf4 !important; }
.border-green-200 { border-color: #bbf7d0 !important; }
.bg-red-50 { background-color: #fef2f2 !important; }
.border-red-200 { border-color: #fecaca !important; }