/* assets/css/test-mode-graph.css */

/* Scope everything under .tm-graph-wrapper to match the new container */
.tm-graph-wrapper {
    position: relative;
    width: 100%;
    height: 100%;
    overflow: hidden;
    background-color: #fff;
    font-family: 'Segoe UI', -apple-system, BlinkMacSystemFont, Roboto, sans-serif;
}

.tm-graph-wrapper canvas {
    display: block;
    cursor: crosshair;
    touch-action: none;
    user-select: none;
    width: 100%;
    height: 100%;
}

/* ===== Control Panel ===== */
#tm-graph-control-panel {
    position: absolute;
    top: 12px;
    left: 12px;
    background: #fff;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    padding: 12px;
    width: 260px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    z-index: 100;
}

#tm-graph-control-panel h3 {
    color: #333;
    font-size: 13px;
    font-weight: 600;
    margin-bottom: 10px;
}

.tm-graph-input-row {
    display: flex;
    gap: 6px;
    margin-bottom: 10px;
}

#tm-graph-function-input {
    flex: 1;
    background: #fff;
    border: 1px solid #ddd;
    border-radius: 4px;
    padding: 8px 10px;
    color: #333;
    font-size: 13px;
    font-family: monospace;
    outline: none;
}

#tm-graph-function-input:focus {
    border-color: #2563eb;
}

#tm-graph-function-input::placeholder {
    color: #999;
}

.tm-graph-btn {
    background: #2563eb;
    border: none;
    border-radius: 4px;
    padding: 8px 14px;
    color: #fff;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
}

.tm-graph-btn:hover {
    background: #1d4ed8;
}

.tm-graph-btn-secondary {
    background: #f5f5f5;
    color: #333;
    border: 1px solid #ddd;
}

.tm-graph-btn-secondary:hover {
    background: #eee;
}

#tm-graph-functions-list {
    max-height: 180px;
    overflow-y: auto;
    margin-bottom: 10px;
}

.tm-graph-function-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 8px;
    background: #f9f9f9;
    border-radius: 4px;
    margin-bottom: 4px;
}

.tm-graph-function-item:hover {
    background: #f0f0f0;
}

.tm-graph-function-color {
    width: 10px;
    height: 10px;
    border-radius: 2px;
    flex-shrink: 0;
}

.tm-graph-function-expr {
    flex: 1;
    color: #333;
    font-size: 12px;
    font-family: monospace;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.tm-graph-function-toggle {
    width: 16px;
    height: 16px;
    background: #fff;
    border: 1.5px solid #ccc;
    border-radius: 3px;
    cursor: pointer;
}

.tm-graph-function-toggle.active {
    background: #2563eb;
    border-color: #2563eb;
}

.tm-graph-function-toggle.active::after {
    content: '✓';
    color: #fff;
    font-size: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.tm-graph-function-remove {
    width: 18px;
    height: 18px;
    background: none;
    border: none;
    color: #999;
    cursor: pointer;
    font-size: 14px;
    border-radius: 3px;
}

.tm-graph-function-remove:hover {
    color: #e53e3e;
    background: #fee;
}

.tm-graph-actions-row {
    display: flex;
    gap: 8px;
}

.tm-graph-actions-row .tm-graph-btn {
    flex: 1;
}

/* ===== Coordinate Display ===== */
#tm-graph-coord-display {
    position: absolute;
    background: #fff;
    border: 1px solid #ddd;
    border-radius: 4px;
    padding: 4px 8px;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.15s;
    z-index: 50;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.1);
}

#tm-graph-coord-display.visible {
    opacity: 1;
}

#tm-graph-coord-display .coords {
    color: #333;
    font-size: 11px;
    font-family: monospace;
}

#tm-graph-coord-display .fn-label {
    color: #2563eb;
    font-size: 10px;
    margin-top: 2px;
}

/* ===== Dropped Points ===== */
.point-marker {
    position: absolute;
    transform: translate(-50%, -50%);
    pointer-events: none;
    z-index: 40;
}

.point-marker .dot {
    width: 10px;
    height: 10px;
    background: #ff6b6b;
    border: 2px solid #fff;
    border-radius: 50%;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

.point-marker .label {
    position: absolute;
    top: 14px;
    left: 50%;
    transform: translateX(-50%);
    background: #fff;
    border: 1px solid #ddd;
    border-radius: 4px;
    padding: 3px 6px;
    color: #333;
    font-size: 10px;
    font-family: monospace;
    white-space: nowrap;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

/* ===== Hint ===== */
#tm-graph-hint {
    position: absolute;
    bottom: 12px;
    left: 50%;
    transform: translateX(-50%);
    background: #fff;
    border: 1px solid #e0e0e0;
    border-radius: 16px;
    padding: 6px 12px;
    color: #666;
    font-size: 11px;
    pointer-events: none;
}

/* ===== Floating AI Button ===== */
#tm-graph-ai-button {
    position: absolute;
    bottom: 20px;
    right: 20px;
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: #fff;
    border: 1px solid #e0e0e0;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    cursor: pointer;
    z-index: 200;
    overflow: hidden;
    transition: transform 0.2s, box-shadow 0.2s;
}

#tm-graph-ai-button:hover {
    transform: scale(1.05);
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.2);
}

#tm-graph-ai-button img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* ===== Chat Panel ===== */
#tm-graph-chat-panel {
    position: absolute;
    bottom: 90px;
    right: 20px;
    width: 450px;
    max-height: 90vh;
    background: #fff;
    border: 1px solid #e0e0e0;
    border-radius: 12px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
    display: none;
    flex-direction: column;
    z-index: 150;
    overflow: hidden;
}

#tm-graph-chat-panel.open {
    display: flex;
}

#tm-graph-chat-header {
    padding: 12px 16px;
    background: #f9f9f9;
    border-bottom: 1px solid #e0e0e0;
    display: flex;
    align-items: center;
    gap: 10px;
}

#tm-graph-chat-header img {
    width: 28px;
    height: 28px;
    border-radius: 50%;
}

#tm-graph-chat-header span {
    font-size: 14px;
    font-weight: 600;
    color: #333;
}

#tm-graph-chat-close {
    margin-left: auto;
    background: none;
    border: none;
    font-size: 18px;
    color: #666;
    cursor: pointer;
    padding: 4px 8px;
    border-radius: 4px;
}

#tm-graph-chat-close:hover {
    background: #eee;
}

#tm-graph-chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 12px;
    max-height: 80vh;
    min-height: 400px;
}

.tm-graph-chat-msg {
    margin-bottom: 12px;
    max-width: 90%;
}

.tm-graph-chat-msg.user {
    margin-left: auto;
    text-align: right;
}

.tm-graph-chat-msg .bubble {
    display: inline-block;
    padding: 10px 14px;
    border-radius: 12px;
    font-size: 14px;
    line-height: 1.6;
    text-align: left;
}

.tm-graph-chat-msg.user .bubble {
    background: #2563eb;
    color: #fff;
    border-bottom-right-radius: 4px;
}

.tm-graph-chat-msg.ai .bubble {
    background: #f5f5f5;
    color: #333;
    border-bottom-left-radius: 4px;
}

/* Math and Markdown (Scoped) */
.tm-graph-chat-msg.ai .bubble p {
    margin: 0 0 8px 0;
}

.tm-graph-chat-msg.ai .bubble code {
    background: #e8e8e8;
    padding: 2px 6px;
    border-radius: 4px;
    font-family: 'Monaco', 'Consolas', monospace;
}

#tm-graph-chat-input-row {
    padding: 12px;
    border-top: 1px solid #e0e0e0;
    display: flex;
    gap: 8px;
}

#tm-graph-chat-input {
    flex: 1;
    border: 1px solid #ddd;
    border-radius: 20px;
    padding: 8px 14px;
    font-size: 13px;
    outline: none;
}

#tm-graph-chat-input:focus {
    border-color: #2563eb;
}

#tm-graph-chat-send {
    background: #2563eb;
    border: none;
    border-radius: 50%;
    width: 36px;
    height: 36px;
    color: #fff;
    cursor: pointer;
    font-size: 16px;
}

#tm-graph-chat-send:hover {
    background: #1d4ed8;
}

#tm-graph-chat-send:disabled {
    background: #ccc;
    cursor: not-allowed;
}

/* ===== Coordinates Table Panel ===== */
.tm-coords-panel {
    display: none;
    position: absolute;
    bottom: 12px;
    left: 12px;
    background: var(--surface-card, #1E1E1E);
    border: 1px solid var(--border-color, #333);
    border-radius: 8px;
    padding: 12px 16px;
    min-width: 300px;
    max-width: 90%;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
    z-index: 100;
}

.tm-coords-panel h4 {
    color: var(--text-secondary, #B5B5B5);
    font-size: 12px;
    font-weight: 600;
    margin: 0 0 10px 0;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.tm-coords-panel .table-content {
    overflow-x: auto;
}

.tm-coords-panel table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}

.tm-coords-panel th {
    padding: 8px 12px;
    text-align: center;
    color: var(--text-secondary, #B5B5B5);
    font-weight: 600;
    border-bottom: 2px solid var(--border-color, #333);
}

.tm-coords-panel td {
    padding: 8px 12px;
    text-align: center;
    color: var(--text-primary, #F5F5F5);
}

.tm-coords-panel tr {
    border-bottom: 1px solid var(--border-color, #333);
}

.tm-coords-panel tr:last-child {
    border-bottom: none;
}