* { box-sizing: border-box; }

/* Grade badge animation */
@keyframes gradeShine {
    0%, 100% { box-shadow: 0 4px 15px -3px rgba(251,191,36,0.4); }
    50% { box-shadow: 0 4px 20px -3px rgba(251,191,36,0.2), 0 0 12px 4px rgba(251,191,36,0.1); }
}
@keyframes slideDown {
    from { transform: translateY(-10px); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}
body {
    margin: 0;
    font-family: 'Inter', sans-serif;
    background-color: #020617;
    color: #f1f5f9;
    min-height: 100vh;
}

::-webkit-scrollbar { width: 8px; }
::-webkit-scrollbar-track { background: #0f172a; }
::-webkit-scrollbar-thumb { background: #334155; border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: #475569; }

.navbar {
    background: #0f172a;
    border-bottom: 1px solid #1e293b;
}

.tool-card {
    background: #0f172a;
    border: 1px solid #1e293b;
    transition: all 0.2s ease-out;
    position: relative;
    overflow: visible;
}
.tool-card:hover {
    transform: translateY(-4px);
    border-color: #3b82f6;
    box-shadow: 0 10px 30px -10px rgba(0, 0, 0, 0.5);
}

.tool-icon-container {
    width: 64px;
    height: 64px;
    border-radius: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 16px auto;
    color: white;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
}
.custom-icon-wrap { width: 100%; height: 100%; display: flex; align-items: center; justify-content: center; }
.custom-icon-wrap svg { width: 100%; height: 100%; display: block; }

.admin-overlay {
    background: rgba(2, 6, 23, 0.9);
    backdrop-filter: blur(4px);
}

.admin-panel {
    background: #0f172a;
    border: 1px solid #334155;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}
.fade-in {
    animation: fadeIn 0.4s ease-out forwards;
}

input:focus, textarea:focus, select:focus {
    outline: none;
    border-color: #3b82f6;
    box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.2);
}

.step-card {
    transition: all 0.3s ease-out;
}

.step-images-scroll {
    scrollbar-width: thin;
    scrollbar-color: #334155 transparent;
}
.step-images-scroll::-webkit-scrollbar { height: 4px; }
.step-images-scroll::-webkit-scrollbar-thumb { background: #334155; border-radius: 2px; }

.step-images-wrapper { position: relative; }
.step-images-wrapper .scroll-fade {
    position: absolute; top: 0; right: 0; bottom: 8px; width: 48px;
    background: linear-gradient(to right, transparent, rgb(15 23 42 / 0.95));
    pointer-events: none; display: flex; align-items: center; justify-content: flex-end;
    padding-right: 4px; transition: opacity 0.3s;
}
.step-images-wrapper .scroll-fade.hidden-fade { opacity: 0; }
.step-images-wrapper .scroll-hint {
    position: absolute; bottom: 12px; right: 0;
    background: rgba(59,130,246,0.9); color: white;
    font-size: 0.7rem; font-weight: 600; padding: 2px 8px; border-radius: 9999px;
    pointer-events: none; transition: opacity 0.3s; white-space: nowrap;
}
.step-images-wrapper .scroll-hint.hidden-fade { opacity: 0; }

/* Template Marketplace Cards */
.template-card {
    background: #0f172a;
    border: 1px solid #1e293b;
    transition: all 0.2s ease-out;
    position: relative;
    overflow: hidden;
}
.template-card:hover {
    transform: translateY(-2px);
    border-color: #8b5cf6;
    box-shadow: 0 8px 25px -8px rgba(139, 92, 246, 0.3);
}
.template-feature-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 0.65rem;
    padding: 2px 8px;
    border-radius: 9999px;
    white-space: nowrap;
}

.toast {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 9999;
    padding: 12px 20px;
    border-radius: 12px;
    font-size: 14px;
    font-weight: 600;
    transform: translateX(120%);
    transition: transform 0.3s ease;
}
.toast.show { transform: translateX(0); }

#track-tabs-container::-webkit-scrollbar { height: 4px; }
#track-tabs-container::-webkit-scrollbar-thumb { background: #334155; border-radius: 2px; }

/* === DRAG & DROP === */
.step-drag-handle { cursor: grab; touch-action: none; user-select: none; color: #475569; transition: color 0.15s; }
.step-drag-handle:hover { color: #94a3b8; }
.step-drag-handle:active { cursor: grabbing; }
.drag-active { border-color: #3b82f6 !important; }
.drag-placeholder { pointer-events: none; }

/* === IMAGE UPLOAD ZONE === */
.image-upload-zone {
    border: 2px dashed #334155; border-radius: 12px; padding: 16px;
    text-align: center; cursor: pointer; transition: all 0.2s;
    background: rgba(15, 23, 42, 0.5);
}
.image-upload-zone:hover, .image-upload-zone.dragover {
    border-color: #3b82f6; background: rgba(59, 130, 246, 0.05);
}
.image-upload-zone-inner { display: flex; flex-direction: column; align-items: center; gap: 8px; }
.image-upload-icon { color: #475569; }
.image-upload-label { color: #64748b; font-size: 13px; }
.image-upload-zone.dragover .image-upload-icon { color: #3b82f6; }
.image-upload-zone.dragover .image-upload-label { color: #93c5fd; }
.image-upload-progress { width: 100%; height: 4px; background: #1e293b; border-radius: 4px; overflow: hidden; margin-top: 8px; }
.image-upload-progress-bar { height: 100%; background: linear-gradient(90deg, #3b82f6, #8b5cf6); border-radius: 4px; transition: width 0.3s; width: 0%; }

/* === RICH TEXT === */
.rich-text-wrapper { position: relative; }
.rich-text-toolbar {
    display: flex; align-items: center; gap: 2px; padding: 4px 6px;
    background: #0f172a; border: 1px solid #334155; border-bottom: none;
    border-radius: 8px 8px 0 0; flex-wrap: wrap;
}
.rich-text-toolbar button {
    padding: 4px 8px; border-radius: 4px; font-size: 12px; font-weight: 600;
    color: #94a3b8; background: transparent; border: none; cursor: pointer; transition: all 0.15s;
}
.rich-text-toolbar button:hover { background: #1e293b; color: #e2e8f0; }
.rich-text-img-chip { background: rgba(59,130,246,0.1) !important; color: #60a5fa !important; font-size: 11px !important; }
.rich-text-sep { color: #334155; margin: 0 4px; font-size: 12px; }
.rich-text-preview-toggle { margin-left: auto !important; font-size: 11px !important; color: #64748b !important; }
.rich-text-preview {
    background: #0f172a; border: 1px solid #334155; border-top: 1px dashed #334155;
    border-radius: 0 0 8px 8px; padding: 12px; font-size: 13px; color: #cbd5e1;
    line-height: 1.6; max-height: 200px; overflow-y: auto;
}
.rich-text-wrapper textarea { border-radius: 0 0 8px 8px !important; }

/* === AUTO-SAVE INDICATOR === */
.autosave-indicator {
    display: inline-flex; align-items: center; gap: 6px;
    font-size: 11px; color: #64748b; padding: 4px 10px;
    background: rgba(30, 41, 59, 0.5); border-radius: 6px;
    transition: all 0.3s;
}
.autosave-indicator.saved { color: #4ade80; }
.autosave-indicator .dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; }

/* === PREVIEW MODE === */
.editor-preview-toggle {
    display: inline-flex; background: #1e293b; border-radius: 8px; overflow: hidden; border: 1px solid #334155;
}
.editor-preview-toggle button {
    padding: 6px 14px; font-size: 12px; font-weight: 600; border: none; cursor: pointer;
    transition: all 0.15s; color: #64748b; background: transparent;
}
.editor-preview-toggle button.active { background: #3b82f6; color: white; }

/* === TRACK OVERVIEW DIAGRAM === */
.track-overview { display: flex; align-items: center; gap: 8px; padding: 12px; overflow-x: auto; }
.track-overview-node {
    flex-shrink: 0; padding: 8px 14px; border-radius: 10px; font-size: 12px; font-weight: 600;
    cursor: pointer; transition: all 0.2s; border: 1px solid #334155; background: #1e293b; color: #94a3b8;
    display: flex; flex-direction: column; align-items: center; gap: 2px;
}
.track-overview-node:hover { border-color: #8b5cf6; color: #c4b5fd; }
.track-overview-node.active { background: rgba(139, 92, 246, 0.15); border-color: #8b5cf6; color: #c4b5fd; }
.track-overview-node.decision { clip-path: polygon(50% 0%, 100% 50%, 50% 100%, 0% 50%); padding: 14px 20px; }
.track-overview-arrow { color: #334155; flex-shrink: 0; font-size: 16px; }
.track-overview-count { font-size: 10px; color: #64748b; }

/* === EDITOR THUMBNAILS === */
.editor-thumb-row { display: flex; gap: 8px; flex-wrap: wrap; padding: 4px 0; }
.editor-thumb {
    position: relative; width: 80px; height: 80px; border-radius: 8px; overflow: hidden;
    border: 1px solid #334155; background: #0f172a; flex-shrink: 0; cursor: grab;
    transition: border-color 0.2s, opacity 0.2s;
}
.editor-thumb:active { cursor: grabbing; }
.editor-thumb:hover { border-color: #3b82f6; }
.editor-thumb img { width: 100%; height: 100%; object-fit: cover; }
.editor-thumb-label {
    position: absolute; bottom: 2px; left: 2px; background: rgba(0,0,0,0.7);
    color: white; font-size: 9px; font-weight: 700; padding: 1px 5px; border-radius: 4px;
}
.editor-thumb-delete {
    position: absolute; top: 2px; right: 2px; width: 18px; height: 18px;
    background: rgba(239, 68, 68, 0.8); color: white; border: none; border-radius: 50%;
    font-size: 11px; cursor: pointer; display: flex; align-items: center; justify-content: center;
    opacity: 0; transition: opacity 0.15s;
}
.editor-thumb:hover .editor-thumb-delete { opacity: 1; }

/* === SORTABLE TABLE HEADERS === */
.sortable-th { cursor: pointer; user-select: none; transition: color 0.15s; position: relative; white-space: nowrap; }
.sortable-th:hover { color: #93c5fd; }
.sort-indicator { margin-left: 4px; font-size: 10px; }

/* === PROGRESS COLOR CODING === */
.progress-high { color: #4ade80; }
.progress-mid { color: #facc15; }
.progress-low { color: #f87171; }

/* === FILTER BAR === */
.filter-bar { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; padding: 12px 16px; border-bottom: 1px solid #1e293b; }
.filter-bar input, .filter-bar select {
    background: #0f172a; border: 1px solid #334155; border-radius: 8px;
    padding: 6px 10px; font-size: 12px; color: #e2e8f0;
}

/* === INLINE GRADING POPOVER === */
.grading-popover {
    position: absolute; z-index: 100; background: #1e293b; border: 1px solid #334155;
    border-radius: 12px; padding: 12px; box-shadow: 0 10px 30px rgba(0,0,0,0.5);
    min-width: 280px;
}

/* === RUBRIC WEIGHT BADGE === */
.weight-badge {
    display: inline-flex; align-items: center; justify-content: center;
    min-width: 24px; height: 20px; border-radius: 4px; font-size: 10px; font-weight: 700;
    background: rgba(139, 92, 246, 0.15); color: #a78bfa; padding: 0 4px;
}

/* === TOOLTIP INFO ICON === */
.werken-info-icon {
    display: inline-flex; align-items: center; justify-content: center;
    width: 16px; height: 16px; border-radius: 50%; background: rgba(59,130,246,0.15);
    color: #60a5fa; font-size: 10px; font-weight: 700; cursor: help;
    margin-left: 6px; flex-shrink: 0; transition: all 0.15s; position: relative;
}
.werken-info-icon:hover { background: rgba(59,130,246,0.3); }
.werken-info-tooltip {
    display: none; position: absolute; bottom: calc(100% + 8px); left: 50%; transform: translateX(-50%);
    background: #1e293b; border: 1px solid #334155; border-radius: 8px; padding: 8px 12px;
    font-size: 12px; color: #cbd5e1; font-weight: 400; white-space: normal; width: 260px;
    box-shadow: 0 8px 20px rgba(0,0,0,0.4); z-index: 100; line-height: 1.5;
}
.werken-info-icon:hover .werken-info-tooltip { display: block; }

/* === PROJECT SEARCH === */
.project-search-bar {
    display: flex; gap: 8px; flex-wrap: wrap; align-items: center;
    margin-bottom: 16px; padding: 0;
}
.project-search-bar input {
    flex: 1; min-width: 200px; background: #0f172a; border: 1px solid #1e293b;
    border-radius: 10px; padding: 8px 14px 8px 36px; font-size: 14px; color: #e2e8f0;
}
.project-search-bar select {
    background: #0f172a; border: 1px solid #1e293b; border-radius: 10px;
    padding: 8px 12px; font-size: 13px; color: #94a3b8;
}

/* === OVERLAY TRANSITIONS === */
.overlay-enter { animation: overlayFadeIn 0.2s ease-out; }
@keyframes overlayFadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

/* === PRINT STYLESHEET === */
@media print {
    body { background: white !important; color: black !important; }
    .navbar, .toast, #gam-xp-bar-wrapper, #gam-level-badge { display: none !important; }
    .bg-slate-900, .bg-slate-950 { background: white !important; }
    .text-slate-300, .text-slate-400, .text-white { color: black !important; }
    .border-slate-700, .border-slate-800 { border-color: #ddd !important; }
}

/* === PULSE ANIMATION === */
@keyframes pulse-blue { 0%, 100% { opacity: 1; } 50% { opacity: 0.5; } }
.pulse-blue { animation: pulse-blue 1.5s ease-in-out infinite; }

/* === SPLIT VIEW (PREVIEW) === */
@media (min-width: 1280px) {
    .editor-split-view { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
    .editor-split-view > .editor-panel { overflow-y: auto; max-height: calc(90vh - 140px); }
}
