:root {
    --bg-base: #09090b;
    --surface: #18181b;
    --surface-hover: #27272a;
    --border: #27272a;
    --border-focus: #8b5cf6;
    --primary: #8b5cf6;
    --primary-hover: #7c3aed;
    --danger: #ef4444;
    --danger-hover: #dc2626;
    
    --text-primary: #fafafa;
    --text-secondary: #a1a1aa;
    
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
}

* {
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

body {
    margin: 0;
    padding: 0;
    background-color: var(--bg-base);
    color: var(--text-primary);
    min-height: 100vh;
    padding-bottom: 80px; 
    transition: background-color 0.3s ease;
}

/* Modo Edición */
body.edit-mode {
    background-color: #1a1014; /* Tinte rojizo leve */
}
.edit-mode-hint {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    background-color: var(--danger);
    color: white;
    text-align: center;
    padding: 8px;
    font-size: 0.85rem;
    font-weight: 600;
    z-index: 1000;
}
body.edit-mode .edit-mode-hint {
    display: block;
}

@keyframes shake {
    0% { transform: rotate(-1deg); }
    50% { transform: rotate(1deg); }
    100% { transform: rotate(-1deg); }
}

body.edit-mode .character-card, 
body.edit-mode .rich-link-item {
    animation: shake 0.3s infinite;
    cursor: grab;
}
body.edit-mode .character-card:active,
body.edit-mode .rich-link-item:active {
    cursor: grabbing;
}

/* Grid Mobile First */
.character-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
    padding: 16px;
    max-width: 600px;
    margin: 0 auto;
}

.character-card {
    background-color: var(--surface);
    border-radius: 16px;
    overflow: hidden;
    border: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    transition: transform 0.2s, border-color 0.2s;
    position: relative;
    user-select: none;
}

.character-card:active:not(.edit-mode *) {
    transform: scale(0.97);
    border-color: var(--primary);
}

.character-img-wrapper {
    width: 100%;
    padding-top: 150%; 
    position: relative;
    background-color: var(--surface-hover);
    pointer-events: none;
}

.character-img-wrapper img {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.character-info {
    padding: 12px 8px;
    text-align: center;
    pointer-events: none;
}

.character-name {
    margin: 0;
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.delete-char-btn {
    display: none;
    position: absolute;
    top: 8px;
    right: 8px;
    background-color: rgba(239, 68, 68, 0.9);
    border: none;
    border-radius: 50%;
    width: 32px;
    height: 32px;
    align-items: center;
    justify-content: center;
    color: white;
    z-index: 10;
}
body.edit-mode .delete-char-btn {
    display: flex;
}

/* Floating Action Button */
.fab {
    position: fixed;
    bottom: 24px;
    right: 24px;
    width: 56px;
    height: 56px;
    border-radius: 28px;
    background-color: var(--primary);
    color: white;
    border: none;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 16px rgba(139, 92, 246, 0.4);
    z-index: 100;
    transition: transform 0.2s, background-color 0.2s, opacity 0.2s;
}
.fab:active {
    transform: scale(0.92);
    background-color: var(--primary-hover);
}
.fab .material-symbols-outlined {
    font-size: 28px;
}
.fab.fab-dialog {
    position: fixed; /* Fijado a la pantalla dentro del modal */
    z-index: 10000;
}
body.edit-mode .fab {
    opacity: 0;
    pointer-events: none;
}

/* Tipografía */
h2 {
    margin: 0;
    font-size: 1.25rem;
    font-weight: 700;
    letter-spacing: -0.02em;
}
.truncate {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Modales Modernos */
.modern-dialog {
    border: 1px solid var(--border);
    border-radius: 20px;
    background: var(--surface);
    color: var(--text-primary);
    padding: 0;
    width: 90%;
    max-width: 400px;
}
.modern-dialog::backdrop {
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(4px);
}

.fullscreen-dialog {
    width: 100vw;
    height: 100vh;
    max-width: none;
    max-height: none;
    border-radius: 0;
    border: none;
    margin: 0;
    position: relative; /* Contexto para el FAB interno */
}

.dialog-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px 20px 10px 20px;
}

.sticky-header {
    position: sticky;
    top: 0;
    background: var(--surface);
    z-index: 10;
    border-bottom: 1px solid var(--border);
    padding-bottom: 16px;
}

form {
    padding: 10px 20px 20px 20px;
}

.dialog-content {
    padding: 20px;
    height: calc(100vh - 75px);
    overflow-y: auto;
}

/* Inputs y Selects */
.form-group {
    display: flex;
    flex-direction: column;
    margin-bottom: 20px;
}
.form-group label {
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--text-secondary);
    margin-bottom: 8px;
}

.modern-input, .modern-select {
    width: 100%;
    background-color: var(--bg-base);
    border: 1px solid var(--border);
    color: var(--text-primary);
    padding: 14px 16px;
    border-radius: 12px;
    font-family: inherit;
    font-size: 1rem;
    transition: border-color 0.2s;
}
.modern-input:focus, .modern-select:focus {
    outline: none;
    border-color: var(--border-focus);
}

/* Botones */
.dialog-actions {
    display: flex;
    justify-content: flex-end;
    gap: 12px;
    margin-top: 24px;
}
.btn {
    padding: 12px 20px;
    border-radius: 10px;
    font-weight: 600;
    font-size: 0.95rem;
    border: none;
    transition: transform 0.1s, background-color 0.2s;
}
.btn-primary {
    background-color: var(--primary);
    color: white;
}
.btn-primary:active { 
    background-color: var(--primary-hover); 
    transform: scale(0.97);
}
.btn-text {
    background-color: transparent;
    color: var(--text-secondary);
}
.btn-text:active { 
    color: var(--text-primary); 
    background-color: var(--surface-hover); 
}
.icon-btn {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    width: 40px;
    height: 40px;
    border-radius: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
}
.icon-btn:active {
    background-color: var(--surface-hover);
    color: var(--text-primary);
}

/* Tabs & Links List */
.tabs-wrapper {
    margin-bottom: 16px;
}

.modern-list {
    list-style: none;
    padding: 0;
    margin: 0;
    display: flex;
    flex-direction: column;
    gap: 12px;
    padding-bottom: 100px; 
}

/* Enlaces enriquecidos */
.rich-link-item {
    -webkit-touch-callout: none; /* Bloquea el menú de safari/chrome al mantener calcado */
    -webkit-user-select: none;
    user-select: none;
    display: flex;
    align-items: center;
    background-color: var(--bg-base);
    border: 1px solid var(--border);
    padding: 12px;
    border-radius: 12px;
    text-decoration: none;
    color: var(--text-primary);
    position: relative;
    user-select: none;
    transition: background-color 0.2s, border-color 0.2s;
}
.rich-link-item:active:not(body.edit-mode *) {
    background-color: var(--surface-hover);
    border-color: var(--primary);
}

.rich-link-logo {
    width: 44px;
    height: 44px;
    border-radius: 8px;
    object-fit: cover;
    background-color: var(--surface-hover);
    margin-right: 16px;
    flex-shrink: 0;
}

.rich-link-info {
    flex: 1;
    overflow: hidden;
    pointer-events: none;
}
.rich-link-title {
    font-size: 1rem;
    font-weight: 600;
    margin: 0 0 4px 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.rich-link-url {
    font-size: 0.75rem;
    color: var(--text-secondary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin: 0;
}

/* Controles de arrastre y borrado */
.link-controls {
    display: none;
    align-items: center;
    gap: 8px;
}
body.edit-mode .link-controls {
    display: flex;
}
body.edit-mode .rich-link-item {
    padding-right: 8px;
}
.drag-handle {
    color: var(--text-secondary);
    cursor: grab;
}
.delete-link-btn {
    color: var(--danger);
    background: transparent;
    border: none;
    padding: 8px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
}
.delete-link-btn:active {
    background-color: rgba(239, 68, 68, 0.15);
}

.empty-state {
    text-align: center;
    padding: 32px 0;
    color: var(--text-secondary);
    font-size: 0.9rem;
}
