/* Reset and Base Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    overflow-x: hidden;
    overflow-y: hidden;
    width: 100vw;
    height: 100vh;
    position: fixed;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    background-color: #f5f5f5;
    color: #333;
    line-height: 1.6;
    overflow: hidden;
    width: 100vw;
    height: 100vh;
    margin: 0;
    padding: 0;
    position: relative;
}

.container {
    margin: 0;
    padding: 10px;
    height: 100%;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

/* Toolbar */
.toolbar {
    background: white;
    padding: 12px 20px;
    border-radius: 6px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
    margin-bottom: 10px;
    flex-shrink: 0;
}

.toolbar-content {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
}

.toolbar-left {
    display: flex;
    align-items: center;
    gap: 24px;
}

.app-title-link {
    text-decoration: none;
}

.app-title-link:hover .app-title {
    color: #3498db;
}

.app-title {
    font-size: 20px;
    font-weight: 600;
    margin: 0;
    color: #2c3e50;
    transition: color 0.2s;
}

.timeline-selector {
    display: flex;
    align-items: center;
    gap: 8px;
}

.timeline-selector label {
    font-size: 14px;
    color: #555;
    font-weight: 500;
}

.timeline-selector select {
    padding: 6px 12px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 14px;
    min-width: 260px;
    background: white;
    cursor: pointer;
    transition: border-color 0.2s;
}

.timeline-selector select:hover:not(:disabled) {
    border-color: #3498db;
}

.timeline-selector select:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.toolbar-right {
    display: flex;
    gap: 10px;
    align-items: center;
}

.btn-toolbar {
    padding: 6px 16px;
    background: #3498db;
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    transition: background-color 0.2s;
}

.btn-toolbar:hover {
    background: #2980b9;
}

.btn-toolbar:active {
    background: #21618c;
}

/* Main Content Layout */
.main-content {
    position: relative;
    flex: 1;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

/* Footer */
footer {
    margin-top: 10px;
    padding: 8px 12px;
    background: white;
    border-radius: 6px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
    flex-shrink: 0;
}

.footer-content {
    text-align: center;
}

.footer-content p {
    margin: 0;
    font-size: 0.85em;
    color: #555;
}

.footer-content a {
    color: #3498db;
    text-decoration: none;
}

.footer-content a:hover {
    text-decoration: underline;
}

/* Controls Panel - Slide-in Drawer */
.controls-panel {
    position: fixed;
    top: 0;
    right: -380px;
    width: 380px;
    height: 100vh;
    background: white;
    box-shadow: -2px 0 10px rgba(0,0,0,0.15);
    z-index: 1000;
    transition: right 0.3s ease;
    display: flex;
    flex-direction: column;
}

.controls-panel.open {
    right: 0;
}

.controls-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 20px;
    border-bottom: 2px solid #ecf0f1;
    background: #f8f9fa;
    flex-shrink: 0;
}

.controls-body {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
}

.controls-header h2 {
    font-size: 1.3em;
    color: #2c3e50;
    margin: 0;
}

.close-btn {
    background: none;
    border: none;
    font-size: 1.5em;
    color: #7f8c8d;
    cursor: pointer;
    padding: 0;
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
    transition: all 0.2s;
}

.close-btn:hover {
    background: #e0e0e0;
    color: #333;
}

.control-section {
    padding: 20px;
    border-bottom: 1px solid #ecf0f1;
}

.control-section:last-child {
    border-bottom: none;
}

.control-section h3 {
    font-size: 1em;
    margin-bottom: 12px;
    color: #2c3e50;
    font-weight: 600;
}

/* Event Set Items */
.event-sets {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.event-set-item {
    border: 1px solid #e0e0e0;
    border-radius: 6px;
    overflow: hidden;
    background: #fafafa;
    cursor: move;
    transition: all 0.2s ease;
}

.event-set-item.dragging {
    opacity: 0.5;
    border: 2px dashed #3498db;
}

.event-set-header {
    display: flex;
    align-items: center;
    padding: 10px 12px;
    gap: 10px;
    background: white;
}

.drag-handle {
    cursor: grab;
    color: #95a5a6;
    font-size: 16px;
    user-select: none;
    padding: 2px 4px;
    transition: color 0.2s ease;
}

.drag-handle:hover {
    color: #3498db;
}

.drag-handle:active {
    cursor: grabbing;
}

.event-set-checkbox {
    width: 18px;
    height: 18px;
    cursor: pointer;
    flex-shrink: 0;
}

.event-set-label {
    flex: 1;
    cursor: pointer;
    font-weight: 500;
    color: #333;
    font-size: 0.95em;
}

.expand-btn {
    background: none;
    border: none;
    color: #7f8c8d;
    font-size: 0.8em;
    cursor: pointer;
    padding: 4px 8px;
    border-radius: 3px;
    transition: all 0.2s;
    flex-shrink: 0;
}

.expand-btn:hover {
    background: #f0f0f0;
    color: #333;
}

/* Event Set Settings - Collapsible */
.event-set-settings {
    max-height: 200px;
    overflow: hidden;
    transition: max-height 0.3s ease, padding 0.3s ease;
    padding: 12px;
    background: #f8f9fa;
    border-top: 1px solid #e0e0e0;
}

.event-set-settings.collapsed {
    max-height: 0;
    padding: 0 12px;
}

.setting-row {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-bottom: 12px;
}

.setting-row:last-child {
    margin-bottom: 0;
}

.setting-label {
    font-size: 0.85em;
    color: #555;
    font-weight: 500;
}

.color-picker {
    width: 100%;
    height: 36px;
    border: 1px solid #ddd;
    border-radius: 4px;
    cursor: pointer;
    padding: 2px;
}

.row-limit-input {
    width: 100%;
    padding: 8px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 0.95em;
}

/* Time and Dimension Controls */
.time-controls,
.dimension-controls {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.time-controls label,
.dimension-controls label {
    display: flex;
    flex-direction: column;
    gap: 5px;
    font-weight: 500;
    color: #555;
    font-size: 0.9em;
}

input[type="number"] {
    padding: 8px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 0.95em;
}

/* Buttons */
.btn {
    width: 100%;
    padding: 10px;
    border: none;
    border-radius: 4px;
    font-size: 0.95em;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    margin-bottom: 8px;
}

.btn-primary {
    background: #3498db;
    color: white;
}

.btn-primary:hover {
    background: #2980b9;
}

.btn-secondary {
    background: #2ecc71;
    color: white;
}

.btn-secondary:hover {
    background: #27ae60;
}

.btn:active {
    transform: translateY(1px);
}

/* Visualization Area */
.visualization-area {
    background: white;
    padding: 15px;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    overflow: auto;
    flex: 1;
}

#svg-container {
    width: fit-content;
    min-width: 100%;
    display: flex;
    justify-content: center;
}

#svg-container svg {
    border: 1px solid #ecf0f1;
    background: white;
}

/* SVG Text Styling */
svg text {
    user-select: none;
    pointer-events: none;
}

svg text.event-label {
    pointer-events: all !important;
}

/* Event hover effects */
svg text.event-label {
    cursor: pointer !important;
    transition: fill-opacity 0.2s ease;
    pointer-events: all !important;
}

svg text.event-label:hover {
    fill-opacity: 0.6 !important;
}

/* Wikipedia Modal */
.wiki-modal {
    display: none;
    position: fixed;
    z-index: 10000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.6);
    animation: fadeIn 0.2s ease;
}

.wiki-modal.show {
    display: flex;
    align-items: center;
    justify-content: center;
}

.wiki-modal-content {
    background-color: white;
    border-radius: 8px;
    width: 90%;
    max-width: 1200px;
    height: 85%;
    max-height: 800px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
    display: flex;
    flex-direction: column;
    animation: slideIn 0.3s ease;
}

.wiki-modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 20px;
    border-bottom: 1px solid #e0e0e0;
    flex-shrink: 0;
}

.wiki-modal-header h2 {
    font-size: 18px;
    font-weight: 600;
    color: #2c3e50;
    margin: 0;
}

.wiki-modal-body {
    flex: 1;
    overflow: hidden;
    position: relative;
}

.wiki-modal-body iframe {
    width: 100%;
    height: 100%;
    border: none;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes slideIn {
    from {
        transform: translateY(-50px);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

/* Responsive Design */
@media (max-width: 768px) {
    .controls-panel {
        width: 100%;
        right: -100%;
    }

    .footer-content {
        flex-direction: column;
        gap: 10px;
    }

    .footer-info {
        text-align: center;
    }

    .wiki-modal-content {
        width: 95%;
        height: 90%;
    }
}
