/* CYOA Base Styles - Shared layout and structural CSS */
/* Theme-specific colors, fonts, and effects should be defined in project cyoa-styles.css */

/* Container */
.container { max-width: 1200px; margin: 0 auto; padding: 20px; padding-bottom: 350px; }

/* Back to Index Link */
.back-link {
    display: inline-block; padding: 8px 12px; margin-bottom: 15px;
    text-decoration: none; font-size: 0.95em; opacity: 0.8;
    transition: opacity 0.2s;
}
.back-link:hover { opacity: 1; text-decoration: underline; }

/* Button Base */
.btn {
    padding: 8px 15px; cursor: pointer; font-weight: 500;
    transition: background-color 0.1s, transform 0.1s;
    margin-right: 5px; display: inline-flex; align-items: center;
    justify-content: center; height: 32px; min-width: 64px;
}

.button-group { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-left: auto; }

/* Section Base */
.section { margin-bottom: 30px; padding: 20px; }
.section-title, .stat-title { padding-bottom: 5px; }
.section-title { margin-bottom: 15px; }
.info-box { padding: 15px; margin-bottom: 15px; }
.element-group h3 { margin-bottom: 10px; }
.group-description, .entity-description, .entry-description { font-style: italic; }
.group-description { margin-bottom: 15px; }

/* Choices Container */
.choices-container { display: flex; flex-wrap: wrap; gap: 15px; margin-bottom: 20px; justify-content: center; }

/* Choice/Option/Roll Items Base */
.choice-item, .option-item, .roll-item {
    padding: 15px; padding-top: 7px; flex: 0 0 calc(22% - 15px);
    min-width: 200px; max-width: calc(22% - 15px);
    cursor: pointer; transition: all 0.05s ease; position: relative;
}
.choice-item.has-preview, .option-item.has-preview, .roll-item.has-preview { flex: 1 1 45%; max-width: 45%; }
.choice-item.max-width, .option-item.max-width, .roll-item.max-width { flex: 1 1 100% !important; max-width: 100% !important; }
.choice-item:has(.preview-container), .option-item:has(.preview-container), .roll-item:has(.preview-container) { padding-bottom: 5px; }
.choice-item h3, .option-item h3 { margin-top: 10px; margin-bottom: 10px; }

/* Entry Metadata */
.entry-metadata { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 8px; }
.destiny-indicator, .requirements-indicator { display: inline-block; padding: 3px 8px; font-size: 0.8em; font-weight: bold; }

/* Effects List */
.effects-list { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; list-style-type: none; padding-left: 0; }
.effect-item { display: inline-block; padding: 2px 6px; margin: 1px 0; line-height: 1.0; font-size: 0.95em; }
.effects-list li { padding: 8px 0; }

/* Repeatable Entry Controls */
.repeatable-item { cursor: default; }
.repeatable-controls {
    display: flex; align-items: center; justify-content: center; gap: 12px;
    margin-top: 12px; padding: 8px; border-radius: 6px;
    background: rgba(128, 128, 128, 0.1);
}
.repeatable-btn {
    width: 36px; height: 36px; font-size: 1.4em; font-weight: bold;
    border: none; border-radius: 6px; cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    transition: all 0.15s ease;
}
.repeatable-btn:disabled { opacity: 0.4; cursor: not-allowed; }
.repeatable-btn:not(:disabled):hover { transform: scale(1.1); }
.repeatable-count {
    font-size: 1.3em; font-weight: bold; min-width: 40px; text-align: center;
}

/* Character Sheet */
.character-sheet {
    position: fixed; bottom: 0; left: 0; right: 0; z-index: 100;
    padding: 0 15px 15px; display: flex; flex-direction: column;
    max-height: 350px; overflow-y: auto;
}
.character-sheet-header {
    display: flex; justify-content: space-between; align-items: center;
    line-height: 0.8; margin-bottom: 10px; position: relative;
}
.character-sheet-toggle {
    padding: 8px 15px; cursor: pointer; min-width: 80px; height: 32px;
    font-weight: 500; display: inline-flex; align-items: center; justify-content: center;
}
.character-stats { display: flex; flex-direction: column; gap: 10px; }
.stat-row { display: flex; flex-wrap: wrap; gap: 15px; }
.stat-group { flex: 1; min-width: 200px; padding: 10px; }
.stat-title { font-weight: bold; margin-bottom: 8px; }
.stat-item { display: flex; justify-content: space-between; margin-bottom: 5px; font-size: 0.9em; }
.stat-name, .meta-resource-label, .summary-stat-name { font-weight: 500; }
.stat-value, .meta-resource-value, .summary-stat-value { font-weight: bold; }

/* Meta Resources Summary */
.meta-resources-summary { display: flex; justify-content: center; gap: 15px; padding: 5px 0; align-items: center; flex-grow: 1; height: 40px; }
.meta-resource-item { display: inline-flex; align-items: center; gap: 5px; height: 32px; }
.character-sheet:not(.minimized) .meta-resources-summary { display: none; }

/* Minimized Character Sheet */
.character-sheet.minimized {
    position: fixed; bottom: 0; left: 0; right: 0;
    max-height: 50px !important; height: 50px; overflow: hidden;
    padding: 0 15px !important; display: flex; align-items: center;
}
.character-sheet.minimized .character-sheet-header {
    margin-bottom: 0; padding: 10px 0; border-bottom: none; z-index: 2;
    width: 100%; position: relative; display: flex; justify-content: flex-end;
}
.character-sheet.minimized .character-sheet-header h3,
.character-sheet.minimized .character-stats { display: none; }
.character-sheet.minimized .button-group { display: flex; align-items: center; }
.character-sheet.minimized .meta-resources-summary {
    border-bottom: none; background-color: transparent; padding: 0;
    position: absolute; left: 0; right: 0; top: 0; bottom: 0;
    height: 100%; display: flex; align-items: center; justify-content: center; z-index: -1;
}
.character-sheet-header.minimized-header {
    justify-content: flex-end; border-bottom: none; padding: 0; margin: 0;
    min-width: 300px; width: 100%;
}

/* Roll Styles */
.roll-container { margin: 20px 0; padding: 15px; padding-top: 7px; }
.roll-container h3 { margin-top: 0; }
.dice-result { font-size: 2rem; font-weight: bold; text-align: center; }
.roll-details { font-size: 0.9rem; display: flex; flex-direction: column; gap: 5px; }
.roll-item { margin: 10px 0; }
.roll-button { padding: 10px 20px; font-size: 16px; cursor: pointer; transition: background-color 0.1s ease; }
.roll-button:disabled, .reroll-button:disabled, .selection-button:disabled { cursor: not-allowed; }
.roll-results { margin-top: 15px; }
.dice-rolls { display: flex; flex-wrap: wrap; gap: 10px; margin-bottom: 15px; }
.dice-roll { padding: 8px 12px; font-weight: bold; }
.selectable-roll { cursor: pointer; transition: all 0.1s ease; }
.roll-effects { padding: 10px 10px 10px 15px; }
.roll-effects p { margin: 0; }
.result-effects-list { margin-top: 0 !important; padding: 5px; }

/* Roll Results Table */
.roll-results-table-container { margin: 10px 0; max-width: 100%; overflow-x: auto; }
.roll-results-table { width: 100%; border-collapse: collapse; font-size: 1em; overflow: hidden; }
.roll-results-table th { text-align: left; padding: 8px 12px; }
.roll-results-table td { padding: 4px 12px; font-size: 1em; }
.roll-cell { font-weight: bold; width: 60px; text-align: center; }
.effects-cell { padding: 4px 8px; }

/* Disabled Choice */
.disabled-choice { opacity: 0.7; cursor: not-allowed !important; transform: none !important; box-shadow: none !important; }
.disabled-choice:hover { transform: none !important; box-shadow: none !important; }
.locked-indicator { display: inline-block; margin-top: 10px; padding: 4px 8px; font-size: 0.8em; }
.lock-icon { font-size: 0.9em; margin-right: 4px; }

/* Reroll and Selection Buttons */
.reroll-button, .selection-button { padding: 8px 12px; margin-left: 8px; cursor: pointer; font-weight: 500; transition: background-color 0.1s; }
.influence-cost-info { float: right; padding: 4px 8px; margin: 5px 0; font-size: 0.9em; font-weight: 500; }
.select-message, .selection-message { margin: 10px 0; font-weight: 500; }
.roll-button-container { display: flex; justify-content: space-between; align-items: center; margin: 10px 0; }
.influence-buttons { display: flex; gap: 8px; justify-content: flex-end; }

/* Preview Styles */
.preview-button { padding: 5px 10px; margin-top: 10px; cursor: pointer; font-size: 0.8em; transition: background-color 0.1s; }
.preview-container { position: relative; width: 100%; z-index: 10; margin-top: 15px; max-height: 60vh; overflow-y: auto; cursor: default; }
.preview-container * { pointer-events: auto; }
.preview-title {
    padding: 10px 15px; font-weight: bold; display: flex;
    justify-content: space-between; align-items: center; position: sticky; top: 0; z-index: 2;
}
.preview-close-button { background: none; border: none; font-size: 1.2em; cursor: pointer; padding: 0 5px; }
.preview-content { padding: 15px; }
.preview-entity-header { padding-bottom: 5px; margin: 10px 0; }
.preview-separator { margin: 15px 0; border: 0; height: 1px; }
.preview-error, .preview-missing { padding: 8px; margin: 10px 0; }

/* Entity and Effects Rendering */
.entity-effects-container { display: flex; flex-direction: column; gap: 6px; padding: 4px; }
.entity-requirements { padding: 8px 10px; margin: 8px 0; }
.requirements-title, .entity-effects-title, .entity-title, .entry-title { font-weight: bold; }
.requirements-title { margin-bottom: 5px; }
.requirements-list { margin: 0; padding-left: 20px; }
.requirement-characteristic, .requirement-skill, .requirement-age,
.requirement-descriptor, .requirement-descriptor-not { margin: 2px 0; font-size: 0.95em; }

/* Semantic Colors */
.requirement-characteristic, .effect-characteristic, .characteristic-effect { color: #2c7be5; }
.requirement-skill, .effect-skill { color: #0e9f6e; }
.requirement-age, .effect-resource { color: #9f7315; }
.requirement-descriptor, .requirement-descriptor-not, .effect-descriptor { color: #9f1239; }
.effect-characteristic, .effect-skill, .effect-execute { font-weight: bold; }
.effect-descriptor { font-style: italic; }
.effect-description, .description-effect { font-style: italic; color: #555; }
.effect-execute { color: #5a32a3; }
.effect-descriptor-remove { color: #F44336; text-decoration: line-through; }
.characteristic-effect { color: #1976d2; }
.skill-effect { color: #7b1fa2; }
.meta-resource-effect { color: #f57c00; }
.descriptor-effect { color: #00796b; }
.resource-effect { color: #c2185b; }
.description-effect { color: #546e7a; }

.entity-test-info { padding: 10px; margin: 10px 0; }
.entity-modifiers { margin-top: 5px; font-size: 0.9em; }
.entity-effects-title { margin-top: 15px; margin-bottom: 5px; }
.entry-description { margin-bottom: 8px; font-size: 0.9em; }
.execute-entity-title { margin-left: 8px; font-style: italic; }
.execute-subcontainer, .entity-entry { margin-left: 16px; padding-left: 8px; margin-top: 4px; }
.entity-title { margin-top: 6px; }
.entity-description { margin-bottom: 4px; }
.entry-title { margin-bottom: 2px; }

/* Roll Details */
.roll-details-container, .roll-modifiers { font-family: 'Courier New', monospace; }
.roll-details-container { margin: 10px 0 0; padding: 10px; line-height: 1.0; }
.test-result-container { margin: 10px 0; padding: 10px; text-align: center; font-weight: bold; }
.roll-modifiers { margin: 10px 0; padding: 8px 12px; font-size: 0.9em; }

/* Tooltip */
.tooltip { position: relative; display: inline-block; }
.tooltip .tooltip-text {
    visibility: hidden; width: 300px; text-align: center; padding: 8px;
    position: absolute; z-index: 1; bottom: 125%; left: 50%; transform: translateX(-50%);
    opacity: 0; transition: opacity 0.1s; font-size: 0.9em; line-height: 1.4;
    max-width: 300px; word-wrap: break-word; white-space: normal;
}
.tooltip .tooltip-text.left-edge { left: 0; transform: none; }
.tooltip .tooltip-text.left-edge::after { left: 20px; }
.tooltip .tooltip-text.right-edge { left: auto; right: 0; transform: none; }
.tooltip .tooltip-text.right-edge::after { left: auto; right: 20px; }
.tooltip .tooltip-text::after { content: ""; position: absolute; top: 100%; left: 50%; margin-left: -5px; border-width: 5px; border-style: solid; }
.tooltip:hover .tooltip-text { visibility: visible; opacity: 1; }

/* Summary Styles */
.summary-container { padding: 20px; margin: 20px 0; }
.summary-full-width { width: 100%; flex: 1 1 100%; }
.summary-section { margin-bottom: 20px; }
.summary-section h3 { padding-bottom: 5px; margin-bottom: 15px; }
.summary-group { margin-bottom: 15px; }
.summary-group h4 { margin-bottom: 10px; }
.summary-container ul { list-style-type: none; padding-left: 20px; margin: 0; }
.summary-container li { margin-bottom: 5px; position: relative; }
.summary-container li::before { content: "•"; position: absolute; left: -15px; }

/* Export Popup */
.export-popup-overlay { position: fixed; top: 0; left: 0; right: 0; bottom: 0; display: flex; justify-content: center; align-items: center; z-index: 1000; }
.export-popup-content { width: 80%; max-width: 800px; max-height: 80vh; display: flex; flex-direction: column; overflow: hidden; }
.export-popup-header { padding: 15px 20px; display: flex; justify-content: space-between; align-items: center; }
.export-popup-header h2 { margin: 0; font-size: 1.5rem; flex-grow: 1; }
.export-popup-buttons { display: flex; align-items: center; gap: 10px; }
.export-popup-copy { padding: 6px 12px; cursor: pointer; font-size: 0.9em; }
.export-popup-close { background: none; border: none; font-size: 1.8rem; cursor: pointer; padding: 0 5px; }
.export-popup-body { padding: 20px; overflow-y: auto; max-height: calc(80vh - 70px); }
.export-popup-body .summary-container { margin: 0; padding: 0; box-shadow: none; max-width: 100%; }

/* Summary Character Sheet */
.summary-character-sheet { margin-bottom: 30px; padding-bottom: 20px; }
.summary-character-sheet h2, .summary-selections h2, .summary-journal h2 { margin-top: 30px; margin-bottom: 15px; font-size: 1.8rem; }
.summary-stat-row { display: flex; flex-wrap: wrap; gap: 20px; margin-bottom: 20px; }
.summary-stat-group { flex: 1; min-width: 200px; padding: 15px; }
.summary-stat-group h3 { margin-top: 0; margin-bottom: 12px; padding-bottom: 8px; font-size: 1.2rem; }
.summary-stats-table { width: 100%; border-collapse: collapse; }
.summary-stats-table td { padding: 8px 4px; }
.summary-stat-value { text-align: right; }
.summary-stat-empty { font-style: italic; text-align: center; padding: 10px; }
.summary-stat-description { font-size: 0.85em; padding: 0 0.5rem 0.5rem 1rem; font-style: italic; text-align: left; }

/* Journal Styles */
.summary-journal { margin-top: 30px; padding-top: 20px; }
.journal-entries { padding: 20px; overflow-y: auto; }
.journal-entries p { margin-bottom: 15px; padding-bottom: 15px; line-height: 1.5; }
.journal-entries p:last-child { margin-bottom: 0; padding-bottom: 0; border-bottom: none; }
.journal-entries ul { margin: 10px 0 10px 20px; padding-left: 20px; }
.journal-entries li { margin-bottom: 5px; }

/* Section Header */
.section-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 15px; }
.section-header-buttons { display: flex; gap: 10px; align-items: center; }
.section-preview-button, .section-minimize-toggle { padding: 6px 12px; cursor: pointer; font-size: 0.9em; transition: all 0.1s ease; }

/* Minimized Section */
.section-minimized { padding-bottom: 15px; }
.section-minimized .section-header { margin-bottom: 0; }
.section-content { transition: max-height 0.3s ease; }
.section-minimized .section-title { border-bottom: none; margin-bottom: 0; padding-bottom: 0; }

/* Section Bottom Controls */
.section-bottom-controls { display: flex; justify-content: flex-end; margin-top: 20px; padding-top: 15px; border-top: 1px solid rgba(128, 128, 128, 0.2); }

/* Images */
.section-image, .entry-image, .roll-image { text-align: center; }
.section-image { margin: 1em 0; }
.roll-image { margin-bottom: 1em; }
.section-image img, .entry-image img, .roll-image img { max-width: 100%; }
.section-image img { max-height: 500px; }
.roll-image img { max-height: 350px; }
.entry-image img { max-height: 300px; }

/* Footer */
.footer-wrapper { max-width: 1200px; margin: 0 auto 50px; padding: 0 20px; position: relative; transition: opacity 0.3s ease, transform 0.3s ease; }
.footer-hidden .footer-section { opacity: 0; transform: translateY(20px); pointer-events: none; }
.footer-toggle { position: absolute; right: 30px; top: 10px; padding: 8px 15px; cursor: pointer; font-weight: 500; font-size: 0.9em; z-index: 10; transition: background-color 0.1s; }
.footer-section { padding: 20px; display: flex; flex-wrap: wrap; gap: 30px; position: relative; transition: opacity 0.3s ease, transform 0.3s ease; }
.credits-container, .changelog-container { flex: 1 1 100%; }
.credits-container h3, .changelog-container h3 { padding-bottom: 5px; margin-bottom: 15px; }
.credits-container p { margin: 5px 0; }
.changelog-entry { display: flex; margin-bottom: 10px; padding-bottom: 10px; }
.changelog-entry .version { font-weight: bold; margin-right: 15px; min-width: 50px; }

/* Title Container */
.title-container { padding: 15px 30px; margin-bottom: 30px; text-align: center; position: relative; }
.title-container h1 { font-size: 2.8rem; margin: 0; }

/* Control Buttons */
.control-buttons { display: flex; flex-direction: column; align-items: center; gap: 5px; margin-bottom: 20px; padding: 5px 5px 10px; }
.control-buttons .group-description { text-align: center; margin: 0; }
.control-buttons > div { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; }
.control-btn { padding: 10px 20px; border: none; cursor: pointer; font-weight: 500; transition: all 0.2s ease; font-size: 14px; min-width: 80px; height: 36px; display: inline-flex; align-items: center; justify-content: center; }

/* Navigation Menu */
.navigation-menu { position: fixed; z-index: 1000; max-height: 80vh; overflow-y: auto; transition: all 0.3s ease; top: 5px; left: 5px; max-width: 250px; min-width: 160px; }
.navigation-menu.collapsed { min-width: 40px; width: 40px; }
.nav-header { padding: 10px 12px; font-size: 0.9em; font-weight: bold; cursor: pointer; display: flex; justify-content: space-between; align-items: center; transition: all 0.3s ease; }
.nav-title { letter-spacing: 0.5px; }
.nav-toggle { font-size: 14px; opacity: 0.8; }
.nav-content { padding: 10px 0; max-height: calc(80vh - 60px); overflow-y: auto; }
.nav-section-title { padding: 6px 12px; font-size: 0.9em; font-weight: bold; cursor: pointer; transition: all 0.2s ease; }

/* Animations */
@keyframes highlight { 0%, 100% { background-color: transparent; } 50% { background-color: rgba(240, 160, 75, 0.3); } }
.highlight { animation: highlight 0.1s ease; }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes slideIn { from { transform: translateY(-50px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }

/* Responsive - Tablet */
@media (min-width: 769px) and (max-width: 1200px) { .choice-item, .option-item { flex: 0 0 calc(30% - 15px); max-width: calc(30% - 15px); } }

/* Responsive - Mobile */
@media (max-width: 768px) {
    .choice-item, .option-item { flex: 0 0 100%; max-width: 100%; }
    .character-sheet { max-height: 300px; }
    .character-sheet.expanded { max-height: 80vh; }
    .stat-group { min-width: 95%; }
    .footer-section, .summary-stat-row { flex-direction: column; }
    .summary-stat-group { min-width: 100%; }
    .control-buttons > div { flex-direction: column; align-items: center; }
    .control-btn { width: 100%; max-width: 200px; }
}

/* Responsive - Minimized Sheet */
@media (max-width: 1100px) {
    .character-sheet.minimized { max-height: 80px !important; height: 80px; }
    .character-sheet.minimized .meta-resources-summary { position: absolute; top: 15px !important; bottom: 20px; left: 0; right: 0; height: 50px; align-items: center; justify-content: center; padding-bottom: 0; z-index: 0; }
    .character-sheet.minimized .character-sheet-header { position: absolute; top: -5px; right: -10px; width: auto; z-index: 2; }
}

/* Cost Modifiers (discounts from other selections) */
.cost-modifiers { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 4px; }
.cost-modifier { font-size: 0.75em; padding: 2px 6px; border-radius: 3px; }
.cost-modifier.potential { color: #888; font-style: italic; background: rgba(128, 128, 128, 0.15); }
.cost-modifier.applied { color: #2a5; font-weight: bold; background: rgba(34, 170, 85, 0.15); }

/* Import Dialog */
.nav-section-subtitle { font-size: 0.75em; font-weight: normal; opacity: 0.7; margin-top: 2px; }
.import-dialog-body { display: flex; flex-direction: column; gap: 15px; }
.import-warning { background: rgba(255, 165, 0, 0.15); border-left: 3px solid orange; padding: 10px; margin: 0; font-size: 0.9em; }
.import-textarea { width: 100%; min-height: 200px; padding: 10px; font-family: monospace; font-size: 0.85em; resize: vertical; border: 1px solid rgba(128, 128, 128, 0.3); border-radius: 4px; background: rgba(0, 0, 0, 0.05); }
.import-submit-btn { padding: 10px 20px; font-weight: bold; cursor: pointer; align-self: flex-end; }
.import-success { color: #2a5; font-weight: bold; }
.import-errors-list { margin: 10px 0; padding-left: 25px; font-size: 0.9em; }
.import-errors-list li { margin-bottom: 5px; }
