@import url('https://fonts.googleapis.com/css2?family=Lexend:wght@400;500;600;700&display=swap');

:root {
    --bg: #f4f4f9;
    --card-bg: #ffffff;
    --primary: #6200ea;
    --success: #00c853;
    --border: #ccc;
    --intro: #1e88e5;
    --recording: #00897b;
    --choice: #f9a825;
    --first: #8e24aa;
    --standard: #546e7a;
    --danger: #d32f2f;
}

* {
    font-family: 'Lexend', 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}

body {
    font-family: 'Lexend', 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    font-weight: 400;
    background-color: var(--bg);
    margin: 0;
    padding: 20px;
}

.container {
    max-width: 900px;
    margin: 0 auto;
}

h1 {
    font-weight: 700;
}

header {
    background: var(--card-bg);
    padding: 20px;
    border-radius: 8px;
    box-shadow: 0 2px 5px rgba(0,0,0,0.1);
    margin-bottom: 20px;
    position: sticky;
    top: 0;
    z-index: 100;
}

.meta-controls {
    margin: 15px 0;
}

.meta-controls input {
    font-size: 1.2rem;
    padding: 8px;
    width: 100%;
    box-sizing: border-box;
}

.node-card {
    background: var(--card-bg);
    border-left: 5px solid var(--primary);
    padding: 20px;
    margin-bottom: 20px;
    border-radius: 4px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
}

.node-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
    padding-bottom: 10px;
    border-bottom: 1px solid #eee;
}

.node-header-left {
    display: flex;
    align-items: center;
    gap: 10px;
}

.node-header-actions {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
    justify-content: flex-end;
}

.node-action-buttons {
    display: flex;
    gap: 6px;
}

.node-type-intro { border-left-color: var(--intro); background: #f5f8ff; }
.node-type-recording { border-left-color: var(--recording); background: #f3fbf8; }
.node-type-choice { border-left-color: var(--choice); background: #fffaf2; }
.node-type-first { border-left-color: var(--first); background: #fbf5ff; }
.node-type-standard { border-left-color: var(--standard); background: #f6f7f8; }

.form-group {
    margin-bottom: 15px;
}

.form-group label {
    display: block;
    font-weight: bold;
    margin-bottom: 5px;
    font-size: 0.9rem;
    color: #555;
}

input[type="text"], 
input[type="number"], 
textarea, 
select {
    width: 100%;
    padding: 10px;
    border: 1px solid var(--border);
    border-radius: 4px;
    box-sizing: border-box;
    font-family: inherit;
}

textarea {
    min-height: 80px;
    resize: vertical;
}

.btn {
    padding: 10px 20px;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-weight: 600;
    color: white;
    text-decoration: none;
    display: inline-block;
}

.btn.primary { background-color: var(--primary); }
.btn.success { background-color: var(--success); }
.btn.secondary { background-color: #455a64; }
.btn.orange { background-color: #ff9800; }

.actions {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.add-node-row {
    display: flex;
    justify-content: center;
    margin: 20px 0 10px;
}

.add-node-row .btn {
    width: 100%;
    max-width: 900px;
}

.code-display {
    margin-top: 8px;
    font-size: 0.9rem;
    color: #444;
    font-weight: 600;
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px;
}

.last-saved {
    color: #666;
    font-weight: 500;
}

.icon-btn {
    border: 1px solid var(--border);
    background: var(--card-bg);
    border-radius: 4px;
    padding: 4px 6px;
    cursor: pointer;
    line-height: 1;
    font-size: 0.9rem;
}

.icon-btn:hover {
    background: #f0f0f0;
}

.icon-btn.ghost {
    background: transparent;
}

.icon-btn.danger {
    color: var(--danger);
    border-color: #f3c5c5;
}

/* Lightweight Tooltip (hover + focus) */
[data-tooltip] {
    position: relative;
}

[data-tooltip]::after {
    content: attr(data-tooltip);
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    background: #333;
    color: #fff;
    padding: 6px 8px;
    border-radius: 4px;
    font-size: 0.8rem;
    white-space: nowrap;
    box-shadow: 0 2px 8px rgba(0,0,0,0.2);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.15s ease, transform 0.15s ease;
    transform-origin: bottom center;
    z-index: 500;
}

[data-tooltip]:hover::after,
[data-tooltip]:focus::after {
    opacity: 1;
    transform: translateX(-50%) translateY(-4px);
}

#copy-code-btn,
#copy-code-btn:hover {
    border: none;
    background: none;
    padding: 4px 6px;
    padding-left: 0px !important;
}

.jump-link {
    background: none;
    border: none;
    color: var(--primary);
    text-decoration: underline;
    cursor: pointer;
    font-size: 0.8rem;
    padding: 2px 0 0;
}

.jump-warning {
    color: var(--danger);
    font-size: 0.8rem;
    margin-top: 4px;
}

.input-warning {
    border-color: var(--danger);
    background: #fff6f6;
}

.jump-highlight {
    animation: jumpFlash 0.8s ease;
}

@keyframes jumpFlash {
    0% { box-shadow: 0 0 0 0 rgba(98, 0, 234, 0.25); }
    50% { box-shadow: 0 0 0 6px rgba(98, 0, 234, 0.18); }
    100% { box-shadow: 0 0 0 0 rgba(98, 0, 234, 0.0); }
}

/* Specific Phase Styling */
.student-block, .choice-block {
    background: #f9f9f9;
    padding: 10px;
    border: 1px solid #e0e0e0;
    margin-bottom: 10px;
}

/* Video Player Styling */
.video-player-container {
    margin: 15px 0;
    border-radius: 4px;
    overflow: hidden;
    background: #000;
    display: flex;
    justify-content: center;
    align-items: center;
}

.scenario-video {
    width: 100%;
    height: auto;
    max-width: 100%;
    max-height: 400px;
    display: block;
}

@media (max-width: 600px) {
    .scenario-video {
        max-height: 250px;
    }
}

.modal {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.4);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 200;
    padding: 15px;
}

.modal.open {
    display: flex;
}

.modal-content {
    background: var(--card-bg);
    border-radius: 8px;
    padding: 20px;
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.2);
    max-width: 420px;
    width: 100%;
    position: relative;
}

.modal-close {
    position: absolute;
    top: 10px;
    right: 10px;
    background: none;
    border: none;
    font-size: 1.1rem;
    cursor: pointer;
    color: #666;
}

.modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    margin-top: 10px;
}

/* Header layout */
.header-top {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.title-row {
    display: flex;
    align-items: center;
    gap: 10px;
}

.unsaved-pill {
    background: #fff0f0;
    color: var(--danger);
    border: 1px solid #ffdada;
    border-radius: 12px;
    padding: 4px 10px;
    font-size: 0.85rem;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.unsaved-pill::before {
    content: '';
    width: 8px;
    height: 8px;
    background: var(--danger);
    display: inline-block;
    border-radius: 50%;
}

.header-top h1 {
    margin: 0;
}

.search-toggle {
    font-size: 1.2rem;
    padding: 8px 12px;
}

/* Search Overlay */
.search-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    display: none;
    align-items: flex-start;
    justify-content: center;
    z-index: 300;
    padding: 60px 15px 15px;
    backdrop-filter: blur(2px);
}

.search-overlay.open {
    display: flex;
}

.search-container {
    background: var(--card-bg);
    border-radius: 12px;
    width: 100%;
    max-width: 600px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
    overflow: hidden;
    max-height: 80vh;
    display: flex;
    flex-direction: column;
}

.search-header {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 16px;
    border-bottom: 1px solid #eee;
}

.search-header input {
    flex: 1;
    font-size: 1.1rem;
    border: none;
    outline: none;
    padding: 8px 0;
}

.search-header .icon-btn {
    font-size: 1rem;
    padding: 8px 10px;
}

.search-results {
    overflow-y: auto;
    max-height: calc(80vh - 70px);
}

.search-results:empty::before {
    content: 'Start typing to search...';
    display: block;
    padding: 20px;
    color: #888;
    text-align: center;
}

.search-result-item {
    padding: 12px 16px;
    border-bottom: 1px solid #f0f0f0;
    cursor: pointer;
    transition: background 0.15s;
}

.search-result-item:hover {
    background: #f5f5ff;
}

.search-result-item:last-child {
    border-bottom: none;
}

.search-result-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 4px;
}

.search-result-id {
    font-weight: 600;
    color: var(--primary);
}

.search-result-type {
    font-size: 0.75rem;
    background: #eee;
    padding: 2px 8px;
    border-radius: 10px;
    color: #666;
}

.search-result-preview {
    font-size: 0.85rem;
    color: #666;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.search-result-preview mark {
    background: #fff3cd;
    color: inherit;
    padding: 0 2px;
    border-radius: 2px;
}

.search-no-results {
    padding: 30px 20px;
    text-align: center;
    color: #888;
}

/* Mobile adjustments */
@media (max-width: 600px) {
    .search-overlay {
        padding: 20px 10px 10px;
    }
    
    .search-container {
        max-height: 90vh;
        border-radius: 8px;
    }
    
    .search-results {
        max-height: calc(90vh - 70px);
    }
    
    .search-header input {
        font-size: 1rem;
    }
}