/* Admin Panel Styles */
:root {
    --primary: #6366f1;
    --primary-dark: #4f46e5;
    --success: #22c55e;
    --danger: #ef4444;
    --warning: #f59e0b;
    --bg-dark: #0f172a;
    --bg-card: #1e293b;
    --bg-card-hover: #334155;
    --text: #f1f5f9;
    --text-muted: #94a3b8;
    --border: #334155;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: 'Roboto', sans-serif;
    background: var(--bg-dark);
    color: var(--text);
    min-height: 100vh;
}

.container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 20px;
}

/* Connection Status */
#connection-status {
    position: fixed;
    top: 10px;
    right: 10px;
    padding: 8px 16px;
    border-radius: 20px;
    font-size: 14px;
    font-weight: 500;
    z-index: 1000;
    transition: all 0.3s ease;
}

#connection-status.connected {
    background: var(--success);
    color: white;
}

#connection-status.disconnected {
    background: var(--danger);
    color: white;
}

/* Header */
.header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    padding: 20px;
    background: var(--bg-card);
    border-radius: 12px;
}

.header h1 {
    font-size: 24px;
}

.system-selector {
    display: flex;
    align-items: center;
    gap: 10px;
}

.system-selector select {
    padding: 10px 16px;
    background: var(--bg-dark);
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 14px;
    cursor: pointer;
}

.system-selector select:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.current-system-display {
    padding: 10px 16px;
    background: var(--primary);
    color: white;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 500;
}

.btn-warning {
    background: var(--warning);
    color: #000;
}

.btn-warning:hover {
    background: #d97706;
}

/* Tabs */
.tabs {
    display: flex;
    gap: 5px;
    margin-bottom: 20px;
    background: var(--bg-card);
    padding: 8px;
    border-radius: 12px;
}

.tab {
    flex: 1;
    padding: 12px 20px;
    background: transparent;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 500;
    transition: all 0.2s ease;
}

.tab:hover {
    background: var(--bg-card-hover);
    color: var(--text);
}

.tab.active {
    background: var(--primary);
    color: white;
}

/* Tab Content */
.tab-content {
    display: none;
}

.tab-content.active {
    display: block;
}

/* Grid Layout */
.grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(400px, 1fr));
    gap: 20px;
}

.card {
    background: var(--bg-card);
    border-radius: 12px;
    padding: 20px;
}

.card.full-width {
    grid-column: 1 / -1;
}

.card h2 {
    font-size: 18px;
    margin-bottom: 16px;
    padding-bottom: 10px;
    border-bottom: 1px solid var(--border);
}

/* Status Grid */
.status-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 15px;
    margin-bottom: 20px;
}

.status-item {
    text-align: center;
    padding: 15px;
    background: var(--bg-dark);
    border-radius: 8px;
}

.status-label {
    display: block;
    font-size: 12px;
    color: var(--text-muted);
    margin-bottom: 5px;
}

.status-value {
    display: block;
    font-size: 24px;
    font-weight: 700;
    color: var(--primary);
}

/* Player List */
.player-list h3 {
    font-size: 14px;
    color: var(--text-muted);
    margin-bottom: 10px;
}

/* Character List */
.character-list {
    max-height: 300px;
    overflow-y: auto;
}

.character-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px;
    background: var(--bg-dark);
    border-radius: 8px;
    margin-bottom: 8px;
}

.character-item:last-child {
    margin-bottom: 0;
}

.character-info {
    display: flex;
    align-items: center;
    gap: 12px;
}

.character-token {
    width: 40px;
    height: 40px;
    background: var(--primary);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
}

.character-name {
    font-weight: 500;
}

.character-player {
    font-size: 12px;
    color: var(--text-muted);
}

.character-stats {
    display: flex;
    gap: 10px;
    font-size: 13px;
}

.stat {
    padding: 4px 8px;
    background: var(--bg-card-hover);
    border-radius: 4px;
}

.stat.health {
    color: var(--success);
}

/* Sheet List */
.sheet-list {
    max-height: 400px;
    overflow-y: auto;
}

.sheet-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px;
    background: var(--bg-dark);
    border-radius: 8px;
    margin-bottom: 10px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.sheet-item:hover {
    background: var(--bg-card-hover);
}

.sheet-info {
    flex: 1;
}

.sheet-name {
    font-weight: 500;
    font-size: 16px;
}

.sheet-player {
    font-size: 12px;
    color: var(--text-muted);
}

.sheet-time {
    font-size: 11px;
    color: var(--text-muted);
    margin-top: 4px;
}

.sheet-actions {
    display: flex;
    gap: 8px;
}

/* Buttons */
.btn {
    padding: 10px 20px;
    border: none;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    background: var(--bg-card-hover);
    color: var(--text);
}

.btn:hover {
    opacity: 0.9;
    transform: translateY(-1px);
}

.btn-primary {
    background: var(--primary);
    color: white;
}

.btn-success {
    background: var(--success);
    color: white;
}

.btn-danger {
    background: var(--danger);
    color: white;
}

.btn-warning {
    background: var(--warning);
    color: white;
}

.btn-sm {
    padding: 6px 12px;
    font-size: 12px;
}

/* Token Assignment */
.token-form {
    margin-bottom: 15px;
}

.token-form label {
    display: block;
    font-size: 14px;
    color: var(--text-muted);
    margin-bottom: 5px;
}

.token-form select {
    width: 100%;
    padding: 12px;
    background: var(--bg-dark);
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 14px;
}

.token-list {
    max-height: 300px;
    overflow-y: auto;
}

.token-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px;
    background: var(--bg-dark);
    border-radius: 8px;
    margin-bottom: 8px;
}

.token-marker {
    width: 40px;
    height: 40px;
    background: var(--primary);
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 18px;
}

/* Combat Controls */
.combat-controls {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    margin-bottom: 20px;
}

.combat-status {
    background: var(--bg-dark);
    border-radius: 8px;
    padding: 15px;
}

.status-row {
    display: flex;
    justify-content: space-between;
    padding: 8px 0;
    border-bottom: 1px solid var(--border);
}

.status-row:last-child {
    border-bottom: none;
}

.initiative-list {
    max-height: 300px;
    overflow-y: auto;
}

.initiative-item {
    display: flex;
    align-items: center;
    gap: 15px;
    padding: 12px;
    background: var(--bg-dark);
    border-radius: 8px;
    margin-bottom: 8px;
}

.initiative-item.active {
    background: var(--primary-dark);
    border: 2px solid var(--primary);
}

.initiative-order {
    width: 30px;
    height: 30px;
    background: var(--bg-card-hover);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
}

.initiative-value {
    margin-left: auto;
    font-weight: 500;
    color: var(--primary);
}

/* Log */
.log {
    max-height: 200px;
    overflow-y: auto;
    font-family: monospace;
    font-size: 12px;
    background: var(--bg-dark);
    padding: 15px;
    border-radius: 8px;
}

.log-entry {
    padding: 4px 0;
    border-bottom: 1px solid var(--border);
}

.log-entry:last-child {
    border-bottom: none;
}

.log-time {
    color: var(--text-muted);
    margin-right: 10px;
}

/* Debug Tools */
.debug-tools {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

/* Modal */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.modal.hidden {
    display: none;
}

.modal-content {
    background: var(--bg-card);
    border-radius: 16px;
    width: 90%;
    max-width: 600px;
    max-height: 80vh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px;
    border-bottom: 1px solid var(--border);
}

.modal-header h2 {
    border-bottom: none;
    margin-bottom: 0;
    padding-bottom: 0;
}

.close-btn {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 28px;
    cursor: pointer;
    line-height: 1;
}

.close-btn:hover {
    color: var(--text);
}

.modal-body {
    padding: 20px;
    overflow-y: auto;
    flex: 1;
}

.modal-footer {
    padding: 20px;
    border-top: 1px solid var(--border);
    display: flex;
    justify-content: flex-end;
    gap: 10px;
}

/* Sheet Fields in Modal */
.sheet-fields {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 15px;
}

.sheet-field {
    padding: 12px;
    background: var(--bg-dark);
    border-radius: 8px;
}

.sheet-field.full-width {
    grid-column: 1 / -1;
}

.field-label {
    font-size: 12px;
    color: var(--text-muted);
    margin-bottom: 4px;
}

.field-value {
    font-size: 16px;
    font-weight: 500;
}

/* Empty State */
.empty-state {
    text-align: center;
    padding: 30px;
    color: var(--text-muted);
    font-style: italic;
}

/* Help Text */
.help-text {
    color: var(--text-muted);
    font-size: 14px;
    margin-bottom: 20px;
}

/* Scrollbar */
::-webkit-scrollbar {
    width: 8px;
}

::-webkit-scrollbar-track {
    background: var(--bg-dark);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--text-muted);
}

/* ==================== MAP EDITOR STYLES ==================== */

.map-editor-container {
    display: flex;
    flex-direction: column;
    height: calc(100vh - 200px);
    min-height: 600px;
    gap: 10px;
}

/* Toolbar */
.map-toolbar {
    display: flex;
    align-items: center;
    gap: 20px;
    padding: 12px 16px;
    background: var(--bg-card);
    border-radius: 12px;
    flex-wrap: wrap;
}

.toolbar-group {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 0 15px;
    border-right: 1px solid var(--border);
}

.toolbar-group:last-child {
    border-right: none;
}

.toolbar-group label {
    font-size: 12px;
    color: var(--text-muted);
}

.tool-btn {
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-dark);
    border: 1px solid var(--border);
    border-radius: 8px;
    cursor: pointer;
    font-size: 18px;
    transition: all 0.2s;
}

.tool-btn:hover {
    background: var(--bg-card-hover);
}

.tool-btn.active {
    background: var(--primary);
    border-color: var(--primary);
}

/* Main Editor Area */
.map-editor-main {
    display: grid;
    grid-template-columns: 220px 1fr 280px;
    gap: 15px;
    flex: 1;
    min-height: 0;
}

/* Tile Panel (Left) */
.tile-panel {
    background: var(--bg-card);
    border-radius: 12px;
    padding: 10px;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.tile-panel h3 {
    font-size: 16px;
    margin-bottom: 12px;
}

.layer-selector {
    display: flex;
    gap: 5px;
    margin-bottom: 12px;
}

.layer-btn {
    flex: 1;
    padding: 8px 4px;
    font-size: 11px;
    background: var(--bg-dark);
    border: 1px solid var(--border);
    border-radius: 6px;
    color: var(--text-muted);
    cursor: pointer;
    transition: all 0.2s;
}

.layer-btn:hover {
    color: var(--text);
    border-color: var(--primary);
}

.layer-btn.active {
    background: var(--primary);
    border-color: var(--primary);
    color: white;
}

.tile-palette {
    display: flex;
    flex-direction: column;
    gap: 8px;
    overflow-y: auto;
    flex: 1;
    padding: 5px;
    background: var(--bg-dark);
    border-radius: 8px;
}

/* Layer selector for systems with layers */
.layer-selector {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px;
    background: var(--bg-card);
    border-radius: 6px;
    margin-bottom: 8px;
}

.layer-selector label {
    font-size: 12px;
    color: var(--text-muted);
}

.layer-selector select {
    flex: 1;
    padding: 6px 10px;
    background: var(--bg-dark);
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: 4px;
    font-size: 12px;
}

/* Category headers */
.palette-category {
    background: var(--bg-card);
    border-radius: 6px;
    overflow: hidden;
}

.category-header {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 10px;
    background: var(--bg-card-hover);
    cursor: pointer;
    font-size: 12px;
    font-weight: 500;
}

.category-header:hover {
    background: var(--border);
}

.category-icon {
    font-size: 14px;
}

.category-count {
    color: var(--text-muted);
    font-size: 10px;
    margin-left: auto;
}

.category-toggle {
    transition: transform 0.2s;
}

.category-tiles {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 6px;
    padding: 8px;
}

.category-tiles.collapsed {
    display: none;
}

.tile-item {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    padding: 6px;
    background: var(--bg-dark);
    border: 2px solid transparent;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s;
    min-width: 0; /* Permite que el item se encoja */
}

.tile-preview {
    width: 100%;
    aspect-ratio: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    border-radius: 4px;
    overflow: hidden;
    max-height: 50px;
}

.tile-preview .tile-thumb {
    width: 100%;
    height: 100%;
    object-fit: contain;
    border-radius: 4px;
}

.tile-preview .tile-color {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
}

.tile-name {
    font-size: 8px;
    text-align: center;
    color: var(--text-muted);
    overflow: hidden;
    text-overflow: ellipsis;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    white-space: normal;
    max-width: 100%;
    width: 100%;
    line-height: 1.2;
    min-height: 18px;
}

.tile-item:hover {
    transform: scale(1.05);
    border-color: var(--primary);
}

.tile-item.selected {
    border-color: var(--success);
    box-shadow: 0 0 10px var(--success);
}

/* Stackable indicator for tiles that can be placed on top of others */
.tile-item.stackable::after {
    content: '';
    position: absolute;
    top: 2px;
    right: 2px;
    width: 8px;
    height: 8px;
    background: var(--warning);
    border-radius: 50%;
}

.stackable-indicator {
    position: absolute;
    top: 1px;
    right: 3px;
    font-size: 10px;
    font-weight: bold;
    color: var(--warning);
}

.tile-info {
    margin-top: 12px;
    padding: 10px;
    background: var(--bg-dark);
    border-radius: 8px;
    font-size: 12px;
}

.tile-info p {
    margin-bottom: 5px;
}

.tile-info .prop {
    display: flex;
    justify-content: space-between;
    color: var(--text-muted);
}

.tile-info .prop span:last-child {
    color: var(--text);
    font-weight: 500;
}

/* Map Canvas Container (Center) */
.map-canvas-container {
    background: var(--bg-card);
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    position: relative;
}

#map-canvas {
    background: #1a1a2e;
    border-radius: 4px;
    cursor: crosshair;
}

.map-canvas-container::before {
    content: '🗺️ Crea un nuevo mapa o carga uno existente';
    position: absolute;
    color: var(--text-muted);
    font-size: 18px;
    pointer-events: none;
}

.map-canvas-container.has-map::before {
    display: none;
}

/* Properties Panel (Right) */
.properties-panel {
    background: var(--bg-card);
    border-radius: 12px;
    padding: 15px;
    display: flex;
    flex-direction: column;
    gap: 15px;
    overflow-y: auto;
}

.properties-panel h3 {
    font-size: 14px;
    color: var(--primary);
    border-bottom: 1px solid var(--border);
    padding-bottom: 8px;
}

.property-group {
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.property-group label {
    font-size: 12px;
    color: var(--text-muted);
}

.property-group input,
.property-group select {
    padding: 8px 12px;
    background: var(--bg-dark);
    border: 1px solid var(--border);
    border-radius: 6px;
    color: var(--text);
    font-size: 14px;
}

.property-group input:focus,
.property-group select:focus {
    outline: none;
    border-color: var(--primary);
}

.full-width {
    width: 100%;
}

/* Saved Maps List */
.saved-maps-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
    max-height: 200px;
    overflow-y: auto;
}

.saved-map-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 12px;
    background: var(--bg-dark);
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s;
}

.saved-map-item:hover {
    background: var(--bg-card-hover);
}

.saved-map-item .map-name {
    font-size: 13px;
    font-weight: 500;
}

.saved-map-item .map-meta {
    font-size: 11px;
    color: var(--text-muted);
}

.saved-map-item .map-actions {
    display: flex;
    gap: 5px;
}

.saved-map-item .map-actions button {
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: 1px solid var(--border);
    border-radius: 4px;
    cursor: pointer;
    font-size: 14px;
    transition: all 0.2s;
}

.saved-map-item .map-actions button:hover {
    background: var(--primary);
    border-color: var(--primary);
}

.saved-map-item .map-actions button.delete:hover {
    background: var(--danger);
    border-color: var(--danger);
}

/* New Map Dialog */
.map-dialog {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.map-dialog-content {
    background: var(--bg-card);
    border-radius: 12px;
    padding: 25px;
    min-width: 350px;
}

.map-dialog-content h2 {
    margin-bottom: 20px;
}

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

.map-dialog-content .form-group label {
    display: block;
    margin-bottom: 5px;
    font-size: 14px;
    color: var(--text-muted);
}

.map-dialog-content .form-group input,
.map-dialog-content .form-group select {
    width: 100%;
    padding: 10px 12px;
    background: var(--bg-dark);
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--text);
    font-size: 14px;
}

.map-dialog-content .btn-row {
    display: flex;
    gap: 10px;
    justify-content: flex-end;
    margin-top: 20px;
}

/* Grid overlay */
.grid-toggle {
    position: absolute;
    bottom: 15px;
    right: 15px;
    padding: 8px 12px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 6px;
    color: var(--text);
    cursor: pointer;
    font-size: 12px;
}

.grid-toggle.active {
    background: var(--primary);
    border-color: var(--primary);
}

/* Zoom controls */
.zoom-controls {
    position: absolute;
    bottom: 15px;
    left: 15px;
    display: flex;
    gap: 5px;
}

.zoom-btn {
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 6px;
    cursor: pointer;
    font-size: 16px;
    color: var(--text);
}

.zoom-btn:hover {
    background: var(--primary);
    border-color: var(--primary);
}

/* Responsive */
@media (max-width: 1200px) {
    .map-editor-main {
        grid-template-columns: 200px 1fr 250px;
    }
}

@media (max-width: 992px) {
    .map-editor-main {
        grid-template-columns: 1fr;
        grid-template-rows: auto 1fr auto;
    }
    
    .tile-panel {
        flex-direction: row;
        flex-wrap: wrap;
    }
    
    .tile-palette {
        max-height: 150px;
    }
    
    .properties-panel {
        flex-direction: row;
        flex-wrap: wrap;
    }
}

/* ==================== END MAP EDITOR STYLES ==================== */

/* ==================== TOKEN ASSIGNMENT VISUAL STYLES ==================== */

.card.full-width {
    grid-column: 1 / -1;
}

.token-assignment-grid {
    display: grid;
    grid-template-columns: 1fr 2fr 1fr;
    gap: 20px;
}

.token-assignment-grid-simple {
    display: grid;
    grid-template-columns: 1fr 2fr;
    gap: 20px;
}

.assignment-step {
    background: var(--bg-dark);
    border-radius: 8px;
    padding: 15px;
    border: 1px solid var(--border);
}

.assignment-step h3 {
    font-size: 14px;
    color: var(--text-muted);
    margin-bottom: 15px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* Sheets Grid para selección */
.sheets-grid {
    display: flex;
    flex-direction: column;
    gap: 8px;
    max-height: 300px;
    overflow-y: auto;
}

.sheet-option {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    background: var(--bg-card);
    border: 2px solid transparent;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.sheet-option:hover {
    background: var(--bg-card-hover);
    border-color: var(--primary);
}

.sheet-option.selected {
    border-color: var(--success);
    background: rgba(34, 197, 94, 0.1);
}

.sheet-option .sheet-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--primary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    font-weight: 700;
}

.sheet-option .sheet-info {
    flex: 1;
}

.sheet-option .sheet-name {
    font-weight: 600;
    font-size: 14px;
}

.sheet-option .sheet-player {
    font-size: 12px;
    color: var(--text-muted);
}

/* Token Category Tabs */
.token-category-tabs {
    display: flex;
    gap: 5px;
    margin-bottom: 15px;
}

.token-tab {
    flex: 1;
    padding: 8px 12px;
    background: var(--bg-card);
    border: none;
    border-radius: 6px;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 12px;
    transition: all 0.2s ease;
}

.token-tab:hover {
    background: var(--bg-card-hover);
    color: var(--text);
}

.token-tab.active {
    background: var(--primary);
    color: white;
}

/* Token Gallery */
.token-gallery {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(70px, 1fr));
    gap: 10px;
    max-height: 320px;
    overflow-y: auto;
    padding: 5px;
}

.token-option {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 8px;
    background: var(--bg-card);
    border: 2px solid transparent;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.token-option:hover {
    background: var(--bg-card-hover);
    border-color: var(--primary);
    transform: scale(1.05);
}

.token-option.selected {
    border-color: var(--success);
    background: rgba(34, 197, 94, 0.15);
}

.token-option.assigned {
    opacity: 0.5;
    cursor: not-allowed;
    border-color: var(--text-muted);
    pointer-events: none;
}

.token-option.assigned .token-image {
    filter: grayscale(70%);
}

.token-option .assigned-badge {
    position: absolute;
    top: 3px;
    left: 3px;
    background: var(--success);
    color: white;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    font-size: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.token-option .token-image {
    width: 48px;
    height: 48px;
    object-fit: contain;
}

.token-option .token-label {
    font-size: 10px;
    color: var(--text-muted);
    text-align: center;
    margin-top: 5px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 100%;
}

/* Weight class badges for BattleTech */
.token-option .weight-badge {
    position: absolute;
    top: 3px;
    right: 3px;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    font-size: 9px;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
}

.token-option {
    position: relative;
}

.weight-badge.light { background: #4CAF50; }
.weight-badge.medium { background: #2196F3; }
.weight-badge.heavy { background: #FF9800; }
.weight-badge.assault { background: #f44336; }

/* Marker Input */
.marker-input-group {
    display: flex;
    flex-direction: column;
    gap: 5px;
    margin-bottom: 15px;
}

.marker-input-group input {
    padding: 12px;
    font-size: 24px;
    text-align: center;
    background: var(--bg-card);
    border: 2px solid var(--border);
    border-radius: 8px;
    color: var(--text);
    width: 100%;
}

.marker-input-group input:focus {
    outline: none;
    border-color: var(--primary);
}

.marker-help {
    font-size: 11px;
    color: var(--text-muted);
    text-align: center;
}

.btn-large {
    width: 100%;
    padding: 15px;
    font-size: 16px;
}

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

/* Assigned Tokens Grid */
.assigned-tokens-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 15px;
}

.assigned-token-card {
    display: flex;
    flex-direction: column;
    background: var(--bg-dark);
    border-radius: 12px;
    overflow: hidden;
    border: 1px solid var(--border);
}

.assigned-token-card .token-header {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 15px;
    background: linear-gradient(135deg, var(--bg-card) 0%, var(--bg-dark) 100%);
}

.assigned-token-card .token-visual {
    width: 56px;
    height: 56px;
    object-fit: contain;
    filter: drop-shadow(0 2px 4px rgba(0,0,0,0.3));
}

.assigned-token-card .token-details {
    flex: 1;
}

.assigned-token-card .character-name {
    font-weight: 700;
    font-size: 14px;
    margin-bottom: 2px;
}

.assigned-token-card .player-name {
    font-size: 12px;
    color: var(--text-muted);
}

.assigned-token-card .marker-badge,
.assigned-token-card .token-type-badge {
    background: var(--primary);
    color: white;
    padding: 4px 10px;
    border-radius: 12px;
    font-size: 11px;
    font-weight: 600;
    white-space: nowrap;
}

.assigned-token-card .token-footer {
    display: flex;
    justify-content: flex-end;
    padding: 10px 15px;
    background: var(--bg-card);
}

/* ==================== END TOKEN ASSIGNMENT STYLES ==================== */


/* ==================== CAMERA PANEL STYLES ==================== */

/* Barra de controles superior */
.camera-controls-bar {
    display: flex;
    gap: 20px;
    padding: 15px 20px;
    background: var(--bg-card);
    border-radius: 12px;
    margin-bottom: 15px;
    align-items: center;
    flex-wrap: wrap;
}

.camera-controls-bar .camera-local {
    display: flex;
    align-items: center;
    gap: 10px;
}

.camera-controls-bar label {
    font-size: 13px;
    color: var(--text-secondary);
    white-space: nowrap;
}

.camera-controls-bar select {
    padding: 8px 12px;
    background: var(--bg-dark);
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 14px;
    min-width: 200px;
}

.camera-status-inline {
    margin-left: auto;
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 13px;
    color: var(--text-secondary);
}

.camera-ip {
    display: flex;
    align-items: center;
    gap: 10px;
}

.camera-ip input[type="text"] {
    padding: 8px 12px;
    background: var(--bg-dark);
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 14px;
    width: 160px;
}

/* Contenedor de los dos feeds */
.dual-feed-container {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 15px;
    margin-bottom: 15px;
}

.feed-panel {
    background: var(--bg-card);
    border-radius: 12px;
    overflow: hidden;
}

.feed-panel h3 {
    padding: 10px 15px;
    margin: 0;
    background: var(--bg-dark);
    font-size: 14px;
    font-weight: 500;
    border-bottom: 1px solid var(--border);
}

.feed-wrapper {
    position: relative;
    aspect-ratio: 16/9;
    background: #000;
}

.feed-wrapper video,
.feed-wrapper img {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.feed-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0,0,0,0.7);
    color: var(--text-secondary);
}

.feed-overlay.hidden {
    display: none;
}

/* Barra de settings inferior */
.camera-settings-bar {
    display: flex;
    gap: 30px;
    padding: 15px 20px;
    background: var(--bg-card);
    border-radius: 12px;
}

.camera-settings-bar .setting-item {
    display: flex;
    align-items: center;
    gap: 10px;
}

.camera-settings-bar label {
    font-size: 13px;
    color: var(--text-secondary);
}

.camera-settings-bar input[type="range"] {
    width: 120px;
}

.camera-settings-bar span {
    min-width: 35px;
    font-size: 13px;
}

/* Estados de cámara */
.camera-state.disconnected { color: #e74c3c; }
.camera-state.connecting { color: #f39c12; }
.camera-state.streaming { color: #2ecc71; }
.camera-state.error { color: #e74c3c; }

/* Responsive */
@media (max-width: 900px) {
    .dual-feed-container {
        grid-template-columns: 1fr;
    }
}

/* Miniaturas */
.miniatures-toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
}

.miniatures-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 15px;
}

.miniature-card {
    display: flex;
    gap: 12px;
    padding: 15px;
    background: var(--bg-card);
    border-radius: 8px;
    border: 2px solid var(--border);
    transition: all 0.2s ease;
}

.miniature-card.visible {
    border-color: var(--success);
}

.miniature-card.hidden {
    border-color: var(--text-muted);
    opacity: 0.6;
}

.miniature-icon {
    font-size: 32px;
}

.miniature-info {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.miniature-id {
    font-weight: 600;
    font-size: 16px;
}

.miniature-player {
    color: var(--success);
    font-weight: 500;
}

.miniature-unassigned {
    color: var(--text-muted);
    font-style: italic;
}

.miniature-position {
    font-size: 12px;
    color: var(--text-muted);
}

.miniature-visibility {
    font-size: 12px;
}

/* Asignación de jugadores */
.assignment-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    margin-bottom: 20px;
}

.assignment-step {
    background: var(--bg-dark);
    padding: 15px;
    border-radius: 8px;
}

.assignment-step h3 {
    margin-bottom: 15px;
    font-size: 14px;
    color: var(--text-muted);
}

.miniatures-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
    max-height: 200px;
    overflow-y: auto;
}

.miniature-select-card {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 15px;
    background: var(--bg-card);
    border-radius: 8px;
    border: 2px solid var(--border);
    cursor: pointer;
    transition: all 0.2s ease;
}

.miniature-select-card:hover {
    border-color: var(--primary);
    background: var(--bg-card-hover);
}

.miniature-select-card.selected {
    border-color: var(--success);
    background: rgba(34, 197, 94, 0.1);
}

.assignments-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.assignment-card {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 15px;
    background: var(--bg-card);
    border-radius: 8px;
    border-left: 4px solid var(--success);
}

.assignment-info {
    display: flex;
    gap: 15px;
    align-items: center;
}

.assignment-marker {
    font-weight: 600;
}

.assignment-player {
    color: var(--success);
}

.assignment-character {
    color: var(--primary);
}

/* Cámara remota */
.camera-remote-info {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    padding: 30px;
    text-align: center;
    color: var(--text);
}

.camera-remote-info .remote-icon {
    font-size: 48px;
    margin-bottom: 15px;
}

.camera-remote-info h3 {
    margin-bottom: 10px;
    color: var(--primary);
}

.camera-remote-info p {
    margin-bottom: 10px;
    color: var(--text-muted);
}

.camera-remote-info code {
    display: block;
    background: var(--bg-dark);
    padding: 12px 20px;
    border-radius: 8px;
    font-family: 'Consolas', monospace;
    font-size: 13px;
    color: var(--success);
    margin: 15px 0;
    word-break: break-all;
}

.camera-state.remote {
    color: var(--primary);
}

/* ==================== END CAMERA PANEL STYLES ==================== */


/* Responsive */
@media (max-width: 768px) {
    .grid {
        grid-template-columns: 1fr;
    }
    
    .header {
        flex-direction: column;
        gap: 15px;
    }
    
    .status-grid {
        grid-template-columns: 1fr;
    }
    
    .tabs {
        flex-wrap: wrap;
    }
    
    .tab {
        flex: 0 0 calc(50% - 5px);
    }
    
    .token-assignment-grid,
    .token-assignment-grid-simple {
        grid-template-columns: 1fr;
    }
    
    .camera-card {
        grid-column: span 1;
    }
    
    .assignment-grid {
        grid-template-columns: 1fr;
    }
}

/* ==================== Detected Miniatures (Camera) ==================== */
.detected-minis-container {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.detected-mini-card {
    display: grid;
    grid-template-columns: 50px 1fr auto;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    background: var(--bg-dark);
    border-radius: 8px;
    border-left: 4px solid var(--border);
    transition: all 0.2s ease;
}

.detected-mini-card:hover {
    background: var(--bg-card-hover);
}

.detected-mini-card.assigned {
    border-left-color: var(--success);
}

.detected-mini-card.unassigned {
    border-left-color: var(--warning);
}

.mini-id {
    font-size: 18px;
    font-weight: 700;
    color: var(--primary);
    text-align: center;
}

.mini-position {
    display: flex;
    flex-direction: column;
    gap: 2px;
    font-size: 12px;
    color: var(--text-muted);
}

.mini-assignment {
    display: flex;
    align-items: center;
    gap: 8px;
}

.mini-assign-select {
    padding: 6px 10px;
    background: var(--bg-card);
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: 6px;
    font-size: 12px;
    min-width: 150px;
}

.assigned-to {
    color: var(--success);
    font-weight: 500;
    font-size: 14px;
}

.btn-sm {
    padding: 4px 8px;
    font-size: 12px;
}

.btn-danger {
    background: var(--danger);
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
}

.btn-danger:hover {
    opacity: 0.9;
}

.detected-minis-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
}

.detected-minis-header h5 {
    margin: 0;
}

.badge-count {
    background: var(--warning);
    color: var(--bg-dark);
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 600;
}

.empty-state {
    text-align: center;
    padding: 20px;
    color: var(--text-muted);
}

.empty-state small {
    display: block;
    margin-top: 8px;
    opacity: 0.7;
}

/* Characters for Assignment */
.characters-assignment-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    gap: 12px;
}

.character-assignment-card {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px;
    background: var(--bg-dark);
    border-radius: 8px;
    border: 2px solid transparent;
    transition: all 0.2s ease;
}

.character-assignment-card:hover {
    background: var(--bg-card-hover);
    border-color: var(--border);
}

.character-assignment-card.has-miniature {
    border-color: var(--success);
    background: rgba(34, 197, 94, 0.1);
}

.char-avatar {
    width: 50px;
    height: 50px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 22px;
    font-weight: bold;
    color: white;
    text-shadow: 1px 1px 2px rgba(0,0,0,0.3);
    flex-shrink: 0;
}

.char-info {
    flex: 1;
    min-width: 0;
}

.char-name {
    font-weight: 600;
    font-size: 14px;
    color: var(--text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.char-player {
    font-size: 12px;
    color: var(--text-muted);
}

.char-class {
    font-size: 11px;
    color: var(--primary);
    margin-top: 2px;
}

.char-hp {
    font-size: 12px;
    color: var(--success);
    margin-top: 2px;
}

.char-status {
    text-align: right;
}

.miniature-linked {
    color: var(--success);
    font-size: 12px;
    font-weight: 500;
}

.miniature-unlinked {
    color: var(--text-muted);
    font-size: 11px;
}
