/* Print-specific styles */
@media print {
    @page {
        size: A4;
        margin: 2cm;
    }
    
    .print-hide,
    .buttons,
    .settings,
    .back-button,
    .header {
        display: none !important;
    }
    
    body {
        font-size: 12pt;
    }

    .lesson-section {
        break-inside: avoid;
        page-break-inside: avoid;
        margin-bottom: 1cm;
    }

    .print-friendly {
        page-break-before: always;
        margin-top: 0;
    }

    .practice-section {
        display: none !important;
    }

    /* Ensure good contrast for printing */
    .expression, .example, .term {
        border: 1px solid #000;
    }

    /* Remove backgrounds to save ink */
    .visual-breakdown,
    .component-item,
    .operation-box,
    .step-example,
    .check-question {
        background: none !important;
        border: 1px solid #000;
    }

    /* Ensure text is black for better printing */
    h1, h2, h3, .label, .value {
        color: #000 !important;
    }
}

/* General styles */
body {
    font-family: Arial, sans-serif;
    max-width: 210mm;
    margin: 0 auto;
    padding: 20px;
    background: white;
    line-height: 1.6;
}

.main-content {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* Header styles */
.header {
    text-align: center;
    margin-bottom: 30px;
    position: relative;
}

.back-button {
    position: absolute;
    left: 0;
    top: 50%;
    transform: translateY(-50%);
}

.back-link {
    color: #4a90e2;
    text-decoration: none;
    font-size: 16px;
    display: flex;
    align-items: center;
    padding: 8px 12px;
    border-radius: 5px;
    transition: background-color 0.2s;
}

.back-link:hover {
    background-color: #f0f7ff;
}

h1 {
    color: #4a90e2;
    font-size: 2.5em;
    margin: 0;
}

/* Lesson sections */
.lesson-section {
    margin-bottom: 40px;
    background: #fff;
    border-radius: 8px;
    padding: 30px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

h2 {
    color: #4a90e2;
    font-size: 1.8em;
    margin: 0 0 20px 0;
}

.definition {
    font-size: 1.2em;
    color: #333;
    margin-bottom: 20px;
}

/* Visual breakdown styles */
.visual-breakdown {
    margin: 30px 0;
    padding: 20px;
    background: #f8f9fa;
    border-radius: 8px;
    text-align: center;
}

.visual-breakdown .term {
    font-size: 2.5em;
    font-weight: bold;
    color: #4a90e2;
    margin-bottom: 20px;
    padding: 10px;
    background: white;
    border-radius: 4px;
    display: inline-block;
}

.breakdown {
    display: flex;
    justify-content: space-around;
    gap: 40px;
    flex-wrap: wrap;
}

.arrow-left, .arrow-right {
    display: flex;
    flex-direction: column;
    align-items: center;
    flex: 1;
    min-width: 200px;
}

.arrow {
    font-size: 2em;
    color: #4a90e2;
    margin-bottom: 10px;
}

.label {
    font-weight: bold;
    color: #333;
    margin-bottom: 5px;
}

.explanation {
    color: #666;
    font-size: 0.9em;
    margin-bottom: 10px;
}

.value {
    background: #e8f4ff;
    padding: 8px 16px;
    border-radius: 4px;
    font-weight: bold;
    color: #4a90e2;
}

/* Component grid */
.component-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 20px;
    margin-top: 20px;
}

.component-item {
    background: #f0f7ff;
    border-radius: 8px;
    padding: 20px;
    text-align: center;
    transition: transform 0.2s;
}

.component-item:hover {
    transform: scale(1.02);
}

/* Operation boxes */
.operation-box {
    background: #f8f9fa;
    border-radius: 8px;
    padding: 20px;
    margin-bottom: 30px;
}

.operation-box h3 {
    color: #4a90e2;
    margin: 0 0 15px 0;
    font-size: 1.4em;
}

.rule {
    background: #fff3cd;
    padding: 15px;
    border-radius: 6px;
    margin-bottom: 20px;
}

.examples ul {
    list-style: none;
    padding: 0;
    margin: 0;
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 10px;
}

.examples li {
    background: white;
    padding: 10px;
    border-radius: 4px;
    text-align: center;
    font-family: monospace;
    font-size: 1.1em;
}

/* Step by step examples */
.step-example {
    background: #f8f9fa;
    padding: 20px;
    border-radius: 8px;
    margin-bottom: 30px;
}

.expression {
    font-size: 1.3em;
    font-weight: bold;
    margin-bottom: 15px;
    padding: 10px;
    background: white;
    border-radius: 4px;
    text-align: center;
}

.step-list {
    margin: 0;
    padding-left: 20px;
    color: #666;
}

.step-list li {
    margin-bottom: 8px;
}

/* Self check styles */
.self-check {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 20px;
}

.check-question {
    background: #f8f9fa;
    padding: 20px;
    border-radius: 8px;
}

.check-question p {
    font-weight: bold;
    margin: 0 0 15px 0;
}

.check-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

.check-list li {
    margin-bottom: 10px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: white;
    padding: 10px;
    border-radius: 4px;
}

.answer {
    color: #4a90e2;
    font-weight: bold;
}

/* Summary styles */
.summary-content {
    background: white;
    padding: 20px;
    border: 1px solid #ddd;
    border-radius: 8px;
}

.summary-section {
    margin-bottom: 25px;
}

.summary-section h3 {
    color: #4a90e2;
    border-bottom: 2px solid #4a90e2;
    padding-bottom: 5px;
    margin-bottom: 15px;
}

.summary-section ul {
    padding-left: 20px;
}

.summary-section li {
    margin-bottom: 8px;
}

/* Practice section */
.practice-section {
    text-align: center;
    margin-top: 40px;
    padding: 30px;
    background: #f0f7ff;
    border-radius: 8px;
}

.practice-links {
    display: flex;
    justify-content: center;
    gap: 20px;
    margin-top: 20px;
}

.practice-link {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    padding: 15px 25px;
    background: #4a90e2;
    color: white;
    text-decoration: none;
    border-radius: 8px;
    transition: background-color 0.2s;
    font-size: 1.1em;
}

.practice-link:hover {
    background: #357abd;
}

/* Responsive styles */
@media (max-width: 768px) {
    .header {
        padding-top: 40px;
    }
    
    .back-button {
        top: 0;
        left: 50%;
        transform: translateX(-50%);
    }
    
    h1 {
        font-size: 2em;
    }

    .lesson-section {
        padding: 20px;
    }

    .breakdown {
        flex-direction: column;
    }

    .arrow-left, .arrow-right {
        min-width: auto;
    }

    .component-grid,
    .self-check {
        grid-template-columns: 1fr;
    }

    .practice-links {
        flex-direction: column;
    }

    .practice-link {
        width: 100%;
    }
}

/* High contrast mode */
@media (prefers-contrast: high) {
    .back-link,
    h1, h2, h3,
    .label,
    .answer {
        color: #000;
    }

    .operation-box,
    .step-example,
    .check-question {
        border: 1px solid #000;
    }
}