/* Timeline Styles */

/* === Research Visualization Typography === */
html {
    font-size: 13px;
}

body {
    font-size: 1rem;
    line-height: 1.5;
}

.leaflet-tile {
    filter: contrast(95%) brightness(105%) saturate(120%);
}

.zoom-indicator {
    background: rgba(0, 0, 0, 0.6);
    color: #fff;
    padding: 4px 8px;
    font-size: 13px;
    border-radius: 4px;
    line-height: 1.2;
}

#controls {
    font-size: clamp(0.6rem, 0.5vw, 0.72rem);
}

#timeline-container {
    --scrubber-height: 34px;
    display: flex;
    flex-direction: column;
}

#timeline-view {
    flex: 1 1 auto;
    min-height: 0;
    position: relative;
}

#time-scrubber {
    position: relative;
    margin: clamp(2px, 0.3vw, 4px) clamp(6px, 0.8vw, 12px) clamp(3px, 0.4vw, 6px);
    display: flex;
    align-items: center;
    gap: clamp(4px, 0.5vw, 8px);
    padding: clamp(2px, 0.2vw, 3px) clamp(4px, 0.5vw, 8px);
    min-height: var(--scrubber-height);
    background: rgba(255, 255, 255, 0.9);
    border: 1px solid #ccc;
    border-radius: 6px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    z-index: 9000;
}

#time-scrubber-label {
    font-size: clamp(0.65rem, 0.5vw, 0.8rem);
    font-weight: 600;
    white-space: nowrap;
    color: #333;
}

#time-scrubber-input {
    width: 100%;
    cursor: pointer;
}

#unknown-popup {
    position: absolute;
    background: rgba(255, 255, 255, 0.96);
    border: 1px solid #ccc;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
    padding: 8px 10px;
    font-size: 1rem;
    color: #333;
    z-index: 1001;
    display: none;
    opacity: 0;
    transition: opacity 0.2s ease;
    pointer-events: none;
}

/* Base item style - unified */
.vis-item {
    border-color: #97B0F8;
    background-color: #D5DDF6;
    font-size: 0.6rem;
    line-height: 1.15;
    border-radius: 3px;
    margin-top: 2px;
    margin-bottom: 2px;
}

/* Exact dates (Birth/Death known) */
.vis-item.exact {
    background-color: #C2D1F0;
    border-color: #7A95D1;
}

/* Approximate dates (Circa / Century) */
.vis-item.approx {
    background-color: #FFF2CC;
    border-color: #D6B656;
    border-style: dashed;
}

/* Floruit (Estimated range) */
.vis-item.floruit {
    background-color: #E2F0D9;
    border-color: #548235;
    background-image: repeating-linear-gradient(45deg,
            transparent,
            transparent 5px,
            rgba(255, 255, 255, .5) 5px,
            rgba(255, 255, 255, .5) 10px);
}

/* Point items */
.vis-item.vis-point {
    color: #333;
}

/* Selected item */
.vis-item.vis-selected {
    background-color: #FFD966;
    border-color: #FFC000;
    z-index: 100;
}


#custom-tooltip .tooltip-wiki {
    color: #007bff;
    font-weight: normal;
    font-size: 0.8em;
    margin-left: 4px;
    text-decoration: none;
}

#custom-tooltip .tooltip-wiki:hover {
    text-decoration: underline;
}

.loading {
    padding: 20px;
    font-size: 18px;
    text-align: center;
    color: #666;
}

.vis-time-axis .vis-text {
    font-size: 0.8rem;
}

/* Reduced height for timeline bars */
.vis-item .vis-item-content {
    padding: 1px 4px;
    font-size: 0.6rem;
    line-height: 1.15;
}

/* Custom Interactive Tooltip */
#custom-tooltip {
    position: absolute;
    background: rgba(255, 255, 255, 0.98);
    border: 1px solid #aaa;
    padding: 5px 8px;
    border-radius: 6px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.25);
    z-index: 10000;
    display: none;
    max-width: 280px;
    font-size: 0.72rem;
    line-height: 1.35;
    pointer-events: auto;
    font-family: sans-serif;
    color: #333;
}

#custom-tooltip .tooltip-name {
    font-weight: bold;
    font-size: 0.8rem;
    margin-bottom: 3px;
    border-bottom: 1px solid #eee;
    padding-bottom: 2px;
}

#custom-tooltip .tooltip-dates {
    font-style: italic;
    color: #666;
    margin-bottom: 3px;
    font-size: 0.7rem;
}

#custom-tooltip .tooltip-occs {
    margin-top: 3px;
}

.tooltip-occ-tag {
    display: inline-block;
    background: #eef;
    color: #007bff;
    padding: 1px 5px;
    border-radius: 3px;
    margin-right: 4px;
    margin-bottom: 2px;
    cursor: pointer;
    font-size: 0.62rem;
    border: 1px solid #dde;
}

.tooltip-occ-tag:hover {
    background: #ddeeff;
    color: #0056b3;
    border-color: #bbf;
}

/* Leaflet popup offset for better visibility */
.leaflet-popup {
    margin-bottom: 40px;
}

.leaflet-popup-content {
    margin: 8px 10px;
}

.leaflet-popup-tip-container {
    height: 30px;
}

.leaflet-popup-tip {
    width: 20px;
    height: 20px;
}

/* Map City Labels */
.city-label {
    background: transparent !important;
    border: none !important;
}

.city-label span {
    font-size: 0.75rem;
    font-weight: 600;
    color: #4a4a4a;
    text-shadow:
        1px 1px 0 rgba(255, 255, 255, 0.9),
        -1px -1px 0 rgba(255, 255, 255, 0.9),
        1px -1px 0 rgba(255, 255, 255, 0.9),
        -1px 1px 0 rgba(255, 255, 255, 0.9);
    white-space: nowrap;
    pointer-events: none;
}

.ancient-label {
    pointer-events: none;
    white-space: nowrap;
    text-shadow: 0 1px 2px rgba(255, 255, 255, 0.9);
    transform: translate(-50%, -50%);
}

.ancient-label-clickable {
    pointer-events: auto;
    cursor: pointer;
}

.ancient-label-clickable span {
    text-decoration: underline;
    text-underline-offset: 2px;
}

.ancient-label-clickable:hover span {
    text-decoration-thickness: 2px;
}

.ancient-label span {
    display: inline-block;
    padding: 1px 2px;
}

.ancient-label-major span {
    font-weight: 700;
    font-size: 12px;
    color: #111;
}

.ancient-label-mid span {
    font-weight: 600;
    font-size: 11px;
    color: #2e2a25;
    opacity: 0.9;
}

.ancient-label-minor span {
    font-weight: 500;
    font-size: 10px;
    color: #3f3a34;
    opacity: 0.82;
}

.ancient-label-sea span {
    font-weight: 600;
    font-size: 12px;
    color: #555;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    opacity: 0.92;
}

/* Marker Popup */
.marker-popup {
    font-family: sans-serif;
    font-size: 0.95rem;
    line-height: 1.5;
}

.marker-popup strong {
    color: #333;
    font-size: 1.1rem;
}

.popup-place {
    color: #555;
}

.popup-prop {
    color: #888;
    font-size: 0.9rem;
}

.marker-popup a {
    color: #007bff;
    text-decoration: none;
}

.marker-popup a:hover {
    text-decoration: underline;
}

/* Place popup (authors list) */
.place-popup {
    font-family: sans-serif;
    font-size: 11px;
    line-height: 1.3;
    min-width: 140px;
}

.place-popup__list {
    margin-top: 4px;
    max-height: 200px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 3px;
    scrollbar-width: thin;
}

.place-popup__list::-webkit-scrollbar {
    width: 4px;
}

.place-popup__list::-webkit-scrollbar-thumb {
    background: #ccc;
    border-radius: 2px;
}

.place-popup__author {
    display: flex;
    flex-direction: column;
    gap: 1px;
    padding: 3px 6px;
    border: 1px solid #e5e5e5;
    border-radius: 4px;
    background: #fafafa;
    cursor: pointer;
    text-align: left;
}

.place-popup__author:hover {
    background: #f0f4f8;
    border-color: #d8dfe6;
}

.place-popup__name {
    font-weight: 600;
    font-size: 11px;
}

.place-popup__badges {
    display: flex;
    flex-wrap: wrap;
    gap: 3px;
    align-items: center;
}

.place-popup__badge {
    display: inline-flex;
    align-items: center;
    gap: 2px;
    font-size: 9px;
    padding: 0 5px;
    border-radius: 999px;
    background: #e9eef4;
    color: #334155;
    line-height: 1.4;
}

.place-popup__badge--role {
    background: #f0f3f7;
}

.place-popup__badge-year {
    font-weight: 600;
}

.place-popup__badge-label {
    text-transform: lowercase;
}

.place-popup__year {
    font-size: 9px;
    color: #444;
    margin-right: 1px;
}

.place-popup__empty,
.place-popup__more {
    margin-top: 4px;
    font-size: 10px;
    color: #777;
}

/* Place popup header with Explore button */
.place-popup__header {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 2px;
    margin-bottom: 2px;
}

.place-popup__header strong {
    font-size: 12px;
}

.place-popup__explore {
    font-size: 9px;
    font-weight: 600;
    padding: 2px 8px;
    border: 1px solid #4a90d9;
    border-radius: 10px;
    background: #4a90d9;
    color: #fff;
    cursor: pointer;
    white-space: nowrap;
    transition: background 0.15s;
}

.place-popup__explore:hover {
    background: #357abd;
}

/* Marker Cluster Icons */
.marker-cluster {
    background-clip: padding-box;
    border-radius: 50%;
}

.marker-cluster div {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 11px;
    color: #fff;
    text-align: center;
    border: 1.5px solid rgba(0, 0, 0, 0.6);
    box-sizing: border-box;
    text-shadow:
        -1px -1px 0 rgba(0, 0, 0, 0.6),
        1px -1px 0 rgba(0, 0, 0, 0.6),
        -1px 1px 0 rgba(0, 0, 0, 0.6),
        1px 1px 0 rgba(0, 0, 0, 0.6);
}

.marker-cluster-small {
    background-color: rgba(181, 226, 140, 0.6);
}

.marker-cluster-small div {
    background-color: rgba(110, 204, 57, 0.6);
    font-size: 14px;
}

.marker-cluster-medium {
    background-color: rgba(241, 211, 87, 0.6);
}

.marker-cluster-medium div {
    background-color: rgba(240, 194, 12, 0.6);
    font-size: 16px;
}

.marker-cluster-large {
    background-color: rgba(253, 156, 115, 0.6);
}

.marker-cluster-large div {
    background-color: rgba(241, 128, 23, 0.6);
    font-size: 18px;
}

/* ====== Chat Panel ====== */
.chat-panel {
    position: absolute;
    top: 0;
    right: 0;
    width: 320px;
    height: 100%;
    background: #fff;
    box-shadow: -4px 0 16px rgba(0, 0, 0, 0.12);
    z-index: 2000;
    display: flex;
    flex-direction: column;
    transform: translateX(100%);
    transition: transform 0.3s ease;
}

.chat-panel--open {
    transform: translateX(0);
}

.chat-panel__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 14px;
    background: #f5f7fa;
    border-bottom: 1px solid #ddd;
    flex-shrink: 0;
}

.chat-panel__header-left {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.chat-panel__title {
    font-weight: 700;
    font-size: 1rem;
    color: #333;
}

.chat-panel__status {
    font-size: 0.75rem;
    color: #888;
}

.chat-panel__close {
    border: none;
    background: none;
    font-size: 1.4rem;
    cursor: pointer;
    color: #666;
    padding: 4px 8px;
    line-height: 1;
}

.chat-panel__close:hover {
    color: #333;
}

.chat-panel__messages {
    flex: 1;
    overflow-y: auto;
    padding: 12px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.chat-msg {
    display: flex;
}

.chat-msg--user {
    justify-content: flex-end;
}

.chat-msg--assistant {
    justify-content: flex-start;
}

.chat-bubble {
    max-width: 85%;
    padding: 8px 12px;
    border-radius: 10px;
    font-size: 0.88rem;
    line-height: 1.5;
    word-wrap: break-word;
}

.chat-msg--user .chat-bubble {
    background: #dbeafe;
    color: #1e3a5f;
    border-bottom-right-radius: 2px;
}

.chat-msg--assistant .chat-bubble {
    background: #f3f4f6;
    color: #333;
    border-bottom-left-radius: 2px;
}

.chat-msg--assistant .chat-bubble p {
    margin: 0.4em 0;
}

.chat-msg--assistant .chat-bubble p:first-child {
    margin-top: 0;
}

.chat-sources {
    padding: 6px 10px;
    margin-top: 4px;
    background: #fafbfc;
    border: 1px solid #e5e7eb;
    border-radius: 6px;
    font-size: 0.75rem;
    color: #555;
}

.chat-sources__title {
    font-weight: 600;
    margin-bottom: 4px;
}

.chat-sources__item {
    padding: 2px 0;
    border-bottom: 1px solid #f0f0f0;
}

.chat-sources__item:last-child {
    border-bottom: none;
}

.chat-panel__input-area {
    display: flex;
    gap: 8px;
    padding: 10px 12px;
    border-top: 1px solid #ddd;
    background: #fafafa;
    flex-shrink: 0;
}

.chat-panel__input {
    flex: 1;
    resize: none;
    border: 1px solid #ccc;
    border-radius: 8px;
    padding: 8px 10px;
    font-size: 0.85rem;
    font-family: sans-serif;
    outline: none;
}

.chat-panel__input:focus {
    border-color: #4a90d9;
}

.chat-panel__send {
    padding: 8px 16px;
    background: #4a90d9;
    color: #fff;
    border: none;
    border-radius: 8px;
    font-weight: 600;
    font-size: 0.85rem;
    cursor: pointer;
    white-space: nowrap;
    align-self: flex-end;
}

.chat-panel__send:hover {
    background: #357abd;
}

.chat-panel__send:disabled {
    background: #aaa;
    cursor: not-allowed;
}
