:root {
    --primary-color: #0d9488; /* Teal-600 */
    --secondary-color: #f59e0b; /* Amber-500 */
    --background-color: #f8fafc; /* Slate-50 */
    --text-color: #334155; /* Slate-700 */
    --light-text-color: #64748b; /* Slate-500 */
    --card-bg-color: #ffffff;
    --border-color: #e2e8f0; /* Slate-200 */
    --shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -2px rgba(0, 0, 0, 0.1);
    --font-family: 'Cairo', sans-serif;
}

body {
    font-family: var(--font-family);
    background-color: var(--background-color);
    color: var(--text-color);
    margin: 0;
    line-height: 1.6;
}

#app {
    max-width: 1200px;
    margin: 0 auto;
    padding: 2rem;
}

.app-header {
    text-align: center;
    margin-bottom: 2rem;
}

.app-header h1 {
    font-size: 2.5rem;
    color: var(--primary-color);
    font-weight: 700;
    margin-bottom: 0.5rem;
}

.app-header p {
    font-size: 1.1rem;
    color: var(--light-text-color);
}

.tabs {
    display: flex;
    justify-content: center;
    border-bottom: 2px solid var(--border-color);
    margin-bottom: 2rem;
}

.tab-btn {
    padding: 1rem 1.5rem;
    font-size: 1.1rem;
    font-weight: 600;
    cursor: pointer;
    background: none;
    border: none;
    border-bottom: 3px solid transparent;
    color: var(--light-text-color);
    transition: all 0.3s ease;
}

.tab-btn.active,
.tab-btn:hover {
    color: var(--primary-color);
    border-bottom-color: var(--primary-color);
}

.view {
    display: none;
}

.view.active {
    display: block;
    animation: fadeIn 0.5s ease-in-out;
}

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

/* --- REBUILT TIMELINE VIEW (Based on your preferred layout) --- */
.timeline-container {
    position: relative;
    width: 100%;
    margin: 0 auto;
}

/* The central vertical line */
.timeline-container::after {
    content: '';
    position: absolute;
    width: 3px;
    background-color: var(--border-color);
    top: 0;
    bottom: 0;
    left: 50%;
    margin-left: -1.5px;
}

.timeline-item {
    padding: 10px 40px;
    position: relative;
    background-color: inherit;
    width: 50%;
    box-sizing: border-box;
}

/* The dot on the timeline */
.timeline-item::after {
    content: '';
    position: absolute;
    width: 20px;
    height: 20px;
    right: -11px;
    background-color: var(--secondary-color);
    border: 4px solid var(--background-color);
    top: 25px;
    border-radius: 50%;
    z-index: 1;
}

/* Place container to the left */
.timeline-item.left {
    left: 0;
}

/* Place container to the right */
.timeline-item.right {
    left: 50%;
}

/* Adjust the dot for right-side items */
.timeline-item.right::after {
    left: -11px;
}

.timeline-card {
    padding: 1.5rem;
    background-color: white;
    position: relative;
    border-radius: 8px;
    box-shadow: var(--shadow);
    cursor: pointer;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.timeline-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 10px 15px -3px rgba(0,0,0,0.1);
}

.timeline-card-header {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.timeline-avatar {
    width: 50px;
    height: 50px;
    border-radius: 50%;
    background-color: var(--primary-color);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 1.5rem;
    flex-shrink: 0;
}

.timeline-info h3 {
    font-size: 1.25rem;
    font-weight: 700;
    margin: 0 0 0.25rem;
    color: var(--text-color);
}

.timeline-info p {
    margin: 0;
    font-size: 0.9rem;
    color: var(--light-text-color);
}
/* --- END OF TIMELINE VIEW --- */

/* Categories View */
.categories-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 1.5rem;
}

.category-card {
    border-radius: 12px;
    padding: 1.5rem;
    color: white;
    cursor: pointer;
    transition: transform 0.3s ease;
    overflow: hidden;
}

.category-card:hover {
    transform: scale(1.03);
}

.category-card h3 {
    font-size: 1.5rem;
    margin: 0 0 1rem;
    border-bottom: 2px solid rgba(255, 255, 255, 0.5);
    padding-bottom: 0.5rem;
}

.category-philosophers {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.5s ease-in-out;
}

.category-card.open .category-philosophers {
    max-height: 1000px;
}

.philosopher-item {
    display: flex;
    align-items: center;
    gap: 1rem;
    background: rgba(0, 0, 0, 0.15);
    padding: 0.75rem;
    border-radius: 8px;
    margin-bottom: 0.5rem;
    transition: background-color 0.3s;
}

.philosopher-item:hover {
    background: rgba(0, 0, 0, 0.3);
}

.philosopher-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background-color: var(--card-bg-color);
    color: var(--text-color);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 1.2rem;
    flex-shrink: 0;
}

.philosopher-item-info h4 { margin: 0; font-size: 1rem; }
.philosopher-item-info p { margin: 0; font-size: 0.8rem; opacity: 0.8; }

/* Graph View */
.graph-container { width: 100%; height: 70vh; border: 1px solid var(--border-color); background-color: white; box-shadow: var(--shadow); border-radius: 12px; }
.graph-instructions { text-align: center; margin-top: 1rem; color: var(--light-text-color); }
.node circle { stroke: #fff; stroke-width: 2px; cursor: pointer; transition: r 0.3s ease; }
.node:hover circle { r: 15; }
.node text { pointer-events: none; font-family: var(--font-family); font-size: 12px; fill: var(--text-color); font-weight: 600; }
.link { stroke: #999; stroke-opacity: 0.6; }

/* Modal */
.modal-overlay { position: fixed; top: 0; left: 0; right: 0; bottom: 0; background: rgba(0, 0, 0, 0.6); display: flex; align-items: center; justify-content: center; z-index: 1000; opacity: 0; visibility: hidden; transition: opacity 0.3s ease, visibility 0.3s ease; }
.modal-overlay.show { opacity: 1; visibility: visible; }
.modal-content { background: var(--card-bg-color); padding: 2.5rem; border-radius: 16px; width: 90%; max-width: 700px; max-height: 90vh; overflow-y: auto; position: relative; transform: scale(0.9); transition: transform 0.3s ease; }
.modal-overlay.show .modal-content { transform: scale(1); }
.modal-close-btn { position: absolute; top: 15px; left: 15px; background: none; border: none; font-size: 2rem; color: var(--light-text-color); cursor: pointer; }
#modal-body h2 { font-size: 2.2rem; color: var(--primary-color); margin: 0 0 0.5rem; }
#modal-body .philosopher-dates { font-size: 1rem; color: var(--light-text-color); margin-bottom: 2rem; }
.modal-section { margin-bottom: 1.5rem; }
.modal-section h4 { font-size: 1.1rem; font-weight: 700; color: var(--primary-color); border-bottom: 2px solid var(--border-color); padding-bottom: 0.5rem; margin-bottom: 0.75rem; }
.modal-section p { margin: 0; font-size: 1rem; color: var(--text-color); }

/* Responsive Design */
@media screen and (max-width: 768px) {
    #app { padding: 1rem; }
    .app-header h1 { font-size: 2rem; }

    /* Responsive Timeline: Stack everything on the left */
    .timeline-container::after {
        left: 20px; /* Move line to the left */
    }

    .timeline-item,
    .timeline-item.right,
    .timeline-item.left {
        width: 100%;
        padding-left: 60px; /* Make space for line and dot */
        padding-right: 15px;
        left: 0;
    }

    .timeline-item::after,
    .timeline-item.right::after,
    .timeline-item.left::after {
        left: 11px; /* Position all dots on the new line */
    }
}
