/* Asset Studio module styles (tc-, sp-, si-, sm- prefixes) */
/* Used by Blazor asset tool pages — no global resets */

/* === Tile Classifier === */

.tc-layout {
    display: flex;
    height: 100%;
}

.tc-left {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.tc-toolbar {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 8px 12px;
    background: #16213e;
    border-bottom: 1px solid #333;
}

.tc-toolbar select {
    padding: 4px 8px;
    background: #0f3460;
    color: #e0e0e0;
    border: 1px solid #444;
    border-radius: 4px;
    font-size: 13px;
}

.tc-toolbar button {
    padding: 4px 12px;
    background: #0f3460;
    color: #e0e0e0;
    border: 1px solid #444;
    border-radius: 4px;
    cursor: pointer;
    font-size: 13px;
}

.tc-toolbar button:hover { background: #1a5276; }

.tc-progress {
    font-size: 13px;
    color: #aaa;
    margin-left: auto;
}

/* Grid */
.tc-grid {
    flex: 1;
    overflow-y: auto;
    padding: 12px;
    display: grid;
    grid-template-columns: repeat(8, 1fr);
    gap: 8px;
    align-content: start;
}

.tc-cell {
    position: relative;
    background: #16213e;
    border: 3px solid #444;
    border-radius: 6px;
    padding: 4px;
    cursor: pointer;
    transition: border-color 0.15s, transform 0.1s;
    aspect-ratio: 132 / 83;
    display: flex;
    align-items: center;
    justify-content: center;
}

.tc-cell:hover { transform: scale(1.05); }
.tc-cell.selected { border-color: #fff !important; box-shadow: 0 0 8px rgba(255,255,255,0.3); }

.tc-cell img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    image-rendering: pixelated;
}

.tc-cell-label {
    position: absolute;
    bottom: 2px;
    left: 4px;
    font-size: 10px;
    color: #fff;
    background: rgba(0,0,0,0.6);
    padding: 1px 4px;
    border-radius: 2px;
}

.tc-cell-slope {
    position: absolute;
    top: 2px;
    right: 4px;
    font-size: 9px;
    color: #ffeb3b;
    background: rgba(0,0,0,0.6);
    padding: 1px 4px;
    border-radius: 2px;
}

/* Detail panel */
.tc-right {
    width: 320px;
    background: #16213e;
    border-left: 1px solid #333;
    overflow-y: auto;
    padding: 16px;
}

.tc-detail-placeholder {
    color: #666;
    text-align: center;
    margin-top: 40%;
    font-size: 14px;
}

.tc-detail-header h3 {
    font-size: 18px;
    margin-bottom: 12px;
}

.tc-detail-preview {
    background: #1a1a2e;
    border: 1px solid #333;
    border-radius: 8px;
    padding: 16px;
    display: flex;
    justify-content: center;
    margin-bottom: 16px;
}

.tc-detail-preview img {
    width: 200px;
    image-rendering: pixelated;
}

.tc-detail-fields label {
    display: block;
    font-size: 12px;
    color: #888;
    margin: 12px 0 6px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* Category buttons */
.tc-category-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
}

.tc-cat-btn {
    padding: 4px 10px;
    font-size: 12px;
    background: #0f3460;
    color: #ccc;
    border: 2px solid transparent;
    border-radius: 4px;
    cursor: pointer;
}

.tc-cat-btn:hover { border-color: var(--cat-color); }
.tc-cat-btn.active { background: var(--cat-color); color: #fff; border-color: var(--cat-color); }

/* Slope */
.tc-slope-section {
    display: flex;
    gap: 12px;
    align-items: flex-start;
}

.tc-slope-diamond {
    flex-shrink: 0;
    text-align: center;
}

.tc-slope-diamond svg { display: block; margin: 0 auto; }

.tc-corner {
    fill: #333;
    stroke: #888;
    stroke-width: 1;
    transition: fill 0.15s;
}

.tc-corner:hover { fill: #555; }
.tc-corner.raised { fill: #4CAF50; stroke: #66BB6A; }

.tc-corner-label {
    fill: #888;
    font-size: 10px;
}

.tc-slope-code {
    font-family: monospace;
    font-size: 14px;
    color: #ffeb3b;
    margin-top: 4px;
}

.tc-slope-presets {
    display: flex;
    flex-wrap: wrap;
    gap: 3px;
}

.tc-slope-btn {
    padding: 3px 8px;
    font-size: 11px;
    background: #0f3460;
    color: #ccc;
    border: 1px solid #444;
    border-radius: 3px;
    cursor: pointer;
}

.tc-slope-btn:hover { border-color: #888; }
.tc-slope-btn.active { background: #4CAF50; color: #fff; border-color: #4CAF50; }

/* Notes */
#tc-notes {
    width: 100%;
    padding: 6px 8px;
    background: #0f3460;
    color: #e0e0e0;
    border: 1px solid #444;
    border-radius: 4px;
    font-size: 13px;
    resize: vertical;
}

#tc-notes:focus { outline: none; border-color: #42A5F5; }

/* === Sprite Studio (unified) === */

.ss-shell {
    display: flex;
    flex-direction: column;
    height: 100%;
}

.ss-tabs {
    display: flex;
    gap: 0;
    background: #16213e;
    border-bottom: 2px solid #333;
    padding: 0 8px;
    flex-shrink: 0;
}

.ss-tab {
    padding: 8px 20px;
    font-size: 13px;
    font-weight: 600;
    background: transparent;
    color: #888;
    border: none;
    border-bottom: 2px solid transparent;
    margin-bottom: -2px;
    cursor: pointer;
    transition: color 0.15s, border-color 0.15s;
}

.ss-tab:hover { color: #ccc; }
.ss-tab.active { color: #42A5F5; border-bottom-color: #42A5F5; }

.ss-body {
    flex: 1;
    overflow: hidden;
}

/* Browse layout (merged preview + management) */
.ss-browse {
    display: flex;
    height: 100%;
}

.ss-browse-left {
    width: 220px;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    border-right: 1px solid #333;
}

.ss-browse-toolbar {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 8px;
    background: #16213e;
    border-bottom: 1px solid #333;
}

.ss-browse-actions {
    display: flex;
    gap: 4px;
    padding: 6px 8px;
    border-bottom: 1px solid #333;
}

.ss-btn-sm {
    flex: 1;
    padding: 4px 8px;
    font-size: 11px;
    background: #0f3460;
    color: #ccc;
    border: 1px solid #444;
    border-radius: 4px;
    cursor: pointer;
}

.ss-btn-sm:hover:not(:disabled) { background: #1a5276; }
.ss-btn-sm:disabled { opacity: 0.4; cursor: not-allowed; }

.ss-browse-right {
    width: 260px;
    background: #16213e;
    border-left: 1px solid #333;
    overflow-y: auto;
}

/* Cell info with validation dot */
.ss-cell-info {
    display: flex;
    align-items: center;
    gap: 4px;
    min-width: 0;
}

.ss-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    flex-shrink: 0;
}

.ss-dot-ok { background: #4CAF50; }
.ss-dot-warn { background: #FFB300; }
.ss-dot-err { background: #EF5350; }

/* Detail section in right panel */
.ss-detail {
    padding: 0 12px 12px;
}

.ss-detail-section {
    margin-top: 10px;
}

.ss-detail-section label {
    display: block;
    font-size: 11px;
    color: #666;
    margin-bottom: 4px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.ss-detail-row {
    display: flex;
    justify-content: space-between;
    font-size: 12px;
    color: #aaa;
    padding: 2px 0;
}

.ss-detail-row span:first-child { color: #888; }
.ss-detail-row span:last-child { color: #ccc; }

.ss-detail-actions {
    max-width: 140px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    text-align: right;
}

.ss-val-item {
    font-size: 11px;
    padding: 2px 0;
    word-break: break-word;
}

.ss-val-err { color: #EF5350; }
.ss-val-warn { color: #FFB300; }

/* === Sprite Previewer === */

.sp-layout {
    display: flex;
    height: 100%;
}

/* Left: Sprite list */
.sp-left {
    width: 200px;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    border-right: 1px solid #333;
}

.sp-toolbar {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 8px;
    background: #16213e;
    border-bottom: 1px solid #333;
}

.sp-search {
    flex: 1;
    padding: 4px 8px;
    background: #0f3460;
    color: #e0e0e0;
    border: 1px solid #444;
    border-radius: 4px;
    font-size: 12px;
    min-width: 0;
}

.sp-search:focus { outline: none; border-color: #42A5F5; }

.sp-count {
    font-size: 11px;
    color: #888;
    white-space: nowrap;
}

.sp-grid {
    flex: 1;
    overflow-y: auto;
    padding: 6px;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.sp-loading {
    color: #666;
    text-align: center;
    margin-top: 40%;
    font-size: 14px;
}

.sp-cell {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 4px 6px;
    background: #16213e;
    border: 2px solid transparent;
    border-radius: 6px;
    cursor: pointer;
    transition: border-color 0.15s;
}

.sp-cell:hover { border-color: #555; }
.sp-cell.selected { border-color: #42A5F5; background: #1a2a4e; }

.sp-cell canvas {
    width: 40px;
    height: 40px;
    image-rendering: pixelated;
    flex-shrink: 0;
}

.sp-cell-label {
    font-size: 12px;
    color: #ccc;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Center: Canvas */
.sp-center {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #111;
    overflow: hidden;
}

#sp-canvas {
    image-rendering: pixelated;
    background: #1a1a2e;
    border: 1px solid #333;
}

/* Right: Unified control panel */
.sp-right {
    width: 240px;
    background: #16213e;
    border-left: 1px solid #333;
    overflow-y: auto;
}

.sp-detail-placeholder {
    color: #666;
    text-align: center;
    margin-top: 40%;
    font-size: 14px;
}

.sp-panel-inner {
    padding: 12px;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.sp-panel-header {
    margin-bottom: 4px;
}

.sp-panel-header h3 {
    font-size: 16px;
    margin-bottom: 2px;
}

.sp-meta {
    font-size: 11px;
    color: #888;
}

.sp-section {
    margin-top: 8px;
}

.sp-section label {
    display: block;
    font-size: 11px;
    color: #666;
    margin-bottom: 6px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* Action buttons */
.sp-action-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
}

.sp-action-btn {
    padding: 4px 10px;
    font-size: 12px;
    background: #0f3460;
    color: #ccc;
    border: 2px solid transparent;
    border-radius: 4px;
    cursor: pointer;
}

.sp-action-btn:hover { border-color: #42A5F5; }
.sp-action-btn.active { background: #42A5F5; color: #fff; border-color: #42A5F5; }

/* 8-way compass + joystick */
.sp-hint {
    font-size: 10px;
    color: #555;
    text-transform: none;
    letter-spacing: 0;
    font-weight: normal;
}

.sp-compass-wrap {
    display: flex;
    justify-content: center;
}

.sp-compass {
    display: grid;
    grid-template-columns: repeat(3, 40px);
    grid-template-rows: repeat(3, 32px);
    gap: 3px;
}

.sp-compass-btn {
    width: 40px;
    height: 32px;
    font-size: 11px;
    font-weight: 600;
    background: #0f3460;
    color: #ccc;
    border: 2px solid transparent;
    border-radius: 4px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

.sp-compass-btn:hover { border-color: #4CAF50; }
.sp-compass-btn.active { background: #4CAF50; color: #fff; border-color: #4CAF50; }
.sp-compass-btn.flipped { color: #999; font-style: italic; }
.sp-compass-btn.flipped.active { color: #fff; }

.sp-compass-handle {
    width: 40px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: grab;
    touch-action: none;
    position: relative;
}

.sp-compass-handle:active { cursor: grabbing; }

.sp-handle-knob {
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: radial-gradient(circle at 40% 35%, #8ab4f8, #42A5F5, #1565C0);
    box-shadow: 0 1px 4px rgba(0,0,0,0.4), inset 0 1px 2px rgba(255,255,255,0.3);
    transition: transform 0.08s ease-out, box-shadow 0.1s;
    position: relative;
    z-index: 1;
}

.sp-handle-knob.dragging {
    transition: none;
    box-shadow: 0 0 8px rgba(66,165,245,0.6), 0 2px 6px rgba(0,0,0,0.5);
    transform-origin: center;
}

/* Playback controls */
.sp-playback {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.sp-playback-row {
    display: flex;
    align-items: center;
    gap: 6px;
}

.sp-pb-btn {
    width: 32px;
    height: 28px;
    background: #0f3460;
    color: #e0e0e0;
    border: 1px solid #444;
    border-radius: 4px;
    cursor: pointer;
    font-size: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.sp-pb-play {
    width: 40px;
    font-size: 13px;
    font-family: monospace;
}

.sp-pb-btn:hover { background: #1a5276; }

.sp-frame-info {
    font-size: 12px;
    color: #aaa;
    font-family: monospace;
    margin-left: auto;
}

#sp-speed, #si-speed {
    flex: 1;
    accent-color: #42A5F5;
    min-width: 0;
}

#sp-speed-label, #si-speed-label {
    font-size: 11px;
    color: #aaa;
    font-family: monospace;
    min-width: 36px;
    text-align: right;
}

.sp-toggles label {
    font-size: 12px;
    color: #aaa;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 4px;
    margin: 0;
    text-transform: none;
    letter-spacing: 0;
}

/* === Sprite Importer (Grid Tag Editor) === */

.si-layout {
    display: flex;
    height: 100%;
}

.si-left {
    width: 280px;
    overflow-y: auto;
    border-right: 1px solid #333;
    padding: 12px;
    flex-shrink: 0;
}

.si-left h3 {
    font-size: 14px;
    margin-bottom: 8px;
    color: #fff;
}

.si-center {
    flex: 1;
    overflow: hidden;
    background: #111;
    position: relative;
    cursor: grab;
}

.si-right {
    width: 260px;
    background: #16213e;
    border-left: 1px solid #333;
    overflow-y: auto;
    flex-shrink: 0;
}

/* Reuse sp- panel styles for si- prefix */
.si-panel-inner { padding: 12px; display: flex; flex-direction: column; gap: 4px; }
.si-section { margin-top: 8px; }
.si-section label { display: block; font-size: 11px; color: #666; margin-bottom: 6px; text-transform: uppercase; letter-spacing: 0.5px; }

.si-preview-section {
    padding: 12px;
    display: flex;
    justify-content: center;
    background: #111;
}

#si-canvas {
    image-rendering: pixelated;
    background: #1a1a2e;
    border: 1px solid #333;
}

/* Upload */
.si-dropzone {
    border: 2px dashed #444;
    border-radius: 8px;
    padding: 20px;
    text-align: center;
    cursor: pointer;
    color: #888;
    font-size: 13px;
    transition: border-color 0.2s, background 0.2s;
    margin-bottom: 8px;
}

.si-dropzone:hover, .si-dropzone.dragover {
    border-color: #42A5F5;
    background: rgba(66, 165, 245, 0.05);
}

.si-file-info {
    font-size: 12px;
    color: #aaa;
    margin-bottom: 8px;
}

/* Config */
.si-config-section { margin-top: 12px; }

.si-config-section label, .si-anim-section label {
    display: block;
    font-size: 11px;
    color: #888;
    margin: 8px 0 4px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.si-frame-size {
    display: flex;
    align-items: center;
    gap: 4px;
}

.si-input {
    width: 100%;
    padding: 5px 8px;
    background: #0f3460;
    color: #e0e0e0;
    border: 1px solid #444;
    border-radius: 4px;
    font-size: 13px;
}

.si-input-half { width: 60px; }
.si-x { color: #666; font-size: 12px; }
.si-input:focus { outline: none; border-color: #42A5F5; }

.si-grid-info {
    font-size: 11px;
    color: #888;
    margin-top: 4px;
}

.si-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 12px;
}

.si-btn, .si-btn-primary {
    padding: 6px 12px;
    font-size: 12px;
    border: 1px solid #444;
    border-radius: 4px;
    cursor: pointer;
    color: #e0e0e0;
}

.si-btn { background: #0f3460; }
.si-btn:hover:not(:disabled) { background: #1a5276; }
.si-btn-primary { background: #2e7d32; border-color: #4CAF50; }
.si-btn-primary:hover:not(:disabled) { background: #388E3C; }
.si-btn:disabled, .si-btn-primary:disabled, .si-btn-register:disabled { opacity: 0.4; cursor: not-allowed; }

.si-btn-register {
    padding: 8px 16px;
    font-size: 13px;
    font-weight: 600;
    background: #1565C0;
    color: #fff;
    border: 1px solid #1976D2;
    border-radius: 4px;
    cursor: pointer;
    width: 100%;
}

.si-btn-register:hover:not(:disabled) { background: #1976D2; }

.si-register-status {
    margin-top: 6px;
    font-size: 12px;
    min-height: 18px;
}

/* Animation toggles */
.si-anim-section { margin-top: 12px; }

.si-anim-toggles {
    display: flex;
    flex-wrap: wrap;
    gap: 3px;
}

.si-anim-toggle {
    padding: 3px 8px;
    font-size: 11px;
    background: #0f3460;
    color: #ccc;
    border: 2px solid transparent;
    border-radius: 4px;
    cursor: pointer;
    transition: border-color 0.1s, background 0.1s;
}

.si-anim-toggle:hover { border-color: var(--anim-color); }
.si-anim-toggle.active {
    background: var(--anim-color);
    color: #fff;
    border-color: var(--anim-color);
}

.si-tag-summary {
    margin-top: 8px;
    font-size: 11px;
    color: #aaa;
}

.si-tag-item {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 2px 0;
}

.si-tag-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    flex-shrink: 0;
}

.si-no-tags { color: #555; font-style: italic; }

/* Sprite Grid */
.si-center:active { cursor: grabbing; }

.si-grid-container {
    display: inline-block;
    padding: 12px;
    transform-origin: 0 0;
}

.si-grid-placeholder {
    color: #555;
    font-size: 14px;
    margin: auto;
    text-align: center;
}

.si-sprite-grid {
    display: grid;
    gap: 2px;
    user-select: none;
    touch-action: none;
}

.si-grid-header {
    font-size: 10px;
    color: #666;
    text-align: center;
    padding: 2px;
    display: flex;
    align-items: flex-end;
    justify-content: center;
}

.si-grid-row-label {
    font-size: 11px;
    font-weight: 600;
    color: #888;
    display: flex;
    align-items: center;
    justify-content: center;
    padding-right: 4px;
}

.si-grid-cell {
    position: relative;
    border: 2px solid transparent;
    border-radius: 3px;
    cursor: pointer;
    overflow: hidden;
    transition: border-color 0.1s;
}

.si-grid-cell:hover {
    border-color: #fff !important;
    z-index: 1;
}

.si-cell-sprite {
    image-rendering: pixelated;
    pointer-events: none;
    position: absolute;
    top: 0;
    left: 0;
}

.si-cell-tag {
    position: absolute;
    bottom: 1px;
    left: 1px;
    font-size: 8px;
    color: #fff;
    padding: 0 3px;
    border-radius: 2px;
    line-height: 1.4;
    pointer-events: none;
}

/* === Sprite Manager === */

.sm-layout {
    display: flex;
    flex-direction: column;
    height: 100%;
}

.sm-toolbar {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 8px 16px;
    background: #16213e;
    border-bottom: 1px solid #333;
}

.sm-toolbar h3 {
    font-size: 14px;
    color: #fff;
}

.sm-status {
    font-size: 13px;
    color: #aaa;
    margin-left: auto;
}

.sm-btn, .sm-btn-primary {
    padding: 6px 14px;
    font-size: 13px;
    border: 1px solid #444;
    border-radius: 4px;
    cursor: pointer;
    color: #e0e0e0;
}

.sm-btn { background: #0f3460; }
.sm-btn:hover { background: #1a5276; }

.sm-btn-primary {
    background: #2e7d32;
    border-color: #4CAF50;
}

.sm-btn-primary:hover { background: #388E3C; }
.sm-btn-primary:disabled { opacity: 0.4; cursor: not-allowed; }

.sm-table-wrap {
    flex: 1;
    overflow-y: auto;
    padding: 12px 16px;
}

.sm-loading {
    color: #666;
    text-align: center;
    margin-top: 20%;
    font-size: 14px;
}

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

.sm-table thead {
    position: sticky;
    top: 0;
    background: #16213e;
    z-index: 1;
}

.sm-table th {
    text-align: left;
    padding: 8px 12px;
    border-bottom: 2px solid #333;
    color: #888;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.sm-table td {
    padding: 6px 12px;
    border-bottom: 1px solid #2a2a3e;
    vertical-align: middle;
}

.sm-table tr:hover {
    background: rgba(66, 165, 245, 0.05);
}

.sm-td-thumb canvas {
    width: 40px;
    height: 40px;
    image-rendering: pixelated;
    display: block;
}

.sm-th-thumb { width: 52px; }
.sm-td-id { font-weight: 600; color: #fff; }
.sm-td-actions { max-width: 200px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.sm-ok { color: #4CAF50; font-weight: 600; }
.sm-warn { color: #FFB300; cursor: help; }
.sm-error { color: #EF5350; font-weight: 600; cursor: help; }
.sm-pending { color: #666; }
