/**
 * GlobeIQ Block System V2 - Comprehensive Styling
 * Professional, accessible, and responsive styling for all block types
 */

/* ======================
   BLOCK CONTAINERS
   ====================== */

.block-renderer {
    width: 100%;
    margin: 0 auto;
}

.lesson-block {
    margin-bottom: 2rem;
    animation: fadeIn 0.3s ease-in;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

/* ======================
   HEADING BLOCK
   ====================== */

.lesson-heading {
    font-weight: 700;
    line-height: 1.2;
    margin-bottom: 1rem;
}

.lesson-heading.h1 {
    font-size: 2.5rem;
    margin-bottom: 1.5rem;
}

.lesson-heading.h2 {
    font-size: 2rem;
    margin-bottom: 1.25rem;
}

.lesson-heading.h3 {
    font-size: 1.75rem;
}

.lesson-heading.h4 {
    font-size: 1.5rem;
}

.lesson-heading.h5 {
    font-size: 1.25rem;
}

.lesson-heading.h6 {
    font-size: 1.1rem;
}

/* ======================
   RICH TEXT BLOCK
   ====================== */

.rich-text-block {
    line-height: 1.75;
    color: inherit;
}

.rich-text-block p {
    margin-bottom: 1rem;
}

.rich-text-block strong {
    font-weight: 600;
}

.rich-text-block em {
    font-style: italic;
}

.rich-text-block code {
    background-color: rgba(110, 118, 129, 0.15);
    padding: 0.2em 0.4em;
    border-radius: 3px;
    font-family: 'Courier New', Courier, monospace;
    font-size: 0.9em;
}

.rich-text-block ul, .rich-text-block ol {
    margin-left: 2rem;
    margin-bottom: 1rem;
}

.rich-text-block li {
    margin-bottom: 0.5rem;
}

/* LaTeX Math in Rich Text */
.math-inline {
    display: inline;
    margin: 0 0.2em;
}

.math-display {
    display: block;
    margin: 1.5rem 0;
    text-align: center;
}

/* ======================
   IMAGE BLOCK
   ====================== */

.image-block {
    margin: 2rem 0;
}

.image-wrapper {
    width: 100%;
}

.block-image {
    border-radius: 8px;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    transition: transform 0.2s ease;
}

.block-image:hover {
    transform: scale(1.02);
}

.image-caption {
    text-align: center;
    font-size: 0.9rem;
    font-style: italic;
    margin-top: 0.75rem;
}

.image-placeholder {
    min-height: 200px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

/* ======================
   VIDEO BLOCK
   ====================== */

.video-block {
    margin: 2rem 0;
}

.video-wrapper video {
    width: 100%;
    border-radius: 8px;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

.video-placeholder {
    min-height: 300px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

/* ======================
   CALLOUT BLOCK
   ====================== */

.callout-block {
    padding: 1.25rem;
    border-left: 4px solid;
    border-radius: 6px;
    margin: 1.5rem 0;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
}

.callout-title {
    font-size: 1.1rem;
    margin-bottom: 0.75rem;
}

.callout-content {
    line-height: 1.6;
}

/* Dark mode callout adjustments */
@media (prefers-color-scheme: dark) {
    .callout-info {
        background-color: rgba(59, 130, 246, 0.15);
        color: rgb(147, 197, 253);
    }
    
    .callout-success {
        background-color: rgba(34, 197, 94, 0.15);
        color: rgb(134, 239, 172);
    }
    
    .callout-warning {
        background-color: rgba(251, 191, 36, 0.15);
        color: rgb(253, 224, 71);
    }
    
    .callout-danger {
        background-color: rgba(239, 68, 68, 0.15);
        color: rgb(252, 165, 165);
    }
    
    .callout-tip {
        background-color: rgba(168, 85, 247, 0.15);
        color: rgb(216, 180, 254);
    }
}

/* ======================
   MULTIPLE CHOICE BLOCK
   ====================== */

.multiple-choice-block {
    margin: 2rem 0;
    padding: 1.5rem;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 8px;
}

.question-prompt {
    font-size: 1.125rem;
    font-weight: 500;
    margin-bottom: 1.5rem;
}

.choices-container {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.choice-item {
    padding: 1rem 1.25rem;
    border: 2px solid #4b5563;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: rgba(255, 255, 255, 0.02);
}

.choice-item:hover {
    border-color: #6b7280;
    background: rgba(255, 255, 255, 0.05);
}

.choice-item.selected {
    border-color: #3b82f6;
    background: rgba(59, 130, 246, 0.1);
}

.choice-item.correct {
    border-color: #10b981;
    background: rgba(16, 185, 129, 0.1);
}

.choice-item.incorrect {
    border-color: #ef4444;
    background: rgba(239, 68, 68, 0.1);
}

.choice-content {
    display: flex;
    align-items: center;
    gap: 1rem;
    flex: 1;
}

.choice-letter {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.1);
    font-weight: 600;
    flex-shrink: 0;
}

.choice-text {
    flex: 1;
}

.choice-icon {
    font-size: 1.25rem;
    font-weight: bold;
}

.explanation-box {
    margin-top: 1.5rem;
    padding: 1.25rem;
    border-radius: 8px;
    border-left: 4px solid;
}

.explanation-box.correct {
    background: rgba(16, 185, 129, 0.1);
    border-color: #10b981;
    color: #10b981;
}

.explanation-box.incorrect {
    background: rgba(239, 68, 68, 0.1);
    border-color: #ef4444;
    color: #ef4444;
}

/* ======================
   MATH INPUT BLOCK
   ====================== */

.math-input-block {
    margin: 2rem 0;
    padding: 1.5rem;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 8px;
}

.math-input-container {
    margin: 1rem 0;
}

.mathquill-input {
    min-height: 50px;
    padding: 0.75rem;
    border: 2px solid #4b5563;
    border-radius: 6px;
    background: white;
    color: black;
    font-size: 18px;
    transition: border-color 0.2s;
}

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

.latex-input-wrapper {
    width: 100%;
}

.latex-textarea {
    width: 100%;
    padding: 0.75rem;
    border: 2px solid #4b5563;
    border-radius: 6px;
    background: rgba(255, 255, 255, 0.05);
    color: inherit;
    font-family: 'Courier New', monospace;
    font-size: 16px;
    resize: vertical;
    transition: border-color 0.2s;
}

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

.latex-preview {
    margin-top: 1rem;
    padding: 1rem;
    background: rgba(255, 255, 255, 0.02);
    border-radius: 6px;
    border: 1px solid #4b5563;
}

.keyboard-input {
    width: 100%;
    padding: 0.75rem 1rem;
    border: 2px solid #4b5563;
    border-radius: 6px;
    background: rgba(255, 255, 255, 0.05);
    color: inherit;
    font-size: 16px;
    transition: border-color 0.2s;
}

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

.units-display {
    font-size: 0.9rem;
    color: #9ca3af;
}

.feedback-box {
    margin-top: 1.5rem;
    padding: 1.25rem;
    border-radius: 8px;
    border-left: 4px solid;
}

.feedback-box.correct {
    background: rgba(16, 185, 129, 0.1);
    border-color: #10b981;
}

.feedback-box.incorrect {
    background: rgba(239, 68, 68, 0.1);
    border-color: #ef4444;
}

.math-display-inline {
    display: inline;
    font-family: 'Courier New', monospace;
    background: rgba(255, 255, 255, 0.1);
    padding: 0.2em 0.4em;
    border-radius: 3px;
}

/* ======================
   GRAPH TASK BLOCK
   ====================== */

.graph-task-block {
    margin: 2rem 0;
    padding: 1.5rem;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 8px;
}

.graph-container {
    margin: 1rem 0;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

.graph-canvas {
    background: white;
    border-radius: 8px;
}

/* ======================
   CODE BLOCKS
   ====================== */

.code-editor-block, .code-task-block {
    margin: 2rem 0;
}

.editor-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.75rem 1rem;
    background: #1f2937;
    border-radius: 8px 8px 0 0;
    border-bottom: 1px solid #374151;
}

.editor-container {
    border-radius: 0 0 8px 8px;
    overflow: hidden;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

.test-results {
    margin-top: 1.5rem;
}

.test-result {
    padding: 0.75rem 1rem;
    border-radius: 6px;
    border: 1px solid;
}

.test-result.pass {
    background: rgba(16, 185, 129, 0.1);
    border-color: #10b981;
}

.test-result.fail {
    background: rgba(239, 68, 68, 0.1);
    border-color: #ef4444;
}

/* ======================
   LAYOUT BLOCKS
   ====================== */

.stack-block {
    width: 100%;
}

.columns-block {
    width: 100%;
}

@media (max-width: 768px) {
    .columns-block {
        display: flex !important;
        flex-direction: column !important;
        gap: 1rem !important;
    }
}

.accordion-block {
    margin: 1.5rem 0;
}

.accordion-item {
    margin-bottom: 0.5rem;
}

.accordion-header {
    width: 100%;
    padding: 1rem 1.25rem;
    font-weight: 500;
    text-align: left;
    border: none;
    background: rgba(255, 255, 255, 0.05);
    color: inherit;
    cursor: pointer;
    transition: background-color 0.2s;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.accordion-header:hover {
    background: rgba(255, 255, 255, 0.08);
}

.accordion-content {
    padding: 1rem 1.25rem;
    line-height: 1.6;
    animation: slideDown 0.2s ease-out;
}

@keyframes slideDown {
    from {
        opacity: 0;
        max-height: 0;
    }
    to {
        opacity: 1;
        max-height: 500px;
    }
}

.tabs-block {
    margin: 1.5rem 0;
}

.tabs-header {
    display: flex;
    gap: 0.5rem;
    border-bottom: 2px solid #374151;
    margin-bottom: 1.5rem;
}

.tab-button {
    padding: 0.75rem 1.5rem;
    font-weight: 500;
    background: none;
    border: none;
    border-bottom: 2px solid transparent;
    cursor: pointer;
    transition: all 0.2s;
    margin-bottom: -2px;
}

.tab-button:hover {
    background: rgba(255, 255, 255, 0.05);
}

.tab-panel {
    animation: fadeIn 0.3s ease-in;
}

/* ======================
   BUTTONS
   ====================== */

.submit-btn {
    padding: 0.75rem 2rem;
    background: #3b82f6;
    color: white;
    border: none;
    border-radius: 6px;
    font-weight: 600;
    font-size: 1rem;
    cursor: pointer;
    transition: all 0.2s;
    box-shadow: 0 2px 4px rgba(59, 130, 246, 0.3);
}

.submit-btn:hover:not(:disabled) {
    background: #2563eb;
    transform: translateY(-1px);
    box-shadow: 0 4px 6px rgba(59, 130, 246, 0.4);
}

.submit-btn:disabled {
    background: #6b7280;
    cursor: not-allowed;
    opacity: 0.6;
}

/* ======================
   UNSUPPORTED BLOCK
   ====================== */

.unsupported-block {
    padding: 1.5rem;
    background: rgba(251, 191, 36, 0.1);
    border: 2px dashed #f59e0b;
    border-radius: 8px;
    margin: 1.5rem 0;
}

.unsupported-block p {
    margin: 0.5rem 0;
}

/* ======================
   RESPONSIVE DESIGN
   ====================== */

@media (max-width: 768px) {
    .lesson-heading.h1 {
        font-size: 2rem;
    }
    
    .lesson-heading.h2 {
        font-size: 1.75rem;
    }
    
    .lesson-heading.h3 {
        font-size: 1.5rem;
    }
    
    .multiple-choice-block,
    .math-input-block,
    .graph-task-block {
        padding: 1rem;
    }
    
    .choice-item {
        padding: 0.75rem 1rem;
    }
    
    .choice-letter {
        width: 28px;
        height: 28px;
        font-size: 0.9rem;
    }
}

/* ======================
   ACCESSIBILITY
   ====================== */

.choice-item:focus {
    outline: 2px solid #3b82f6;
    outline-offset: 2px;
}

.submit-btn:focus {
    outline: 2px solid #3b82f6;
    outline-offset: 2px;
}

.accordion-header:focus,
.tab-button:focus {
    outline: 2px solid #3b82f6;
    outline-offset: -2px;
}

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

/* ======================
   LOADING STATES
   ====================== */

.block-loading {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100px;
    color: #9ca3af;
}

.spinner {
    width: 40px;
    height: 40px;
    border: 3px solid rgba(255, 255, 255, 0.1);
    border-top-color: #3b82f6;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* ======================
   DARK MODE UTILITIES
   ====================== */

.dark .block-image,
.dark .graph-canvas {
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.3);
}

.dark .choice-item {
    border-color: #6b7280;
}

.dark .choice-item:hover {
    border-color: #9ca3af;
}

/* ======================
   PRINT STYLES
   ====================== */

@media print {
    .submit-btn {
        display: none;
    }
    
    .choice-item {
        page-break-inside: avoid;
    }
    
    .accordion-header {
        page-break-after: avoid;
    }
    
    .block-image,
    .graph-canvas {
        box-shadow: none;
        page-break-inside: avoid;
    }
}
