/* Base styles */
body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    line-height: 1.6;
    color: #333;
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
    background-color: #f9f9f9;
}

/* Chapter navigation */
.chapter-nav {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-bottom: 20px;
    padding: 10px;
    background-color: #f0f0f0;
    border-radius: 5px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.chapter-nav a {
    padding: 8px 15px;
    background-color: #4a6fa5;
    color: white;
    text-decoration: none;
    border-radius: 4px;
    transition: background-color 0.3s;
}

.chapter-nav a:hover {
    background-color: #3a5a80;
}

.chapter-nav a.active {
    background-color: #2c4361;
    font-weight: bold;
}

/* Controls */
.controls {
    display: flex;
    gap: 10px;
    margin-bottom: 20px;
}

.controls button {
    padding: 8px 15px;
    background-color: #5a8f5a;
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    transition: background-color 0.3s;
}

.controls button:hover {
    background-color: #457345;
}

.status-message {
    margin-top: 10px;
    padding: 8px;
    border-radius: 4px;
    display: none;
}

.status-message.success {
    display: block;
    background-color: #d4edda;
    color: #155724;
    border: 1px solid #c3e6cb;
}

.status-message.error {
    display: block;
    background-color: #f8d7da;
    color: #721c24;
    border: 1px solid #f5c6cb;
}

/* Chapter content */
.chapter-title {
    text-align: center;
    margin-bottom: 30px;
}

.chapter-title h1 {
    font-size: 2.5em;
    margin-bottom: 5px;
    color: #2c4361;
}

.chapter-title h2 {
    font-size: 1.8em;
    margin-top: 0;
    color: #4a6fa5;
}

.chapter-title h3 {
    font-style: italic;
    font-weight: normal;
    color: #666;
}

section {
    margin-bottom: 40px;
}

h2 {
    color: #2c4361;
    border-bottom: 2px solid #4a6fa5;
    padding-bottom: 5px;
}

h3 {
    color: #4a6fa5;
    margin-top: 25px;
}

h4 {
    color: #5a8f5a;
    margin-top: 20px;
}

/* Form elements */
textarea {
    width: 100%;
    min-height: 100px;
    padding: 10px;
    border: 1px solid #ddd;
    border-radius: 4px;
    margin-bottom: 15px;
    resize: vertical;
    font-family: inherit;
    line-height: 1.5;
}

textarea:focus {
    border-color: #4a6fa5;
    outline: none;
    box-shadow: 0 0 5px rgba(74, 111, 165, 0.5);
}

input[type="text"] {
    padding: 8px;
    border: 1px solid #ddd;
    border-radius: 4px;
    margin-bottom: 10px;
    font-family: inherit;
}

input[type="text"]:focus {
    border-color: #4a6fa5;
    outline: none;
    box-shadow: 0 0 5px rgba(74, 111, 165, 0.5);
}

/* Tables */
table {
    width: 100%;
    border-collapse: collapse;
    margin-bottom: 20px;
}

th, td {
    border: 1px solid #ddd;
    padding: 10px;
    text-align: left;
}

th {
    background-color: #f2f2f2;
    font-weight: bold;
}

.expandable-table td textarea {
    min-height: 60px;
    width: 100%;
    box-sizing: border-box;
    margin-bottom: 0;
}

.add-row, .remove-row {
    padding: 5px 10px;
    margin-right: 10px;
    margin-bottom: 20px;
    background-color: #4a6fa5;
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
}

.remove-row {
    background-color: #d9534f;
}

.add-row:hover {
    background-color: #3a5a80;
}

.remove-row:hover {
    background-color: #c9302c;
}

/* Checkboxes */
.checkbox-item {
    margin-bottom: 10px;
    display: flex;
    align-items: center;
}

.checkbox-item input[type="checkbox"] {
    margin-right: 10px;
    transform: scale(1.2);
}

/* Special elements */
.text-center {
    text-align: center;
}

hr {
    border: 0;
    height: 1px;
    background-color: #ddd;
    margin: 30px 0;
}

.meditation-script {
    background-color: #f5f5f5;
    padding: 20px;
    border-left: 4px solid #4a6fa5;
    margin-bottom: 20px;
    font-style: italic;
}

/* Integration Matrix */
.integration-matrix-container {
    margin-bottom: 30px;
    overflow-x: auto;
}

.integration-matrix {
    min-width: 800px;
}

.integration-matrix th {
    background-color: #4a6fa5;
    color: white;
    padding: 10px;
    text-align: center;
}

.integration-matrix th:first-child {
    background-color: #f2f2f2;
    color: #333;
}

.integration-matrix td {
    padding: 5px;
    vertical-align: top;
}

.integration-matrix textarea {
    min-height: 80px;
    font-size: 0.9em;
}

/* Causal map placeholder */
.causal-map-container {
    margin: 20px 0;
    padding: 15px;
    border: 1px dashed #aaa;
    background-color: #f9f9f9;
}

.causal-map-placeholder {
    height: 300px;
    border: 1px solid #ddd;
    display: flex;
    justify-content: center;
    align-items: center;
    background-color: white;
    color: #777;
    font-style: italic;
}

/* Print styles */
@media print {
    body {
        font-size: 12pt;
        background: white;
        color: black;
    }
    
    .chapter-nav, .controls, .add-row, .remove-row {
        display: none;
    }
    
    textarea, input[type="text"] {
        border: 1px solid #999;
        background: white;
        min-height: auto;
    }
    
    textarea {
        height: auto;
        min-height: 100px;
        overflow: visible;
        page-break-inside: avoid;
    }
    
    h1, h2, h3, h4 {
        page-break-after: avoid;
    }
    
    table, figure {
        page-break-inside: avoid;
    }
    
    .chapter-title {
        page-break-after: avoid;
    }
    
    section {
        page-break-before: always;
    }
    
    section:first-of-type {
        page-break-before: auto;
    }
    
    .integration-matrix {
        font-size: 10pt;
    }
    
    .integration-matrix textarea {
        min-height: 60px;
    }
}

/* Responsive styles */
@media (max-width: 768px) {
    body {
        padding: 10px;
    }
    
    .chapter-nav {
        flex-direction: column;
    }
    
    .integration-matrix-container {
        overflow-x: scroll;
    }
}
