/* ── Wikidata Graph Explorer ─────────────────────────────────────────────── */

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
    height: 100%;
    background: #0d1117;
    color: #e6edf3;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    overflow-x: hidden;
}

/* ── Page wrapper ────────────────────────────────────────────────────────── */

.page-wrapper {
    display: flex;
    flex-direction: column;
    height: 100vh;
    padding: 10px 14px 0;
}

/* ── Two-column app layout ───────────────────────────────────────────────── */

.app-layout {
    display: flex;
    gap: 12px;
    flex: 1;
    min-height: 0;
    padding-bottom: 10px;
}

/* ── Left panel ──────────────────────────────────────────────────────────── */

.left-panel {
    width: 340px;
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    gap: 16px;
    overflow-y: auto;
    scrollbar-width: thin;
    scrollbar-color: rgba(255,255,255,0.1) transparent;
}

.back-to-projects {
    display: inline-block;
    padding: 6px 12px;
    color: #4fc3f7;
    text-decoration: none;
    font-size: 13px;
    border: 1px solid rgba(79,195,247,0.3);
    border-radius: 6px;
    transition: background 0.2s, border-color 0.2s;
    align-self: flex-start;
}
.back-to-projects:hover { background: rgba(79,195,247,0.1); border-color: #4fc3f7; }

/* ── Header ─────────────────────────────────────────────────────────────── */

.project-header {
    padding: 4px 0;
}
.project-header h1 {
    font-size: clamp(1.3rem, 2vw, 1.6rem);
    font-weight: 700;
    background: linear-gradient(135deg, #ff7043, #ffd54f, #4fc3f7);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}
.project-header .subtitle {
    margin-top: 4px;
    color: rgba(230,237,243,0.55);
    font-size: 0.8rem;
    line-height: 1.4;
}

/* ── Search section ──────────────────────────────────────────────────────── */

.search-section {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.search-area {
    position: relative;
    width: 100%;
}

.search-row {
    display: flex;
    gap: 6px;
}

.search-row input {
    flex: 1;
    min-width: 0;
    padding: 11px 14px;
    background: #161b22;
    border: 1px solid rgba(255,255,255,0.1);
    border-radius: 8px;
    color: #e6edf3;
    font-size: 14px;
    outline: none;
    transition: border-color 0.2s;
}
.search-row input:focus { border-color: #ff7043; }
.search-row input::placeholder { color: rgba(230,237,243,0.35); font-size: 13px; }

.btn-search {
    padding: 11px 16px;
    background: #ff7043;
    border: none;
    border-radius: 8px;
    color: #fff;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s, transform 0.1s;
    white-space: nowrap;
    flex-shrink: 0;
}
.btn-search:hover { background: #ff5722; }
.btn-search:active { transform: scale(0.97); }

/* Suggestions — categorized accordion */

.suggestions-list {
    display: flex;
    flex-direction: column;
    gap: 0;
}

.suggestion-category-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.07em;
    color: rgba(230,237,243,0.45);
    padding: 6px 4px;
    cursor: pointer;
    border-bottom: 1px solid rgba(255,255,255,0.06);
    transition: color 0.2s;
    user-select: none;
}
.suggestion-category-header:hover { color: rgba(230,237,243,0.75); }
.suggestion-category-header.open  { color: #ff7043; border-bottom-color: rgba(255,112,67,0.3); }

.suggestion-caret {
    font-size: 10px;
    transition: transform 0.2s;
}
.suggestion-category-header.open .suggestion-caret { transform: rotate(180deg); }

.suggestions-body {
    display: none;
    flex-direction: column;
    gap: 4px;
    padding: 4px 0 8px;
}
.suggestions-body.open { display: grid; grid-template-columns: 1fr 1fr; gap: 4px; }

.suggestion-chip {
    padding: 8px 10px;
    background: rgba(255,112,67,0.1);
    border: 1px solid rgba(255,112,67,0.3);
    border-radius: 16px;
    color: #ff7043;
    font-size: 13px;
    cursor: pointer;
    transition: background 0.2s, border-color 0.2s;
    text-align: center;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.suggestion-chip:hover { background: rgba(255,112,67,0.22); border-color: #ff7043; }

/* Dropdown */

.search-dropdown {
    display: none;
    position: absolute;
    top: calc(100% + 4px);
    left: 0;
    right: 0;
    background: #161b22;
    border: 1px solid rgba(255,255,255,0.12);
    border-radius: 8px;
    overflow: hidden;
    z-index: 100;
    box-shadow: 0 8px 24px rgba(0,0,0,0.5);
    max-height: 280px;
    overflow-y: auto;
}

.dropdown-item {
    padding: 10px 14px;
    cursor: pointer;
    border-bottom: 1px solid rgba(255,255,255,0.06);
    transition: background 0.15s;
}
.dropdown-item:last-child { border-bottom: none; }
.dropdown-item:hover { background: rgba(255,112,67,0.1); }
.dropdown-label { font-size: 13px; font-weight: 600; color: #e6edf3; }
.dropdown-desc  { font-size: 11px; color: rgba(230,237,243,0.5); margin-top: 2px;
                  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* Status message */

.status-msg {
    display: none;
    font-size: 13px;
    padding: 6px 10px;
    border-radius: 6px;
}
.status-loading { color: #ffd54f; background: rgba(255,213,79,0.1); border: 1px solid rgba(255,213,79,0.3); }
.status-error   { color: #ff7043; background: rgba(255,112,67,0.1); border: 1px solid rgba(255,112,67,0.3); }
.status-success { color: #66bb6a; background: rgba(102,187,106,0.1); border: 1px solid rgba(102,187,106,0.3); }
.status-info    { color: #4fc3f7; background: rgba(79,195,247,0.1); border: 1px solid rgba(79,195,247,0.3); }

/* ── Right panel ─────────────────────────────────────────────────────────── */

.right-panel {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
}

/* Empty state */

.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    flex: 1;
    min-height: 300px;
    border: 1px dashed rgba(255,255,255,0.1);
    border-radius: 12px;
    gap: 12px;
    color: rgba(230,237,243,0.35);
}
.empty-icon { font-size: 3rem; opacity: 0.5; }
.empty-state p { font-size: 14px; }

/* Graph container */

.graph-container {
    display: none;
    flex-direction: column;
    flex: 1;
    min-height: 0;
}

.canvas-wrapper {
    position: relative;
    flex: 1;
    min-height: 400px;
    background: #0d1117;
    border: 1px solid rgba(255,255,255,0.08);
    border-radius: 10px;
    overflow: hidden;
}

#graphCanvas {
    width: 100%;
    height: 100%;
}

/* ── Graph overlays ──────────────────────────────────────────────────────── */

.graph-legend {
    position: absolute;
    bottom: 10px;
    left: 10px;
    display: flex;
    flex-direction: column;
    gap: 5px;
    background: rgba(13,17,23,0.75);
    border: 1px solid rgba(255,255,255,0.08);
    border-radius: 8px;
    padding: 8px 10px;
    pointer-events: none;
}
.legend-item {
    display: flex;
    align-items: center;
    gap: 7px;
    font-size: 11px;
    color: rgba(230,237,243,0.6);
}
.legend-swatch {
    width: 14px;
    height: 14px;
    border-radius: 2px;
    flex-shrink: 0;
}
.legend-diamond {
    transform: rotate(45deg);
    width: 10px;
    height: 10px;
    border-radius: 1px;
}

.graph-toolbar {
    position: absolute;
    top: 10px;
    right: 10px;
    display: flex;
    gap: 6px;
}

.btn-tool {
    padding: 6px 12px;
    background: rgba(13,17,23,0.85);
    border: 1px solid rgba(255,255,255,0.15);
    border-radius: 6px;
    color: rgba(230,237,243,0.7);
    font-size: 12px;
    cursor: pointer;
    transition: background 0.2s, color 0.2s;
}
.btn-tool:hover { background: rgba(255,112,67,0.15); color: #ff7043; border-color: rgba(255,112,67,0.4); }

.graph-stats {
    position: absolute;
    bottom: 10px;
    right: 10px;
    display: flex;
    gap: 12px;
    font-size: 12px;
    color: rgba(230,237,243,0.4);
    background: rgba(13,17,23,0.7);
    padding: 4px 10px;
    border-radius: 6px;
}
.stat-item span { color: rgba(230,237,243,0.8); font-weight: 600; }

/* ── Responsive ──────────────────────────────────────────────────────────── */

@media (max-width: 768px) {
    .page-wrapper { height: auto; }
    .app-layout { flex-direction: column; height: auto; }
    .left-panel { width: 100%; overflow-y: visible; }
.canvas-wrapper { min-height: 60vh; }
    .about-grid { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 480px) {
    .canvas-wrapper { min-height: 55vh; }
    .about-grid { grid-template-columns: 1fr; }
    .graph-stats { display: none; }
    .suggestions-body.open { grid-template-columns: 1fr; }
}
