
:root {
    --primary-color: #6366f1;
    --primary-hover: #5855eb;
    --secondary-color: #64748b;
    --success-color: #10b981;
    --warning-color: #f59e0b;
    --danger-color: #ef4444;
    --bg-primary: #ffffff;
    --bg-secondary: #f8fafc;
    --bg-tertiary: #f1f5f9;
    --text-primary: #1e293b;
    --text-secondary: #64748b;
    --border-color: #e2e8f0;
    --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
    --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
    --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
    --radius-sm: 0.375rem;
    --radius-md: 0.5rem;
    --radius-lg: 0.75rem;
    --radius-xl: 1rem;
}

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

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 2rem 1rem;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.app-header {
    text-align: center;
    margin-bottom: 3rem;
    background: var(--bg-primary);
    padding: 2.5rem;
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-lg);
}

.app-header h1 {
    font-size: 2.5rem;
    font-weight: 700;
    color: var(--primary-color);
    margin-bottom: 0.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 1rem;
}

.app-header h1 i {
    font-size: 2.2rem;
}

.subtitle {
    font-size: 1.125rem;
    color: var(--text-secondary);
    font-weight: 400;
}

.main-content {
    flex: 1;
    display: grid;
    grid-template-columns: 1fr;
    gap: 2rem;
}

.input-section {
    background: var(--bg-primary);
    padding: 2rem;
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-lg);
}

.model-selection {
    margin-bottom: 2rem;
}

.model-selection label {
    display: block;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 0.75rem;
    font-size: 1rem;
}

.model-selection label i {
    color: var(--primary-color);
    margin-right: 0.5rem;
}

.select-wrapper {
    position: relative;
}

#model-select {
    width: 100%;
    padding: 1rem 3rem 1rem 1rem;
    border: 2px solid var(--border-color);
    border-radius: var(--radius-md);
    font-size: 1rem;
    font-weight: 500;
    background: var(--bg-primary);
    color: var(--text-primary);
    appearance: none;
    cursor: pointer;
    transition: all 0.2s ease;
}

#model-select:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgb(99 102 241 / 0.1);
}

#model-select:hover {
    border-color: var(--primary-hover);
}

.select-arrow {
    position: absolute;
    right: 1rem;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-secondary);
    pointer-events: none;
}

#model-select optgroup {
    font-weight: 600;
    color: var(--text-primary);
    background: var(--bg-secondary);
    padding: 0.5rem 0;
}

#model-select option {
    padding: 0.5rem 1rem;
    font-weight: 400;
    color: var(--text-primary);
}

.text-input-section {
    margin-bottom: 1rem;
}

.text-input-section label {
    display: block;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 0.75rem;
    font-size: 1rem;
}

.text-input-section label i {
    color: var(--primary-color);
    margin-right: 0.5rem;
}

#text-input {
    width: 100%;
    padding: 1rem;
    border: 2px solid var(--border-color);
    border-radius: var(--radius-md);
    font-size: 1rem;
    font-family: inherit;
    background: var(--bg-primary);
    color: var(--text-primary);
    resize: vertical;
    min-height: 120px;
    transition: all 0.2s ease;
}

#text-input:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgb(99 102 241 / 0.1);
}

#text-input::placeholder {
    color: var(--text-secondary);
}

.input-actions {
    display: flex;
    gap: 1rem;
    margin-top: 1rem;
}

.btn {
    padding: 0.75rem 1.5rem;
    border: none;
    border-radius: var(--radius-md);
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    text-decoration: none;
}

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

.btn-primary:hover {
    background: var(--primary-hover);
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
}

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

.btn-secondary:hover {
    background: #475569;
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
}

.results-section {
    background: var(--bg-primary);
    padding: 2rem;
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-lg);
    animation: fadeInUp 0.3s ease;
    transition: all 0.3s ease;
}

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1.5rem;
    margin-bottom: 2rem;
}

.stat-card {
    background: var(--bg-secondary);
    padding: 1.5rem;
    border-radius: var(--radius-lg);
    display: flex;
    align-items: center;
    gap: 1rem;
    transition: all 0.3s ease;
}

.stat-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.stat-icon {
    width: 50px;
    height: 50px;
    border-radius: var(--radius-md);
    background: var(--primary-color);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 1.25rem;
}

.stat-content {
    display: flex;
    flex-direction: column;
}

.stat-number {
    font-size: 1.75rem;
    font-weight: 700;
    color: var(--text-primary);
    line-height: 1;
    transition: all 0.3s ease;
}

.stat-label {
    font-size: 0.875rem;
    color: var(--text-secondary);
    font-weight: 500;
}

.model-info {
    background: var(--bg-secondary);
    padding: 1.5rem;
    border-radius: var(--radius-lg);
    margin-bottom: 2rem;
}

.model-info h3 {
    color: var(--text-primary);
    margin-bottom: 1rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.model-info h3 i {
    color: var(--primary-color);
}

.model-details p {
    margin-bottom: 0.5rem;
    color: var(--text-secondary);
}

.model-details p strong {
    color: var(--text-primary);
}

.tokens-visualization {
    margin-bottom: 2rem;
}

.tokens-visualization h3 {
    color: var(--text-primary);
    margin-bottom: 1rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.tokens-visualization h3 i {
    color: var(--primary-color);
}

.tokens-container {
    background: var(--bg-secondary);
    padding: 1.5rem;
    border-radius: var(--radius-lg);
    min-height: 100px;
    line-height: 2;
    transition: all 0.3s ease;
}

.token {
    display: inline-block;
    background: var(--primary-color);
    color: white;
    padding: 0.25rem 0.5rem;
    margin: 0.125rem;
    border-radius: var(--radius-sm);
    font-size: 0.875rem;
    font-weight: 500;
    transition: all 0.2s ease;
    cursor: pointer;
    animation: tokenAppear 0.3s ease;
    position: relative;
}

@keyframes tokenAppear {
    from {
        opacity: 0;
        transform: scale(0.8);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

.token:hover {
    background: var(--primary-hover);
    transform: scale(1.05);
    box-shadow: var(--shadow-md);
}

/* Estilos específicos para diferentes tipos de tokens */
.token.special {
    background: var(--warning-color);
}

.token.number {
    background: var(--success-color);
}

.token.punctuation {
    background: var(--secondary-color);
}

.token.whitespace,
.token.espacio_en_blanco {
    background: var(--border-color);
    color: var(--text-secondary);
}

.token.subword {
    background: var(--danger-color);
}

.token.palabra_con_espacio {
    background: #8b5cf6;
}

.token.suffix {
    background: #8b5cf6;
}

.token.space_marker {
    background: #06b6d4;
    font-weight: bold;
}

.token.word,
.token.palabra {
    background: var(--primary-color);
}

/* Indicador visual para IDs aproximados */
.token.approximate-id {
    border: 2px dashed rgba(255, 255, 255, 0.5);
    opacity: 0.8;
}

.token.approximate-id::after {
    content: '≈';
    position: absolute;
    top: -5px;
    right: -5px;
    background: var(--warning-color);
    color: white;
    font-size: 0.6rem;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
}

.tokens-list h3 {
    color: var(--text-primary);
    margin-bottom: 1rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.tokens-list h3 i {
    color: var(--primary-color);
}

.tokens-array {
    background: var(--bg-secondary);
    padding: 1.5rem;
    border-radius: var(--radius-lg);
    max-height: 300px;
    overflow-y: auto;
    transition: all 0.3s ease;
}

.token-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.75rem;
    margin-bottom: 0.5rem;
    background: var(--bg-primary);
    border-radius: var(--radius-sm);
    font-family: 'Courier New', monospace;
    font-size: 0.875rem;
    transition: all 0.2s ease;
    animation: tokenItemAppear 0.3s ease;
    border-left: 4px solid var(--primary-color);
}

@keyframes tokenItemAppear {
    from {
        opacity: 0;
        transform: translateX(-10px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

.token-item:hover {
    background: var(--bg-tertiary);
    transform: translateX(5px);
    box-shadow: var(--shadow-sm);
}

.token-text {
    color: var(--text-primary);
    font-weight: 600;
    flex: 1;
}

.token-id {
    color: var(--text-secondary);
    font-size: 0.75rem;
    text-align: right;
    min-width: fit-content;
    margin-left: 1rem;
    background: var(--bg-secondary);
    padding: 0.25rem 0.5rem;
    border-radius: var(--radius-sm);
}

/* Estilos para tokens aproximados en la lista */
.token-item.approximate-token {
    border-left: 4px solid var(--warning-color);
    background: rgba(245, 158, 11, 0.05);
}

.token-item.approximate-token .token-id {
    background: rgba(245, 158, 11, 0.1);
    border: 1px solid rgba(245, 158, 11, 0.3);
}

/* Indicador de precisión en la lista */
.token-item.approximate-token::before {
    content: '≈ ';
    color: var(--warning-color);
    font-weight: bold;
    margin-right: 0.25rem;
}

/* Información de precisión de tokens */
.tokens-precision-info {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.75rem;
    margin-bottom: 1rem;
    border-radius: var(--radius-sm);
    font-size: 0.875rem;
    font-weight: 500;
}

.tokens-precision-info.accurate {
    background: rgba(16, 185, 129, 0.1);
    border: 1px solid rgba(16, 185, 129, 0.3);
    color: var(--success-color);
}

.tokens-precision-info.approximate {
    background: rgba(245, 158, 11, 0.1);
    border: 1px solid rgba(245, 158, 11, 0.3);
    color: var(--warning-color);
}

.tokens-precision-info i {
    font-size: 1rem;
}

.app-footer {
    text-align: center;
    padding: 2rem;
    color: white;
    font-size: 0.875rem;
    margin-top: 2rem;
}

@media (max-width: 768px) {
    .container {
        padding: 1rem;
    }
    
    .app-header {
        padding: 1.5rem;
        margin-bottom: 2rem;
    }
    
    .app-header h1 {
        font-size: 2rem;
        flex-direction: column;
        gap: 0.5rem;
    }
    
    .input-section,
    .results-section {
        padding: 1.5rem;
    }
    
    .stats-grid {
        grid-template-columns: 1fr;
    }
    
    .input-actions {
        flex-direction: column;
    }
    
    .btn {
        justify-content: center;
    }
}

@media (prefers-color-scheme: dark) {
    :root {
        --bg-primary: #1e293b;
        --bg-secondary: #334155;
        --bg-tertiary: #475569;
        --text-primary: #f1f5f9;
        --text-secondary: #cbd5e1;
        --border-color: #475569;
    }
    
    body {
        background: linear-gradient(135deg, #1e293b 0%, #334155 100%);
    }
}

.loading {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 3px solid rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    border-top-color: white;
    animation: spin 1s ease-in-out infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}
