/* GraphTutor - Graph + Panel layout */

/* Override tutor.css defaults for graphtutor-app */
body.graphtutor-app {
    background: #1a1d23;
    color: #e0e0e0;
    overflow: hidden;
    height: 100vh;
    display: flex;
    flex-direction: column;
}

/* ── Header ──────────────────────────────────────────────── */
#app-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 20px;
    height: 52px;
    background: #22252b;
    border-bottom: 1px solid #333;
    flex-shrink: 0;
    z-index: 100;
}

#app-header .header-left h1 {
    font-size: 1.2rem;
    font-weight: 700;
    color: #7c8cf5;
    margin: 0;
}

#app-header .header-center {
    font-size: 0.85rem;
    color: #999;
}

#app-header .header-right {
    display: flex;
    align-items: center;
    gap: 10px;
}

#user-email {
    font-size: 0.85rem;
    color: #aaa;
}

/* ── Buttons ─────────────────────────────────────────────── */
.gt-btn {
    border: none;
    border-radius: 6px;
    padding: 7px 16px;
    font-size: 0.85rem;
    cursor: pointer;
    transition: background 0.15s, opacity 0.15s;
}

.gt-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.gt-btn-primary {
    background: #667eea;
    color: #fff;
}

.gt-btn-primary:hover:not(:disabled) {
    background: #5568d4;
}

.gt-btn-text {
    background: transparent;
    color: #7c8cf5;
    padding: 5px 10px;
}

.gt-btn-text:hover {
    background: rgba(124, 140, 245, 0.1);
}

.gt-btn-icon {
    background: transparent;
    border: none;
    color: #999;
    font-size: 1.4rem;
    cursor: pointer;
    padding: 4px 8px;
    line-height: 1;
    border-radius: 4px;
}

.gt-btn-icon:hover {
    color: #fff;
    background: rgba(255, 255, 255, 0.1);
}

.gt-btn-danger {
    background: transparent;
    color: #e57373;
    border: 1px solid #e57373;
}

.gt-btn-danger:hover {
    background: rgba(229, 115, 115, 0.15);
}

/* ── Auth gate ───────────────────────────────────────────── */
#auth-gate {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
}

#auth-gate .auth-message {
    text-align: center;
    max-width: 400px;
}

#auth-gate .auth-message h2 {
    color: #e0e0e0;
    margin-bottom: 12px;
}

#auth-gate .auth-message p {
    color: #999;
    margin-bottom: 24px;
}

/* ── Toolbar ─────────────────────────────────────────────── */
#toolbar {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 16px;
    background: #22252b;
    border-bottom: 1px solid #333;
    flex-shrink: 0;
}

#toolbar input[type="text"] {
    padding: 7px 12px;
    border: 1px solid #444;
    border-radius: 6px;
    background: #2a2d35;
    color: #e0e0e0;
    font-size: 0.9rem;
    outline: none;
    transition: border-color 0.15s;
}

#toolbar input[type="text"]:focus {
    border-color: #667eea;
}

#concept-input {
    flex: 1;
    max-width: 400px;
}

#search-input {
    width: 200px;
}

/* ── Similar warning ─────────────────────────────────────── */
#similar-warning {
    padding: 8px 16px;
    background: #3a3520;
    border-bottom: 1px solid #555530;
    font-size: 0.85rem;
    color: #e8d44d;
    display: flex;
    align-items: center;
    gap: 8px;
}

/* ── Main area ───────────────────────────────────────────── */
#app-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

#main-area {
    flex: 1;
    display: flex;
    overflow: hidden;
    position: relative;
}

/* ── Graph container ─────────────────────────────────────── */
#graph-container {
    flex: 1;
    position: relative;
    overflow: hidden;
}

#graph-svg {
    width: 100%;
    height: 100%;
    display: block;
}

#graph-empty {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    text-align: center;
    color: #666;
    font-size: 1rem;
}

/* ── Graph nodes & edges ─────────────────────────────────── */
.graph-edge {
    stroke: #444;
    stroke-width: 1.5;
    fill: none;
}

.graph-edge.highlighted {
    stroke: #667eea;
    stroke-width: 2.5;
}

.graph-node {
    cursor: pointer;
}

.graph-node circle {
    fill: #2a2d35;
    stroke: #555;
    stroke-width: 2;
    transition: stroke 0.2s, stroke-width 0.2s;
}

.graph-node:hover circle {
    stroke: #7c8cf5;
    stroke-width: 3;
}

.graph-node.selected circle {
    stroke: #667eea;
    stroke-width: 3;
    filter: drop-shadow(0 0 6px rgba(102, 126, 234, 0.5));
}

.graph-node text {
    fill: #ccc;
    font-size: 11px;
    text-anchor: middle;
    pointer-events: none;
    user-select: none;
}

/* Knowledge-level ring colors — set via JS */
.graph-node .knowledge-ring {
    fill: none;
    stroke-width: 3;
    stroke-linecap: round;
}

/* ── Tutor panel ─────────────────────────────────────────── */
#tutor-panel {
    width: 520px;
    min-width: 380px;
    background: #f8f9fc;
    border-left: 1px solid #333;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    color: #333;
}

#panel-header {
    padding: 14px 16px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: #fff;
    display: flex;
    align-items: center;
    gap: 12px;
    flex-shrink: 0;
}

#panel-header #btn-close-panel {
    color: rgba(255, 255, 255, 0.8);
    font-size: 1.5rem;
}

#panel-header #btn-close-panel:hover {
    color: #fff;
    background: rgba(255, 255, 255, 0.15);
}

#panel-title {
    flex: 1;
    font-size: 1.1rem;
    font-weight: 600;
    margin: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

#panel-knowledge-bar {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
}

.knowledge-track {
    width: 80px;
    height: 6px;
    background: rgba(255, 255, 255, 0.25);
    border-radius: 3px;
    overflow: hidden;
}

#knowledge-fill {
    height: 100%;
    background: #4caf50;
    border-radius: 3px;
    transition: width 0.4s ease;
    width: 0%;
}

#knowledge-label {
    font-size: 0.8rem;
    opacity: 0.9;
    min-width: 30px;
}

/* ── Panel infographic ───────────────────────────────────── */
#panel-infographic {
    max-height: 200px;
    overflow: hidden;
    cursor: pointer;
}

#panel-infographic.hidden {
    display: none;
}

#panel-hero-img {
    width: 100%;
    display: block;
    object-fit: cover;
}

/* ── Panel connections ───────────────────────────────────── */
#panel-connections {
    padding: 10px 16px;
    border-bottom: 1px solid #e0e0e0;
    flex-shrink: 0;
}

#panel-connections h3 {
    font-size: 0.8rem;
    text-transform: uppercase;
    color: #888;
    margin-bottom: 6px;
}

#connections-list {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.connection-chip {
    padding: 4px 10px;
    background: #e8ecf1;
    border-radius: 12px;
    font-size: 0.8rem;
    color: #555;
    cursor: pointer;
    transition: background 0.15s;
    white-space: nowrap;
}

.connection-chip:hover {
    background: #d0d6e0;
    color: #333;
}

/* ── Curriculum display inside panel ─────────────────────── */
#tutor-panel #curriculumDisplay {
    padding: 10px 16px;
    border-bottom: 1px solid #e0e0e0;
    max-height: 200px;
    overflow-y: auto;
    font-size: 0.85rem;
}

/* ── Chat container inside panel ─────────────────────────── */
#tutor-panel #chatContainer {
    flex: 1;
    overflow-y: auto;
    padding: 12px 16px;
    background: #fff;
}

/* ── Input area ──────────────────────────────────────────── */
#responseGroup {
    padding: 10px 16px;
    border-top: 1px solid #e0e0e0;
    background: #f8f9fc;
    flex-shrink: 0;
}

#inputArea {
    display: flex;
    gap: 8px;
    align-items: flex-end;
}

#responseInput {
    flex: 1;
    padding: 8px 12px;
    border: 1px solid #ccc;
    border-radius: 8px;
    font-size: 0.9rem;
    resize: none;
    outline: none;
    font-family: inherit;
    background: #fff;
    color: #333;
}

#responseInput:focus {
    border-color: #667eea;
}

#inputArea #sendBtn {
    flex-shrink: 0;
    height: 38px;
}

/* ── Panel footer ────────────────────────────────────────── */
#panel-footer {
    padding: 10px 16px;
    border-top: 1px solid #e0e0e0;
    text-align: center;
    flex-shrink: 0;
}

/* ── Status bar ──────────────────────────────────────────── */
#status-bar {
    height: 28px;
    padding: 0 16px;
    display: flex;
    align-items: center;
    background: #1e2127;
    border-top: 1px solid #333;
    flex-shrink: 0;
    font-size: 0.78rem;
    color: #777;
}

/* ── Spinner (used by tutor.js) ──────────────────────────── */
@keyframes spin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

.spinner {
    width: 20px;
    height: 20px;
    border: 2px solid #e0e0e0;
    border-top: 2px solid #667eea;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

/* ── Utility ─────────────────────────────────────────────── */
.hidden {
    display: none !important;
}

/* ── Mobile ──────────────────────────────────────────────── */
@media (max-width: 768px) {
    #tutor-panel {
        position: fixed;
        top: 52px;
        left: 0;
        right: 0;
        bottom: 0;
        width: 100%;
        z-index: 200;
    }

    #search-input {
        display: none;
    }

    #concept-input {
        max-width: unset;
    }
}
