/* --- TEF Canada Grammar Learning Styles --- */

.grammar-page {
    max-width: 1140px;
    margin: 2rem auto;
    padding: 0 1rem;
}

/* --- Teaching Message / Disclaimer Banner --- */
.grammar-teaching-card {
    background: #ffffff;
    border-radius: 12px;
    padding: 1.75rem 2rem;
    margin-bottom: 2rem;
    box-shadow: 0 4px 14px rgba(0,0,0,0.06);
    border-left: 5px solid #004d99;
}

.grammar-teaching-card h2 {
    color: #004d99;
    margin-top: 0;
    font-size: 1.75rem;
    display: flex;
    align-items: center;
    gap: 0.6rem;
}

.grammar-teaching-card p {
    color: #334155;
    line-height: 1.6;
    margin-bottom: 0.85rem;
    font-size: 0.98rem;
}

.grammar-teaching-quote {
    background: #e7f1ff;
    border-left: 4px solid #004d99;
    padding: 0.85rem 1.25rem;
    border-radius: 0 8px 8px 0;
    font-style: italic;
    color: #003366;
    font-weight: 600;
    margin-top: 1rem;
}

/* --- Dashboard Overview Stats --- */
.grammar-dashboard-summary {
    background: #ffffff;
    border-radius: 12px;
    padding: 1.5rem 2rem;
    margin-bottom: 2rem;
    box-shadow: 0 4px 14px rgba(0,0,0,0.05);
}

.grammar-stat-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: 1rem;
    margin-bottom: 1.25rem;
}

.grammar-stat-card {
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    padding: 1rem;
    text-align: center;
}

.grammar-stat-value {
    font-size: 1.8rem;
    font-weight: 800;
    color: #004d99;
}

.grammar-stat-label {
    font-size: 0.8rem;
    color: #64748b;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-top: 0.2rem;
}

/* --- Action Controls & Search Bar --- */
.grammar-controls-bar {
    background: #ffffff;
    border-radius: 12px;
    padding: 1.25rem 1.5rem;
    margin-bottom: 1.75rem;
    box-shadow: 0 4px 12px rgba(0,0,0,0.04);
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
}

.grammar-level-filters {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.grammar-filter-btn {
    padding: 0.5rem 1rem;
    border: 1px solid #cbd5e1;
    border-radius: 20px;
    background: #f8fafc;
    color: #475569;
    font-weight: 600;
    font-size: 0.9rem;
    cursor: pointer;
    transition: all 0.2s ease;
}

.grammar-filter-btn:hover, .grammar-filter-btn.active {
    background: #004d99;
    color: #ffffff;
    border-color: #004d99;
}

.grammar-search-input {
    min-width: 240px;
    padding: 0.5rem 1rem;
    border: 1px solid #cbd5e1;
    border-radius: 20px;
    font-size: 0.9rem;
}

.grammar-quick-actions {
    display: flex;
    gap: 0.75rem;
    flex-wrap: wrap;
}

/* --- Level Grid & Cards --- */
.grammar-level-section {
    margin-bottom: 2.5rem;
}

.grammar-level-header {
    background: #f1f5f9;
    border-left: 5px solid #004d99;
    padding: 1rem 1.25rem;
    border-radius: 0 8px 8px 0;
    margin-bottom: 1.25rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.grammar-level-header h3 {
    margin: 0;
    color: #0f172a;
    font-size: 1.35rem;
}

.grammar-level-desc {
    color: #64748b;
    font-size: 0.9rem;
    margin-top: 0.25rem;
}

.grammar-topic-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 1.25rem;
}

.grammar-topic-card {
    background: #ffffff;
    border: 1px solid #e2e8f0;
    border-radius: 10px;
    padding: 1.25rem 1.5rem;
    box-shadow: 0 2px 8px rgba(0,0,0,0.04);
    transition: all 0.2s ease;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
}

.grammar-topic-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 18px rgba(0,0,0,0.08);
    border-color: #004d99;
}

.grammar-topic-card-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 0.5rem;
    margin-bottom: 0.5rem;
}

.grammar-topic-title {
    font-size: 1.15rem;
    font-weight: 700;
    color: #0f172a;
    margin: 0;
}

.grammar-topic-purpose {
    color: #475569;
    font-size: 0.88rem;
    line-height: 1.4;
    margin-bottom: 0.85rem;
}

.grammar-topic-example {
    background: #f8fafc;
    border-left: 3px solid #cbd5e1;
    padding: 0.5rem 0.75rem;
    border-radius: 0 6px 6px 0;
    font-size: 0.85rem;
    color: #334155;
    font-style: italic;
    margin-bottom: 1rem;
}

.grammar-status-badge {
    padding: 0.25rem 0.6rem;
    border-radius: 12px;
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.3px;
    white-space: nowrap;
}

.status-not_started { background: #f1f5f9; color: #64748b; }
.status-learning { background: #e0f2fe; color: #0369a1; }
.status-review_due { background: #fef3c7; color: #b45309; }
.status-completed { background: #dcfce7; color: #15803d; }
.status-mastered { background: #dbeafe; color: #1d4ed8; }

.grammar-topic-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-top: 1px solid #f1f5f9;
    padding-top: 0.85rem;
    margin-top: auto;
}

/* --- Lesson View Layout --- */
.grammar-lesson-header {
    background: #ffffff;
    border-radius: 12px;
    padding: 1.5rem 2rem;
    margin-bottom: 1.5rem;
    box-shadow: 0 4px 14px rgba(0,0,0,0.05);
}

.grammar-lesson-nav {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
}

.grammar-quick-ref-card {
    background: #eff6ff;
    border: 1px solid #bfdbfe;
    border-radius: 10px;
    padding: 1.25rem 1.5rem;
    margin-bottom: 1.75rem;
}

.grammar-quick-ref-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 1rem;
    margin-top: 0.75rem;
}

.grammar-quick-ref-item {
    background: #ffffff;
    padding: 0.85rem 1rem;
    border-radius: 8px;
    border: 1px solid #dbeafe;
}

.grammar-quick-ref-label {
    font-size: 0.75rem;
    font-weight: 800;
    text-transform: uppercase;
    color: #1d4ed8;
    margin-bottom: 0.25rem;
}

/* --- Expandable Rule Accordion Sections --- */
.grammar-rules-container {
    background: #ffffff;
    border-radius: 12px;
    padding: 1.75rem 2rem;
    margin-bottom: 2rem;
    box-shadow: 0 4px 15px rgba(0,0,0,0.06);
}

.grammar-rules-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.75rem;
    margin-bottom: 1.25rem;
}

.grammar-rule-panel {
    border: 1px solid #cbd5e1;
    border-radius: 8px;
    margin-bottom: 1rem;
    overflow: hidden;
    transition: border-color 0.2s;
}

.grammar-rule-panel[open], .grammar-rule-panel.expanded {
    border-color: #004d99;
}

.grammar-rule-summary {
    background: #f8fafc;
    padding: 1rem 1.25rem;
    font-weight: 700;
    font-size: 1.05rem;
    color: #0f172a;
    cursor: pointer;
    list-style: none;
    display: flex;
    justify-content: space-between;
    align-items: center;
    user-select: none;
}

.grammar-rule-summary::-webkit-details-marker {
    display: none;
}

.grammar-rule-summary:hover {
    background: #f1f5f9;
}

.grammar-rule-summary::after {
    content: "▼";
    font-size: 0.8rem;
    color: #64748b;
    transition: transform 0.2s ease;
}

.grammar-rule-panel[open] .grammar-rule-summary::after,
.grammar-rule-panel.expanded .grammar-rule-summary::after {
    transform: rotate(180deg);
}

.grammar-rule-content {
    padding: 1.25rem 1.5rem;
    background: #ffffff;
    border-top: 1px solid #e2e8f0;
}

.grammar-formula-box {
    background: #f0fdf4;
    border: 1px solid #bbf7d0;
    border-radius: 6px;
    padding: 0.75rem 1rem;
    font-family: monospace;
    font-size: 0.95rem;
    color: #166534;
    font-weight: 600;
    margin: 0.75rem 0;
}

.grammar-mistake-box {
    background: #fef2f2;
    border: 1px solid #fecaca;
    border-radius: 8px;
    padding: 0.85rem 1.15rem;
    margin-top: 0.85rem;
}

.bad-example {
    color: #dc2626;
    font-weight: 700;
}

.good-example {
    color: #166534;
    font-weight: 700;
}

/* --- Section Exercises & Interactive Engines --- */
.grammar-section-card {
    background: #ffffff;
    border-radius: 12px;
    padding: 1.75rem 2rem;
    margin-bottom: 2rem;
    box-shadow: 0 4px 15px rgba(0,0,0,0.06);
}

.grammar-exercise-item {
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    padding: 1.25rem;
    margin-bottom: 1.25rem;
}

.grammar-exercise-question {
    font-weight: 700;
    font-size: 1.05rem;
    color: #1e293b;
    margin-bottom: 0.85rem;
}

.grammar-option-btn {
    width: 100%;
    text-align: left;
    padding: 0.75rem 1rem;
    border: 1px solid #cbd5e1;
    border-radius: 6px;
    background: #ffffff;
    margin-bottom: 0.5rem;
    font-size: 0.95rem;
    cursor: pointer;
    transition: all 0.15s ease;
}

.grammar-option-btn:hover {
    border-color: #004d99;
    background: #f0f7ff;
}

.grammar-option-btn.selected-correct {
    background: #dcfce7;
    border-color: #166534;
    color: #166534;
    font-weight: 700;
}

.grammar-option-btn.selected-incorrect {
    background: #fee2e2;
    border-color: #dc2626;
    color: #991b1b;
}

.grammar-feedback-box {
    margin-top: 0.85rem;
    padding: 0.85rem 1rem;
    border-radius: 6px;
    font-size: 0.9rem;
}

.grammar-feedback-box.correct {
    background: #dcfce7;
    color: #14532d;
    border: 1px solid #86efac;
}

.grammar-feedback-box.incorrect {
    background: #fee2e2;
    color: #7f1d1d;
    border: 1px solid #fca5a5;
}

.grammar-rule-link-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    color: #004d99;
    font-weight: 700;
    font-size: 0.85rem;
    text-decoration: underline;
    cursor: pointer;
    background: none;
    border: none;
    padding: 0;
    margin-top: 0.4rem;
}

/* --- Print Expansion Support --- */
@media print {
    .grammar-rule-panel details, .grammar-rule-panel {
        display: block !important;
    }
    .grammar-rule-content {
        display: block !important;
    }
    .grammar-controls-bar, .grammar-quick-actions, .btn {
        display: none !important;
    }
}

/* --- Responsive Adjustments --- */
@media (max-width: 768px) {
    .grammar-page {
        padding: 0 0.5rem;
    }
    .grammar-teaching-card, .grammar-dashboard-summary, .grammar-rules-container, .grammar-section-card {
        padding: 1.25rem;
    }
    .grammar-topic-grid {
        grid-template-columns: 1fr;
    }
}
