/* General styles */
body {
    font-family: 'Arial', sans-serif;
    line-height: 1.6;
    margin: 0;
    padding: 0;
    background: #f5f5f5;
    color: #333;
    transition: background 0.3s ease, color 0.3s ease;
}

body.dark-mode {
    background: #1a1a1a;
    color: #d9d9d9;
}

main {
    max-width: 1000px;
    margin: 2rem auto;
    padding: 1.5rem;
    background: #fff;
    border-radius: 8px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.05);
    position: relative;
}

body.dark-mode main {
    background: #2d2d2d;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.3);
}

/* Top Bar (Nav and Mode Toggle) */
.top-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 0;
    margin-bottom: 1.5rem;
}

.nav-buttons {
    display: flex;
    gap: 1rem;
}

.nav-btn {
    background: #e0e0e0;
    color: #333;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    text-decoration: none;
    transition: background 0.3s ease, transform 0.2s ease;
}

body.dark-mode .nav-btn {
    background: #4a4a4a;
    color: #d9d9d9;
}

.nav-btn:hover {
    background: #2e7d32;
    color: #fff;
    transform: scale(1.05);
}

.nav-btn svg {
    width: 20px;
    height: 20px;
}

.mode-toggle {
    background: #e0e0e0;
    color: #333;
    width: 40px;
    height: 40px;
    border: none;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background 0.3s ease, transform 0.2s ease;
}

body.dark-mode .mode-toggle {
    background: #4a4a4a;
    color: #d9d9d9;
}

.mode-toggle:hover {
    background: #2e7d32;
    color: #fff;
    transform: scale(1.05);
}

.mode-toggle svg {
    width: 20px;
    height: 20px;
}

/* Section styles */
section {
    padding: 1.5rem 0;
}

h1 {
    font-size: 2.2rem;
    color: #333;
    margin-bottom: 1rem;
    text-align: center;
    font-weight: 600;
}

body.dark-mode h1 {
    color: #d9d9d9;
}

h2 {
    font-size: 1.8rem;
    color: #333;
    margin-bottom: 1.2rem;
    border-bottom: 2px solid #e0e0e0;
    padding-bottom: 0.5rem;
}

body.dark-mode h2 {
    color: #d9d9d9;
    border-bottom-color: #4a4a4a;
}

h3 {
    font-size: 1.5rem;
    color: #2e7d32;
    margin: 1rem 0 0.8rem;
    font-weight: 600;
}

body.dark-mode h3 {
    color: #4caf50;
}

h4 {
    font-size: 1.3rem;
    color: #555;
    margin: 0.8rem 0 0.5rem;
    font-weight: 500;
}

body.dark-mode h4 {
    color: #b0b0b0;
}

p {
    font-size: 1.1rem;
    margin-bottom: 1rem;
}

.subsection {
    margin-bottom: 1.5rem;
}

/* Example styles */
.examples {
    background: #f9f9f9;
    padding: 1rem;
    border-radius: 6px;
    border-left: 4px solid #2e7d32;
    margin-bottom: 1rem;
}

body.dark-mode .examples {
    background: #3a3a3a;
    border-left-color: #4caf50;
}

.example-list {
    list-style: none;
    padding: 0;
}

.example-list li {
    margin-bottom: 0.75rem;
    font-size: 1rem;
    display: block;
    padding: 0.25rem 0;
}

.example-list li em {
    font-style: italic;
    color: #2e7d32;
}

body.dark-mode .example-list li em {
    color: #4caf50;
}

/* Table Styling */
.table-container {
    overflow-x: auto;
    margin: 1rem 0;
}

table {
    width: 100%;
    border-collapse: collapse;
    background: #f9f9f9;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    border-radius: 8px;
    overflow: hidden;
}

body.dark-mode table {
    background: #3a3a3a;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
}

table th,
table td {
    padding: 0.75rem 1rem;
    text-align: left;
    font-size: 0.95rem;
    border-bottom: 1px solid #ddd;
}

body.dark-mode table th,
body.dark-mode table td {
    border-bottom: 1px solid #555;
}

table th {
    background: #2e7d32;
    color: #fff;
    font-weight: 600;
}

body.dark-mode table th {
    background: #4caf50;
}

table td {
    color: #333;
}

body.dark-mode table td {
    color: #e0e0e0;
}

table tr:last-child td {
    border-bottom: none;
}

table tr:nth-child(even) {
    background: #f0f0f0;
}

body.dark-mode table tr:nth-child(even) {
    background: #424242;
}

/* Select styles for exercises */
.answer-select {
    padding: 0.3rem;
    font-size: 1rem;
    border: 1px solid #ccc;
    border-radius: 4px;
    margin-left: 0.5rem;
    background: #fff;
    color: #333;
    transition: border 0.3s ease;
}

body.dark-mode .answer-select {
    background: #3a3a3a;
    color: #d9d9d9;
    border-color: #555;
}

/* Toggle button styles */
.toggle-btn {
    background: #2e7d32;
    color: #fff;
    border: none;
    padding: 0.5rem 1rem;
    border-radius: 6px;
    cursor: pointer;
    font-weight: 600;
    transition: background 0.3s ease;
    margin-top: 0.5rem;
    margin-right: 1rem;
    display: inline-block;
}

body.dark-mode .toggle-btn {
    background: #4caf50;
}

.toggle-btn:hover {
    background: #1b5e20;
}

body.dark-mode .toggle-btn:hover {
    background: #388e3c;
}

.hidden {
    display: none;
    margin-top: 1rem;
    padding: 1rem;
    background: #f0f0f0;
    border-radius: 6px;
}

body.dark-mode .hidden {
    background: #424242;
}

/* See Also Section */
#see-also {
    padding: 1.5rem 0;
}

.see-also-links {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 0.75rem;
    justify-items: center;
}

.see-also-rect {
    display: inline-block;
    padding: 0.6rem 1.2rem;
    color: #333;
    text-decoration: none;
    border-radius: 4px;
    font-size: 0.9rem;
    font-weight: 500;
    background: #f0f0f0;
    border: 1px solid #d1d1d1;
    text-align: center;
    transition: background 0.3s ease, border-color 0.3s ease, transform 0.2s ease;
    width: 100%;
    box-sizing: border-box;
}

body.dark-mode .see-also-rect {
    color: #e0e0e0;
    background: #424242;
    border-color: #616161;
}

.see-also-rect:hover {
    background: #e0e0e0;
    border-color: #2e7d32;
    transform: translateY(-2px);
}

body.dark-mode .see-also-rect:hover {
    background: #616161;
    border-color: #4caf50;
}

/* Next Page Button */
.next-page {
    text-align: right;
    padding: 1.5rem 0;
}

.next-btn {
    background: #2e7d32;
    color: #fff;
    padding: 0.6rem 1.2rem;
    border-radius: 6px;
    text-decoration: none;
    font-weight: 600;
    transition: background 0.3s ease;
    display: inline-block;
}

body.dark-mode .next-btn {
    background: #4caf50;
}

.next-btn:hover {
    background: #1b5e20;
}

body.dark-mode .next-btn:hover {
    background: #388e3c;
}

/* Responsive Design */
@media (max-width: 1024px) {
    main {
        max-width: 90%;
        margin: 1.5rem auto;
        padding: 1.25rem;
    }

    h1 {
        font-size: 2rem;
    }

    h2 {
        font-size: 1.6rem;
    }

    h3 {
        font-size: 1.4rem;
    }

    h4 {
        font-size: 1.2rem;
    }

    p, .example-list li {
        font-size: 1rem;
    }

    .top-bar {
        padding: 0.75rem 0;
    }

    .nav-btn, .mode-toggle {
        width: 38px;
        height: 38px;
    }

    .nav-btn svg, .mode-toggle svg {
        width: 18px;
        height: 18px;
    }

    .table-container {
        font-size: 0.9rem;
    }

    table th, table td {
        padding: 0.6rem 0.8rem;
    }

    .see-also-links {
        grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
        gap: 0.6rem;
    }

    .see-also-rect {
        padding: 0.5rem 1rem;
        font-size: 0.85rem;
    }
}

@media (max-width: 768px) {
    main {
        max-width: 95%;
        padding: 1rem;
        margin: 1rem auto;
    }

    h1 {
        font-size: 1.8rem;
    }

    h2 {
        font-size: 1.5rem;
    }

    h3 {
        font-size: 1.3rem;
    }

    h4 {
        font-size: 1.1rem;
    }

    p, .example-list li {
        font-size: 0.95rem;
    }

    .top-bar {
        flex-direction: column;
        gap: 0.5rem;
    }

    .nav-buttons {
        justify-content: center;
    }

    .nav-btn, .mode-toggle {
        width: 36px;
        height: 36px;
    }

    .nav-btn svg, .mode-toggle svg {
        width: 16px;
        height: 16px;
    }

    .examples {
        padding: 0.8rem;
    }

    .table-container {
        font-size: 0.85rem;
    }

    table th, table td {
        padding: 0.5rem 0.6rem;
    }

    .answer-select {
        font-size: 0.9rem;
        padding: 0.25rem;
        margin-left: 0.3rem;
    }

    .toggle-btn {
        padding: 0.4rem 0.8rem;
        font-size: 0.9rem;
    }

    .see-also-links {
        grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
        gap: 0.5rem;
    }

    .see-also-rect {
        padding: 0.4rem 0.8rem;
        font-size: 0.8rem;
    }

    .next-btn {
        padding: 0.5rem 1rem;
        font-size: 0.9rem;
    }
}

@media (max-width: 480px) {
    main {
        max-width: 100%;
        padding: 0.75rem;
        margin: 0.5rem auto;
        border-radius: 0;
    }

    h1 {
        font-size: 1.6rem;
    }

    h2 {
        font-size: 1.3rem;
    }

    h3 {
        font-size: 1.2rem;
    }

    h4 {
        font-size: 1rem;
    }

    p, .example-list li {
        font-size: 0.9rem;
    }

    .top-bar {
        padding: 0.5rem 0;
    }

    .nav-btn, .mode-toggle {
        width: 32px;
        height: 32px;
    }

    .nav-btn svg, .mode-toggle svg {
        width: 14px;
        height: 14px;
    }

    .examples {
        padding: 0.6rem;
    }

    .table-container {
        font-size: 0.8rem;
    }

    table th, table td {
        padding: 0.4rem 0.5rem;
    }

    .answer-select {
        font-size: 0.85rem;
        padding: 0.2rem;
        width: 100%;
        margin: 0.2rem 0;
    }

    .toggle-btn {
        padding: 0.3rem 0.6rem;
        font-size: 0.85rem;
        width: 100%;
        margin: 0.3rem 0;
    }

    .hidden {
        padding: 0.75rem;
    }

    .see-also-links {
        grid-template-columns: 1fr;
        gap: 0.4rem;
    }

    .see-also-rect {
        padding: 0.3rem 0.6rem;
        font-size: 0.75rem;
    }

    .next-btn {
        padding: 0.4rem 0.8rem;
        font-size: 0.85rem;
        width: 100%;
        text-align: center;
    }
}